This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function test(f) | |
tmin = 1e10 | |
for i in 1:5 | |
t = time() | |
f() | |
t = time() - t | |
if t < tmin | |
tmin = t | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add(A,B,reps) | |
for i in 1:reps | |
C = A + B | |
end | |
end | |
function add_bc(A,B,reps) | |
for i in 1:reps | |
C = A .+ B | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pyopencl as cl | |
import pyopencl.array as array | |
ctx = cl.create_some_context() | |
queue = cl.CommandQueue(ctx) | |
a = np.random.rand(128).astype(np.float32) | |
a_gpu = array.to_device(queue, a) | |
dest_gpu = array.empty_like(a_gpu) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Exercise 1 from http://webapp.dam.brown.edu/wiki/SciComp/CudaExercises | |
# Transposition of a matrix | |
# by Hendrik Riedmann <riedmann@dam.brown.edu> | |
from __future__ import division, print_function | |
import pycuda.driver as cuda | |
import pycuda.gpuarray as gpuarray | |
import pycuda.autoinit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bogdan@Aldan ~/w/r/h/test> py.test | |
======================================= test session starts ======================================== | |
platform darwin -- Python 3.4.2 -- py-1.4.25 -- pytest-2.6.3 | |
plugins: cov | |
collected 847 items | |
test_Parser.py . | |
test_blocks.py ............... | |
test_call.py ................................................... | |
test_cast.py .................................................................................... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
from reikna.cluda import ocl_api | |
from reikna.core import Annotation, Type, Parameter | |
from reikna.algorithms import PureParallel | |
import reikna.cluda.functions as functions | |
api = ocl_api() | |
thr = api.Thread.create() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import numpy as np | |
import pyopencl as cl | |
from mako.template import Template | |
a_np = np.random.rand(50000).astype(np.float32) | |
b_np = np.random.rand(50000).astype(np.float32) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import numpy | |
from reikna.cluda import cuda_api | |
from reikna.fft import FFT, FFTShift | |
import reikna.cluda.dtypes as dtypes | |
from reikna.core import Transformation, Parameter, Annotation, Type | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
import pyopencl as cl | |
import pyopencl.array as array | |
ctx = cl.create_some_context() | |
queue = cl.CommandQueue(ctx) | |
program = cl.Program(ctx, """ | |
#define BLOCK_LEN 256 |
OlderNewer