20CUDADeviceQueue::CUDADeviceQueue(CUDADevice *device)
23 const CUDAContextScope scope(cuda_device_);
24 cuda_device_assert(cuda_device_, cuStreamCreate(&cuda_stream_, CU_STREAM_NON_BLOCKING));
27CUDADeviceQueue::~CUDADeviceQueue()
29 const CUDAContextScope scope(cuda_device_);
30 cuStreamDestroy(cuda_stream_);
35 const int max_num_threads = cuda_device_->get_num_multiprocessors() *
36 cuda_device_->get_max_num_threads_per_multiprocessor();
48void CUDADeviceQueue::get_memory_info(
size_t &total,
size_t &free)
const
50 cuda_device_->get_device_memory_info(total, free);
53int CUDADeviceQueue::num_sort_partitions(
int max_num_paths, uint max_scene_shaders)
const
57 if (max_scene_shaders <
min(300, cuda_device_->max_shared_mem_bytes / (
int)
sizeof(
int))) {
58 return max(max_num_paths / 65536, 1);
65bool CUDADeviceQueue::supports_local_atomic_sort()
const
70void CUDADeviceQueue::init_execution()
75 CUDAContextScope scope(cuda_device_);
76 cuda_device_->load_image_info(
nullptr);
77 cuda_device_assert(cuda_device_, cuCtxSynchronize());
79 debug_init_execution();
82void CUDADeviceQueue::load_image_info()
84 CUDAContextScope scope(cuda_device_);
85 cuda_device_->load_image_info(
this);
92 if (cuda_device_->have_error()) {
98 const CUDAContextScope scope(cuda_device_);
101 if (cuda_device_->load_image_info(
nullptr)) {
102 cuda_device_assert(cuda_device_, cuCtxSynchronize());
103 if (cuda_device_->have_error()) {
109 const CUDADeviceKernel &cuda_kernel = cuda_device_->kernels.get(kernel);
111 int num_threads_per_block = cuda_kernel.num_threads_per_block;
112 int shared_mem_bytes = 0;
124 shared_mem_bytes = (num_threads_per_block + 1) *
sizeof(
int);
130 shared_mem_bytes = cuda_device_->scene_max_shaders_ *
sizeof(int);
140 assert_success(cuLaunchKernel(cuda_kernel.function,
144 num_threads_per_block,
149 const_cast<void **
>(args.
values),
155 return !(cuda_device_->have_error());
158bool CUDADeviceQueue::synchronize()
160 if (cuda_device_->have_error()) {
164 const CUDAContextScope scope(cuda_device_);
165 assert_success(cuStreamSynchronize(cuda_stream_),
"synchronize");
169 return !(cuda_device_->have_error());
183 cuda_device_->global_alloc(mem);
186 cuda_device_->mem_alloc(mem);
194 const CUDAContextScope scope(cuda_device_);
195 assert_success(cuMemsetD8Async((CUdeviceptr)d_ptr, 0, mem.
memory_size(), cuda_stream_),
210 cuda_device_->global_alloc(mem);
213 cuda_device_->mem_alloc(mem);
226 const CUDAContextScope scope(cuda_device_);
248 const CUDAContextScope scope(cuda_device_);
266 const CUDAContextScope scope(cuda_device_);
268 cuMemcpyDtoHAsync(
storage.data(), (CUdeviceptr)d_ptr, mem.
memory_size(), cuda_stream_),
269 "copy_from_device_synchronized");
275void CUDADeviceQueue::assert_success(CUresult result,
const char *operation)
277 if (result != CUDA_SUCCESS) {
278 const char *name = cuewErrorString(result);
280 "%s in CUDA queue %s (%s)", name, operation, debug_active_kernels().c_str()));
286 return make_unique<CUDADeviceGraphicsInterop>(
this);
#define GPU_PARALLEL_SORT_BLOCK_SIZE
virtual device_ptr mem_device_ptr(const device_memory &mem, Device *sub_device)
bool is_shared(Device *sub_device) const
device_ptr device_pointer
#define CCL_NAMESPACE_END
#define assert(assertion)
#define storage(slot, qualifiers)
ccl_gpu_kernel_postfix const ccl_global int ccl_global float const int work_size
@ DEVICE_KERNEL_INTEGRATOR_QUEUED_PATHS_ARRAY
@ DEVICE_KERNEL_INTEGRATOR_SORT_WRITE_PASS
@ DEVICE_KERNEL_INTEGRATOR_QUEUED_SHADOW_PATHS_ARRAY
@ DEVICE_KERNEL_INTEGRATOR_TERMINATED_PATHS_ARRAY
@ DEVICE_KERNEL_INTEGRATOR_SORTED_PATHS_ARRAY
@ DEVICE_KERNEL_INTEGRATOR_COMPACT_SHADOW_PATHS_ARRAY
@ DEVICE_KERNEL_INTEGRATOR_SORT_BUCKET_PASS
@ DEVICE_KERNEL_INTEGRATOR_TERMINATED_SHADOW_PATHS_ARRAY
@ DEVICE_KERNEL_INTEGRATOR_ACTIVE_PATHS_ARRAY
@ DEVICE_KERNEL_INTEGRATOR_COMPACT_PATHS_ARRAY
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
bool use_local_atomic_sort
ccl_device_inline size_t divide_up(const size_t x, const size_t y)