11#ifndef __stir_cuda_utilities_H__
12#define __stir_cuda_utilities_H__
26# include <cuda_runtime.h>
28# ifndef CUVEC_DISABLE_CUDA
29# define CUVEC_DISABLE_CUDA
50 unsigned int x = 1, y = 1, z = 1;
54 int x = 0, y = 0, z = 0;
57typedef dim3 cuda_dim3;
58typedef int3 cuda_int3;
65template <
int num_dimensions,
typename elemT>
72template <
int num_dimensions,
typename elemT>
80template <
int num_dimensions,
typename elemT>
87template <
int num_dimensions,
typename elemT>
93template <
typename elemT>
95blockReduction(elemT* shared_mem,
int thread_in_block,
int block_threads)
97 for (
int stride = block_threads / 2; stride > 0; stride /= 2)
99 if (thread_in_block < stride)
100 shared_mem[thread_in_block] += shared_mem[thread_in_block + stride];
106template <
typename elemT>
107__device__
inline double
108atomicAddGeneric(
double* address, elemT val)
110# if defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 600
111 return atomicAdd(address,
static_cast<double>(val));
113 if (threadIdx.x == 0 && threadIdx.y == 0 && threadIdx.z == 0 && blockIdx.x == 0 && blockIdx.y == 0 && blockIdx.z == 0)
115 printf(
"CudaGibbsPenalty: atomicAdd(double) unsupported on this GPU. "
116 "Upgrade to compute capability >= 6.0 or check code at "
117 "sources/STIR/src/include/stir/cuda_utilities.h:108.\n");
118 asm volatile(
"trap;");
138checkCudaError(
const std::string& operation)
140 cudaError_t cuda_error = cudaGetLastError();
141 if (cuda_error != cudaSuccess)
143 const char* err = cudaGetErrorString(cuda_error);
144 error(std::string(
"CudaGibbsPrior: CUDA error in ") + operation +
": " + err);
defines the stir::Array class for multi-dimensional (numeric) arrays
This class defines multi-dimensional (numeric) arrays.
Definition Array.h:78
Declaration of stir::error().
void array_to_host(Array< num_dimensions, elemT > &stir_array, const elemT *dev_data, bool=true)
copy CUDA pointer to Array
void array_to_device(elemT *dev_data, const Array< num_dimensions, elemT > &stir_array)
copy an Array to pre-allocated device memory
Declaration of stir::info().