Use of Intel oneAPI <sycl/ext/intel/math.hpp> and -fsycl-targets=nvptx64-nvidia-cuda

Hello

I am encountering a compile error if I use the intel include file <sycl/ext/intel/math.hpp> when compiling for an NVIDIA GPU target using “-fsycl-targets=nvptx64-nvidia-cuda”. I wish to use this include file to get access to bessel function maths, which I have tested on Intel GPUs using oneAPI…

I have installed the NVIDIA GPU plugin for oneAPI and have successfully run the sample program simple-sycl-app.cpp supplied by Codeplay.

This is my sycl-ls output

sycl-ls
[opencl:cpu][opencl:0] Intel(R) OpenCL, Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz OpenCL 3.0 (Build 0) [2024.18.7.0.11_160000]
[cuda:gpu][cuda:0] NVIDIA CUDA BACKEND, Tesla T4 7.5 [CUDA 12.4]

if I include <sycl/ext/intel/math.hpp>, but do NOT use the “-fsycl-targets=nvptx64-nvidia-cuda” option, the program compiles and runs, but of course it does NOT use the NVIDIA GPU.

However as soon as I include <sycl/ext/intel/math.hpp> I get lots of errors implying that some functions have been declared with conflicting types. For example;

==================
In file included from /opt/intel/oneapi/compiler/2024.2/bin/compiler/…/…/include/sycl/ext/intel/math.hpp:37:
/opt/intel/oneapi/compiler/2024.2/bin/compiler/…/…/include/sycl/ext/intel/math/imf_fp_conversions.hpp:52:7: error: conflicting types for ‘__imf_half2float’
52 | float __imf_half2float(_iml_half_internal);
| ^
/opt/intel/oneapi/compiler/2024.2/bin/compiler/…/…/include/sycl/builtins.hpp:178:36: note: previous declaration is here
178 | extern __DPCPP_SYCL_EXTERNAL float __imf_half2float(_Float16 x);
| ^

Could you please advise if it possible to use this include file <sycl/ext/intel/math.hpp> as I use it for the function
e.g. float b1 = sycl::ext::intel::math::jn(0, 1.0f);

Thank you.
RCB

Hi @RCB ,

unfortunately these functions are designed to be used on Intel hardware, so I have been unable to get them running properly. I was able to make one change to the file /opt/intel/oneapi/compiler/2024.2/include/sycl/ext/intel/math.hpp on line 29, adding || defined(__NVPTX__). This stops the slew of build errors but doesn’t actually work inside kernel code unfortunately, as there are missing builtin functions, but does work on the host side. There might be some things that do work but the function that you listed sadly does not.

I hope this helps,
Duncan.

Hi Duncan

Thanks for your help. So, would it be correct to say that I need to avoid using anything in sycl/ext/intel namespace if targeting a NVIDIA GPU device?

I guess I just have to wait until the bessel functions become a part of the SYCL specification.

Thanks
RCB

Hi @RCB,

I wouldn’t say that’s generally true - for example, this morning my colleagues and I have been discussing a local memory extension that works perfectly well on Nvidia devices.

Additionally I do think it should be possible to support these functions within the extension as it exists today, and I will be contacting one of my colleagues to see if he has some ideas about how we can fix it in the short term (without bringing it into the specification, which would be good too, but is considerably slower a process).