Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View eyalroz's full-sized avatar

Eyal Rozenberg eyalroz

View GitHub Profile
@eyalroz
eyalroz / get_cuda_sm.sh
Created April 15, 2017 20:28
Shell script for determining the SM value for your (single) GPU
#!/bin/bash
#
# Prints the compute capability of the first CUDA device installed
# on the system, or alternatively the device whose index is the
# first command-line argument
device_index=${1:-0}
timestamp=$(date +%s.%N)
gcc_binary=${CMAKE_CXX_COMPILER:-$(which c++)}
cuda_root=${CUDA_DIR:-/usr/local/cuda}
@eyalroz
eyalroz / limits.cuh
Created October 21, 2017 10:57
CUDA-compatible version of C++ <limits>
// CUDA-device-accessible version of gcc 4.9.3's <limits>. -*- C++ -*-
/*
* The C++ standard library's numeric_limits classes cannot currently be used
* in device code, since their methods are not marked __host__ __device__, and
* even though they're constexpr - CUDA 7.5 and earlier does not properly support
* using __host__ constpexr's on the device (there's experimental support but
* it causes trouble in different places).
*/
#define __CL_ENABLE_EXCEPTIONS
#include <stdio.h>
#include <math.h>
#ifdef __APPLE__
#include <OpenCL/cl.hpp>
#else
#include <CL/cl.hpp>
#endif
@eyalroz
eyalroz / proxy.hpp
Created November 8, 2021 22:17
A generic proxy class for replacing getters and setters
#include <type_traits>
#include <utility>
#ifndef CONSTEXPR_SINCE_CPP14
# if __cplusplus >= 201402L
# define CONSTEXPR_SINCE_CPP14 constexpr
# else
# define CONSTEXPR_SINCE_CPP14
# endif
#endif
@eyalroz
eyalroz / benchmark.cpp
Last active April 5, 2020 23:24
benchmarks for stackoverflow question 61047308
#include <geiger/geiger.h>
#include <cmath>
#include <cstdlib>
#include <string>
#include <iostream>
#include <random>
namespace aliberro {
@eyalroz
eyalroz / column-2019-03-27.md
Last active July 23, 2019 08:37
Better column abstraction in cudf - rejoinder 1

Rejoinder to the initial design document / proposal

These comments and questions follow this gist by Jacob Hemstad. They appear in order of the text in Jacob's gist. Please excuse the somewhat argumentative/critical tone - I'm actually very pleased that we are hammering this out.


We want to write an algorithm once and allow it to work on a variety of columns.

Well, yes, but aren't we doing that now already?

@eyalroz
eyalroz / static_block.h
Last active March 20, 2019 12:19
A static block implementation in almost-C C++
/**
* static_block.h
*
* An implementation of a Java-style static block, in C++ (and potentially a
* GCC/clang extension to avoid warnings). Almost, but not quite, valid C.
* Partially inspired by Andrei Alexandrescu's Scope Guard and
* discussions on stackoverflow.com
*
* By Eyal Rozenberg <eyalroz@technion.ac.il>
*
@eyalroz
eyalroz / sgn2pdf
Last active December 27, 2016 10:43
#!/bin/bash
#
# sgn2pdf
# by Eyal Rozenberg <eyalroz@technion.ac.il>
# version: 2016-12-27
#
# Extracts a PDF file from an Israeli courts' .sgn PDF document envelope
#
#
# This program is free software: you can redistribute it and/or modify
/**
* memory_region.h
*
* Definition of the gsl::span-like memory_region class
*/
#pragma once
#ifndef SRC_UTIL_MEMORY_REGION_H_
#define SRC_UTIL_MEMORY_REGION_H_
#if ( __cplusplus < 201103L )
/**
* Implementation of the factory pattern, based on suggestions here:
*
* http://stackoverflow.com/q/5120768/1593077
*
* and on the suggestions for corrections here:
*
* http://stackoverflow.com/a/34948111/1593077
*