0

I have a C++ code and I execute C++ code in IOS device ( IPAD) which takes around 1 sec as execution time. I need to increase the performance of the code by running it in GPU.

Is it possible to run my particular C++ code in GPU? If possible can somebody list out the steps to run a C++ code in GPU? My main aim is to increase the performance of the current C++ code from 1 sec to milliseconds.

2vision2
  • 4,933
  • 16
  • 83
  • 164
  • You should first look at simple optimisations for your code, by profiling and identifying bottlenecks, then if that still does not yield sufficient improvement consider SIMD (NEON) for critical routines. – Paul R Aug 16 '13 at 12:16
  • 6
    you can not run arbitrary C++ code on the GPU (of a iOS device). – Jonathan Cichon Aug 16 '13 at 12:21
  • See http://stackoverflow.com/questions/3258257/are-either-the-ipad-or-iphone-capable-of-opencl – Erbureth Aug 16 '13 at 12:27

1 Answers1

4

CPUs and GPUs are far too distinct for this to happen. On a CPU, you are accustomed to a few large cores each executing a thread, while a GPU has hundreds or thousands of smaller cores that require different programming.

Your problem that takes one second needs to be "embarrasingly parallel" as cores cannot communicate as quickly as they can calculate, so any GPU gains would be lost if there is a need for synchronization and cross-core communication.

And unless you have an Intel 8008 as your CPU and an nVidia 680 for the GPU, one second of CPU stuff won't magically turn into a few milliseconds for the GPU.

iOS doesn't support this anyway. You could create shaders that would do calculations but it is far more complex, less elegant, and slower.

nanofarad
  • 40,330
  • 4
  • 86
  • 117
  • 4
    100x speedup is completely reasonable to expect for massively parallel problems... – Erbureth Aug 16 '13 at 12:52
  • 1
    @Erbureth Yes, but it requires adapting the problem for the GPU. It's not going to happen magically. This is also one of multiple models of mobile GPU of which the specs are not too bright. – nanofarad Aug 16 '13 at 12:53
  • Well, compared to mobile CPUs... – Erbureth Aug 16 '13 at 13:27