Skip to content

Instantly share code, notes, and snippets.

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 / 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)
@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 / 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 / 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 <[email protected]>
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 / 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 / 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 / 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 / .bash_profile
Created December 7, 2015 15:34
ssh-agent setup on windows with git bash 2.6.3
# Based on http://mah.everybody.org/docs/ssh
# set environment variables if user's agent already exists
[ -z "$SSH_AUTH_SOCK" ] && SSH_AUTH_SOCK=$(ls -l /tmp/ssh-*/agent.* 2> /dev/null | grep $(whoami) | awk '{print $9}')
[ -z "$SSH_AGENT_PID" -a "$SSH_AUTH_SOCK" ] && [ -n `echo $SSH_AUTH_SOCK | cut -d. -f2` ] && SSH_AGENT_PID=$((`echo $SSH_AUTH_SOCK | cut -d. -f2` + 1))
[ -n "$SSH_AUTH_SOCK" ] && export SSH_AUTH_SOCK
[ -n "$SSH_AGENT_PID" ] && export SSH_AGENT_PID
# start agent if necessary
if [ -z $SSH_AGENT_PID ] && [ -z $SSH_TTY ]; then # if no agent & not in ssh
import hashlib
d = {}
for i in range(1200000):
k = hashlib.md5('%x' % i).digest()
d[k] = i
#for k in d.keys():
# print k