Neko 0.9.99
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
nvtx.F90
Go to the documentation of this file.
1
3module nvtx
4 use, intrinsic :: iso_c_binding
5 implicit none
6 private
7
8 integer, parameter :: nvtx_max_len = 256
9 integer, parameter :: color(24) = [int(z'00A6CEE3'), int(z'001F78B4'), &
10 int(z'00B2DF8A'), int(z'0033A02C'), &
11 int(z'00FB9A99'), int(z'00E31A1C'), &
12 int(z'00FDBF6F'), int(z'00FF7F00'), &
13 int(z'00CAB2D6'), int(z'006A3D9A'), &
14 int(z'00FFFF99'), int(z'00B15928'), &
15 int(z'008DD3C7'), int(z'00FFFFB3'), &
16 int(z'00BEBADA'), int(z'00FB8072'), &
17 int(z'0080B1D3'), int(z'00FDB462'), &
18 int(z'00B3DE69'), int(z'00FCCDE5'), &
19 int(z'00D9D9D9'), int(z'00BC89BD'), &
20 int(z'00CCEBC5'), int(z'00FFED6F')]
21
22#ifdef HAVE_NVTX
23
24 type, bind(c) :: nvtxeventattributes
25 integer(c_int16_t) :: version = 1
26 integer(c_int16_t) :: size = 48
27 integer(c_int32_t) :: category = 0
28 integer(c_int32_t) :: colortype = 1
29 integer(c_int32_t) :: color
30 integer(c_int32_t) :: payloadtype = 0
31 integer(c_int32_t) :: reserved0
32 integer(c_int64_t) :: payload
33 integer(c_int) :: messagetype = 1
34 type(c_ptr) :: message
35 end type nvtxeventattributes
36
37 interface nvtxrangepusha
38 subroutine nvtxrangepusha(name) bind(C, name='nvtxRangePushA')
39 use iso_c_binding
40 character(kind=c_char) :: name(256)
41 end subroutine nvtxrangepusha
42 end interface nvtxrangepusha
43
44 interface nvtxrangepushex
45 subroutine nvtxrangepushex(event) bind(C, name='nvtxRangePushEx')
46 use iso_c_binding
47 import :: nvtxeventattributes
48 type(nvtxeventattributes) :: event
49 end subroutine nvtxrangepushex
50 end interface nvtxrangepushex
51
52 interface nvtxrangepop
53 subroutine nvtxrangepop() bind(C, name='nvtxRangePop')
54 end subroutine nvtxrangepop
55 end interface nvtxrangepop
56
57 public :: nvtxstartrange, nvtxrangepusha, nvtxrangepop
58
59contains
60
61 subroutine nvtxstartrange(name, region_id)
62 character(kind=c_char,len=*) :: name
63 integer, optional :: region_id
64 type(nvtxeventattributes) :: event
65 character, target :: c_name(nvtx_max_len)
66 integer :: i, str_len
67
68 str_len = len(trim(name))
69 do i = 1, len(trim(name))
70 c_name(i) = name(i:i)
71 end do
72 c_name(str_len+1) = c_null_char
73
74 if (present(region_id)) then
75 event%color = color(mod(region_id, 24) + 1)
76 event%message = c_loc(c_name)
77 call nvtxrangepushex(event)
78 else
79 call nvtxrangepusha(c_name)
80 end if
81
82 end subroutine nvtxstartrange
83
84#endif
85end module nvtx
Interface to NVTX Based on https://github.com/maxcuda/NVTX_example.
Definition nvtx.F90:3
integer, parameter nvtx_max_len
Definition nvtx.F90:8
integer, dimension(24), parameter color
Definition nvtx.F90:9