Skip to content

Instantly share code, notes, and snippets.

View gmarkall's full-sized avatar

Graham Markall gmarkall

View GitHub Profile
@gmarkall
gmarkall / inspect.py
Created April 15, 2015 12:02
inspect types, llvm, and asm in Numba
import numpy as np
from numba import njit
@njit
def f(arr1, arr2):
for i in range(len(arr1)):
arr1[i] += arr2[i]
a = np.arange(10)
b = np.arange(10)
@gmarkall
gmarkall / numba_cuda_mpi.py
Created March 30, 2015 09:45
Numba CUDA + MPI example
from __future__ import print_function
from mpi4py import MPI
from numba import cuda
import numpy as np
mpi_comm = MPI.COMM_WORLD
# Input data size
total_n = 10
@gmarkall
gmarkall / gpumem.py
Created February 24, 2015 14:35
Get memory info for all GPUs in Numba
from numba import cuda
gpus = cuda.gpus.lst
for gpu in gpus:
with gpu:
meminfo = cuda.current_context().get_memory_info()
print("%s, free: %s bytes, total, %s bytes" % (gpu, meminfo[0], meminfo[1]))
@gmarkall
gmarkall / 0001-Add-debug-and-lineinfo-options.patch
Created January 14, 2015 11:38
Generate debug and line number info in matrixMulDynlinkGIT CUDA 7 RC example for GPU PC Sampling
From 6db58ab934b7210787f5bd7ad92f7050f43edcb3 Mon Sep 17 00:00:00 2001
From: Graham Markall <graham.markall@continuum.io>
Date: Wed, 14 Jan 2015 11:10:28 +0000
Subject: [PATCH 1/2] Add debug and lineinfo options
---
matrixMulDynlinkJIT.cpp | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/matrixMulDynlinkJIT.cpp b/matrixMulDynlinkJIT.cpp
@gmarkall
gmarkall / calc_z_njit.py
Created December 8, 2014 09:14
calculate_z function using @njit
from numba import njit
import numpy as np
@njit
def calculate_z(q, z, output, maxiter):
#"""Pure python with complex datatype, iterating over list of q and z"""
for i in range(len(q)):
zi = z[i]
qi = q[i]
for iteration in range(maxiter):
@gmarkall
gmarkall / vectorized_calc_z.py
Created December 8, 2014 09:13
calculate_z function using @vectorize
from numba import vectorize
import numpy as np
@vectorize(['uint(c8, c8, uint)'])
def calculate_z(qi, zi, maxiter):
output = 0.0
for iteration in range(maxiter):
zi = zi * zi + qi
if abs(zi) > 2.0:
output = iteration
@gmarkall
gmarkall / gist:1564a9e92ff3392c35af
Created November 7, 2014 11:10
Extending the Numba frontend with an interval type - corrected ordering
# Define a new class
class Interval(object):
'''A half-open interval on the real number line.'''
def __init__(self, lo, hi):
self.lo = lo
self.hi = hi
def __repr__(self):
return 'Interval(%f, %f)' % (self.lo, self.hi)
The USB Blaster udev rules on the Altera website
( http://www.altera.com/download/drivers/dri-usb_b-lnx.html )
did not work for me on Debian Jessie/Sid. A modified version of the file, listed below, works for me
(this is the contents of /etc/udev/rules.d/51-usbblaster.rules ). After restarting udev
(`sudo service udev restart`) I was able to program the DE0-Nano.
# USB-Blaster
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6001", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6002", MODE="0666", GROUP="plugdev"
SUBSYSTEM=="usb", ATTR{idVendor}=="09fb", ATTR{idProduct}=="6003", MODE="0666", GROUP="plugdev"
@gmarkall
gmarkall / ibz.f90
Last active December 29, 2015 10:09
module IBZ
implicit none
type Plane
integer :: M(1,1)
end type Plane
contains
integer function t()
int* f()
{
static int a[3] = {1,2,3};
return a;
}