chew socks
chew socks

Reputation: 1446

ifort not parallelizing code

Why does ifort not parallelize this code? It keeps saying "loop was not parallelized: existence of parallel dependence". I can't understand where the dependence is. gfortran will generate parallel code, but the speed up is not very high.

PROGRAM erat
IMPLICIT NONE

INTEGER*8 :: i, rm, sn=1000000000
LOGICAL*1 , ALLOCATABLE, DIMENSION(:) :: nums

rm = INT( DBLE(sn)**0.5) + 1

ALLOCATE(nums(sn))
nums = .TRUE.                       !This line not parallelized

PRINT *, 'Doing initial sieve...'
nums(1) = .FALSE.
DO i = 2,rm
    nums(i**2:sn:i) = .FALSE.       !This line not parallelized
END DO
END PROGRAM erat

Upvotes: 0

Views: 501

Answers (1)

IanH
IanH

Reputation: 21451

That diagnostic is reported against the DO statement. As one specific example:

  • When i is 2, the loop sets num(8) to false.

  • When i is 4, the loop also sets num(8) to false.

That's two different iterations of the loop writing to the same memory location.

(The relevant Intel forums are a better place to ask questions that might get into the specifics of the behaviours of their compilers.)

Upvotes: 3

Related Questions