Skip to content
Discussion options

You must be logged in to vote

Hi @liblaf,

You are correct, Warp doesn't explicitly zero-initialize the output buffers. That would be wasteful for pure output buffers that would just be overwritten by the kernel launch. I don't know whether XLA initializes the output buffers in any way, but I wouldn't count on it (for the same reasons).

The best way to ensure initialization it is to use in-out arguments. You can initialize the in-out array however you need (not just zero), then modify it in the kernel.

@wp.kernel
def warp_kernel(
    inputs: wp.array(dtype=wp.float32), output: wp.array(dtype=wp.float32)
) -> None:
    idx = wp.tid()
    wp.atomic_add(output, 0, inputs[idx])  # <--- note atomic_add()

jax_kernel = warp.j…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@liblaf
Comment options

Answer selected by liblaf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants