开发者

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

开发者 https://www.devze.com 2023-02-07 11:40 出处:网络
Hey all, I Am currently porting a raytracer from FORTRAN 77 to C for a research开发者_Python百科 project.

Hey all, I Am currently porting a raytracer from FORTRAN 77 to C for a research开发者_Python百科 project.

After having ported the essentials, the question is how we proceed to parallelization.

In the lab, I have access to a couple of different Opteron machines, with between 2 and 8 cores, but no GPUs (for now). We are running 64b gentoo.

A GPGPU version would be (very) desirable, but with only one programmer on the project, maintaining separate non-GPU and GPU versions isn't an option.

Also, the code will be GPLed, and we'd like to see it being used by others that may have vastly different hardware.

So the entire program has to be easy to compile/run without having a GPU or even a multicore system.

OpenCl seems like a good option, as it can be run on machines without GPUs, but how will this code perform on a single-core or 32b system?

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


Currently there are four major OpenCL implementations: AMD, nVidia (Cuda), Apple, Intel and there will be more soon probably: OpenCL implementations. OpenCL is not a language specifically targeted at GPU computing, it was designed as generic computing language for heterogeneous devices. E.g. you can use the AMD implementation even with no GPU and any non-AMD CPU (x86 of course).

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

As you say it's a one man project I doubt it will be worth the effort.

How will this code perform on a single-core or 32b system?

As good as any native program would run. You have access to SIMD through OpenCL vector types. And you can handle the threading through the work group configuration.

But don't expect that you can get 100% performance out of every device with the same kernel/ work group settings. There's a lot of device specific tweaking possible (OpenCL CPU Tutorial for a start).

I would say go for OpenCL. It provides more possibilities for your application and it's platform independet.


It may well be feasible to exploit the commonality of OpenCL and C99, and use the pre-processor to handle the differences. Then, you would have a C99 and OpenCL codebase in one. This is the approach taken in SmallPT-GPU

However, the OpenCL implementations for CPU should be pretty much as good as any portable scalar C code, and better if you are using the vector types of OpenCL to allow portable SIMD.

0

精彩评论

暂无评论...
验证码 换一张
取 消