KernelCode is the representation of WGSL GPU code with template substitutions applied. It is a type around the code string with additional metadata for workgroup size and precision since they are specified in the WGSL code. Additionally, label and entryPoint are used by createKernel()
to specify the label and entry point of the kernel.
More...
#include <gpu.h>
Public Member Functions | |
KernelCode (const std::string &pData="", size_t workgroupSize=256, NumType precision=kf32) | |
Constructor to create a code object from a template string and optional workgroup size and precision. | |
KernelCode (const std::string &pData, const Shape &workgroupSize={256, 1, 1}, NumType precision=kf32) | |
Overload of the constructor to create a code object from a template string and workgroup size. Unlike the main factory function, this overload takes a single size_t workgroupSize parameter instead of a 3D shape for the workgroup size and instantiates a 3D shape with the workgroupSize in the x dimension and 1 in the y and z dimensions. | |
Public Attributes | |
std::string | data |
Shape | workgroupSize |
NumType | precision = kf32 |
std::string | label = "kernel" |
std::string | entryPoint = "main" |
KernelCode is the representation of WGSL GPU code with template substitutions applied. It is a type around the code string with additional metadata for workgroup size and precision since they are specified in the WGSL code. Additionally, label and entryPoint are used by createKernel()
to specify the label and entry point of the kernel.
|
inline |
Constructor to create a code object from a template string and optional workgroup size and precision.
[in] | pData | Shader template string with placeholders |
[in] | workgroupSize | Shape of the workgroup. Unlike tensor shapes which can be of arbitrary rank, workgroup size is always of rank 3 corresponding to x y and z. workgroupSize is stored as a field in the KernelCode instance that is returned by createShader(). |
[in] | precision | Data type precision to be substituted for {{precision}} in the WGSL code. As with workgroupSize, precision is stored as a field in the KernelCode instance that is returned by createShader(). KernelCode code = {kShaderText, {256, 1, 1}, kf32};
KernelCode is the representation of WGSL GPU code with template substitutions applied.... Definition gpu.h:272 |
Definition at line 289 of file gpu.h.
|
inline |
Overload of the constructor to create a code object from a template string and workgroup size. Unlike the main factory function, this overload takes a single size_t workgroupSize parameter instead of a 3D shape for the workgroup size and instantiates a 3D shape with the workgroupSize in the x dimension and 1 in the y and z dimensions.
[in] | pData | Shader template string with placeholders |
[in] | workgroupSize | Workgroup size in the x dimension |
[in] | precision | Data type precision for the shader |
Definition at line 317 of file gpu.h.