oneMKL icon indicating copy to clipboard operation
oneMKL copied to clipboard

Illegal instruction error with oneMKL mt2203 instruction

Open ghost opened this issue 1 year ago • 16 comments

Summary

MersenneTwisterGP11213 Sample migrated from CUDA fails on NVIDIA GPU with opensource oneMKL library - Illegal instruction (core dumped)

checkCudaErrors(DPCT_CHECK_ERROR(prngGPU = dpct::rng::create_host_rng(
                                       dpct::rng::random_engine_type::mt2203)));

Version

onemkl version - https://github.com/oneapi-src/oneMKL/releases/tag/v0.3

Environment

  • HW - Tesla P100-PCIE-12GB
  • OS name and version - Ubuntu* 22.04
  • Compiler version - clang version 18.0.0git (https://github.com/intel/llvm 3468f496c04ca9091da19ff5c73aa5f7ef792924)
  • output log -
./a.out Starting...

 Allocating data for 2400000 samples...
 Seeding with 777 ...

 Illegal instruction (core dumped)

Steps to reproduce

Code Repo - MersenneTwister Compile command - clang++ -fsycl -fsycl-targets=nvptx64-nvidia-cuda MersenneTwister.cpp.dp.cpp -I../../../Common/ -I ../../../include/ -I <path to oneMKL include> -L <path to oneMKL lib> -lonemkl_rng_curand -lonemkl

Observed behavior

Sample executes successfully with Intel oneMKL library on intel hardware(Gen9, Gen11)

Expected output

/a.out Starting...

Allocating data for 2400000 samples...
Seeding with 777 ...
Generating random numbers on GPU...


Reading back the results...
Shutting down...

ghost avatar Jan 23 '24 17:01 ghost

Hi, Any update on this issue, can someone help with this ?

ghost avatar Feb 02 '24 04:02 ghost

@aelizaro any update?

ghost avatar Feb 09 '24 05:02 ghost

Hi, @Shwetha-Selma, sorry for the delayed responce, I missed this issue.

MT2203 generator is not yet available via oneMKL interfaces project, only via Intel oneMKL and so it can be used only on x86 CPUs and Intel's GPUs from the oneAPI package (however illegal instruction issue is a surprise, I can check it within dpct tool). In order to run on Tesla P100-PCIE-12GB, please, try another generator available in OneMKL Interfaces with cuRAND backend (Philox4x32x10 or mrg32k3a)

or if the point is the sample migration itself - you can build it with icpx compiler, link it against Intel oneMKL but it won't work on NVIDIA HW yet, you can validate it on x86 CPU:

icpx -fsycl -DMKL_ILP64 -I"${MKLROOT}/include MersenneTwister.cpp.dp.cpp -L${MKLROOT}/lib -lmkl_sycl_rng -lmkl_intel_ilp64 -lmkl_tbb_thread -lmkl_core -lsycl -lpthread -lm -ldl

aelizaro avatar Feb 09 '24 12:02 aelizaro

Thanks @aelizaro for confirming MT2203 generator is not yet available for the NVIDIA backend. And It would be helpful if you check about the 'Illegal instruction' error.

Also Is there any plan to include support for MT2203 generator with open-source oneMKL?

ghost avatar Feb 12 '24 09:02 ghost

@Shwetha-Selma, yes, we plan to extend oneMKL Interfaces with more generators, the ones which are used in DPCT as the first priority, but no exact timeline yet.

aelizaro avatar Feb 12 '24 09:02 aelizaro

Hi, any update for MT2203 support in oneMKL ??

AvijitBag07 avatar Jul 12 '24 08:07 AvijitBag07

Hi @AvijitBag07, no updates yet. Please let us know if it blocks your work - we can try to prioritize it

paveldyakov avatar Jul 12 '24 11:07 paveldyakov

Yes it blocks our work, it will be beneficial if it is completed earlier.

AvijitBag07 avatar Jul 15 '24 05:07 AvijitBag07

@AvijitBag07, got it, thank you for the feedback. We will increase priority for this engine

Just some clarification - we can introduce MT2203 in oneMKL Interfaces, but it won't support Nvidia backend. Is that fine for you?

paveldyakov avatar Jul 16 '24 08:07 paveldyakov

No, we are looking for Nvidia Backend support only.

AvijitBag07 avatar Jul 16 '24 10:07 AvijitBag07

cuRAND is the Nvidia backend in oneMKL Interfaces. But cuRAND doesn't support MT2203 engine.

paveldyakov avatar Jul 16 '24 11:07 paveldyakov

As oneMKL supports other RNG functions such as philox4x32x10<1> and mcg59<1> added for Nvidia backends, we also want MT2203 to be included

AvijitBag07 avatar Jul 17 '24 09:07 AvijitBag07

@AvijitBag07, do you reference to Device RNG API? If yes, we have a list of engines that is defined in oneMKL spec - https://github.com/uxlfoundation/oneAPI-spec/blob/main/source/elements/oneMKL/source/domains/rng/device_api/device-engines.rst

If you are interested in adding new engines to oneMKL Interfaces - please propose it for oneMKL spec

paveldyakov avatar Jul 17 '24 10:07 paveldyakov

How Intel oneMKL supports MT2203 generator, you can add MT2203 generator too in oneMKL too

AvijitBag07 avatar Jul 19 '24 11:07 AvijitBag07

Intel oneMKL supports MT2203 in Host API only (with x86 CPUs and Intel GPUs as the supported HW).

We can add support for MT2203 Host API into oneMKL Interfaces with Intel oneMKL backend. It means that it will have x86 CPUs and Intel GPUs supported HW. As there is no MT2203 in cuRAND - we cannot enable cuRAND as Nvidia backend for this generator.

paveldyakov avatar Jul 23 '24 08:07 paveldyakov

We can link intel oneMKL lib and use it for intel GPU, but for Nvidia there is no option yet. It will be helpful if you can add it

AvijitBag07 avatar Jul 24 '24 10:07 AvijitBag07