This page describes the lambda function signatures used in segment scan (prefix-sum) operations.
Fetch Lambda
The fetch lambda retrieves the value of an element for the scan operation. It has one of the following forms:
Full form:
auto fetch = [=]
__cuda_callable__ ( IndexType segmentIdx, IndexType localIdx, IndexType globalIdx )
{
return ...;
};
#define __cuda_callable__
Definition Macros.h:49
Brief form:
In both variants:
- segmentIdx is the index of the segment.
- localIdx is the rank of the element within the segment.
- globalIdx is the index of the element in the corresponding container.
Reduction Function Object
The scan operation uses a reduction function object to combine values. See Function objects for reduction operations for available reduction operations like:
- TNL::Plus - Addition
- TNL::Multiplies - Multiplication
- TNL::Min - Minimum
- TNL::Max - Maximum
Write Lambda
The write lambda stores the result of the scan operation. It has the following signature:
{
output[globalIdx] = value;
};
- globalIdx is the index where the result should be written.
- value is the scan result to write.
Note: The implementation allows in-place scan (the write function may modify the input array).
Condition Lambda
The condition lambda determines which elements should be included in the scan operation. It has the following signature:
auto condition = [=]
__cuda_callable__ ( IndexType segmentIdx, IndexType localIdx, IndexType globalIdx ) ->
bool
{
return ...;
};
- segmentIdx is the index of the segment.
- localIdx is the rank of the element within the segment.
- globalIdx is the index of the element in the corresponding container.
The lambda should return true if the element should be included in the scan.