Skip to content

Instantly share code, notes, and snippets.

@c200chromebook
Created February 24, 2020 14:21
Show Gist options
  • Save c200chromebook/4e0bdb672c2f1c3bfda251c71a478eff to your computer and use it in GitHub Desktop.
Save c200chromebook/4e0bdb672c2f1c3bfda251c71a478eff to your computer and use it in GitHub Desktop.
@cuda.jit(device=True, debug=True)
def expensive(x):
return math.pow(x, 1.001)
@cuda.jit(device=True, debug=True)
def cheap(x):
return math.sqrt(x)
@cuda.jit(device=True, debug=True)
def calc(x):
s1 = expensive(x)
q = cheap(s1)
return q + 1
@cuda.jit(device=True, debug=True)
def threadid():
return cuda.blockDim.x * cuda.blockIdx.x + cuda.threadIdx.x
@cuda.jit(argtypes=[numba.int32[:]], debug=True)
def kernel(arr):
for i in range(1000):
arr[threadid()] = calc(arr[threadid()])
def main():
print("SUP")
z = np.array(range(0, 5000))
print(z)
kernel[5000 // 128 + 1, 128](z)
print(z)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment