1414
1515
1616def output_file_schema (target ):
17+ """ Get the requested JSON schema and the version number
18+
19+ :param target: Name of the T4 schema to return, should be any of ['output', 'metadata']
20+ :type target: string
21+
22+ :returns: the current version of the T4 schemas and the JSON string of the target schema
23+ :rtype: string, string
24+
25+ """
1726 current_version = "1.0.0"
1827 file = schema_dir + f"/T4/{ current_version } /{ target } -schema.json"
1928 with open (file , 'r' ) as fh :
@@ -22,6 +31,23 @@ def output_file_schema(target):
2231
2332
2433def store_output_file (output_filename , results , tune_params , objective = "time" ):
34+ """ Store the obtained auto-tuning results in a JSON output file
35+
36+ This function produces a JSON file that adheres to the T4 auto-tuning output JSON schema.
37+
38+ :param output_filename: Name of the to be created output file
39+ :type output_filename: string
40+
41+ :param results: Results list as return by tune_kernel
42+ :type results: list of dicts
43+
44+ :param tune_params: Tunable parameters as passed to tune_kernel
45+ :type tune_params: OrderedDict
46+
47+ :param objective: The objective used during auto-tuning, default is 'time'.
48+ :type objective: string
49+
50+ """
2551 if output_filename [- 5 :] != ".json" :
2652 output_filename += ".json"
2753
@@ -90,6 +116,7 @@ def store_output_file(output_filename, results, tune_params, objective="time"):
90116
91117
92118def get_dependencies (package = 'kernel_tuner' ):
119+ """ Get the Python dependencies of Kernel Tuner currently installed and their version numbers """
93120 requirements = requires (package )
94121 deps = [Requirement (req ).name for req in requirements ]
95122 depends = []
@@ -104,6 +131,7 @@ def get_dependencies(package='kernel_tuner'):
104131
105132
106133def get_device_query (target ):
134+ """ Get the information about GPUs in the current system, target is any of ['nvidia', 'amd'] """
107135 if target == "nvidia" :
108136 nvidia_smi_out = subprocess .run (["nvidia-smi" , "--query" , "-x" ], capture_output = True )
109137 nvidia_smi = xmltodict .parse (nvidia_smi_out .stdout )
@@ -117,6 +145,17 @@ def get_device_query(target):
117145
118146
119147def store_metadata_file (metadata_filename , target = "nvidia" ):
148+ """ Store the metadata about the current hardware and software environment in a JSON output file
149+
150+ This function produces a JSON file that adheres to the T4 auto-tuning metadata JSON schema.
151+
152+ :param metadata_filename: Name of the to be created metadata file
153+ :type metadata_filename: string
154+
155+ :param target: Target specifies whether to include the metadata of the 'nvidia' or 'amd' GPUs in the system
156+ :type target: string
157+
158+ """
120159 if metadata_filename [- 5 :] != ".json" :
121160 metadata_filename += ".json"
122161 metadata = {}
0 commit comments