Skip to content

Commit

Permalink
conditionally define macro
Browse files Browse the repository at this point in the history
  • Loading branch information
monofuel committed Sep 2, 2024
1 parent 3178622 commit bc52fbb
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions src/hippo.nim
Original file line number Diff line number Diff line change
Expand Up @@ -134,28 +134,29 @@ proc `=destroy`*(mem: var GpuMemory) =
# -------------------
# Kernel Execution

macro hipLaunchKernelGGLWithTuple(
kernel: proc,
gridDim: Dim3 = newDim3(1,1,1),
blockDim: Dim3 = newDim3(1,1,1),
sharedMemBytes: uint32 = 0,
stream: HippoStream = nil,
args: tuple
): untyped =

var callNode = newCall(bindSym"hipLaunchKernelGGL")

# add the fixed vars
callNode.add kernel
callNode.add gridDim
callNode.add blockDim
callNode.add sharedMemBytes
callNode.add stream

# add every value of the tuple
for child in args:
callNode.add child
result = callNode
when HippoRuntime == "HIP" or HippoRuntime == "HIP_CPU":
macro hipLaunchKernelGGLWithTuple(
kernel: proc,
gridDim: Dim3 = newDim3(1,1,1),
blockDim: Dim3 = newDim3(1,1,1),
sharedMemBytes: uint32 = 0,
stream: HippoStream = nil,
args: tuple
): untyped =

var callNode = newCall(bindSym"hipLaunchKernelGGL")

# add the fixed vars
callNode.add kernel
callNode.add gridDim
callNode.add blockDim
callNode.add sharedMemBytes
callNode.add stream

# add every value of the tuple
for child in args:
callNode.add child
result = callNode

template hippoLaunchKernel*(
kernel: proc, ## The GPU kernel procedure to launch
Expand Down

0 comments on commit bc52fbb

Please sign in to comment.