Skip to content

Commit a8285b0

Browse files
Bugfix/multiple ptxas options values (#678)
* Correctly handle multiple values of ptxas_options The correct way to handle multiple options is to pass them to NVRTC one at a time, e.g., ``` --ptxas-options=val1 --ptxas-options=val2 ``` * Test single and multiple values of ptxas_options in ProgramOptions
1 parent e75b3ac commit a8285b0

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

cuda_core/cuda/core/experimental/_program.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ def __post_init__(self):
242242
if self.device_code_optimize is not None:
243243
self._formatted_options.append(f"--dopt={'on' if self.device_code_optimize else 'off'}")
244244
if self.ptxas_options is not None:
245-
self._formatted_options.append("--ptxas-options")
245+
opt_name = "--ptxas-options"
246246
if isinstance(self.ptxas_options, str):
247-
self._formatted_options.append(self.ptxas_options)
247+
self._formatted_options.append(f"{opt_name}={self.ptxas_options}")
248248
elif is_sequence(self.ptxas_options):
249-
for option in self.ptxas_options:
250-
self._formatted_options.append(option)
249+
for opt_value in self.ptxas_options:
250+
self._formatted_options.append(f"{opt_name}={opt_value}")
251251
if self.max_register_count is not None:
252252
self._formatted_options.append(f"--maxrregcount={self.max_register_count}")
253253
if self.ftz is not None:

cuda_core/tests/test_program.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def ptx_code_object():
4343
ProgramOptions(diag_error=1234, diag_suppress=1234),
4444
ProgramOptions(diag_error=[1234, 1223], diag_suppress=(1234, 1223)),
4545
ProgramOptions(diag_warn=1000),
46+
ProgramOptions(std="c++11", ptxas_options=["-v"]),
47+
ProgramOptions(std="c++11", ptxas_options=["-v", "-O2"]),
4648
],
4749
)
4850
def test_cpp_program_with_various_options(init_cuda, options):

0 commit comments

Comments
 (0)