warp.Launch#

class warp.Launch(
kernel,
device,
hooks=None,
params=None,
params_addr=None,
bounds=None,
max_blocks=0,
block_dim=256,
adjoint=False,
)[source]#

Represents all data required for a kernel launch so that launches can be replayed quickly.

Users should not directly instantiate this class, instead use wp.launch(..., record_cmd=True) to record a launch.

Parameters:
  • device (Device)

  • hooks (KernelHooks | None)

  • params (Sequence[Any] | None)

  • params_addr (Sequence[ctypes.c_void_p] | None)

  • bounds (launch_bounds_t | None)

  • max_blocks (int)

  • block_dim (int)

  • adjoint (bool)

__init__(
kernel,
device,
hooks=None,
params=None,
params_addr=None,
bounds=None,
max_blocks=0,
block_dim=256,
adjoint=False,
)[source]#
Parameters:

Methods

__init__(kernel, device[, hooks, params, ...])

launch([stream])

Launch the kernel.

set_dim(dim)

Set the launch dimensions.

set_param_at_index(index, value[, adjoint])

Set a kernel parameter at an index.

set_param_at_index_from_ctype(index, value)

Set a kernel parameter at an index without any type conversion.

set_param_by_name(name, value[, adjoint])

Set a kernel parameter by argument name.

set_param_by_name_from_ctype(name, value)

Set a kernel parameter by argument name with no type conversions.

set_params(values)

Set all parameters.

set_params_from_ctypes(values)

Set all parameters without performing type-conversions.

Attributes

device

The device to launch on.

bounds

The launch bounds.

max_blocks

The maximum number of CUDA thread blocks to use.

block_dim

The number of threads per block.

adjoint

Whether to run the adjoint kernel instead of the forward kernel.

device: Device#

The device to launch on. This should not be changed after the launch object is created.

bounds: launch_bounds_t#

The launch bounds. Update with set_dim().

max_blocks: int#

The maximum number of CUDA thread blocks to use.

block_dim: int#

The number of threads per block.

adjoint: bool#

Whether to run the adjoint kernel instead of the forward kernel.

set_dim(dim)[source]#

Set the launch dimensions.

Parameters:

dim (int | list[int] | tuple[int, ...]) – The dimensions of the launch.

set_param_at_index(index, value, adjoint=False)[source]#

Set a kernel parameter at an index.

Parameters:
  • index (int) – The index of the param to set.

  • value (Any) – The value to set the param to.

  • adjoint (bool)

set_param_at_index_from_ctype(index, value)[source]#

Set a kernel parameter at an index without any type conversion.

Parameters:
  • index (int) – The index of the param to set.

  • value (Structure | int | float) – The value to set the param to.

set_param_by_name(name, value, adjoint=False)[source]#

Set a kernel parameter by argument name.

Parameters:
  • name (str) – The name of the argument to set.

  • value (Any) – The value to set the argument to.

  • adjoint (bool) – If True, set the adjoint of this parameter instead of the forward parameter.

set_param_by_name_from_ctype(name, value)[source]#

Set a kernel parameter by argument name with no type conversions.

Parameters:
  • name (str) – The name of the argument to set.

  • value (Structure) – The value to set the argument to.

set_params(values)[source]#

Set all parameters.

Parameters:

values (Sequence[Any]) – A list of values to set the params to.

set_params_from_ctypes(values)[source]#

Set all parameters without performing type-conversions.

Parameters:

values (Sequence[Structure]) – A list of ctypes or basic int / float types.

launch(stream=None)[source]#

Launch the kernel.

Parameters:

stream (Stream | None) – The stream to launch on.

Return type:

None