Skip to content

Commit 5ef5227

Browse files
Add new NVTX tests for skipping regions
These two new tests, `drhook_nvtx_skip_spam_regions` & `drhook_nvtx_no_skip_spam_regions`, demonstrate the following behaviours: - drhook_nvtx_skip_spam_regions - Regions are successfully skipped when called frequently & with low total runtime - drhook_nvtx_no_skip_spam_regions - Regions are successfully not skipped when called frequently, but with sufficient total runtime
1 parent 95dccd7 commit 5ef5227

File tree

3 files changed

+123
-1
lines changed

3 files changed

+123
-1
lines changed

tests/drhook/drhook_nvtx/CMakeLists.txt

+42-1
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,46 @@ ecbuild_add_test( TARGET fiat_test_drhook_nvtx_mismatched_regions
3939
COMMAND "nsys"
4040
ARGS "profile" "--force-overwrite=true" "--trace=nvtx" "--kill=none" "--output=nsys.drhook_nvtx_mismatched_regions.qdrep" "./drhook_nvtx_mismatched_regions"
4141
ENVIRONMENT DR_HOOK=1 DR_HOOK_NVTX=1
42-
PROPERTIES WILL_FAIL TRUE
4342
CONDITION HAVE_DR_HOOK_NVTX )
43+
44+
set_tests_properties(fiat_test_drhook_nvtx_mismatched_regions
45+
PROPERTIES WILL_FAIL TRUE )
46+
47+
# Test skip on spammy regions
48+
49+
ecbuild_add_executable( TARGET drhook_nvtx_skip_spam_regions
50+
SOURCES drhook_nvtx_skip_spam_regions.F90
51+
LIBS fiat
52+
LINKER_LANGUAGE Fortran
53+
CONDITION HAVE_DR_HOOK_NVTX
54+
NOINSTALL )
55+
56+
ecbuild_add_test( TARGET fiat_test_drhook_nvtx_skip_spam_regions
57+
TYPE SCRIPT
58+
COMMAND "nsys"
59+
ARGS "profile" "--force-overwrite=true" "--trace=nvtx" "--kill=none" "--output=nsys.drhook_nvtx_skip_spam_regions.qdrep" "./drhook_nvtx_skip_spam_regions"
60+
ENVIRONMENT DR_HOOK=1 DR_HOOK_NVTX=1 DR_HOOK_SILENT=0
61+
CONDITION HAVE_DR_HOOK_NVTX )
62+
63+
set_tests_properties(fiat_test_drhook_nvtx_skip_spam_regions
64+
PROPERTIES PASS_REGULAR_EXPRESSION "DRHOOK:NVTX: Skipping closing of region foo" PASS_REGULAR_EXPRESSION "DRHOOK:NVTX: Skipping opening of region foo" )
65+
66+
# Test not to skip on spammy regions with long runtimes
67+
68+
ecbuild_add_executable( TARGET drhook_nvtx_no_skip_spam_regions
69+
SOURCES drhook_nvtx_no_skip_spam_regions.F90
70+
LIBS fiat
71+
LINKER_LANGUAGE Fortran
72+
CONDITION HAVE_DR_HOOK_NVTX
73+
NOINSTALL )
74+
75+
ecbuild_add_test( TARGET fiat_test_drhook_nvtx_no_skip_spam_regions
76+
TYPE SCRIPT
77+
COMMAND "nsys"
78+
ARGS "profile" "--force-overwrite=true" "--trace=nvtx" "--kill=none" "--output=nsys.drhook_nvtx_no_skip_spam_regions.qdrep" "./drhook_nvtx_no_skip_spam_regions"
79+
ENVIRONMENT DR_HOOK=1 DR_HOOK_NVTX=1 DR_HOOK_SILENT=0
80+
81+
CONDITION HAVE_DR_HOOK_NVTX )
82+
83+
set_tests_properties(fiat_test_drhook_nvtx_no_skip_spam_regions
84+
PROPERTIES FAIL_REGULAR_EXPRESSION "DRHOOK:NVTX: Skipping closing of region foo" FAIL_REGULAR_EXPRESSION "DRHOOK:NVTX: Skipping opening of region foo" )
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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_nvtx_no_skip_spam_regions
11+
12+
use yomhook, only : jphook, dr_hook
13+
14+
implicit none
15+
16+
real(jphook) :: zhook_handle
17+
call dr_hook('drhook_nvtx_no_skip_spam_regions', 0, zhook_handle)
18+
call foo(-1)
19+
call foo(0)
20+
call dr_hook('drhook_nvtx_no_skip_spam_regions', 1, zhook_handle)
21+
22+
contains
23+
24+
recursive subroutine foo (depth)
25+
integer, intent(in) :: depth
26+
real(jphook) :: zhook_handle
27+
28+
call dr_hook('foo', 0, zhook_handle)
29+
30+
if (depth == -1) then
31+
call sleep(1)
32+
call dr_hook('foo', 1, zhook_handle)
33+
return
34+
end if
35+
36+
if (depth < 10) then
37+
call foo(depth + 1)
38+
end if
39+
40+
call dr_hook('foo', 1, zhook_handle)
41+
end subroutine
42+
43+
end program drhook_nvtx_no_skip_spam_regions
44+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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_nvtx_skip_spam_regions
11+
12+
use yomhook, only : jphook, dr_hook
13+
14+
implicit none
15+
16+
real(jphook) :: zhook_handle
17+
call dr_hook('drhook_nvtx_skip_spam_regions', 0, zhook_handle)
18+
call foo(0)
19+
call dr_hook('drhook_nvtx_skip_spam_regions', 1, zhook_handle)
20+
21+
contains
22+
23+
recursive subroutine foo (depth)
24+
integer, intent(in) :: depth
25+
real(jphook) :: zhook_handle
26+
27+
call dr_hook('foo', 0, zhook_handle)
28+
29+
if (depth < 10) then
30+
call foo(depth + 1)
31+
end if
32+
33+
call dr_hook('foo', 1, zhook_handle)
34+
end subroutine
35+
36+
end program drhook_nvtx_skip_spam_regions
37+

0 commit comments

Comments
 (0)