intel / llvm

Intel staging area for llvm.org contribution. Home for Intel LLVM-based projects.
Other
1.21k stars 727 forks source link

[SYCL] Time functions #8191

Closed zjin-lcf closed 1 year ago

zjin-lcf commented 1 year ago

Are there time functions (e.g. clock() and clock64()) in SYCL ?

Reference http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#time-function

AlexeySachkov commented 1 year ago

Hi @zjin-lcf,

As far as I know there are no similar functions in SYCL. You can use event::get_profiling_info to get various info about command group execution. It allows you to measure kernel execution time, but it won't allow you to measure time of a certain segment of a kernel.

Please also note that profiling info must be enabled when creating a queue.

zjin-lcf commented 1 year ago

I hope that the SYCL specification team will add them. Thank you.

zjin-lcf commented 1 year ago

https://medium.com/rapids-ai/extending-numbas-cuda-target-with-the-high-level-api-cc9309b129a1

Does the SYCL compiler allow people to add intrinsics in the kernel ?

AlexeySachkov commented 1 year ago

Does the SYCL compiler allow people to add intrinsics in the kernel ?

It would be good to align on the meaning of "intrinsic" here. Essentially, if you know that device compiler for a target you are interested in supports some built-in functions, then you can technically declare them in your application as SYCL_EXTERNAL functions and call them.

Some of our experimental features are implemented this way: https://github.com/intel/llvm/blob/37960cda2d6c190cfe30c3e199ecc20fed7f03f6/sycl/include/sycl/ext/oneapi/experimental/invoke_simd.hpp#L31-L55

If you are interested in injecting some inline assembly into your kernel, then it should also be possible, theoretically. I say theoretically, because we do support that for Intel GPUs, for example and have corresponding tests: InlineAsm, but I haven't seen any examples with inline asm for CUDA devices, so I don't know if it really works there.

zjin-lcf commented 1 year ago

Most users don't necessarily know about the compiler implementations. Examples with inline asm for CUDA/HIP devices are very helpful for users.

AlexeySachkov commented 1 year ago

I hope that the SYCL specification team will add them. Thank you.

@zjin-lcf, we have noted this feature request internally, but if you want this functionality to be a core part of the specification, then it perhaps worth to submit an issue against KhronosGroup/SYCL-Docs repo.

Most users don't necessarily know about the compiler implementations. Examples with inline asm for CUDA/HIP devices are very helpful for users.

@intel/llvm-reviewers-cuda, do you know if inline asm works for CUDA/HIP?

zjin-lcf commented 1 year ago

https://github.com/KhronosGroup/SYCL-Docs/issues/385