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

久未见 提交于 2019-12-10 16:55:05

问题


Hey all, I Am currently porting a raytracer from FORTRAN 77 to C for a research 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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/4850358/when-writing-opencl-code-how-does-it-perform-on-a-single-core-machine-without-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!