test_kernel
Test one kernel without writing a program: supply its source, launch config, arguments and expected outputs, and it compiles, runs and reports the elements that differ.
Instructions
Test one kernel without writing a program: give its source, the launch configuration, its arguments (scalars, and arrays with their data, given or generated), and the expected outputs, as values or as a host reference function. A generated program launches the kernel, compares each output (exactly for integers, within a tolerance for floating point) and reports the elements that differ. With check (the default), it also runs in the thread orders and with the sanitizers that check uses.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"kernel": "<kernel>",
"name": "<name>",
"grid": "<grid>",
"block": "<block>",
"arguments": "<arguments>"
},
"name": "test_kernel"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| grid | Yes | Blocks: a number or [x, y, z] | |
| name | Yes | The kernel to launch (a template with its arguments, e.g. scale<float>, works too) | |
| block | Yes | Threads per block: a number or [x, y, z] | |
| check | No | Also run in other thread orders and with the sanitizers (default true) | |
| seeds | No | As check's | |
| kernel | Yes | The source of the kernel, with what it needs (device functions, includes, constants) | |
| options | No | Compiler options, as nvcc's (-arch, -Xcompiler, -std, -I, -D, ...) or hipcc's; GPU options are accepted and ignored. Default -O2 -g. | |
| language | No | cuda (cuda4cpu-nvcc, the default) or hip (cuda4cpu-hipcc, the default when a source is a .hip file) | |
| arguments | Yes | The kernel's arguments, in order | |
| reference | No | C++ host code that defines void reference(...) with the kernel's parameters: it gets host copies of the inputs and writes the expected outputs into the output arrays (those without expected values) | |
| tolerance | No | For floating-point outputs: an element matches if |got - expected| <= absolute + relative * |expected| (default 1e-5 and 1e-5) | |
| shared_bytes | No | Dynamic shared memory per block (default 0) | |
| timeout_seconds | No | Time limit for each run (default 60, at most 600) |