Skip to content

Instantly share code, notes, and snippets.

@gmarkall
Created August 31, 2022 15:41
Show Gist options
  • Save gmarkall/0b5777e2ffacd6e5c26faab169cc8037 to your computer and use it in GitHub Desktop.
Save gmarkall/0b5777e2ffacd6e5c26faab169cc8037 to your computer and use it in GitHub Desktop.
# Use with https://github.com/gmarkall/numba/tree/cuda-linker-options
from numba import cuda, float32, void
def axpy(r, a, x, y):
start = cuda.grid(1)
step = cuda.gridsize(1)
for i in range(start, len(r), step):
r[i] = a * x[i] + y[i]
sig = void(float32[::1], float32, float32[::1], float32[::1])
with_dlcm_cg = cuda.jit(sig, dlcm='cg')(axpy)
with_dlcm_ca = cuda.jit(sig, dlcm='ca')(axpy)
with_dlcm_xx = cuda.jit(sig)(axpy)
with open('dlcm_cg.sass', 'w') as f:
f.write(with_dlcm_cg.inspect_sass()[sig.args])
with open('dlcm_ca.sass', 'w') as f:
f.write(with_dlcm_ca.inspect_sass()[sig.args])
with open('dlcm_xx.sass', 'w') as f:
f.write(with_dlcm_xx.inspect_sass()[sig.args])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment