Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29235 Discussions

auto parallelization with sum and spread function

bouwman
Beginner
410 Views
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
forall(i=1:100)
forall(j=1:100)
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?
0 Kudos
1 Reply
Steven_L_Intel1
Employee
410 Views
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.

Steve
0 Kudos
Reply