Commit: cba113a953c610fabd4507a80b2781f311e43c8a Author: Xavier Hallade Date: Fri Jun 3 15:15:27 2022 +0200 Branches: cycles_oneapi https://developer.blender.org/rBcba113a953c610fabd4507a80b2781f311e43c8a
Cycles: finish removing oneAPI custom kernel stats =================================================================== M intern/cycles/device/oneapi/queue.cpp M intern/cycles/kernel/device/oneapi/kernel.cpp M intern/cycles/kernel/device/oneapi/kernel.h =================================================================== diff --git a/intern/cycles/device/oneapi/queue.cpp b/intern/cycles/device/oneapi/queue.cpp index 7d559236606..0d68e31b0e3 100644 --- a/intern/cycles/device/oneapi/queue.cpp +++ b/intern/cycles/device/oneapi/queue.cpp @@ -19,67 +19,6 @@ struct KernelExecutionInfo { int enqueue_count = 0; }; -// TODO: Use or extend base Queue implementation for statistics. -struct OneapiKernelStats { - OneapiKernelStats(){}; - ~OneapiKernelStats() - { - } - - void print_and_reset() - { - if (stats_data.size() != 0) { - std::vector<std::pair<DeviceKernel, KernelExecutionInfo>> stats_sorted; - for (const auto &stat : stats_data) { - stats_sorted.push_back(stat); - } - - sort(stats_sorted.begin(), - stats_sorted.end(), - [](const std::pair<DeviceKernel, KernelExecutionInfo> &a, - const std::pair<DeviceKernel, KernelExecutionInfo> &b) { - return a.second.elapsed_summary > b.second.elapsed_summary; - }); - - VLOG(1) << "oneAPI execution kernels statistics:"; - double summary = 0.0; - for (const std::pair<DeviceKernel, KernelExecutionInfo> &iter : stats_sorted) { - VLOG(1) << " " << std::setfill(' ') << std::setw(10) << std::fixed << std::setprecision(5) - << std::right << iter.second.elapsed_summary - << "s: " << device_kernel_as_string(iter.first) << " (" - << iter.second.enqueue_count << " runs)"; - summary += iter.second.elapsed_summary; - } - VLOG(1) << "Total measured kernel execution time: " << std::fixed << std::setprecision(5) - << summary << "s"; - - stats_data.clear(); - active_kernels.clear(); - } - } - - void kernel_enqueued(DeviceKernel kernel) - { - assert(active_kernels.find(kernel) == active_kernels.end()); - active_kernels[kernel] = time_dt(); - } - - void kernel_finished(DeviceKernel kernel, unsigned int /*kernel_work_size*/) - { - assert(active_kernels.find(kernel) != active_kernels.end()); - double elapsed_time = time_dt() - active_kernels[kernel]; - active_kernels.erase(kernel); - - stats_data[kernel].elapsed_summary += elapsed_time; - stats_data[kernel].enqueue_count += 1; - } - - std::map<DeviceKernel, KernelExecutionInfo> stats_data; - std::map<DeviceKernel, double> active_kernels; -}; - -static OneapiKernelStats global_kernel_stats; - /* OneapiDeviceQueue */ OneapiDeviceQueue::OneapiDeviceQueue(OneapiDevice *device) @@ -88,21 +27,11 @@ OneapiDeviceQueue::OneapiDeviceQueue(OneapiDevice *device) oneapi_dll_(device->oneapi_dll_object()), kernel_context_(nullptr) { - if (getenv("CYCLES_ONEAPI_KERNEL_STATS") != nullptr && VLOG_IS_ON(1)) { - with_kernel_statistics_ = true; - } - else { - with_kernel_statistics_ = false; - } } OneapiDeviceQueue::~OneapiDeviceQueue() { delete kernel_context_; - - if (with_kernel_statistics_) { - global_kernel_stats.print_and_reset(); - } } int OneapiDeviceQueue::num_concurrent_states(const size_t state_size) const @@ -162,7 +91,7 @@ void OneapiDeviceQueue::init_execution() void *kg_dptr = (void *)oneapi_device_->kernel_globals_device_pointer(); assert(device_queue); assert(kg_dptr); - kernel_context_ = new KernelContext{device_queue, kg_dptr, with_kernel_statistics_}; + kernel_context_ = new KernelContext{device_queue, kg_dptr}; debug_init_execution(); } @@ -187,16 +116,10 @@ bool OneapiDeviceQueue::enqueue(DeviceKernel kernel, assert(kernel_context_); - if (with_kernel_statistics_) - global_kernel_stats.kernel_enqueued(kernel); - /* Call the oneAPI kernel DLL to launch the requested kernel. */ bool is_finished_ok = oneapi_dll_.oneapi_enqueue_kernel( kernel_context_, kernel, uniformed_kernel_work_size, args); - if (with_kernel_statistics_) - global_kernel_stats.kernel_finished(kernel, uniformed_kernel_work_size); - if (is_finished_ok == false) { oneapi_device_->set_error("oneAPI kernel \"" + std::string(device_kernel_as_string(kernel)) + "\" execution error: got runtime exception \"" + diff --git a/intern/cycles/kernel/device/oneapi/kernel.cpp b/intern/cycles/kernel/device/oneapi/kernel.cpp index 9429badc62c..141f25dd357 100644 --- a/intern/cycles/kernel/device/oneapi/kernel.cpp +++ b/intern/cycles/kernel/device/oneapi/kernel.cpp @@ -619,9 +619,6 @@ bool oneapi_enqueue_kernel(KernelContext *kernel_context, assert(0); return false; }); - if (kernel_context->with_per_kernel_statistics) { - queue->wait_and_throw(); - } } catch (sycl::exception const &e) { if (s_error_cb) { diff --git a/intern/cycles/kernel/device/oneapi/kernel.h b/intern/cycles/kernel/device/oneapi/kernel.h index 606238f5919..70aca382f21 100644 --- a/intern/cycles/kernel/device/oneapi/kernel.h +++ b/intern/cycles/kernel/device/oneapi/kernel.h @@ -37,8 +37,6 @@ struct KernelContext { SyclQueue *queue; // Pointer to USM device memory with all global/constant allocation on this device void *kernel_globals; - // true, if Blender user have requested per-kernel statistics, overwise false - bool with_per_kernel_statistics; }; /* Use extern C linking so that the symbols can be easily load from the dynamic library at runtime. _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs