Skip to content

Instantly share code, notes, and snippets.

View rofirrim's full-sized avatar

Roger Ferrer Ibáñez rofirrim

View GitHub Profile
@rofirrim
rofirrim / minipool.hpp
Last active March 7, 2022 10:14
Very simple memory pool
#ifndef MINIPOOL_H
#define MINIPOOL_H
#include <cassert>
#include <cstddef>
#include <memory>
#include <new>
#include <utility>
/*
AQ (Antarctica) -> QA (Qatar)
AU (Australia) -> UA (Ukraine)
BG (Bulgaria) -> GB (United Kingdom)
BL (St. Barthélemy) -> LB (Lebanon)
BS (Bahamas) -> SB (Solomon Islands)
CA (Canada) -> AC (Ascension Island)
CI (Côte d'Ivoire) -> IC (Canary Islands)
CL (Chile) -> LC (St. Lucia)
CV (Cape Verde) -> VC (St. Vincent & Grenadines)
EA (Ceuta & Melilla) -> AE (United Arab Emirates)
@rofirrim
rofirrim / recmap.cc
Created August 5, 2018 19:33
Recmap Tentative Idea
#include <unordered_map>
struct RecMap
{
using Map = std::unordered_map<int, RecMap*>;
Map M;
};
int main(int argc, char* argv[])
{
#!/bin/bash
TOOL="$1"
MY_PATH=$(dirname $(realpath $0))
IWYUC_FLAGS="\
-Xiwyu --no_comments \
-isystem /home/roger/soft/llvm-4.0/install/bin/../lib/clang/4.0.0/include/ \
-isystem /usr/lib/gcc/x86_64-linux-gnu/6/include"
@rofirrim
rofirrim / build-flang.sh
Created June 17, 2017 14:47
Build flang
#!/bin/bash -ex
export STAGEDIR=$(pwd)
export INSTALLDIR=$(pwd)/install
export BUILDDIR=$(pwd)/build
export BUILDFLANGDIR=$(pwd)/build-flang
mkdir -p ${BUILDDIR}
mkdir -p ${BUILDFLANGDIR}
.model large
.386
; Constants per comoditat
CERT equ 0FFh
FALS equ 00h
; Convencio de valors del sentit
#ifndef Q_NUMBERS_HPP
#define Q_NUMBERS_HPP
// Simple implementation of Q numbers
// There may be bugs. Use at your own risk
/*
See https://en.wikipedia.org/wiki/Q_%28number_format%29
*/
@rofirrim
rofirrim / gist:7358592
Created November 7, 2013 17:35
Intel Fortran does not compile this :(
MODULE a
IMPLICIT NONE
INTEGER(4), PUBLIC :: x1
INTEGER(4), PUBLIC :: x2
END MODULE a
MODULE a2
IMPLICIT NONE
INTEGER(4), PUBLIC :: x1
INTEGER(4), PUBLIC :: x2
#include <iostream>
#include <assert.h>
#include <math.h>
__global__ void f(float sum, int B, float *z, float *z2)
{
*z = sum / B;
*z2 = sum / (float)B;
}
@rofirrim
rofirrim / gist:5441275
Last active December 16, 2015 13:19
Another C++ rant
template <typename T>
struct f // This is ::f
{
};
namespace B
{
template <typename T>
struct f // This is B::f
{