forked from OpenMP/Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample_affinity.6.f90
More file actions
34 lines (26 loc) · 913 Bytes
/
Example_affinity.6.f90
File metadata and controls
34 lines (26 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
! @@name: affinity.6f
! @@type: F-free
! @@compilable: yes
! @@linkable: no
! @@expect: success
subroutine socket_init(socket_num)
use omp_lib
integer :: socket_num, n_procs
n_procs = omp_get_place_num_procs(socket_num)
!$omp parallel num_threads(n_procs) proc_bind(close)
print*,"Reporting in from socket num, thread num: ", &
socket_num,omp_get_thread_num()
!$omp end parallel
end subroutine
program numa_teams
use omp_lib
integer :: n_sockets, socket_num
call omp_set_nested(.true.) ! or export OMP_NESTED=true
call omp_set_max_active_levels(2) ! or export OMP_MAX_ACTIVE_LEVELS=2
n_sockets = omp_get_num_places()
!$omp parallel num_threads(n_sockets) private(socket_num) &
!$omp& proc_bind(spread)
socket_num = omp_get_place_num()
call socket_init(socket_num)
!$omp end parallel
end program