- Code: Select all
PROGRAM TEST
use omp_lib ! Fortran 95; omp_get_thread_num, omp_get_num_threads
implicit none
integer j,i,k,tot,x,nthreads
integer,dimension(3)::counter
real*8,dimension(3)::A
A(1) = 10
A(2) = 600
A(3) = 10000000
tot = OMP_get_max_threads() ! tells you maximum allowable thread on machine
write(*,*) 'maximum allowable threads =', tot
x = 2
call OMP_SET_NUM_THREADS(x) ! allows you to set the number of threads outside of parallel environment
!$OMP PARALLEL
nthreads = omp_get_num_threads() ! get number of threads being used
!$OMP DO SCHEDULE(DYNAMIC)
do j = 1,3,1
do i = 1,150000,1
do k = 1,150000,1
A(j) = A(j)+i-(k/j)
enddo
enddo
enddo
!$OMP END DO NOWAIT
WRITE (*,*) 'Parallel threads used: ',nthreads
!$OMP END PARALLEL
write(*,*) 'A =', A
end
I see the same run time putting it in serial as I do threading it. I basically just want to be able to thread through the first j loop with each thread taking a j and doing the rest of the calculations since each j is not dependent on the other j values. Any ideas on what is happening/I'm doing wrong?
