Skip to content

Instantly share code, notes, and snippets.

Avatar

ugo ugovaretto

  • The Pawsey Supercomputing Centre
  • Kensington, Western Australia
View GitHub Profile
View barrier.cpp
#include <chrono>
#include <condition_variable>
#include <iostream>
#include <thread>
class Barrier {
public:
Barrier(uint32_t count) : threadCount(count), counter(0), waiting(0) {}
void wait() {
@ugovaretto
ugovaretto / du_hidden.sh
Last active Nov 16, 2020
List disk usage for hidden files
View du_hidden.sh
#!/usr/bin/env bash
du -sch .[!.]* * | sort -h
View vector_allocation.cpp
// Author: Ugo Varetto
// buffer allocation performance tests: vector, vector+pod allocator (same as
// vector), raw aligned buffer (faster)
#include <sys/mman.h>
#include <unistd.h>
#include <cstdlib>
#include <ctime>
#include <iostream>
@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