Skip to content

Instantly share code, notes, and snippets.

import json
from pprint import pprint as pp
import numpy as np
from numba import autojit, typeof, int32
INF = float('inf')
@autojit
def jenks_matrics_init(data, n_classes, ):
@sklam
sklam / abstractIR.ll
Created March 25, 2013 16:10
numba-bytecode->llvm test3 dump
define %unknown* @test3(%unknown* %a, %unknown* %b, %unknown* %c) {
block0:
%0 = load %unknown** @numba.builtin.range
%1 = call %unknown* @numba.abstract.const.i32(i32 1)
%2 = call %unknown* @numba.abstract.pack.unknown_p.unknown_p(%unknown* %1, %unknown* %a)
%3 = call %unknown* @numba.abstract.call.unknown_p.unknown_p.unknown_p(%unknown* %0, %unknown* %2, %unknown* null)
%4 = call %unknown* @numba.abstract.get_iter.unknown_p(%unknown* %3)
br label %block16
@sklam
sklam / test_ptxas_verbose.c
Created July 26, 2013 19:20
test_ptxas_verbose.c
#if __APPLE__
#include "CUDA/cuda.h"
#else
#include "cuda.h"
#endif
const char ptx[] = "//\n// Generated by NVIDIA NVVM Compiler\n// Compiler built on Thu May 16 17:15:21 2013 (1368742521)\n// Cuda compilation tools, release 5.5, V5.5.0\n//\n\n.version 3.2\n.target sm_20\n.address_size 64\n\n\n.visible .entry sum(\n\t.param .u64 sum_param_0\n)\n{\n\t.reg .s32 \t%r<3>;\n\t.reg .s64 \t%rd<5>;\n\n\n\tld.param.u64 \t%rd1, [sum_param_0];\n\tcvta.to.global.u64 \t%rd2, %rd1;\n\tld.global.u64 \t%rd3, [%rd2];\n\tcvta.to.global.u64 \t%rd4, %rd3;\n\tld.global.u32 \t%r1, [%rd4];\n\tadd.s32 \t%r2, %r1, 1;\n\tst.global.u32 \t[%rd4], %r2;\n\tret;\n}\n\n\n\x00";
int main(int argc, char **argv){
@sklam
sklam / numbapro_async_api.py
Created August 23, 2013 15:37
numbapro async API draft & notes
import numpy as np
from numbapro import async
# Create a plan for a asynchronous computation task
plan = async.Plan()
# Create the data sources as arrays
@sklam
sklam / functionwrapper.py
Last active December 29, 2015 18:49
Comparing numba new and old
@contextlib.contextmanager
def benchmark(ident):
ts = timer()
yield
te = timer()
print('%s %.3fms' % (ident, (te - ts)*1000))
class FunctionWrapper(object):
"""
Result of @jit for functions.
@sklam
sklam / autoscale_problem.py
Last active December 31, 2015 13:09
bokeh-autoscale
from __future__ import division
import time
import numpy as np
import bokeh.plotting as bkhplt
from bokeh.objects import Range1d
RADIUS = 1
FRAMERATE = 1 / 24
# -*- coding: utf-8 -*-
"""
Test and wrapper script for simulator core functions.
To recompile the C++ library type ! ./make.sh from the ipython console and restart
the ipython kernel.
"""
import os
import sys
path = os.path.dirname(os.path.realpath(__file__))
sys.path.append(path + '/..')
@sklam
sklam / numba_testing.txt
Created July 30, 2014 15:11
error log win32
This file has been truncated, but you can view the full file.
There was an error importing jinja2.
Please run `conda install jinja2` to enable jinja template support
BUILD START: numba-testing-np17py26_0
Fetching package metadata: ...
Solving package specifications: .
C:\Users\win7x32\Miniconda\conda-bld\work>call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86
Setting environment for using Microsoft Visual Studio 2008 x86 tools.
C:\Users\win7x32\Miniconda\conda-bld\work>set TMP=C:\Users\win7x32\AppData\Local\Temp
@sklam
sklam / numba-testing.txt
Created July 31, 2014 19:29
error log win32
BUILD START: numba-testing-np17py26_0
Fetching package metadata: ...
Solving package specifications: .
C:\Users\win7x32\Miniconda\conda-bld\work>call "C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat" x86
Setting environment for using Microsoft Visual Studio 2008 x86 tools.
C:\Users\win7x32\Miniconda\conda-bld\work>set TMP=C:\Users\win7x32\AppData\Local\Temp
C:\Users\win7x32\Miniconda\conda-bld\work>set COMPUTERNAME=WIN7X32-PC
@sklam
sklam / numba-testing.txt
Created July 31, 2014 20:20
error log win64
BUILD START: numba-testing-np17py26_0
Fetching package metadata: ...
Solving package specifications: .
The following packages will be downloaded:
package | build
---------------------------|-----------------
numpy-1.7.1 | py26_3 14.6 MB
The following packages will be linked: