Configuration#
Warp has settings at the global, module, and kernel level that can be used to fine-tune the compilation and verbosity
of Warp programs. In cases in which a setting can be changed at multiple levels (e.g.: enable_backward
),
the setting at the more-specific scope takes precedence.
Global Settings#
To change a setting, prepend wp.config.
to the name of the variable and assign a value to it.
Some settings may be changed on the fly, while others need to be set prior to calling wp.init()
to take effect.
For example, the location of the user kernel cache can be changed with:
import os
import warp as wp
example_dir = os.path.dirname(os.path.realpath(__file__))
# set default cache directory before wp.init()
wp.config.kernel_cache_dir = os.path.join(example_dir, "tmp", "warpcache1")
wp.init()
Basic Global Settings#
Field |
Type |
Default Value |
Description |
---|---|---|---|
|
Boolean |
|
If |
|
Boolean |
|
If |
|
Boolean |
|
If |
|
String |
|
Controls whether to compile Warp kernels in debug or release mode.
Valid choices are |
|
Integer |
Global setting |
The maximum fixed-size loop to unroll. Note that |
|
Boolean |
|
If |
|
Boolean |
|
If |
|
Boolean |
|
If |
|
String |
|
The path to the directory used for the user kernel cache. Subdirectories
beginning with |
|
Boolean |
|
If |
|
Boolean |
|
If |
|
Boolean |
|
If |
Advanced Global Settings#
Field |
Type |
Default Value |
Description |
---|---|---|---|
|
Boolean |
|
If |
|
String |
|
The preferred CUDA output format for kernels. Valid choices are |
|
Integer |
70 |
The target architecture for PTX generation. |
|
Boolean |
|
If |
Module Settings#
Module-level settings to control runtime compilation and code generation may be changed by passing a dictionary of
option pairs to wp.set_module_options()
.
For example, compilation of backward passes for the kernel in an entire module can be disabled with:
wp.set_module_options({"enable_backward": False})
The options for a module can also be queried using wp.get_module_options()
.
Field |
Type |
Default Value |
Description |
---|---|---|---|
|
String |
Global setting |
Controls whether to compile the module’s kernels in debug or release
mode by default. Valid choices are |
|
Integer |
Global setting |
The maximum fixed-size loop to unroll. Note that |
|
Boolean |
Global setting |
If |
|
Boolean |
|
If |
|
String |
|
The preferred CUDA output format for kernels. Valid choices are |
Kernel Settings#
enable_backward
is currently the only setting that can also be configured on a per-kernel level.
Backward-pass compilation can be disabled by passing an argument into the @wp.kernel
decorator
as in the following example:
@wp.kernel(enable_backward=False)
def scale_2(
x: wp.array(dtype=float),
y: wp.array(dtype=float),
):
y[0] = x[0] ** 2.0