Hi all
I am trying to run a FORTRAN program with OpenMP in a cluster, but it is not using all the threads. Below is the code and the output. I am new to FORTRAN and OpenMP, please guide me on overcoming the issue
use OMP_LIB
implicit none
integer:: thread_num
integer:: num_threads, num_procs
num_threads = omp_get_max_threads()
call omp_set_num_threads(num_threads)
!$omp parallel
!$omp critical
!$thread_num = omp_get_thread_num()
print *, "Hello world thread number", thread_num
!$omp end critical
!$omp end parallel
end
Output:
Hello world thread number, 10
Thanks
Aru
On 11/8/2022 5:40 PM, Arumugam ce19d044 wrote:
Output:
Hello world thread number, 10
Hi all
I am trying to run a FORTRAN program with OpenMP in a cluster, but it is not using all the threads. Below is the code and the output. I am new to FORTRAN and OpenMP, please guide me on overcoming the issue ..
use OMP_LIB
implicit none
integer:: thread_num
integer:: num_threads, num_procs
num_threads = omp_get_max_threads()
call omp_set_num_threads(num_threads)
!$omp parallel
!$omp critical
!$thread_num = omp_get_thread_num()
print *, "Hello world thread number", thread_num
!$omp end critical
!$omp end parallel
end
Output:
Hello world thread number, 10
Hi all
I am trying to run a FORTRAN program with OpenMP in a cluster, but it is not using all the threads. Below is the code and the output. I am new to FORTRAN and OpenMP, please guide me on overcoming the issue
use OMP_LIB
implicit none
integer:: thread_num
integer:: num_threads, num_procs
num_threads = omp_get_max_threads()
call omp_set_num_threads(num_threads)
!$omp parallel
!$omp critical
!$thread_num = omp_get_thread_num()
print *, "Hello world thread number", thread_num
!$omp end critical
!$omp end parallel
end
Output:
Hello world thread number, 10
Thanks
Aru
On 09/11/2022 01:40, Arumugam ce19d044 wrote:
Hi all
I am trying to run a FORTRAN program with OpenMP in a cluster, but it
is not using all the threads. Below is the code and the output. I am
new to FORTRAN and OpenMP, please guide me on overcoming the issue
use OMP_LIB
implicit none
integer:: thread_num
integer:: num_threads, num_procs
num_threads = omp_get_max_threads()
call omp_set_num_threads(num_threads)
!$omp parallel
!$omp critical
!$thread_num = omp_get_thread_num()
print *, "Hello world thread number", thread_num
!$omp end critical
!$omp end parallel
end
Output:
Hello world thread number, 10
Thanks
Aru
Hello,
IMHO, the problem is missing spaces in the 6th line before the end: !$thread_num = omp_get_thread_num()
If we insert a space there, then it works:
!$ thread_num = omp_get_thread_num()
What??? Are you kidding? Have you tested, or is it just IYHO ?
Le 11/11/2022 à 10:47, Ev. Drikos a écrit :
IMHO, the problem is missing spaces in the 6th line before the end: !$thread_num = omp_get_thread_num()
If we insert a space there, then it works:
!$ thread_num = omp_get_thread_num()
What??? Are you kidding? Have you tested, or is it just IYHO ?
On Friday, November 11, 2022 at 3:37:06 AM UTC-8, pehache wrote:
Le 11/11/2022 à 10:47, Ev. Drikos a écrit :
(snip)
IMHO, the problem is missing spaces in the 6th line before the end:
!$thread_num = omp_get_thread_num()
If we insert a space there, then it works:
!$ thread_num = omp_get_thread_num()
What??? Are you kidding? Have you tested, or is it just IYHO ?
Directives like !$OMP must NOT have a space.
Conditional compilation, like above, MUST have a space.
https://www.openmp.org/spec-html/5.0/openmpsu24.html#x40-470002.2.2
Le 11/11/2022 à 20:37, gah4 a écrit :..
On Friday, November 11, 2022 at 3:37:06 AM UTC-8, pehache wrote:
Le 11/11/2022 à 10:47, Ev. Drikos a écrit :
...If we insert a space there, then it works:
!$ thread_num = omp_get_thread_num()
Conditional compilation, like above, MUST have a space.
https://www.openmp.org/spec-html/5.0/openmpsu24.html#x40-470002.2.2
My bad, I answered too quickly without reading the post correctly :(
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 159 |
Nodes: | 16 (0 / 16) |
Uptime: | 100:05:21 |
Calls: | 3,209 |
Files: | 10,563 |
Messages: | 3,009,979 |