1
1
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
2
2
# See file LICENSE for terms.
3
3
4
+ # usage: kvikio_stat [-h] --nsys-report-path NSYS_REPORT_PATH
5
+ # [--sql-path SQL_PATH]
6
+ # [--nsys-binary NSYS_BINARY]
7
+ #
8
+ # Generate I/O size histogram from Nsight System report.
9
+ #
10
+ # options:
11
+ # -h, --help show this help message and exit
12
+ # --nsys-report-path NSYS_REPORT_PATH
13
+ # The path of the Nsight System report.
14
+ # --sql-path SQL_PATH kvikio_stat will invoke Nsight System to generated a SQL
15
+ # database from the provided Nsight System report. --sql-path
16
+ # specifies the path of this SQL database. If unspecified, the
17
+ # current working directory will be used to store it, and the
18
+ # file name will be derived from the Nsight System report.
19
+ # --nsys-binary NSYS_BINARY
20
+ # The path of the Nsight System CLI program. If unspecified,
21
+ # "nsys" will be used.
22
+
4
23
import argparse
5
24
import os
6
25
import pathlib
@@ -22,14 +41,12 @@ def __init__(self, args: argparse.Namespace):
22
41
"""
23
42
self .nsys_report_path = args .nsys_report_path
24
43
25
- self .sql_path = None
26
44
if args .sql_path is None :
27
45
report_basename_no_ext = pathlib .Path (self .nsys_report_path ).stem
28
46
self .sql_path = os .getcwd () + os .sep + report_basename_no_ext + ".sqlite"
29
47
else :
30
48
self .sql_path = args .sql_path
31
49
32
- self .nsys_binary = None
33
50
if args .nsys_binary is None :
34
51
self .nsys_binary = "nsys"
35
52
else :
@@ -91,8 +108,6 @@ def _sql_query(self, filter_string: str) -> pd.DataFrame:
91
108
)
92
109
93
110
df = pd .read_sql (sql_expr , self .db_connection )
94
- if df .empty :
95
- print (f'Warning: SQL result is empty for filter string "{ filter_string } "' )
96
111
return df
97
112
98
113
def _generate_hist (self , df : pd .DataFrame ) -> tuple [np .ndarray , np .ndarray ]:
@@ -183,6 +198,8 @@ def _process(self, filter_string: str):
183
198
"""
184
199
df = self ._sql_query (filter_string )
185
200
if df .empty :
201
+ print (f"\n { filter_string } " )
202
+ print (" Data is not detected." )
186
203
return
187
204
188
205
hist , bin_edges = self ._generate_hist (df )
@@ -196,16 +213,46 @@ def run(self):
196
213
self .db_connection = sqlite3 .connect (self .sql_path )
197
214
198
215
filter_string_list = [
216
+ # Size of the read to be performed by KvikIO in parallel.
217
+ # Source is the file, and destination is the host or device memory.
199
218
"FileHandle::pread()" ,
219
+ # Size of the write to be performed by KvikIO in parallel.
220
+ # Source is the host or device memory, and destination is the file.
200
221
"FileHandle::pwrite()" ,
222
+ # Size of the read to be iteratively processed by POSIX pread() and CUDA
223
+ # H2D memory copy.
224
+ # Source is the file, and destination is the device memory.
225
+ # This can be the individual task size as a result of KvikIO's
226
+ # parallelization.
227
+ # This can also be a simple sequential read size.
201
228
"posix_device_read()" ,
229
+ # Size of the write to be iteratively processed by CUDA D2H memory copy
230
+ # and POSIX pwrite().
231
+ # Source is the device memory, and destination is the file.
232
+ # This can be the individual task size as a result of KvikIO's
233
+ # parallelization.
234
+ # This can also be a simple sequential write size.
202
235
"posix_device_write()" ,
236
+ # Size of the read to be iteratively processed by POSIX pread().
237
+ # Source is the file, and destination is the host memory.
238
+ # This can be the individual task size as a result of KvikIO's
239
+ # parallelization.
203
240
"posix_host_read()" ,
241
+ # Size of the write to be iteratively processed by POSIX pwrite().
242
+ # Source is the host memory, and destination is the file.
243
+ # This can be the individual task size as a result of KvikIO's
244
+ # parallelization.
204
245
"posix_host_write()" ,
246
+ # Size of the read passed to cuFile API.
247
+ # Source is the file, and destination is the device memory.
205
248
"cufileRead()" ,
249
+ # Size of the write passed to cuFile API.
250
+ # Source is the device memory, and destination is the file.
206
251
"cufileWrite()" ,
207
252
"RemoteHandle::read()" ,
208
253
"RemoteHandle::pread()" ,
254
+ "RemoteHandle - callback_host_memory()" ,
255
+ "RemoteHandle - callback_device_memory()" ,
209
256
]
210
257
211
258
for filter_string in filter_string_list :
@@ -215,7 +262,7 @@ def run(self):
215
262
if __name__ == "__main__" :
216
263
parser = argparse .ArgumentParser (
217
264
prog = "kvikio_stat" ,
218
- description = "Generate I/O size histogram from Nsight System report" ,
265
+ description = "Generate I/O size histogram from Nsight System report. " ,
219
266
)
220
267
parser .add_argument (
221
268
"--nsys-report-path" ,
@@ -225,15 +272,17 @@ def run(self):
225
272
)
226
273
parser .add_argument (
227
274
"--sql-path" ,
228
- help = "The path of the SQL database exported from the Nsight System report. "
229
- + "If unspecified, the current working directory is used to store the SQL "
230
- + "database, and the file name is derived from the Nsight System report." ,
275
+ help = "kvikio_stat will invoke Nsight System to generated a SQL database from "
276
+ + "the provided Nsight System report. --sql-path specifies the path of this "
277
+ + "SQL database. If unspecified, the current working directory will be used "
278
+ + "to store it, and the file name will be derived from the Nsight System "
279
+ + "report." ,
231
280
type = str ,
232
281
)
233
282
parser .add_argument (
234
283
"--nsys-binary" ,
235
- help = 'The path of the Nsight System CLI program. If unspecified, "nsys" is '
236
- + " used." ,
284
+ help = 'The path of the Nsight System CLI program. If unspecified, "nsys" will '
285
+ "be used." ,
237
286
type = str ,
238
287
)
239
288
args = parser .parse_args ()
0 commit comments