physx::Ext::PxCudaHelpersExt

Defined in include/extensions/PxCudaHelpersExt.h

class PxCudaHelpersExt

Public Static Functions

template<typename T>
static inline T *allocDeviceBuffer(PxCudaContextManager &cudaContextManager, PxU64 numElements)

Allocates a device buffer and returns the pointer to the memory.

The cuda context will get acquired automatically

Parameters
  • cudaContextManager[in] the PxCudaContextManager managing the CUDA context the allocation should be attributed to.

  • numElements[in] the number of elements of type T to allocate.

Returns

a pointer to the allocated memory.

template<typename T>
static inline void freeDeviceBuffer(PxCudaContextManager &cudaContextManager, T *&deviceBuffer)

Frees a device buffer.

The cuda context will get acquired automatically

Parameters
  • cudaContextManager[in] the PxCudaContextManager managing the CUDA context the device buffer is attributed to.

  • deviceBuffer[in] reference to a pointer pointing to the device memory buffer.

template<typename T>
static inline T *allocPinnedHostBuffer(PxCudaContextManager &cudaContextManager, PxU64 numElements)

Allocates a pinned host buffer and returns the pointer to the memory.

A pinned host buffer can be used on the gpu after getting a mapped device pointer from the pinned host buffer pointer, see getMappedDevicePtr The cuda context will get acquired automatically

Parameters
  • cudaContextManager[in] the PxCudaContextManager managing the CUDA context the allocation should be attributed to.

  • numElements[in] the number of elements of type T to allocate.

Returns

a pointer to the allocated memory.

template<typename T>
static inline void freePinnedHostBuffer(PxCudaContextManager &cudaContextManager, T *&pinnedHostBuffer)

Frees a pinned host buffer.

The cuda context will get acquired automatically

Parameters
  • cudaContextManager[in] the PxCudaContextManager managing the CUDA context the pinned memory buffer is attributed to.

  • pinnedHostBuffer[in] reference to a pointer pointing to the pinned memory buffer.

template<typename T>
static inline void copyDToH(PxCudaContextManager &cudaContextManager, T *hostBuffer, const T *deviceBuffer, PxU64 numElements)

Copies a device buffer to the host.

The cuda context will get acquired automatically

Parameters
  • cudaContextManager[in] the PxCudaContextManager managing the CUDA context executing the operation.

  • hostBuffer[in] pointer to the destination (pinned) host memory buffer.

  • deviceBuffer[in] pointer to the source device buffer.

  • numElements[in] the number of elements of type T to copy.

template<typename T>
static inline void copyHToD(PxCudaContextManager &cudaContextManager, T *deviceBuffer, const T *hostBuffer, PxU64 numElements)

Copies a host buffer to the device.

The cuda context will get acquired automatically

Parameters
  • cudaContextManager[in] the PxCudaContextManager managing the CUDA context executing the operation.

  • deviceBuffer[in] pointer to the destination device buffer.

  • hostBuffer[in] pointer to the source (pinned) host memory buffer.

  • numElements[in] the number of elements of type T to copy.

template<typename T>
static inline void copyDToHAsync(PxCudaContextManager &cudaContextManager, T *hostBuffer, const T *deviceBuffer, PxU64 numElements, CUstream stream)

Schedules device to host copy operation on the specified stream.

The cuda context will get acquired automatically

Parameters
  • cudaContextManager[in] the PxCudaContextManager managing the CUDA context executing the operation.

  • hostBuffer[in] pointer to the destination (pinned) host memory buffer.

  • deviceBuffer[in] pointer to the source device buffer.

  • numElements[in] the number of elements of type T to copy.

  • stream[in] the CUDA stream to perform the operation on.

template<typename T>
static inline void copyHToDAsync(PxCudaContextManager &cudaContextManager, T *deviceBuffer, const T *hostBuffer, PxU64 numElements, CUstream stream)

Schedules host to device copy operation on the specified stream.

The cuda context will get acquired automatically

Parameters
  • cudaContextManager[in] the PxCudaContextManager managing the CUDA context executing the operation.

  • deviceBuffer[in] pointer to the destination device buffer.

  • hostBuffer[in] pointer to the source (pinned) host memory buffer.

  • numElements[in] the number of elements of type T to copy.

  • stream[in] the CUDA stream to perform the operation on.

template<typename T>
static inline void copyDToDAsync(PxCudaContextManager &cudaContextManager, T *dstDeviceBuffer, const T *srcDeviceBuffer, PxU64 numElements, CUstream stream)

Schedules device to device copy operation on the specified stream.

The cuda context will get acquired automatically

Parameters
  • cudaContextManager[in] the PxCudaContextManager managing the CUDA context executing the operation.

  • dstDeviceBuffer[in] pointer to the destination device buffer.

  • srcDeviceBuffer[in] pointer to the source device buffer.

  • numElements[in] the number of elements of type T to copy.

  • stream[in] the CUDA stream to perform the operation on.

template<typename T>
static inline void memsetAsync(PxCudaContextManager &cudaContextManager, T *dstDeviceBuffer, const T &value, PxU64 numElements, CUstream stream)

Schedules a memset operation on the device on the specified stream.

Only supported for 1 bytes or 4 byte data types.

The cuda context will get acquired automatically

Parameters
  • cudaContextManager[in] the PxCudaContextManager managing the CUDA context executing the operation.

  • dstDeviceBuffer[in] pointer to the destination device buffer.

  • value[in] the value to set the memory to.

  • numElements[in] the number of elements of type T to set.

  • stream[in] the CUDA stream to perform the operation on.