MCPcopy Create free account
hub / github.com/blender/cycles / enqueue

Method enqueue

src/device/cuda/queue.cpp:75–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75bool CUDADeviceQueue::enqueue(DeviceKernel kernel,
76 const int work_size,
77 const DeviceKernelArguments &args)
78{
79 if (cuda_device_->have_error()) {
80 return false;
81 }
82
83 debug_enqueue_begin(kernel, work_size);
84
85 const CUDAContextScope scope(cuda_device_);
86
87 /* Update image info in case integrator memory alloc caused texture to move to host. */
88 if (cuda_device_->load_image_info()) {
89 cuda_device_assert(cuda_device_, cuCtxSynchronize());
90 if (cuda_device_->have_error()) {
91 return false;
92 }
93 }
94
95 /* Compute kernel launch parameters. */
96 const CUDADeviceKernel &cuda_kernel = cuda_device_->kernels.get(kernel);
97 const int num_threads_per_block = cuda_kernel.num_threads_per_block;
98 const int num_blocks = divide_up(work_size, num_threads_per_block);
99
100 int shared_mem_bytes = 0;
101
102 switch (kernel) {
103 case DEVICE_KERNEL_INTEGRATOR_QUEUED_PATHS_ARRAY:
104 case DEVICE_KERNEL_INTEGRATOR_QUEUED_SHADOW_PATHS_ARRAY:
105 case DEVICE_KERNEL_INTEGRATOR_ACTIVE_PATHS_ARRAY:
106 case DEVICE_KERNEL_INTEGRATOR_TERMINATED_PATHS_ARRAY:
107 case DEVICE_KERNEL_INTEGRATOR_SORTED_PATHS_ARRAY:
108 case DEVICE_KERNEL_INTEGRATOR_COMPACT_PATHS_ARRAY:
109 case DEVICE_KERNEL_INTEGRATOR_TERMINATED_SHADOW_PATHS_ARRAY:
110 case DEVICE_KERNEL_INTEGRATOR_COMPACT_SHADOW_PATHS_ARRAY:
111 /* See parall_active_index.h for why this amount of shared memory is needed. */
112 shared_mem_bytes = (num_threads_per_block + 1) * sizeof(int);
113 break;
114
115 default:
116 break;
117 }
118
119 /* Launch kernel. */
120 assert_success(cuLaunchKernel(cuda_kernel.function,
121 num_blocks,
122 1,
123 1,
124 num_threads_per_block,
125 1,
126 1,
127 shared_mem_bytes,
128 cuda_stream_,
129 const_cast<void **>(args.values),
130 nullptr),
131 "enqueue");
132

Callers 1

reserve_local_memoryMethod · 0.45

Calls 3

divide_upFunction · 0.85
have_errorMethod · 0.80
load_image_infoMethod · 0.45

Tested by

no test coverage detected