MCPcopy Create free account
hub / github.com/NVIDIA/SOL-ExecBench / compile

Method compile

src/sol_execbench/driver/problem_packager.py:163–189  ·  view source on GitHub ↗

Stage compilation files and return (command, artifact_path). Writes build_ext.py, solution.json, and C++/CUDA source files to output_dir. Injects gencode flags for the target hardware. The CLI should run the command in output_dir. After success, the artifact (benchm

(self)

Source from the content-addressed store, hash-verified

161 dest.write_text(src.content)
162
163 def compile(self) -> tuple[list[str], str]:
164 """Stage compilation files and return (command, artifact_path).
165
166 Writes build_ext.py, solution.json, and C++/CUDA source files to
167 output_dir. Injects gencode flags for the target hardware.
168
169 The CLI should run the command in output_dir.
170 After success, the artifact (benchmark_kernel.so) will be at artifact_path.
171 """
172 assert self._is_cpp, (
173 f"compile() only handles C++/CUDA solutions, "
174 f"got languages={self.solution.spec.languages}"
175 )
176
177 sol_dict = json.loads(self.solution.model_dump_json())
178 sol_dict = self._inject_gencode_flags(sol_dict)
179
180 # Overwrite solution.json with injected gencode flags.
181 (self.output_dir / "solution.json").write_text(json.dumps(sol_dict))
182 (self.output_dir / "build_ext.py").write_text(
183 (_TEMPLATES_DIR / "build_ext.py").read_text()
184 )
185
186 cmd = ["python", "build_ext.py"]
187 artifact_path = str(self.output_dir / "benchmark_kernel.so")
188
189 return cmd, artifact_path
190
191 def execute(self) -> list[str]:
192 """Stage execution files and return the command to run.

Callers 10

cliFunction · 0.95
test_e2eFunction · 0.95
test_exampleFunction · 0.95
test_build_ext_stagedMethod · 0.80
runFunction · 0.80

Calls 1

_inject_gencode_flagsMethod · 0.95