NVIDIA / warp

A Python framework for high performance GPU simulation and graphics

Home Page:https://nvidia.github.io/warp/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kernels are not recompiled when python globals change

jc211 opened this issue · comments

Example:

import warp as wp

MY_GLOBAL = 5
# MY_GLOBAL = 10  # Changing this value does not retrigger a recompile

@wp.kernel
def foo(data: wp.array(dtype=wp.int32)):
      i = wp.tid()
      if i > MY_GLOBAL:
        data[i] = 0
        return
      data[i] = i 

wp.init()
data = wp.zeros((10, ), dtype=wp.int32)
wp.launch(
    kernel=foo,
    dim=(10,),
    inputs=[data]
)
wp.synchronize()
print(data)  # still using old value of MY_GLOBAL

Changing MY_GLOBAL does not trigger a recompile of foo.

I think in this case, one is supposed to use wp.constant on MY_GLOBAL.