code that may not be directly parallelized by OpenMP

General OpenMP discussion
Post Reply
david.livshin
Posts: 2
Joined: Mon Jul 09, 2018 10:11 pm

code that may not be directly parallelized by OpenMP

Post by david.livshin »

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 = exp( ret );
ret += a;
}

return ret;

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

return ret;



Thank you in advance,

David

MarkB
Posts: 802
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Re: code that may not be directly parallelized by OpenMP

Post by MarkB »

Neither of these examples can be parallelised simply by adding OpenMP directives: they would both require code refactoring.

Post Reply