intel / llvm

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

GPU emulator #8661

Open mirenradia opened 1 year ago

mirenradia commented 1 year ago

Is your feature request related to a problem? Please describe

It would be great if one could emulate a GPU (like there is an FPGA emulator) purely for correctness testing rather than for performance (I would naively expect performance to be very bad). The use case I have in mind is for testing in CI (e.g. using GitHub actions) where we do not typically have access to GPUs (unless we shift to hosting ourselves).

Describe the solution you would like

The creation of a GPU emulator like there is for FPGAs.

Describe alternatives you have considered

For SYCL, I guess one could just test the CPU device but this does not fully test correct behavior on GPUs. The other alternative is just testing on physical hardware but this is not always feasible.

Additional context

I understand this is a rather large feature request so don't expect anything soon but thought I'd create the issue following discussions with @Pennycook.

keryell commented 1 year ago

If you execute a SYCL program on a CPU device instead of a GPU or FPGA, isn't it a way to have emulation for free with SYCL? I guess you can add more or less features to be closer than the real hardware behavior but at the cost of performance? But I am curious about which difference in behavior you would like to expose.

mirenradia commented 1 year ago

The main one I had in mind was the separation of host and device memory but I don't know enough to say what others there might be.

Basically, I want to guarantee (or so far as is possible) that if I observe correct behavior with the emulated device, then I will obtain correct behaviour with a physical GPU device.

keryell commented 1 year ago

That is a good point. Probably both are useful. A cool feature with pure CPU implementation is that you can detect some bugs with tools like ThreadSanitizer, UBSan, etc. which might not be available on other hardware like GPU or emulators/simulators for other hardware like GPU.