code that may not be directly parallelized by OpenMP

General OpenMP discussion

code that may not be directly parallelized by OpenMP

Postby david.livshin » Mon Jul 30, 2018 5:59 am

Working on autoparallelizer and looking for benchmarks that may not be directly parallelized by OpenMP.

Being on the subject, is it possible to parallelize the following code using OpenMP?

1.
double a[ARRAY_DIM], c[ARRAY_DIM];
.
double ret;
ret = 0.;
for ( i = 0; i < ARRAY_DIM; i++ )
{
c[i] = exp( ret );
ret += a[i];
}

return ret;

2.
double a[ARRAY_DIM], c[ARRAY_DIM];
.
double ret;
ret = 0.;
for ( i = 0; i < ARRAY_DIM; i++ )
{
if ( a[i] > 0.01 )
{
ret = c[i];
}
}

return ret;



Thank you in advance,

David
david.livshin
 
Posts: 2
Joined: Mon Jul 09, 2018 10:11 pm

Re: code that may not be directly parallelized by OpenMP

Postby MarkB » Tue Aug 14, 2018 1:56 am

Neither of these examples can be parallelised simply by adding OpenMP directives: they would both require code refactoring.
MarkB
 
Posts: 768
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 5 guests

cron