|
9 | 9 | from dataclasses import dataclass |
10 | 10 | from typing import List, Optional |
11 | 11 |
|
| 12 | +from cuda.core.experimental._device import Device |
12 | 13 | from cuda.core.experimental._module import ObjectCode |
13 | 14 | from cuda.core.experimental._utils import check_or_create_options, driver, handle_return |
14 | 15 |
|
@@ -91,10 +92,10 @@ class LinkerOptions: |
91 | 92 |
|
92 | 93 | Attributes |
93 | 94 | ---------- |
94 | | - arch : str |
95 | | - Pass the SM architecture value, such as ``-arch=sm_<CC>`` (for generating CUBIN) or |
96 | | - ``compute_<CC>`` (for generating PTX). |
97 | | - This is a required option. |
| 95 | + arch : str, optional |
| 96 | + Pass the SM architecture value, such as ``sm_<CC>`` (for generating CUBIN) or |
| 97 | + ``compute_<CC>`` (for generating PTX). If not provided, the current device's architecture |
| 98 | + will be used. |
98 | 99 | max_register_count : int, optional |
99 | 100 | Maximum register count. |
100 | 101 | Maps to: ``-maxrregcount=<N>``. |
@@ -172,7 +173,7 @@ class LinkerOptions: |
172 | 173 | Default: False. |
173 | 174 | """ |
174 | 175 |
|
175 | | - arch: str |
| 176 | + arch: Optional[str] = None |
176 | 177 | max_register_count: Optional[int] = None |
177 | 178 | time: Optional[bool] = None |
178 | 179 | verbose: Optional[bool] = None |
@@ -204,6 +205,8 @@ def __post_init__(self): |
204 | 205 | def _init_nvjitlink(self): |
205 | 206 | if self.arch is not None: |
206 | 207 | self.formatted_options.append(f"-arch={self.arch}") |
| 208 | + else: |
| 209 | + self.formatted_options.append("-arch=sm_" + "".join(f"{i}" for i in Device().compute_capability)) |
207 | 210 | if self.max_register_count is not None: |
208 | 211 | self.formatted_options.append(f"-maxrregcount={self.max_register_count}") |
209 | 212 | if self.time is not None: |
|
0 commit comments