Skip to content

Instantly share code, notes, and snippets.

# based on https://github.com/numpy/numpy/issues/18471#issuecomment-785019387
import numpy
import os
import ctypes
def get_ilp64():
if os.environ.get("NPY_USE_BLAS_ILP64", "0") == "0":
return None
if IS_32BIT:
raise RuntimeError("NPY_USE_BLAS_ILP64 set on 32-bit arch")
@inducer
inducer / instructions.md
Last active February 12, 2021 07:09
Instrumenting POCL memory allocation

Tracing POCL Memory Allocation

To use this, build pocl with the patch below and then run your OpenCL program with

POCL_DEBUG=memory

Since you'll be using a patched pocl, maybe you will need ocl-icd to see that. To get that to happen, you can use this shell script. Save as, maybe, with-my-pocl:

#! /bin/bash
@inducer
inducer / plot-ecobee.py
Created January 8, 2021 17:27
Plot Ecobee CSV data
#! /usr/bin/env python3
import pandas as pd
from glob import glob
import matplotlib.pyplot as plt
therm = pd.concat([
pd.read_csv(fn, comment="#",
index_col=False,
parse_dates={"Datetime": [0, 1]})
@inducer
inducer / build-submission-zip.sh
Created September 16, 2020 16:28
Arxiv submission script
#! /bin/zsh
setopt -o EXTENDED_GLOB
set -e
set -x
if [ "$(uname)" = "Darwin" ]; then
TAR=gtar
else
TAR=tar
@inducer
inducer / purge-tex-comments.py
Created September 16, 2020 15:59
Purge Comments from LaTeX
#! /usr/bin/env python3
import sys
import re
with open(sys.argv[1], "rt") as infile:
tex = infile.read()
tex, _ = re.subn("%.*\n", "", tex)
tex, _ = re.subn(r"\\begin\{comment\}.*\\end\{comment\}", "", tex, flags=re.DOTALL)
@inducer
inducer / unstructuredmesh.tex
Last active March 27, 2020 19:16
Unstructured mesh for a domain in TikZ
\newcommand{\meshnodes}{
\coordinate (a) at (4.53,2.86) ;
\coordinate (b) at (2.91,3.55) ;
\coordinate (c) at (2.25,1.8) ;
\coordinate (d) at (-0.3,3.25) ;
\coordinate (e) at (1.31,4.17) ;
\coordinate (f) at (1.19,0.43) ;
\coordinate (g) at (2.77,0.7) ;
\coordinate (h) at (3.96,3.54) ;
\coordinate (i) at (0.05,1.17) ;
@inducer
inducer / treebuild.py
Last active October 21, 2019 23:22
Simple numpy FMM Tree Build
import numpy as np
class Tree:
def __init__(
self, box_centers, root_box_extent,
box_parents, box_children, box_levels):
self.box_centers = box_centers
self.root_box_extent = root_box_extent
self.box_parents = box_parents
@inducer
inducer / python-simple.supp
Created August 25, 2019 23:00
Simple Python valgrind suppression file
{
zzz
Memcheck:Addr4
obj:*python*
}
{
zzz
Memcheck:Addr4
obj:*python*
}
@inducer
inducer / kill-sidekiq-if-huge.py
Created May 11, 2018 20:21
Gitlab Sidekiq Memory Killer
#! /usr/bin/env python3
import psutil
import signal
from time import sleep
from subprocess import Popen, PIPE
import logging
logger = logging.getLogger("sidekiq-killer")
#logging.basicConfig(level=logging.INFO)
@inducer
inducer / build-pocl-branch.sh
Created December 28, 2017 23:51
Pocl build script
#! /bin/bash
set -e
set -x
apt-get remove --purge pocl-opencl-icd
apt autoremove
apt install libhwloc-dev libz-dev cmake pkg-config
USE_LLVM_PACKAGES=0