-
Couldn't load subscription status.
- Fork 0
Pattern Interface programming methodology
Dinei A. Rockenbach edited this page Feb 26, 2024
·
2 revisions
We recommend programmers follow the methodology described here when using GSParLib Pattern Interface.
To use the Map pattern, programmers may follow three simple steps:
- identify where are the stateless data-parallel regions of the code to apply the Map pattern;
- check whether the operation computed in the data-parallel region is compatible with CUDA C or OpenCL C, which is a requirement for GSParLib's GPU kernel code; and
- define the Map pattern object with the GPU kernel core, configure the desired properties such as batch size and device to be used when executing the pattern, and set the pattern's parameters.
In the following image we use the GSPAR_STRINGIZE_SOURCE macro to pass the GPU kernel code to the pattern, which is a code wrapper.

The methodology to use the Reduce pattern comprises two steps:
- check if there is a data container that is being reduced to a single value by a binary associative and commutative operator; and
- define the Reduce pattern object with the output name, input name, and operator, configure the desired properties such as the device to be used when executing the pattern, and set the pattern's parameters.
In the following image we are setting total as the output name, vec as the input name, and + as the operator.
