Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to emulate a GPU for CUDA/OpenCL unit testing purposes?

I would like to develop a library with an algorithm that can run on the CPU or the GPU. The GPU can be Nvidia (then the algorithm will use CUDA) or not (then the algorithm will use OpenCL).

I would like to emulate a GPU in this project because maybe:

  • I will use different computer to develop the software and some of them don't have a GPU.

  • The software will be finally executed in servers that can have a GPU or not and the unit test must be executed and passed.

Is there a way to emulate a GPU for unit testing purposes?

In the following link:

GPU Emulator for CUDA programming without the hardware

They show a solution but only for CUDA, not for OpenCL and the software they propose "GPUOcelot" is no longer actively maintained.

like image 902
Rob Avatar asked Nov 07 '16 09:11

Rob


People also ask

Can you simulate a GPU?

Yes, but simulating something is very intensive which is why we need somewhat high end hardware to emulate PS2 games - even though the hardware itself is not powerful, you are trying to simulate the functions of the hardware in order to "trick" the game.

Does OpenCL run on GPU?

OpenCL™ (Open Computing Language) is a low-level API for heterogeneous computing that runs on CUDA-powered GPUs. Using the OpenCL API, developers can launch compute kernels written using a limited subset of the C programming language on a GPU.

Can you run CUDA on non NVIDIA GPU?

Unfortunately, you cannot use CUDA without a Nvidia Graphics Card. CUDA is a framework developed by Nvidia that allows people with a Nvidia Graphics Card to use GPU acceleration when it comes to deep learning, and not having a Nvidia graphics card defeats that purpose.

Which is better for rendering CUDA or OpenCL?

If you have an Nvidia card, then use CUDA. It's considered faster than OpenCL much of the time. Note too that Nvidia cards do support OpenCL. The general consensus is that they're not as good at it as AMD cards are, but they're coming closer all the time.


1 Answers

It depends on what you mean on emulation. You cannot emulate the speed of GPUs.

The GPU is architecturally very different from the CPU, with a lot of working threads (1000s, 10000s, ...), that's why we use it. The CPU can have only a few threads, even when you parallelize the code. They also have different instruction sets.

You can however emulate the execution using special softwares, like NVEmulate for NVIDIA GPUs and OpenCL Emulator-Debugger for AMD.

A related question: GPU Emulator for CUDA programming without the hardware, where the accepted answer recommends gpuocelot for CUDA emulation.

like image 91
plasmacel Avatar answered Sep 21 '22 12:09

plasmacel