SIMD code generation for math function "exp" using OPENMP

General OpenMP discussion

SIMD code generation for math function "exp" using OPENMP

Postby mandar.s123 » Wed Nov 14, 2018 1:24 am

Code: Select all
void calculate_exp_opt(float *out, float *in, int size)
{
    for(int i = 0; i < size; i++)
    {
        out[i] = exp(in[i]);
    }
}


I am very new to OpenMP.
I wanted to use OpenMP SIMD pragmas to optimize it. The code should work independent of compiler(at least gcc and clag) and independent of hardware architecture(say intel-sse/avx or arm-neon). I tried few pragmas like "omp simd", 'omp simd safelen' etc which is not very useful for above code. I have few quires about using OpenMP for this.
1. Is it possible to generate SIMD code for "exp" using OpenMP ?
2. Which hints I should use to generate SIMD code for above code ?
mandar.s123
 
Posts: 2
Joined: Tue Nov 13, 2018 2:40 am

Re: SIMD code generation for math function "exp" using OPENM

Postby MarkB » Thu Nov 15, 2018 3:26 am

My (possibly naive) expectation is that whether code like this gets vectorised depends mostly on whether the compiler can link in a vectorised maths library, and if it can, it will do so (given the right optimisation flags) without needing OpenMP SIMD directives.
MarkB
 
Posts: 776
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Re: SIMD code generation for math function "exp" using OPENM

Postby mandar.s123 » Thu Nov 15, 2018 4:05 am

I wanted the code which get vectorized independent of compiler(at least gcc/clang) and independent of architecture(intel sse/ arm neon). That is why I am trying to use OpenMP. Currently I am trying it with gcc-intel linux combination but I wanted it should wark with other combination as well. Can you suggest anything in OpenMP which does this job ?
mandar.s123
 
Posts: 2
Joined: Tue Nov 13, 2018 2:40 am

Re: SIMD code generation for math function "exp" using OPENM

Postby MarkB » Fri Nov 16, 2018 9:13 am

mandar.s123 wrote:I wanted the code which get vectorized independent of compiler(at least gcc/clang) and independent of architecture(intel sse/ arm neon).


Even with OpenMP, vectorisation is still going to be compiler and hardware dependent, I'm afraid.
MarkB
 
Posts: 776
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 4 guests

cron