Array constructor

fah10
Total Points:
50
Status Points:
0
Green Belt
July 18, 2009 11:05 AM PDT
Rate
 
#2 Reply to #1
The following test program usually produces errors when running with multiple OpenMP threads. Sometimes it is very hard to get the test failed. Using static arrays, it seems to be more likely that the test passes. However, in any case Intel's thread checker reports "Write->Write data-races" at the line with the array constructor.

program arraytest
  ! compiled with ifort -openmp arraytest.F90
  
  integer(kind=4), parameter :: n=1000000
  integer(kind=4) :: i
  real(kind=8), dimension(:,:),allocatable :: data
  real(kind=8), dimension(:),allocatable :: arr

  allocate(data(3,n))

  !$omp parallel private(arr,i) shared(data)
  allocate(arr(3))

  !$omp do
  do i=1,n

     arr(:) = (/ real(i,kind=8)**2, real(i,kind=8)**3, 1.0_8 /)

     ! uncommenting the following lines never produces an error
     !arr(1) = real(i,kind=8)**2
     !arr(2) = real(i,kind=8)**3
     !arr(3) = 1.0_8

     data(:,i) = arr(:)

  end do
  !$omp end do

  deallocate(arr)
  !$omp end parallel

  do i=1,n
     if ( data(1,i) /= real(i,kind=8)**2 ) then
        print*,'test failed'
        print*,real(i,kind=8)**2
        print*,data(1,i)
        stop
     end if
  end do

  print*,'test passed'
  deallocate(data)
end program arraytest



Intel Software Network Forums Statistics

8488 users have contributed to 31627 threads and 100743 posts to date.
In the past 24 hours, we have 35 new thread(s) 136 new posts(s), and 196 new user(s).

In the past 3 days, the most popular thread for everyone has been gemm(A,A,A) like possible? The most posts were made to gemm(A,A,A) like possible? The post with the most views is Dear Steve, excuse me for a d

Please welcome our newest member chat1983