auto parallelization with sum and spread function

auto parallelization with sum and spread function

Hi All,

I have a problem when auto parallelizing forall constructs containing a sum() or spread() function. The problem with the sum() functions occurs when using a logical mask. for instance:

real, dimension(100,100) :: a
real, dimension(100,100,100) :: b,c
a(j,i) = sum(b(:,:,j)*c(:,:,i))
end forall
end forall

works fine and is parallelized, however if I use in the above example something like

a(j,i) = sum(b(:,:,j)*c(:,:,i), mask=(d(:,:) > 0.)

i.e. use a logical mask, the forall construct can not be parallelized. Is this a problem of the ifc compiler or can masked summations simply not be parallel?

Also, when using the spread() function in something like

real, dimension(100,100,100) :: a
real, dimension(100) :: b
forall (i=1:100)
a(i,:,:) = spread(b,dim=1,ncopies=100 )
end forall

does not parallelize. Still, one can use these functions within a forall construct without the compiler complaining so it should be possible to run things parallel or not?

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I can't speak to the parallelizing aspect, but just because you CAN say something in a FORALL, that doesn't mean it automatically can (or will) be run in parallel. The FORALL is your hint to the compiler that you don't care about the order of execution across the FORALL, but the compiler needs to do its own analysis and there may be some complex expressions it doesn't know how to automatically run in parallel.


Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today