Last active
December 9, 2018 17:33
-
-
Save wpjunior/d1b69d1649b013f371494515afaa5782 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
from numba import cuda | |
@cuda.jit | |
def add_2(array): | |
pos = cuda.grid(1) | |
array[pos] = array[pos] + 2 | |
# criamos um vetor ordenado até 100000, [0, 1, 2, .. 999999] | |
an_array = np.arange(100000) | |
threadsperblock = 32 | |
blockspergrid = (an_array.size + (threadsperblock - 1)) // threadsperblock | |
for x in range(1000): | |
add_2[blockspergrid, threadsperblock](an_array) | |
print(an_array) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment