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
# -*- coding: utf-8 -*- | |
""" | |
Created on Wed Jan 15 10:17:16 2020 | |
@author: Mike | |
""" | |
from reikna.core import Annotation, Type, Transformation, Parameter | |
from reikna.cluda import dtypes, any_api | |
from pyopencl import cltypes |
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 | |
src = """ | |
__kernel void test(__global int *a) | |
{ | |
int gid = get_global_id(0); | |
a[gid] = gid; | |
} |
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 as np | |
from scipy.interpolate import griddata | |
def func(x, y): | |
return x*(1-x)*np.cos(4*np.pi*x) * np.sin(4*np.pi*y**2)**2 | |
grid_x, grid_y = np.mgrid[0:1:200j, 0:1:200j] | |
points = np.random.rand(410500, 2) |
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 |
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
#!/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 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
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
# 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
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) |
NewerOlder