Skip to content

Commit 4cd9b52

Browse files
Add PAPI tests
1 parent 9596442 commit 4cd9b52

6 files changed

+230
-1
lines changed

tests/drhook/CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,9 @@ ecbuild_add_test( TARGET fiat_test_drhook_ex5
8484
# NVTX
8585
if (HAVE_DR_HOOK_NVTX)
8686
add_subdirectory(drhook_nvtx)
87-
endif ()
87+
endif ()
88+
89+
# PAPI
90+
if (HAVE_DR_HOOK_PAPI)
91+
add_subdirectory(drhook_papi)
92+
endif ()
+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#
2+
# (C) Copyright 2024- ECMWF.
3+
#
4+
# This software is licensed under the terms of the Apache Licence Version 2.0
5+
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6+
# In applying this licence, ECMWF does not waive the privileges and immunities
7+
# granted to it by virtue of its status as an intergovernmental organisation
8+
# nor does it submit to any jurisdiction.
9+
#
10+
11+
# Test basic implementation
12+
13+
ecbuild_add_executable( TARGET drhook_papi_basic
14+
SOURCES drhook_papi_basic.F90
15+
LIBS fiat
16+
LINKER_LANGUAGE Fortran
17+
CONDITION HAVE_DR_HOOK_PAPI
18+
NOINSTALL )
19+
20+
ecbuild_add_test( TARGET fiat_test_drhook_papi_basic
21+
COMMAND drhook_papi_basic
22+
ENVIRONMENT DR_HOOK=1 DR_HOOK_OPT=COUNTERS
23+
CONDITION HAVE_DR_HOOK_PAPI )
24+
25+
set_tests_properties(fiat_test_drhook_papi_basic
26+
PROPERTIES PASS_REGULAR_EXPRESSION "Writing counter information of proc#1 into file" )
27+
28+
29+
ecbuild_add_test( TARGET fiat_test_drhook_papi_basic_valid_csv
30+
TYPE SCRIPT
31+
# Just making sure it's not an empty file
32+
COMMAND "find"
33+
ARGS "." "-name" "drhook.prof.0.csv" "-type" "f" "-size" "+100c"
34+
ENVIRONMENT DR_HOOK=1 DR_HOOK_OPT=COUNTERS
35+
CONDITION HAVE_DR_HOOK_PAPI )
36+
37+
set_tests_properties(fiat_test_drhook_papi_basic_valid_csv
38+
PROPERTIES DEPENDS fiat_test_drhook_papi_basic
39+
FAIL_REGULAR_EXPRESSION "no matches found" )
40+
41+
# Test MPI implementation
42+
43+
ecbuild_add_executable( TARGET drhook_papi_mpi
44+
SOURCES drhook_papi_mpi.F90
45+
LIBS fiat
46+
LINKER_LANGUAGE Fortran
47+
CONDITION HAVE_DR_HOOK_PAPI AND HAVE_MPI
48+
NOINSTALL )
49+
50+
ecbuild_add_test( TARGET fiat_test_drhook_papi_mpi
51+
COMMAND drhook_papi_mpi
52+
MPI 5
53+
ENVIRONMENT DR_HOOK=1 DR_HOOK_OPT=COUNTERS
54+
CONDITION HAVE_DR_HOOK_PAPI AND HAVE_MPI )
55+
56+
57+
ecbuild_add_test( TARGET fiat_test_drhook_papi_mpi_valid_csv
58+
TYPE SCRIPT
59+
# Just making sure it's not an empty file
60+
# We have to do this weird thing with bash so that we can
61+
# use a redirect. CMake tests are really basic...
62+
COMMAND "bash"
63+
ARGS "-c" "find . -name 'drhook.prof.[1-5].csv' -type f -size +100c | wc -l"
64+
ENVIRONMENT DR_HOOK=1 DR_HOOK_OPT=COUNTERS
65+
CONDITION HAVE_DR_HOOK_PAPI AND HAVE_MPI )
66+
67+
set_tests_properties(fiat_test_drhook_papi_mpi_valid_csv
68+
PROPERTIES DEPENDS fiat_test_drhook_papi_mpi
69+
PASS_REGULAR_EXPRESSION "5" )
70+
71+
# Test user specified output file names
72+
73+
ecbuild_add_executable( TARGET drhook_papi_user_filename
74+
SOURCES drhook_papi_user_filename.F90
75+
LIBS fiat
76+
LINKER_LANGUAGE Fortran
77+
CONDITION HAVE_DR_HOOK_PAPI
78+
NOINSTALL )
79+
80+
ecbuild_add_test( TARGET fiat_test_drhook_papi_user_filename
81+
COMMAND drhook_papi_user_filename
82+
ENVIRONMENT DR_HOOK=1 DR_HOOK_OPT=COUNTERS DR_HOOK_PROFILE=fiat_test_drhook_papi_user_filename
83+
CONDITION HAVE_DR_HOOK_PAPI )
84+
85+
ecbuild_add_test( TARGET fiat_test_drhook_papi_user_filename_valid_csv
86+
TYPE SCRIPT
87+
# Just making sure it's not an empty file
88+
COMMAND "find"
89+
ARGS "." "-name" "fiat_test_drhook_papi_user_filename.1.csv" "-type" "f"
90+
ENVIRONMENT DR_HOOK=1 DR_HOOK_OPT=COUNTERS
91+
CONDITION HAVE_DR_HOOK_PAPI )
92+
93+
set_tests_properties(fiat_test_drhook_papi_user_filename_valid_csv
94+
PROPERTIES DEPENDS fiat_test_drhook_papi_user_filename
95+
FAIL_REGULAR_EXPRESSION "no matches found" )
96+
97+
# Test user specified counters
98+
99+
ecbuild_add_executable( TARGET drhook_papi_user_counters
100+
SOURCES drhook_papi_user_counters.F90
101+
LIBS fiat
102+
LINKER_LANGUAGE Fortran
103+
CONDITION HAVE_DR_HOOK_PAPI
104+
NOINSTALL )
105+
106+
ecbuild_add_test( TARGET fiat_test_drhook_papi_user_counters
107+
COMMAND drhook_papi_user_counters
108+
ENVIRONMENT DR_HOOK=1 DR_HOOK_OPT=COUNTERS DR_HOOK_PAPI_COUNTERS=PAPI_TOT_INS DR_HOOK_PROFILE=fiat_test_drhook_papi_user_counters
109+
CONDITION HAVE_DR_HOOK_PAPI )
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
! (C) Copyright 2024- ECMWF.
2+
!
3+
! This software is licensed under the terms of the Apache Licence Version 2.0
4+
! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
!
6+
! In applying this licence, ECMWF does not waive the privileges and immunities
7+
! granted to it by virtue of its status as an intergovernmental organisation
8+
! nor does it submit to any jurisdiction.
9+
10+
program drhook_papi_basic
11+
12+
use yomhook, only : jphook, dr_hook
13+
14+
implicit none
15+
16+
real(jphook) :: zhook_handle
17+
integer :: a
18+
19+
call dr_hook('drhook_papi_basic', 0, zhook_handle)
20+
21+
a = 1
22+
a = a + a
23+
24+
call dr_hook('drhook_papi_basic', 1, zhook_handle)
25+
26+
end program drhook_papi_basic
27+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
! (C) Copyright 2024- ECMWF.
2+
!
3+
! This software is licensed under the terms of the Apache Licence Version 2.0
4+
! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
!
6+
! In applying this licence, ECMWF does not waive the privileges and immunities
7+
! granted to it by virtue of its status as an intergovernmental organisation
8+
! nor does it submit to any jurisdiction.
9+
10+
program drhook_papi_mpi
11+
use mpl_module
12+
use yomhook, only : jphook, dr_hook
13+
use sdl_mod, only : sdl_traceback
14+
implicit none
15+
integer jpe, npes, mype, a
16+
character(len=256) arg, env
17+
real(jphook) :: zhook_handle
18+
19+
call mpl_init(ldinfo=.false.)
20+
call dr_hook('drhook_papi_mpi',0,zhook_handle)
21+
22+
npes = mpl_nproc()
23+
mype = mpl_myrank()
24+
25+
do jpe=1,npes
26+
if (mype == jpe) then
27+
a = a + jpe
28+
endif
29+
enddo
30+
31+
call mpl_barrier()
32+
call dr_hook('drhook_papi_mpi',1,zhook_handle)
33+
call mpl_end()
34+
end program drhook_papi_mpi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
! (C) Copyright 2024- ECMWF.
2+
!
3+
! This software is licensed under the terms of the Apache Licence Version 2.0
4+
! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
!
6+
! In applying this licence, ECMWF does not waive the privileges and immunities
7+
! granted to it by virtue of its status as an intergovernmental organisation
8+
! nor does it submit to any jurisdiction.
9+
10+
program drhook_papi_user_counters
11+
12+
use yomhook, only : jphook, dr_hook
13+
14+
implicit none
15+
16+
real(jphook) :: zhook_handle
17+
integer :: a
18+
19+
call dr_hook('drhook_papi_user_counters', 0, zhook_handle)
20+
21+
a = 1
22+
a = a + a
23+
24+
call dr_hook('drhook_papi_user_counters', 1, zhook_handle)
25+
26+
end program drhook_papi_user_counters
27+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
! (C) Copyright 2024- ECMWF.
2+
!
3+
! This software is licensed under the terms of the Apache Licence Version 2.0
4+
! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5+
!
6+
! In applying this licence, ECMWF does not waive the privileges and immunities
7+
! granted to it by virtue of its status as an intergovernmental organisation
8+
! nor does it submit to any jurisdiction.
9+
10+
program drhook_papi_user_filename
11+
12+
use yomhook, only : jphook, dr_hook
13+
14+
implicit none
15+
16+
real(jphook) :: zhook_handle
17+
integer :: a
18+
19+
call dr_hook('drhook_papi_user_filename', 0, zhook_handle)
20+
21+
a = 1
22+
a = a + a
23+
24+
call dr_hook('drhook_papi_user_filename', 1, zhook_handle)
25+
26+
end program drhook_papi_user_filename
27+

0 commit comments

Comments
 (0)