Skip to content

Instantly share code, notes, and snippets.

function test(f)
tmin = 1e10
for i in 1:5
t = time()
f()
t = time() - t
if t < tmin
tmin = t
end
end
@fjarri
fjarri / perf.jl
Last active August 29, 2015 13:57
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
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
{
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)
# 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
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 ....................................................................................
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()
#!/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)
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
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