Skip to content

Commit

Permalink
fix the options for multiple args
Browse files Browse the repository at this point in the history
  • Loading branch information
ksimpson-work committed Nov 27, 2024
1 parent de32d15 commit cd6cca1
Showing 1 changed file with 39 additions and 48 deletions.
87 changes: 39 additions & 48 deletions cuda_core/cuda/core/experimental/_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ class ProgramOptions:
for optimized device code.
Default: None
Maps to: --dopt on (-dopt)
ptxas_options : str, optional
Specify options directly to ptxas, the PTX optimizing assembler.
ptxas_options : Union[str, List[str]], optional
Specify one or more options directly to ptxas, the PTX optimizing assembler. Options should be strings without
hyphens. For example ["v", "O2"].
Default: None
Maps to: --ptxas-options <options> (-Xptxas)
maxrregcount : int, optional
Expand Down Expand Up @@ -80,10 +81,6 @@ class ProgramOptions:
Enables more aggressive device code vectorization in the NVVM optimizer.
Default: False
Maps to: --extra-device-vectorization (-extra-device-vectorization)
modify_stack_limit : bool, optional
On Linux, during compilation, use setrlimit() to increase stack size to maximum allowed.
Default: True
Maps to: --modify-stack-limit={true|false} (-modify-stack-limit)
dlink_time_opt : bool, optional
Generate intermediate code for later link-time optimization.
Default: False
Expand All @@ -92,34 +89,21 @@ class ProgramOptions:
Run the optimizer passes before generating the LTO IR.
Default: False
Maps to: --gen-opt-lto (-gen-opt-lto)
optix_ir : bool, optional
Generate OptiX IR. Only intended for consumption by OptiX through appropriate APIs.
Default: False
Maps to: --optix-ir (-optix-ir)
jump_table_density : int, optional
Specify the case density percentage in switch statements, and use it as a minimal threshold to determine
whether jump table (brx.idx instruction) will be used to implement a switch statement.
Default: 101
Maps to: --jump-table-density=[0-101] (-jtd)
device_stack_protector : bool, optional
Enable (disable) the generation of stack canaries in device code.
Default: False
Maps to: --device-stack-protector={true|false} (-device-stack-protector)
define_macro : Union[str, Tuple[str, str]], optional
Predefine a macro. Can be either a string, in which case that macro will be set to 1, or a 2 element tuple of
strings, in which case the first element is defined as the second.
define_macro : Union[str, Tuple[str, str], List[Union[str, Tuple[str, str]]]], optional
Predefine a macro. Can be either a string, in which case that macro will be set to 1, a 2 element tuple of
strings, in which case the first element is defined as the second, or a list of strings or tuples.
Default: None
Maps to: --define-macro=<def> (-D)
undefine_macro : str, optional
Cancel any previous definition of a macro.
undefine_macro : Union[str, List[str]], optional
Cancel any previous definition of a macro, or list of macros.
Default: None
Maps to: --undefine-macro=<def> (-U)
include_path : Union[str, List[str]], optional
Add the directory or directories to the list of directories to be searched for headers.
Default: None
Maps to: --include-path=<dir> (-I)
pre_include : str, optional
Preinclude a header during preprocessing.
pre_include : Union[str, List[str]], optional
Preinclude one or more headers during preprocessing. Can be either a string or a list of strings.
Default: None
Maps to: --pre-include=<header> (-include)
no_source_include : bool, optional
Expand Down Expand Up @@ -204,24 +188,20 @@ class ProgramOptions:
device_debug: Optional[bool] = None
generate_line_info: Optional[bool] = None
device_optimize: Optional[bool] = None
ptxas_options: Optional[str] = None
ptxas_options: Optional[Union[str, List[str]]] = None
maxrregcount: Optional[int] = None
ftz: Optional[bool] = None
prec_sqrt: Optional[bool] = None
prec_div: Optional[bool] = None
fmad: Optional[bool] = None
use_fast_math: Optional[bool] = None
extra_device_vectorization: Optional[bool] = None
modify_stack_limit: Optional[bool] = None
dlink_time_opt: Optional[bool] = None
gen_opt_lto: Optional[bool] = None
optix_ir: Optional[bool] = None
jump_table_density: Optional[int] = None
device_stack_protector: Optional[bool] = None
define_macro: Optional[Union[str, Tuple[str, str]]] = None
undefine_macro: Optional[str] = None
define_macro: Optional[Union[str, Tuple[str, str], List[Union[str, Tuple[str, str]]]]] = None
undefine_macro: Optional[Union[str, List[str]]] = None
include_path: Optional[Union[str, List[str]]] = None
pre_include: Optional[str] = None
pre_include: Optional[Union[str, List[str]]] = None
no_source_include: Optional[bool] = None
std: Optional[str] = None
builtin_move_forward: Optional[bool] = None
Expand Down Expand Up @@ -262,7 +242,12 @@ def __post_init__(self):
if self.dopt is not None:
self._formatted_options.append(f"--dopt={'on' if self.dopt else 'off'}")
if self.ptxas_options is not None:
self._formatted_options.append(f"--ptxas-options={self.ptxas_options}")
self._formatted_options.append("--ptxas-options")
if isinstance(self.ptxas_options, list):
for option in self.ptxas_options:
self._formatted_options.append(option)
else:
self._formatted_options.append("self.ptxas_options")
if self.maxrregcount is not None:
self._formatted_options.append(f"--maxrregcount={self.maxrregcount}")
if self.ftz is not None:
Expand All @@ -277,36 +262,42 @@ def __post_init__(self):
self._formatted_options.append("--use_fast_math")
if self.extra_device_vectorization is not None and self.extra_device_vectorization:
self._formatted_options.append("--extra-device-vectorization")
if self.modify_stack_limit is not None:
self._formatted_options.append(f"--modify-stack-limit={_handle_boolean_option(self.modify_stack_limit)}")
if self.dlink_time_opt is not None and self.dlink_time_opt:
self._formatted_options.append("--dlink-time-opt")
if self.gen_opt_lto is not None and self.gen_opt_lto:
self._formatted_options.append("--gen-opt-lto")
if self.optix_ir is not None and self.optix_ir:
self._formatted_options.append("--optix-ir")
if self.jump_table_density is not None:
self._formatted_options.append(f"--jump-table-density={self.jump_table_density}")
if self.device_stack_protector is not None:
self._formatted_options.append(
f"--device-stack-protector={_handle_boolean_option(self.device_stack_protector)}"
)
if self.define_macro is not None:
if isinstance(self.define_macro, tuple):
if isinstance(self.define_macro, list):
for macro in self.define_macro:
if isinstance(macro, tuple):
assert len(macro) == 2
self._formatted_options.append(f"--define-macro={macro[0]}={macro[1]}")
else:
self._formatted_options.append(f"--define-macro={macro}")
elif isinstance(self.define_macro, tuple):
assert len(self.define_macro) == 2
self._formatted_options.append(f"--define-macro={self.define_macro[0]}={self.define_macro[1]}")
else:
self._formatted_options.append(f"--define-macro={self.define_macro}")

if self.undefine_macro is not None:
self._formatted_options.append(f"--undefine-macro={self.undefine_macro}")
if isinstance(self.undefine_macro, list):
for macro in self.undefine_macro:
self._formatted_options.append(f"--undefine-macro={macro}")
else:
self._formatted_options.append(f"--undefine-macro={self.undefine_macro}")
if self.include_path is not None:
if isinstance(self.include_path, list):
for path in self.include_path:
self._formatted_options.append(f"--include-path={path}")
else:
self._formatted_options.append(f"--include-path={self.include_path}")
if self.pre_include is not None:
self._formatted_options.append(f"--pre-include={self.pre_include}")
if isinstance(self.pre_include, list):
for header in self.pre_include:
self._formatted_options.append(f"--pre-include={header}")
else:
self._formatted_options.append(f"--pre-include={self.pre_include}")
if self.no_source_include is not None and self.no_source_include:
self._formatted_options.append("--no-source-include")
if self.std is not None:
Expand Down

0 comments on commit cd6cca1

Please sign in to comment.