sycl::info::event_profiling 中的 command_submit 是提交整个代码还是只提交parallel-for?

问题描述

我尝试分析我的函数在设备上的执行时间。 我读了这个链接https://docs.oneapi.com/versions/latest/dpcpp/iface/event.html 但我没有在文档中找到任何关于 sycl::info::event_profiling 的信息,这让我了解它们究竟对应什么。 我的意思是,command_start、command_end、command_submit。 例如: 这是我的代码的一部分,内核,

auto event = gpuQueue.submit([&](sycl::handler &h) {
                //local copy of fun
                auto f = fun;
                sycl::accessor in_accessor(in_buffer,h,sycl::read_only);
                sycl::accessor out_accessor(out_buffer,sycl::write_only);
                h.parallel_for(n_item,[=](sycl::id<1> index) {
                    out_accessor[index] = f(in_accessor[index]);
                });
            });
            event.wait();
            auto end_overall = std::chrono::system_clock::Now();
            cl_ulong submit_time = event.template get_profiling_info<
                    cl::sycl::info::event_profiling::command_submit>();
            cl_ulong start_time = event.template get_profiling_info<
                    cl::sycl::info::event_profiling::command_start>();
            cl_ulong end_time = event.template get_profiling_info<
                    cl::sycl::info::event_profiling::command_end>();

我想了解cl::sycl::info::event_profiling::command_submit,提交整个代码还是只提交parallel-for?

解决方法

SYCL 2020 specification 上更清楚一点:

  • command_submit 是命令组提交到 SYCL 运行时的时间戳。
  • command_start 是实际并行开始的时间戳
  • command_end 是并行完成的时间戳

因此,您在设备中的内核执行时间为 command_start - command_end, 而命令组的总处理时间(即潜在副本、运行时开销等)为 command_submit - command_end