-
Notifications
You must be signed in to change notification settings - Fork 233
/
Copy pathF-markerAPI.F90
79 lines (72 loc) · 3.07 KB
/
F-markerAPI.F90
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
! =======================================================================================
!
! Filename: F-markerAPI.F90
!
! Description: Example how to use the Fortran90 Marker API
!
! Version: <VERSION>
! Released: <DATE>
!
! Author: Thomas Gruber (tr), thomas.roehl@googlemail.com
! Project: likwid
!
! Copyright (C) 2015 RRZE, University Erlangen-Nuremberg
!
! This program is free software: you can redistribute it and/or modify it under
! the terms of the GNU General Public License as published by the Free Software
! Foundation, either version 3 of the License, or (at your option) any later
! version.
!
! This program is distributed in the hope that it will be useful, but WITHOUT ANY
! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
! PARTICULAR PURPOSE. See the GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License along with
! this program. If not, see <http://www.gnu.org/licenses/>.
!
! =======================================================================================
#define SLEEPTIME 2
program FmarkerAPI
use likwid
include "omp_lib.h"
INTEGER :: nr_events
DOUBLE PRECISION, DIMENSION(10) :: events
DOUBLE PRECISION :: time
INTEGER :: c
nr_events = 10
! Init Marker API in serial region once in the beginning.
call likwid_markerInit()
!$OMP PARALLEL
! Each thread must add itself to the Marker API, therefore must be
! in parallel region.
call likwid_markerthreadInit()
! Optional. Register region name and initialize hash table entries.
call likwid_markerRegisterRegion("example")
!$OMP END PARALLEL
!$OMP PARALLEL
print '(a,i0,a,i0,a)', "Thread ", omp_get_thread_num()," sleeps now for ", SLEEPTIME," seconds"
! Start measurements inside a parallel region.
call likwid_markerStartRegion("example")
! Insert your code here
! Often contains an OpenMP for pragma. Regions can be nested.
call Sleep(SLEEPTIME)
! Stop measurements inside a parallel region.
call likwid_markerStopRegion("example")
print '(a,i0,a)', "Thread ", omp_get_thread_num()," wakes up again"
! If multiple groups given, you can switch to the next group.
call likwid_markerNextGroup();
! If you need the performance data inside your application, use
call likwid_markerGetRegion("example", nr_events, events, time, c)
! Events is an array of DOUBLE PRECISION with nr_events (INTEGER) entries,
! time is a DOUBLE PRECISION and count an INTEGER.
! After returning the events array contains maximally nr_events results.
print '(a,i0,a,f9.3)', "Region example measures ", nr_events, " events, total measurement time is ", time
print '(a,i0,a)', "The region was called ", c, " times"
do i=1,nr_events
print '(a,i0,a,e13.7)', "Event ",i,": ",events(i)
end do
!$OMP END PARALLEL
! Close Marker API and write results to file for further evaluation done
! by likwid-perfctr.
call likwid_markerClose()
end program FmarkerAPI