OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU.
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.
1718 Discussions

CPU vs GPU optimizations

akhal
Beginner
618 Views
Hello

I have implemented a straightaway naive matrix multiplication in OpenCL with AMD SDK. I get Speedup of around 16 for just an 8-core CPU system while I only run it on CPUs. I have applied some popular optimizations like utilizing private memory and local memory optimizations, and grouping my matrix in one dimension so I use both global and local dimension sizes. Now I get Speedup of around 24 with same 8-core CPU.

First I wonder this much speedup because for 8-cores I normally get around or less than 8 speedup with OpenMP for example. so these figures of 16 and 24 amaze me how its possible?

Second these local + private memory and grouping of work items are optimizations that I heard are only for GPUs and arent for CPUs so I again wonder how I get so much boost in speedup when I run it only on CPUs ?

Thirdly, I wonder how local and private memory and grouping are handled for CPUs as they cause speedup, caches or processor registers or what? Because this is magic to get so much speedup...

I also want to know what are CPU specific optimizations in OpenCL ?

Please help me clarify because I am so new to OpenCL and its giving me so big performance I cant beleive it, I have verified results and they are perfectly accurate.
Thanks in advance
0 Kudos
7 Replies
Polar01
Beginner
618 Views
Maybe because OpenMP does not optimize your code for parallelization, like using SIMD instructions :-)
Also, as you say, you play with different kind of memory, it is very important even on CPU (Like avoiding switching the registers etc...)
0 Kudos
Evgeny_F_Intel
Employee
618 Views
Hi,

It depends how you port your code to OpenCL.
But major factors could SIMD utilization mention by Polar01. Another reason could be better cache utilization. when you use local memories and all mapped to L1 cache, you might have significant speed up.

However, all of this are only assumptions and we can't comment on AMD SDK.

Thanks.
0 Kudos
akhal
Beginner
618 Views
But is SIMD utilization or auto-vectorization possible if I havent used OpencL vectors for example? Also local/private memory can boost speedup on CPUs? I am confused because someone told me that for device CPUs there is no local memory in OpenCL so no benefit, and that it only gives performance for GPUs...
0 Kudos
Evgeny_F_Intel
Employee
618 Views
CPU does have local memories and those are caches. When properly used they can gain significant speed up.

As alredy said, it's very difficult to understand from where coming the performance numbers w/o touching the code.

First of all try to understand code correctness, in some case you can have speed up because MT code produces different results.

You can try to use Intel OpenCL SDK and together with VTune Amplifier (http://software.intel.com/en-us/articles/intel-vtune-amplifier-xe/), which is supported by SDK, you can tryunderstand what is the real reason.

I also can reference you to Intel performance guidelines document (http://www.intel.com/Assets/PDF/manual/248966.pdf) which can provide few answers.
0 Kudos
akhal
Beginner
618 Views
Ok thank you for kind and useful information:)
0 Kudos
ARNON_P_Intel
Employee
618 Views
Continue with Evgeny direction, using OpenCL with CPU is very much relevance in boosting the performance of data parallel workloads.
To understand better how you optimize your code, I suggest to read it all in the Intel OpenCL Community,
And specifically:

Arnon
0 Kudos
akhal
Beginner
618 Views
Thank you very much for the kind hints :)
0 Kudos
Reply