@@ -58,75 +58,5 @@ module phase
58
58
end module phase
59
59
60
60
61
- ! added NVTX for profiing from maxcuda/NVTX_example
62
- module nvtx
63
- use iso_c_binding
64
- implicit none
65
- integer ,private :: col(7 ) = [ int (Z' 0000ff00' ), int (Z' 000000ff' ), int (Z' 00ffff00' ), int (Z' 00ff00ff' ), int (Z' 0000ffff' ), int (Z' 00ff0000' ), int (Z' 00ffffff' )]
66
- character ,private ,target :: tempName(256 )
67
61
68
- type, bind(C):: nvtxEventAttributes
69
- integer (C_INT16_T):: version= 1
70
- integer (C_INT16_T):: size= 48 !
71
- integer (C_INT):: category= 0
72
- integer (C_INT):: colorType= 1 ! NVTX_COLOR_ARGB = 1
73
- integer (C_INT):: color
74
- integer (C_INT):: payloadType= 0 ! NVTX_PAYLOAD_UNKNOWN = 0
75
- integer (C_INT):: reserved0
76
- integer (C_INT64_T):: payload ! union uint,int,double
77
- integer (C_INT):: messageType= 1 ! NVTX_MESSAGE_TYPE_ASCII = 1
78
- type (C_PTR):: message ! ascii char
79
- end type
80
-
81
- interface nvtxRangePush
82
- ! push range with custom label and standard color
83
- subroutine nvtxRangePushA (name ) bind(C, name= ' nvtxRangePushA' )
84
- use iso_c_binding
85
- character (kind= C_CHAR) :: name (256 )
86
- end subroutine
87
-
88
- ! push range with custom label and custom color
89
- subroutine nvtxRangePushEx (event ) bind(C, name= ' nvtxRangePushEx' )
90
- use iso_c_binding
91
- import:: nvtxEventAttributes
92
- type (nvtxEventAttributes):: event
93
- end subroutine
94
- end interface
95
-
96
- interface nvtxRangePop
97
- subroutine nvtxRangePop () bind(C, name= ' nvtxRangePop' )
98
- end subroutine
99
- end interface
100
-
101
- contains
102
-
103
- subroutine nvtxStartRange (name ,id )
104
- character (kind= c_char,len=* ) :: name
105
- integer , optional :: id
106
- type (nvtxEventAttributes):: event
107
- character (kind= c_char,len= 256 ) :: trimmed_name
108
- integer :: i
109
-
110
- trimmed_name= trim (name)// c_null_char
111
-
112
- ! move scalar trimmed_name into character array tempName
113
- do i= 1 ,LEN (trim (name)) + 1
114
- tempName(i) = trimmed_name(i:i)
115
- enddo
116
-
117
-
118
- if ( .not. present (id)) then
119
- call nvtxRangePush(tempName)
120
- else
121
- event% color= col(mod (id,7 )+ 1 )
122
- event% message= c_loc(tempName)
123
- call nvtxRangePushEx(event)
124
- end if
125
- end subroutine
126
-
127
- subroutine nvtxEndRange
128
- call nvtxRangePop
129
- end subroutine
130
-
131
- end module nvtx
132
62
0 commit comments