Quantcast
Channel: Intel® Software - OpenCL*
Viewing all articles
Browse latest Browse all 1182

Intel OpenCL Performance comparison to OpenMP on CPU using simple codes

$
0
0

Hi,

I'd like to evaluate and choose the parallel computing tools on CPU. And OpenMP and OpenCL should be the preferred choices. So I write very simple example codes to give a comparision of performance. The test is done on OpenSUSE 12.3 with Intel Core I5-2500K (overclocking to 4GHz). And the Intel® SDK for OpenCL* Applications XE 2013 R2 is used.

The example Just do some nonsense computation on two random number arrays. 

OpenMP codes:


    const size_t dim=1024*1024*32; 
    std::vector<float> a(dim);
    std::vector<float> b(dim);
    std::vector<float> c(dim);
    for(size_t i=0; i<dim; i++){
        a[i]=rand();
        b[i]=rand();
 }

#pragma omp parallel for 
    for(size_t i=0; i<dim; i++){

        c[i]=sqrt(sqrt(a[i])*sqrt(b[i]));
    }

OpenCL kernel codes

__kernel void testKernel(__global float* a, __global float* b,  __global float* c)
 {
            size_t i=get_global_id(0); 
            c[i]=sqrt(sqrt((double)a[i])*sqrt((double)b[i])); 
}

The codes is so simple that I can not find more space for optimization.

=============

For the first, GCC 4.7 is used to compile the codes and the performance is as follow.

OpenMP codes:  0.166845 s

OpenCL codes:  0.0827546 s

The behaved as my expectation that the OpenCL codes is faster.

========

Then the Intel C++ Compiler 14.0.1 is used.

OpenMP codes:  0.082298 s

OpenCL codes:  0.117268 s

It is interesting that the Intel OpenMP implementation is near twice faster than GCC, but the OpenCL codes is slower although the same implementation is used. Anyone has ideas why this could happen? Does it mean that the Intel OpenCL implementation needs more optimizations compared to OpenMP? 

By the way are there any comprehensive benchmarks for OpenMP and OpenCL with different compilers and implementations?

Thanks!


Viewing all articles
Browse latest Browse all 1182

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>