File cuda_utils.cuh

Defines

IDX_3D(tensor, dims, idx)

indexes into a 3-dimensional tensor that is represented in memory as a single nested array. Note: 0 <= idx.x < dim.x

Parameters:
  • tensor – the array to be indexed into

  • dims – (outermost, middle, innermost) dimensions

  • idx – (outermost, middle, innermost) index

Returns:

address of the desired element

CUDA_CALL(x)

Wrapper for CUDA API calls to do error checking.

CURAND_CALL(x)

Wrapper for CURAND API calls to do error checking.

paranoid_assert(x)

Asserts whether x is true if the PARANOID compiler flag is set (-P)

namespace controls

Functions

static const char *curandGetErrorString(curandStatus_t error)

Converts an opaque error into a human-readable string.

static void cuda_assert(cudaError_t code, const char *file, int line, bool abort = true)

Checks for CUDA errors and prints them to stderr.

static void curand_assert(curandStatus_t code, const char *file, int line, bool abort = true)

Checks for CURAND errors and prints them to stderr.

static __host__ __device__ bool any_nan (const float *vec, size_t n)

Checks for NaN values inside the input vector.

template<typename T> __host__ __device__ T dot (const T *a, const T *b, size_t n)

Arbitrary dot product function.

template<typename T>
static void print_tensor(T tensor, dim3 dims)

Pretty printing function for a 3D tensor.

static __device__ void printf_vector (const float vec[], size_t n)

Pretty printing function for a 1D vector.

template<typename T> static __host__ __device__ T clamp (T n, T low, T high)

Forces a value to be within a certain range.

constexpr float radians(float degrees)

Converts degrees to radians.

template<typename T>
struct cudaTensor3D

3D pitched tensor

Public Members

cudaPitchedPtr pitched_ptr

Pointer to the data */.

cudaExtent extent