Tools to help implement irritating C-style APIs.
More...
|
| Enum Validation |
| A general mechanism for checking if an enum value is in range.
|
|
|
#define | CUDA_VEC_E(TYPE, SIZE, CUDATYPE) |
|
#define | CUDA_VEC(TYPE, SIZE) CUDA_VEC_E(TYPE, SIZE, TYPE ## SIZE) |
|
|
enum class | sp::PtrLocation { HOST
, DEVICE
, UNKNOWN
} |
| Represents which device a pointer resides on, if known. More...
|
|
Tools to help implement irritating C-style APIs.
This is helpful when:
- Writing bindings to other programming or scripting languages.
- Creating drop-in replacements for older CUDA libraries.
- Integrating a thirdparty library with an annoying API while wrapping it with modern features like RAII.
◆ CUDA_VEC_E
#define CUDA_VEC_E |
( |
|
TYPE, |
|
|
|
SIZE, |
|
|
|
CUDATYPE |
|
) |
| |
Value:template<> \
struct CudaVec<TYPE, SIZE> { \
using type = CUDATYPE; \
};
◆ CudaVec_t
template<typename T , int Size>
The CUDA vector type representing a vector of type T
and length Size
. Such as float4
or int2
.
◆ ThinCudaVec_t
template<typename T , int Size>
Like CudaVec_t
, except that if Size
is 1 this is equal to T
.
◆ PtrLocation
Represents which device a pointer resides on, if known.
◆ asCudaType()
template<typename T >
cudaDataType_t sp::asCudaType |
( |
| ) |
|
Convert a C++ type to a CUDA type enumeration value.
◆ outputToAddress()
Conditionally copy a result back to the host.
Some APIs allow the output address to be either a host or device pointer. Kernels always produce results on the GPU, so we need to conditionally copy the result back to the device.
If they are the same address, nothing happens. Otherwise a copy (potentially between devices) occurs. This allows values to be returned to the host, or to other devices, after a library call.
- Parameters
-
s | The stream to enqueue any copies on. |
outputAddress | The address the caller wants the result to end up at. |
stagingAddress | The GPU address where the result is due to be written. |