0
votes

Is it possible to maintain one sources base to compile for CPU or GPU(make choice using building system)? Are there any pitfalls for this approach?

1
Thrust is a complete example of such a system. So in a word, yestalonmies
Are you sure they have common sources ? Maybe they maintain separate sources for each of possibilitiesAlex
thrust maintains things that must be platform specific separately, of course. But things that need not be platform specific (e.g. algorithm implementation) are generally common. You can inspect the source-code for thrust yourself, if you want. It is open-source here. Another possibility to consider would be openACC which allows you to maintain a single source base and target different platforms (CPU or GPU) for executable.Robert Crovella

1 Answers

1
votes

The Alpaka library could be a thing for you. The alpaka library is a header-only C++11 abstraction library for accelerator development. Its supports different accelerators like OpenMP, Boost.Fiber and CUDA. You need to implement your kernel one times. With template parameter you can choose your accelerator platform.