Skip to content

Instantly share code, notes, and snippets.

@inducer
inducer / bandwidth.py
Created September 11, 2017 21:25
PyOpenCL bandwidth measurement
import numpy as np
import pyopencl as cl
from time import time
def bandwidth_calculator(n_numbers):
a = np.random.rand(n_numbers).astype(np.float32)
mf = cl.mem_flags
a_dev = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=a)
@inducer
inducer / block-based-nav.vim
Created September 11, 2017 16:02
Block-based navigation in Vim
" {{{ python: block-based navigation
if has("python")
" pyblock.vim
"au FileType python map ( :python move_same_indent(-1)<enter>
"au FileType python map ) :python move_same_indent(1)<enter>
"au FileType python map { :python move_outer_indent(-1)<enter>
"au FileType python map } :python move_outer_indent(1)<enter>
python << EOF
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="utf-8"
From: Andreas Kloeckner <inform@tiker.net>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: xserver-xorg-video-intel: none
Package: xserver-xorg-video-intel
Version: 2:2.99.917+git20161105-1
Severity: wishlist
@inducer
inducer / shoprun
Created March 29, 2016 16:23
Run a command across the machine shop
#! /bin/bash
if [[ -z "$TMUX" ]]; then
echo "This wants to be run inside of tmux"
exit 1
fi
tmux set-option set-remain-on-exit on
for machine in porter stout quail pheas; do
tmux neww -n $machine ssh -t root@$machine "$@"
def map_comparison(self, expr, *args, **kwargs):
return type(expr)(
self.rec(expr.left, *args, **kwargs),
expr.operator,
self.rec(expr.right, *args, **kwargs))
def map_logical_not(self, expr, *args, **kwargs):
return type(expr)(
self.rec(expr.child, *args, **kwargs))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@inducer
inducer / cu-mem-reg.c
Created July 17, 2014 19:13
cuMemHostRegister failure reproducer
#include <cuda.h>
#include <stdio.h>
#include <stdexcept>
#include <iostream>
#define CUDAPP_CALL_GUARDED(NAME, ARGLIST) \
{ \
CUresult cu_status_code; \
cu_status_code = NAME ARGLIST; \
if (cu_status_code != CUDA_SUCCESS) \
#! /bin/zsh
setopt -o EXTENDED_GLOB
cp -R /usr/share/texlive/texmf-dist/tex/latex/tcolorbox .
tar cvfz loopy-submission.tar.gz --transform='s,.*/,,' \
loopy.{tex,bib} out/loopy.bbl media/*.pdf *.cls \
tcolorbox/*
rm -Rf tcolorbox
import numpy
import pycuda.autoinit
import pycuda.driver as drv
from pycuda.compiler import SourceModule
from pycuda.gpuarray import to_gpu
mod = SourceModule("""
typedef struct _pair
{
@inducer
inducer / closure.py
Created March 7, 2014 04:22
Closures demo
def fake_newton(f):
print f(17)
def main():
target_value = 18
def f(x):
return x - target_value
fake_newton(f)