Skip to content

Commit 2926d23

Browse files
committed
Merge branch 'output_file_writer' of https://github.com/benvanwerkhoven/kernel_tuner into output_file_writer
2 parents 13b0d19 + 192f935 commit 2926d23

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

kernel_tuner/file_utils.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414

1515

1616
def 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
output_file = schema_dir + f"/T4/{current_version}/{target}-schema.json"
1928
with open(output_file, 'r') as fh:
@@ -37,6 +46,23 @@ def get_configuration_validity(objective) -> str:
3746

3847

3948
def store_output_file(output_filename, results, tune_params, objective="time"):
49+
""" Store the obtained auto-tuning results in a JSON output file
50+
51+
This function produces a JSON file that adheres to the T4 auto-tuning output JSON schema.
52+
53+
:param output_filename: Name of the to be created output file
54+
:type output_filename: string
55+
56+
:param results: Results list as return by tune_kernel
57+
:type results: list of dicts
58+
59+
:param tune_params: Tunable parameters as passed to tune_kernel
60+
:type tune_params: OrderedDict
61+
62+
:param objective: The objective used during auto-tuning, default is 'time'.
63+
:type objective: string
64+
65+
"""
4066
if output_filename[-5:] != ".json":
4167
output_filename += ".json"
4268

@@ -103,6 +129,7 @@ def store_output_file(output_filename, results, tune_params, objective="time"):
103129

104130

105131
def get_dependencies(package='kernel_tuner'):
132+
""" Get the Python dependencies of Kernel Tuner currently installed and their version numbers """
106133
requirements = requires(package)
107134
deps = [Requirement(req).name for req in requirements]
108135
depends = []
@@ -117,6 +144,7 @@ def get_dependencies(package='kernel_tuner'):
117144

118145

119146
def get_device_query(target):
147+
""" Get the information about GPUs in the current system, target is any of ['nvidia', 'amd'] """
120148
if target == "nvidia":
121149
nvidia_smi_out = subprocess.run(["nvidia-smi", "--query", "-x"],
122150
capture_output=True)
@@ -132,6 +160,17 @@ def get_device_query(target):
132160

133161

134162
def store_metadata_file(metadata_filename, target="nvidia"):
163+
""" Store the metadata about the current hardware and software environment in a JSON output file
164+
165+
This function produces a JSON file that adheres to the T4 auto-tuning metadata JSON schema.
166+
167+
:param metadata_filename: Name of the to be created metadata file
168+
:type metadata_filename: string
169+
170+
:param target: Target specifies whether to include the metadata of the 'nvidia' or 'amd' GPUs in the system
171+
:type target: string
172+
173+
"""
135174
if metadata_filename[-5:] != ".json":
136175
metadata_filename += ".json"
137176
metadata = {}

0 commit comments

Comments
 (0)