PROGRESS  master
prg_nvtx_mod.F90
Go to the documentation of this file.
2  use iso_c_binding
3  implicit none
4 
5 
6  integer(4),private :: col(7) = [ int(z'0000ff00',4), int(z'000000ff',4), &
7  & int(z'00ffff00',4), int(z'00ff00ff',4), int(z'0000ffff',4), &
8  & int(z'00ff0000',4), int(z'00ffffff',4)]
9  character(kind=c_char,len=256),private,target :: tempname
10 
11  type, bind(C):: nvtxEventAttributes
12  integer(C_INT16_T):: version=1
13  integer(C_INT16_T):: size=48 !
14  integer(C_INT):: category=0
15  integer(C_INT):: colortype=1 ! NVTX_COLOR_ARGB = 1
16  integer(C_INT):: color
17  integer(C_INT):: payloadtype=0 ! NVTX_PAYLOAD_UNKNOWN = 0
18  integer(C_INT):: reserved0
19  integer(C_INT64_T):: payload ! union uint,int,double
20  integer(C_INT):: messagetype=1 ! NVTX_MESSAGE_TYPE_ASCII = 1
21  type(c_ptr):: message ! ascii char
22  end type nvtxeventattributes
23 
24 #if defined(USE_NVTX)
25  interface gpmdrangepush
26  ! push range with custom label and standard color
27  subroutine gpmdrangepusha(name) bind(C, name='nvtxRangePushA')
28  use iso_c_binding
29  character(kind=C_CHAR,len=*) :: name
30  end subroutine gpmdrangepusha
31 
32  ! push range with custom label and custom color
33  subroutine gpmdrangepushex(event) bind(C, name='nvtxRangePushEx')
34  use iso_c_binding
35  import:: nvtxeventattributes
36  type(nvtxeventattributes):: event
37  end subroutine gpmdrangepushex
38  end interface gpmdrangepush
39 
40  interface gpmdrangepop
41  subroutine gpmdrangepop() bind(C, name='nvtxRangePop')
42  end subroutine gpmdrangepop
43  end interface gpmdrangepop
44 
45  public :: gpmdstartrange, gpmdendrange
46 
47 contains
48 
49  subroutine gpmdstartrange(name,id)
50  character(kind=c_char,len=*) :: name
51  integer, optional:: id
52  type(nvtxeventattributes):: event
53 
54  tempname=trim(name)//c_null_char
55 ! write(*,*)"gpmdcov_nvtx"," Tag = "//name
56  if ( .not. present(id)) then
57  call gpmdrangepush(tempname)
58  else
59  event%color=col(mod(id,7)+1)
60  event%message=c_loc(tempname)
61  call gpmdrangepushex(event)
62  end if
63  end subroutine gpmdstartrange
64 
65  subroutine gpmdendrange
66  call gpmdrangepop
67  end subroutine gpmdendrange
68 #endif
69 !END if defined USE_NVTX
70 
71 end module prg_nvtx_mod
character(kind=c_char, len=256), target, private tempname
Definition: prg_nvtx_mod.F90:9
integer(4), dimension(7), private col
Definition: prg_nvtx_mod.F90:6