Commit 654c8934c91160c2a206f6950546ab93528b0c58

Authored by David Mayerich
1 parent 685a889c

CUDA_CALLABLE fix and CUDA_UNCALLABLE implementation

stim/cuda/cudatools/callable.h
... ... @@ -7,4 +7,10 @@
7 7 #define CUDA_CALLABLE
8 8 #endif
9 9  
  10 +#ifdef __CUDACC__
  11 +#define CUDA_UNCALLABLE __host__ inline
  12 +#else
  13 +#define CUDA_UNCALLABLE
  14 +#endif
  15 +
10 16 #endif
... ...
stim/math/vec3.h
... ... @@ -243,9 +243,9 @@ public:
243 243 return false;
244 244 }
245 245  
246   -#ifndef __NVCC__
  246 +//#ifndef __CUDA_ARCH__
247 247 /// Outputs the vector as a string
248   - std::string str() const{
  248 +CUDA_UNCALLABLE std::string str() const{
249 249 std::stringstream ss;
250 250  
251 251 const size_t N = 3;
... ... @@ -261,7 +261,7 @@ public:
261 261  
262 262 return ss.str();
263 263 }
264   -#endif
  264 +//#endif
265 265  
266 266 size_t size(){ return 3; }
267 267  
... ...
stim/visualization/colormap.h
... ... @@ -166,14 +166,12 @@ static void gpu2gpu(T* gpuSource, unsigned char* gpuDest, unsigned int nVals, T
166 166 gridX = 65535;
167 167 }
168 168 dim3 dimGrid(gridX, gridY);
169   - //int gridDim = (nVals + blockDim - 1)/blockDim;
170 169 if(cm == cmGrayscale)
171 170 applyGrayscale<<<dimGrid, blockDim>>>(gpuSource, gpuDest, nVals, minVal, maxVal);
172 171 else if(cm == cmBrewer)
173 172 {
174 173 initBrewer();
175 174 applyBrewer<<<dimGrid, blockDim>>>(gpuSource, gpuDest, nVals, minVal, maxVal);
176   - //HANDLE_ERROR(cudaMemset(gpuDest, 0, sizeof(unsigned char) * nVals * 3));
177 175 destroyBrewer();
178 176 }
179 177  
... ... @@ -190,13 +188,9 @@ static void gpu2cpu(T* gpuSource, unsigned char* cpuDest, unsigned int nVals, T
190 188 unsigned char* gpuDest;
191 189 HANDLE_ERROR(cudaMalloc( (void**)&gpuDest, sizeof(unsigned char) * nVals * 3 ));
192 190  
193   - //HANDLE_ERROR(cudaMemset(gpuSource, 0, sizeof(T) * nVals));
194   -
195 191 //create the image on the gpu
196 192 gpu2gpu(gpuSource, gpuDest, nVals, minVal, maxVal, cm);
197   -
198   - //HANDLE_ERROR(cudaMemset(gpuDest, 0, sizeof(unsigned char) * nVals * 3));
199   -
  193 +
200 194 //copy the image from the GPU to the CPU
201 195 HANDLE_ERROR(cudaMemcpy(cpuDest, gpuDest, sizeof(unsigned char) * nVals * 3, cudaMemcpyDeviceToHost));
202 196  
... ...