11# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
22# See file LICENSE for terms.
33
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+
423import argparse
524import os
625import pathlib
@@ -22,14 +41,12 @@ def __init__(self, args: argparse.Namespace):
2241 """
2342 self .nsys_report_path = args .nsys_report_path
2443
25- self .sql_path = None
2644 if args .sql_path is None :
2745 report_basename_no_ext = pathlib .Path (self .nsys_report_path ).stem
2846 self .sql_path = os .getcwd () + os .sep + report_basename_no_ext + ".sqlite"
2947 else :
3048 self .sql_path = args .sql_path
3149
32- self .nsys_binary = None
3350 if args .nsys_binary is None :
3451 self .nsys_binary = "nsys"
3552 else :
@@ -91,8 +108,6 @@ def _sql_query(self, filter_string: str) -> pd.DataFrame:
91108 )
92109
93110 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 } "' )
96111 return df
97112
98113 def _generate_hist (self , df : pd .DataFrame ) -> tuple [np .ndarray , np .ndarray ]:
@@ -183,6 +198,8 @@ def _process(self, filter_string: str):
183198 """
184199 df = self ._sql_query (filter_string )
185200 if df .empty :
201+ print (f"\n { filter_string } " )
202+ print (" Data is not detected." )
186203 return
187204
188205 hist , bin_edges = self ._generate_hist (df )
@@ -196,16 +213,46 @@ def run(self):
196213 self .db_connection = sqlite3 .connect (self .sql_path )
197214
198215 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.
199218 "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.
200221 "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.
201228 "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.
202235 "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.
203240 "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.
204245 "posix_host_write()" ,
246+ # Size of the read passed to cuFile API.
247+ # Source is the file, and destination is the device memory.
205248 "cufileRead()" ,
249+ # Size of the write passed to cuFile API.
250+ # Source is the device memory, and destination is the file.
206251 "cufileWrite()" ,
207252 "RemoteHandle::read()" ,
208253 "RemoteHandle::pread()" ,
254+ "RemoteHandle - callback_host_memory()" ,
255+ "RemoteHandle - callback_device_memory()" ,
209256 ]
210257
211258 for filter_string in filter_string_list :
@@ -215,7 +262,7 @@ def run(self):
215262if __name__ == "__main__" :
216263 parser = argparse .ArgumentParser (
217264 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. " ,
219266 )
220267 parser .add_argument (
221268 "--nsys-report-path" ,
@@ -225,15 +272,17 @@ def run(self):
225272 )
226273 parser .add_argument (
227274 "--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." ,
231280 type = str ,
232281 )
233282 parser .add_argument (
234283 "--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." ,
237286 type = str ,
238287 )
239288 args = parser .parse_args ()
0 commit comments