Skip to content

Instantly share code, notes, and snippets.

Avatar

Ugo Varetto ugovaretto

  • The Pawsey Supercomputing Centre
  • Kensington, Western Australia
View GitHub Profile
@ugovaretto
ugovaretto / pwcpp_mm.cpp
Created Oct 15, 2020
Parallel copy with memory mapped files
View pwcpp_mm.cpp
/*******************************************************************************
* BSD 3-Clause License
*
* Copyright (c) 2020, Ugo Varetto
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions inputFile source code must retain the above copyright
View pwcp.cpp
/*******************************************************************************
* BSD 3-Clause License
*
* Copyright (c) 2020, Ugo Varetto
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions inputFile source code must retain the above copyright
@ugovaretto
ugovaretto / csiro_license.txt
Created Oct 15, 2020
CSIRO open-source software license
View csiro_license.txt
CSIRO Open Source Software License Agreement (variation of the BSD / MIT License)
Copyright (c) 2016, Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230.
All rights reserved. CSIRO is willing to grant you a license to this tool named PSL:Proof Strategy Language on the following terms, except where otherwise indicated for third party material.
Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of CSIRO nor the names of its contributors may be used to endorse or promote products derived from this software without specific p
@ugovaretto
ugovaretto / tomlparse.cpp
Last active Oct 12, 2020
Parse TOML files using only C++ standard regex module
View tomlparse.cpp
// Parse TOML file with standard regex module, no validation
// Author: Ugo Varetto
#include <fstream>
#include <iostream>
#include <regex>
#include <string>
#include <unordered_map>
using namespace std;
@ugovaretto
ugovaretto / gnuplot_dsl.nim
Last active Oct 5, 2020
mini GNUPlot DSL in NIM
View gnuplot_dsl.nim
# Generate gnuplot string from NIM DSL with variable substitution
# Author: Ugo Varetto
import macros, sets, sequtils, strutils, strformat, sugar
proc genCommands(node: NimNode,
stmts: var seq[seq[string]],
cur: var seq[string],
commands: HashSet[string],
subst: bool = false): bool =
@ugovaretto
ugovaretto / cflags_qt_gnuplot.sh
Created Oct 3, 2020
Set QT_CFLAGS for gnuplot >= 5 compilation
View cflags_qt_gnuplot.sh
#sudo apt install qt5-default
#sudo apt install libqt5svg5-dev
#-fPIC !!!
export pre="/usr/include/x86_64-linux-gnu/qt5"
export QT_CFLAGS="-I $pre/QtSvg -I $pre/QtConcurrent -I $pre/QtConcurrent -I $pre/QtDBus -I $pre/QtNetwork -I $pre/QtOpenGLExtensions -I $pre/QtPrintSupport -I $pre/QtTest -I $pre/QtCore -I $pre/QtGui -I $pre/QtOpenGL -I $pre/QtPlatformHeaders -I $pre/QtSql -I $pre/QtWidgets -I $pre/QtXml -I $pre -fPIC"
@ugovaretto
ugovaretto / hello_fibers.cr
Last active Sep 23, 2020
Parallel update of elements in large arrays in Crystal
View hello_fibers.cr
# Author: Ugo Varetto
# Fiber test: parallel update of array elements in arrays larger than 2^32
# build with 'crystal build -Dpreview_mt --release hello_fibers.cr'
require "process"
unless ARGV.size > 0
p "#{PROGRAM_NAME} <size> <num threads> <channel buffer size>"
exit 1
end
@ugovaretto
ugovaretto / mount_s3_bucket.sh
Last active Sep 19, 2020
mount s3 bucket as filesystem
View mount_s3_bucket.sh
#credentials are read from .aws/credentials, configure with 'aws configure' first
#use_path_request_style is always required when mounting non-Amazon Web Services resources
#note: large files are uploaded in parallel:
#-o parallel_count (default="5")
# number of parallel request for uploading big objects. s3fs uploads large object (over 20MB) by multipart post request, and sends parallel requests. This option limits parallel request count which
# s3fs requests at once. It is necessary to set this value depending on a CPU and a network band.
#-o multipart_size (default="10")
# part size, in MB, for each multipart request. The minimum value is 5 MB and the maximum value is 5 GB.
s3fs uv-bucket-3 ./magenta -o url="https://nimbus.pawsey.org.au:8080" -o profile=ceph -o use_path_request_style
@ugovaretto
ugovaretto / instance_descriptors.py
Last active Aug 17, 2020
Python instance descriptors
View instance_descriptors.py
### Per-instance descriptors
### Author: Ugo Varetto
### for standard basic descriptors see:
### https://www.datacamp.com/community/tutorials/python-descriptors
### Instance descriptor through overloading __getattribute__, __setattr__
def make_getattr(cls, n):
def custom_getattr(self, name):
get = lambda i, n: type(i).__bases__[0].__getattribute__(i, n)
View rocm-c_cpp_properties.json
{
"env": {
"myDefaultIncludePath": ["${workspaceFolder}"]
},
"configurations": [
{
"name": "ROCm",
"intelliSenseMode": "clang-x64",
"includePath": ["${myDefaultIncludePath}", "/opt/rocm/hip/include"],
"compilerPath": "/opt/rocm/hip/bin/hipcc",