은은의 숫자는 때때로 잘못 아래 내 프로젝트에 일하고 나는 test1,2,3 루틴과 이상한 병렬 데 문제가 약간 변경 코드입니다 :OMP와의 병렬 오버랩 및 포트란에서의 백 업데이트 어레이?
integer, parameter :: N=6
integer, parameter :: chunk_size=3
integer, dimension(1:N) :: a,b,c
contains
subroutine array_setup
implicit none
integer :: i
do i=1,N
a(i)=2*i
b(i)=i*i
c(i)=i*i-i+2
end do
return
end subroutine array_setup
subroutine test1
implicit none
integer :: i
!$OMP parallel do private(i) shared(a,b,c) schedule(static,chunk_size)
do i=2,N
a(i-1)=b(i)
c(i)=a(i)
end do
!$OMP end parallel do
return
end subroutine test1
subroutine test2
implicit none
integer :: i
!$OMP parallel do private(i) shared(a,b,c) schedule(static,chunk_size)
do i=2,N
a(i-1)=b(i)
a(i)=c(i)
end do
!$OMP end parallel do
return
end subroutine test2
subroutine test3
implicit none
integer :: i
!$OMP parallel do private(i) shared(a,b,c) schedule(static,chunk_size)
do i=2,N
b(i)=a(i-1)
a(i)=c(i)
end do
!$OMP end parallel do
return
end subroutine test3
end program vectorize_test
이 아래는 나는 1 위에서 스레드 수를 증가시킬 때
after setup
1 2 1 2
2 4 4 4
3 6 9 8
4 8 16 14
5 10 25 22
6 12 36 32
after test1
1 4 1 2
2 9 4 4
3 16 9 6
4 25 16 8
5 36 25 10
6 12 36 12
after test2
1 4 1 2
2 9 4 4
3 16 9 8
4 25 16 14
5 36 25 22
6 32 36 32
after test3
1 2 1 2
2 4 2 4
3 8 4 8
4 14 8 14
5 22 14 22
6 32 22 32
, 내가 오전, 출력이 잘못된 만드는 각 컬럼에 변화 이상한 숫자를 얻을 : 올바른 OMP_NUM_THREADS = 1 출력 샘플 이 문제가 생기면 어떻게해야합니까? 당신이
!$OMP parallel do private(i) shared(a,b,c) schedule(static,chunk_size)
do i=2,N
a(i-1)=b(i)
c(i)=a(i)
end do
!$OMP end parallel do
을 수행 할 때
환영합니다. [둘러보기]를 읽고 [질문]을 읽으십시오. 모든 포트란 질문에 [태그 : 포트란]을 사용하십시오. 특정 버전의 questio에 특정 버전 태그를 추가 할 수는 있지만 일반적으로 2017 년에는 오래되고 쓸모없는 Fortran 90으로 제한하고 싶지 않습니다. 코드는 Fortran 버전과 전혀 관련이 없습니다. –