Skip to content

Instantly share code, notes, and snippets.

View amadio's full-sized avatar

Guilherme Amadio amadio

View GitHub Profile
@amadio
amadio / tracks.cc
Last active February 5, 2021 08:18
Example of how to handle data on CPU/GPU using SoA layout to obtain good performance
#include <cstdio>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <typeinfo>
#include <utility>
#ifndef __CUDACC__
# define __host__
# define __device__
@amadio
amadio / ctest-cdash.cmake
Created August 14, 2020 21:15
Simple CTest/CDash script template
set(CTEST_PROJECT_NAME "MyProject")
set(CTEST_BUILD_NAME "MyProject Build")
set(ENV{LANG} "C")
set(ENV{LC_ALL} "C")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "cdash.example.com")
set(CTEST_DROP_LOCATION "/submit.php?project=${CTEST_PROJECT_NAME}")
set(CTEST_DROP_SITE_CDASH TRUE)
@amadio
amadio / tdfexample.cc
Created April 20, 2017 09:33
TDataFrame Prototype with std::vector as data source
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <string>
#include <tuple>
#include <vector>
class TDFBranchMap {
@amadio
amadio / libffi-3.2.1-k1om.patch
Last active July 17, 2021 16:27
Workaround for compiling libffi for K1OM architecture (Intel® Xeon Phi™)
diff -ur libffi-3.2.1.orig/src/raw_api.c libffi-3.2.1/src/raw_api.c
--- libffi-3.2.1.orig/src/raw_api.c 2016-08-11 10:02:18.561329225 -0300
+++ libffi-3.2.1/src/raw_api.c 2016-08-11 10:03:43.853948157 -0300
@@ -29,7 +29,7 @@
#include <ffi.h>
#include <ffi_common.h>
-#if !FFI_NO_RAW_API
+//#if !FFI_NO_RAW_API
@amadio
amadio / simd-filtering-avx2.cc
Last active June 15, 2021 01:12
SIMD data filtering example with AVX2
#include <chrono>
#include <cstdio>
#include <cstdint>
#include <cstring>
#include <cstdlib>
#include <malloc.h>
#include <x86intrin.h>
class StopWatch {
public:

Keybase proof

I hereby claim:

  • I am amadio on github.
  • I am amadio (https://keybase.io/amadio) on keybase.
  • I have a public key ASCSP_ZhrVGsAlfE1VE5QKlU3wrW9ZWRVMmWwuuaErkPaQo

To claim this, I am signing this object:

@amadio
amadio / emerge-mic
Created March 4, 2015 23:53
Simple script to cross-compile stuff for the Xeon Phi in a prefix
#!/bin/bash
MICDIR=${HOME}/mic
# must copy MIC libs to ${MICDIR}/opt/intel/lib
LIBFLAGS="-L${MICDIR}/opt/intel/lib -L${MICDIR}/usr/lib"
FEATURES='-news -binchecks' ROOT=/ EPREFIX=${MICDIR} \
CC=icc CXX=icpc MPI_C=mpiicc MPI_CXX=mpiicpc LD=xild AR=xiar \
CPPFLAGS="-I${MICDIR}/usr/include" \
@amadio
amadio / linux-3.11.1-shebang-multiple-args.patch
Created September 21, 2013 05:05
Add support for shebang lines with multiple arguments to Linux.
Add support for shebang lines with multiple arguments.
Signed-off-by: Guilherme Amadio <guilherme.amadio@gmail.com>
--- a/fs/binfmt_script.c 2013-09-02 17:46:10.000000000 -0300
+++ b/fs/binfmt_script.c 2013-09-21 00:44:05.516150638 -0300
@@ -16,86 +16,121 @@
static int load_script(struct linux_binprm *bprm)
@amadio
amadio / quat_mult.c
Last active May 6, 2019 18:52
Multiplication of quaternions with minimal instructions
#include <pmmintrin.h> /* SSE3 intrinsics */
/* multiplication of two quaternions (x, y, z, w) x (a, b, c, d) */
__m128 _mm_cross4_ps(__m128 xyzw, __m128 abcd)
{
/* the product of two quaternions is: */
/* (X,Y,Z,W) = (xd+yc-zb+wa, -xc+yd+za+wb, xb-ya+zd+wc, -xa-yb-zc+wd) */
__m128 wzyx = _mm_shuffle_ps(xyzw, xyzw, _MM_SHUFFLE(0,1,2,3));