When writing openCL code, how does it work on a single-core computer without a GPU?

Hey, I am currently porting a raytracer from FORTRAN 77 to C for a research project.

After porting the basics, the question is how do we go about parallelizing.
In the laboratory, I have access to several other Opteron machines, from 2 to 8 cores, but without GPUs (at the moment). We are running 64b gentoo.

A GPGPU version would be (very) desirable, but with one programmer in the project, supporting separate versions without a GPU and GPU is not an option.
In addition, the code will be GPLed, and we would like it to be used by others who may have completely different hardware.

Thus, the entire program needs to be easily compiled / run without using a GPU or even a multi-core system.
OpenCl seems like a good option, since it can be run on machines without GPUs, but how will this code work on a single-core or 32-bit system?
Is it possible to write code in such a way that it can be easily compiled without openCL?

+4
source share
2 answers

Currently, there are four main options for OpenCL: AMD, nVidia (Cuda), Apple, Intel, and soon it will be possible: OpenCL-implementation . OpenCL is not a language specifically designed for GPU computing, it was developed as a general computing language for heterogeneous devices. For instance. you can use the AMD implementation even without a GPU and any processor without AMD (x86, of course).

Is it possible to write code in such a way that it can be easily compiled without openCL?

As you say, one person’s project, I doubt it will be worth the effort.

How will this code work in a single-core or 32-bit system?

Like any native program. You have access to SIMD through the OpenCL vector types. And you can handle threads through workgroup configuration.

But do not expect that you can get 100% performance on every device with the same kernel / workgroup settings. There are many special settings possible ( OpenCL CPU Tutorial for starters ).

I would say for OpenCL. It provides more features for your application, and it is platform independent.

+8
source

Perhaps it is entirely possible to use the OpenCL and C99 commonality and use a preprocessor to handle the differences. Then you will have the code base C99 and OpenCL in one. This is the approach adopted by SmallPT-GPU

However, OpenCL implementations for the CPU should be pretty good than any portable scalar C code, and better if you use OpenCL vector types to port portable SIMDs.

+2
source

Source: https://habr.com/ru/post/1337759/


All Articles