Created
October 21, 2022 11:37
-
-
Save gmarkall/e69344b4994877006a55dfea4ee9d2aa to your computer and use it in GitHub Desktop.
Example defining an intrinsic in the Numba CUDA target
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
from numba.cuda.extending import intrinsic | |
from llvmlite import ir | |
@intrinsic | |
def cuda_clock64(typingctx): | |
sig = types.uint64() | |
def codegen(context, builder, sig, args): | |
function_type = ir.FunctionType(ir.IntType(64), []) | |
instruction = "mov.u64 $0, %clock64;" | |
clock64 = ir.InlineAsm(function_type, instruction, "=l", | |
side_effect=True) | |
return builder.call(clock64, []) | |
return sig, codegen |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment