17HIPDeviceQueue::HIPDeviceQueue(HIPDevice *device)
20 const HIPContextScope scope(hip_device_);
21 hip_device_assert(hip_device_, hipStreamCreateWithFlags(&hip_stream_, hipStreamNonBlocking));
24HIPDeviceQueue::~HIPDeviceQueue()
26 const HIPContextScope scope(hip_device_);
27 hipStreamDestroy(hip_stream_);
32 const int max_num_threads = hip_device_->get_num_multiprocessors() *
33 hip_device_->get_max_num_threads_per_multiprocessor();
39 params.
baseline = ((max_num_threads == 0) ? 65536 : max_num_threads) * 16;
45void HIPDeviceQueue::get_memory_info(
size_t &total,
size_t &free)
const
47 hip_device_->get_device_memory_info(total, free);
50void HIPDeviceQueue::init_execution()
53 HIPContextScope scope(hip_device_);
54 hip_device_->load_image_info(
nullptr);
55 hip_device_assert(hip_device_, hipDeviceSynchronize());
57 debug_init_execution();
60void HIPDeviceQueue::load_image_info()
62 HIPContextScope scope(hip_device_);
63 hip_device_->load_image_info(
this);
70 if (hip_device_->have_error()) {
76 const HIPContextScope scope(hip_device_);
79 if (hip_device_->load_image_info(
nullptr)) {
80 hip_device_assert(hip_device_, hipDeviceSynchronize());
81 if (hip_device_->have_error()) {
87 const HIPDeviceKernel &hip_kernel = hip_device_->kernels.get(kernel);
88 const int num_threads_per_block = hip_kernel.num_threads_per_block;
91 int shared_mem_bytes = 0;
103 shared_mem_bytes = (num_threads_per_block + 1) *
sizeof(
int);
110 assert_success(hipModuleLaunchKernel(hip_kernel.function,
114 num_threads_per_block,
119 const_cast<void **
>(args.
values),
125 return !(hip_device_->have_error());
128bool HIPDeviceQueue::synchronize()
130 if (hip_device_->have_error()) {
134 const HIPContextScope scope(hip_device_);
135 assert_success(hipStreamSynchronize(hip_stream_),
"synchronize");
138 return !(hip_device_->have_error());
152 hip_device_->global_alloc(mem);
155 hip_device_->mem_alloc(mem);
163 const HIPContextScope scope(hip_device_);
164 assert_success(hipMemsetD8Async((hipDeviceptr_t)d_ptr, 0, mem.
memory_size(), hip_stream_),
179 hip_device_->global_alloc(mem);
182 hip_device_->mem_alloc(mem);
191 const HIPContextScope scope(hip_device_);
209 const HIPContextScope scope(hip_device_);
227 const HIPContextScope scope(hip_device_);
229 hipMemcpyDtoHAsync(
storage.data(), (hipDeviceptr_t)d_ptr, mem.
memory_size(), hip_stream_),
230 "copy_from_device_synchronized");
236void HIPDeviceQueue::assert_success(hipError_t result,
const char *operation)
238 if (result != hipSuccess) {
239 const char *name = hipewErrorString(result);
240 hip_device_->set_error(
241 string_printf(
"%s in HIP queue %s (%s)", name, operation, debug_active_kernels().c_str()));
247 return make_unique<HIPDeviceGraphicsInterop>(
this);
virtual device_ptr mem_device_ptr(const device_memory &mem, Device *sub_device)
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_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_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,...)
ccl_device_inline size_t divide_up(const size_t x, const size_t y)