MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / process

Function process

cpp/5_Domain_Specific/postProcessGL/main.cpp:209–244  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// Run the Cuda part of the computation ///////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

207//! Run the Cuda part of the computation
208////////////////////////////////////////////////////////////////////////////////
209void process(int width, int height, int radius)
210{
211 cudaArray *in_array;
212 unsigned int *out_data;
213
214#ifdef USE_TEXSUBIMAGE2D
215 checkCudaErrors(cudaGraphicsMapResources(1, &cuda_pbo_dest_resource, 0));
216 size_t num_bytes;
217 checkCudaErrors(cudaGraphicsResourceGetMappedPointer((void **)&out_data, &num_bytes, cuda_pbo_dest_resource));
218// printf("CUDA mapped pointer of pbo_out: May access %ld bytes, expected %d\n",
219// num_bytes, size_tex_data);
220#else
221 out_data = cuda_dest_resource;
222#endif
223
224 // map buffer objects to get CUDA device pointers
225 checkCudaErrors(cudaGraphicsMapResources(1, &cuda_tex_screen_resource, 0));
226 // printf("Mapping tex_in\n");
227 checkCudaErrors(cudaGraphicsSubResourceGetMappedArray(&in_array, cuda_tex_screen_resource, 0, 0));
228
229 // calculate grid size
230 dim3 block(16, 16, 1);
231 // dim3 block(16, 16, 1);
232 dim3 grid(width / block.x, height / block.y, 1);
233 int sbytes = (block.x + (2 * radius)) * (block.y + (2 * radius)) * sizeof(unsigned int);
234
235 // execute CUDA kernel
236 launch_cudaProcess(
237 grid, block, sbytes, in_array, out_data, width, height, block.x + (2 * radius), radius, 0.8f, 4.0f);
238
239 checkCudaErrors(cudaGraphicsUnmapResources(1, &cuda_tex_screen_resource, 0));
240#ifdef USE_TEXSUBIMAGE2D
241 checkCudaErrors(cudaGraphicsUnmapResources(1, &cuda_pbo_dest_resource, 0));
242#endif
243 checkCudaErrors(cudaDestroyTextureObject(inTexObject));
244}
245
246#ifdef USE_TEXSUBIMAGE2D
247////////////////////////////////////////////////////////////////////////////////

Callers 1

processImageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected