Skip to content

Instantly share code, notes, and snippets.

@CJ-Wright
Forked from sklam/multikernels.py
Last active August 29, 2015 14:15
Show Gist options
  • Save CJ-Wright/713e35b417087a8a7c71 to your computer and use it in GitHub Desktop.
Save CJ-Wright/713e35b417087a8a7c71 to your computer and use it in GitHub Desktop.
from numba import cuda
import numpy as np
@cuda.jit
def foo(arr):
for i in range(arr.size):
arr[i] += i
A = np.arange(10000)
B = np.arange(10000)
dA=cuda.to_device(A)
dB=cuda.to_device(A)
cuda.synchronize()
streamA = cuda.stream()
streamB = cuda.stream()
for _ in range(100):
foo[1, 1, streamA](dA)
foo[1, 1, streamB](dB)
cuda.synchronize()
dA.copy_to_host(A)
dB.copy_to_host(B)
print(A)
print(B)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment