Intel® oneAPI Data Parallel C++
Support for Intel® oneAPI DPC++ Compiler, Intel® oneAPI DPC++ Library, Intel ICX Compiler , Intel® DPC++ Compatibility Tool, and GDB*

can we use dpct in WSL2

Shukla__Gagandeep
1,951 Views

Hi,

I have windows for linux subsystem with ubuntu version 18.04.1 LTS (Bionic Beaver). I have installed cuda toolchain and OneAPI basetoolkit.

I am trying to use dpct to convert a cuda file and i am getting math.h file not found error.

>dpct --extra-arg="-I /usr/include/" utils.cu
NOTE: Could not auto-detect compilation database for file 'utils.cu' in '/home/gdshukla/code/h2o4gpu/src/gpu' or any parent directory.
The directory "dpct_output" is used as "out-root"
Processing: /home/gdshukla/code/h2o4gpu/src/gpu/utils.cu
In file included from <built-in>:1:
In file included from /opt/intel/inteloneapi/dpcpp-ct/2021.1-beta06/lib/clang/11.0.0/include/__clang_cuda_runtime_wrapper.h:37:
/usr/include/c++/7.5.0/cmath:45:15: fatal error: 'math.h' file not found
#include_next <math.h>
              ^~~~~~~~
1 error generated when compiling for host.
Error while processing /home/gdshukla/code/h2o4gpu/src/gpu/utils.cu.
dpct exited with code: -17 (Error: Cannot parse input file(s))

I even tried to supply the folder in which math.h is located using --extra-args command as can be seen in the command above.

No matter which file I try to convert, they all give same error. Although I am able to write a simple c program which uses math.h and compile it successfully.

I have looked all over google and most of the pages I found are related to macos issue of linker not able to find math library symbols.

So my question is -- can we use dpct in windows for linux subsystem and if yes, any ideas how to solve this issue.

Gagan

 

0 Kudos
9 Replies
RahulV_intel
Moderator
1,951 Views

Hi Gagandeep,

I'm not sure whether WSL/WSL2 is supported by oneAPI.

As per the official documentation, these are the hardware/software requirements: https://software.intel.com/content/www/us/en/develop/articles/intel-oneapi-dpcpp-system-requirements-beta.html

I will check with the concerned team and get back to you regarding WSL/WSL2 support.

 

--Rahul

0 Kudos
Shukla__Gagandeep
1,951 Views

Hi Rahul,

A point to note is that I just want to be able to compile/convert code in WSL as I don't have separate linux machine. So it's okay if I can't execute the binary. I just want to be able to run dpcpp and dpct tools in WSL2.

Gagan

 

0 Kudos
Shukla__Gagandeep
1,950 Views

Hi Rahul,

Just sharing an observation about WSL.

I tried compiling and running a OneAPI program on WSL using three modes:

  • cl::sycl::device(cl::sycl::cpu_selector());

  • cl::sycl::device(cl::sycl::default_selector());

  • cl::sycl::device(cl::sycl::gpu_selector());

In case of cpu_selector, program ran just fine and it used my CPU (Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz) as host device

In case of default_selector, program found "Intel(R) FPGA Emulation Device" and ran just fine.

In case of gpu_selector, it failed to find gpu device and went back to running on CPU.

Another thing I observed is that the first time I ran the program it took  50 seconds but when I ran the program again, it just took 2 seconds. Does it have some thing to do with JIT or something. Any idea  why time taken dropped so much. Just curious.

Gagan

 

0 Kudos
RahulV_intel
Moderator
1,950 Views

Hi,

Another thing I observed is that the first time I ran the program it took  50 seconds but when I ran the program again, it just took 2 seconds

Is it the compile time or the run time? 

In case of AOT(Ahead of Time), compilation could take more time since we specify the target device beforehand (using -fsycl-targets flag). The machine code in this case is generated during compile time.

Where as, when using JIT(Just in time) compilation(normal case), the machine code is generated on the fly, during runtime. Because of this "Jitting overhead", the run time of the program could increase to some extent.

Coming back to your 1st question, could you provide the sample cuda code, header files etc that you have used for dpct migration?

 

Regards,

Rahul

0 Kudos
Shukla__Gagandeep
1,951 Views

Thanks for the explanation.

And I was compiling utils.cu file from h2o4gpu repo. I got same error for other cuda files of this repo.

The command I used is: 

dpct --extra-arg="-I./../include" --extra-arg="-I/usr/include/"  --out-root=dpct utils.cu

I have even made sure that /usr/include is present in CPATH environment variable and it contains math.h file.

Regards,
Gagan

 

0 Kudos
RahulV_intel
Moderator
1,951 Views

Hi,

I do not observe any such error with Linux host OS(Ubuntu 18.04). Dpcpp migrated files are getting generated correctly for me (Some of the cuda APIs are not supported currently by Dpct. Anyway, that's a different issue).

Dpct command that I've used: 

dpct utils.cu --extra-arg="-std=c++11"

Also, I've checked with my cmath header and I do not see the line #include_next <math.h> (Strange!).

I'd suggest you to re-install GCC and check if it helps.

 

In case of gpu_selector, it failed to find gpu device and went back to running on CPU.

The GPU device is actually bound to the host(not to the WSL itself!). That could be the reason for the fallback.

 

--Rahul

0 Kudos
RahulV_intel
Moderator
1,951 Views

Hi,

/usr/include/c++/7.5.0/cmath:45:15: fatal error: 'math.h' file not found #include_next <math.h>

This error might have got triggered due to the order in which header files are being used(order of headers matter!).

I've spoken to the concerned team. The fix is expected in oneAPI beta07 version.

Meanwhile, could you try on Windows host and see if the same error is reproducible?

 

Thanks,

Rahul

0 Kudos
RahulV_intel
Moderator
1,945 Views

Hi Gagan,


Could you try this out again with the latest beta07 build and see if it works?


--Rahul


0 Kudos
RahulV_intel
Moderator
1,929 Views

Hi,


I have not heard back from you and hence I shall be closing this thread. Post a new question if your issue persists.


--Rahul


0 Kudos
Reply