Repository: mesonbuild/meson

Issue:
cuda: add Ampere+Orin, Ada and Hopper support with 11.8



Discussion:
@obilaniu 
# [Codecov](https://codecov.io/gh/mesonbuild/meson/pull/11114?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report
> Merging [#11114](https://codecov.io/gh/mesonbuild/meson/pull/11114?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (b7b8b82) into [master](https://codecov.io/gh/mesonbuild/meson/commit/81d7c24a59bf4a991fe57579aa11a32b32779680?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (81d7c24) will **decrease** coverage by `2.71%`.
> The diff coverage is `n/a`.

> :exclamation: Current head b7b8b82 differs from pull request most recent head 2834f52. Consider uploading reports for the commit 2834f52 to get more accurate results

```diff
@@            Coverage Diff             @@
##           master   #11114      +/-   ##
==========================================
- Coverage   68.65%   65.94%   -2.72%     
==========================================
  Files         412      207     -205     
  Lines       87875    44942   -42933     
  Branches    20730     9283   -11447     
==========================================
- Hits        60327    29635   -30692     
+ Misses      23041    12948   -10093     
+ Partials     4507     2359    -2148     
```


| [Impacted Files](https://codecov.io/gh/mesonbuild/meson/pull/11114?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | |
|---|---|---|
| [scripts/clangtidy.py](https://codecov.io/gh/mesonbuild/meson/pull/11114/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c2NyaXB0cy9jbGFuZ3RpZHkucHk=) | `0.00% <0.00%> (-93.34%)` | :arrow_down: |
| [modules/cuda.py](https://codecov.io/gh/mesonbuild/meson/pull/11114/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-bW9kdWxlcy9jdWRhLnB5) | `0.00% <0.00%> (-72.64%)` | :arrow_down: |
| [templates/cudatemplates.py](https://codecov.io/gh/mesonbuild/meson/pull/11114/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-dGVtcGxhdGVzL2N1ZGF0ZW1wbGF0ZXMucHk=) | `37.50% <0.00%> (-62.50%)` | :arrow_down: |
| [compilers/cuda.py](https://codecov.io/gh/mesonbuild/meson/pull/11114/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-Y29tcGlsZXJzL2N1ZGEucHk=) | `19.63% <0.00%> (-45.40%)` | :arrow_down: |
| [dependencies/cuda.py](https://codecov.io/gh/mesonbuild/meson/pull/11114/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-ZGVwZW5kZW5jaWVzL2N1ZGEucHk=) | `19.23% <0.00%> (-43.75%)` | :arrow_down: |
| [modules/icestorm.py](https://codecov.io/gh/mesonbuild/meson/pull/11114/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-bW9kdWxlcy9pY2VzdG9ybS5weQ==) | `57.14% <0.00%> (-40.00%)` | :arrow_down: |
| [compilers/cython.py](https://codecov.io/gh/mesonbuild/meson/pull/11114/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-Y29tcGlsZXJzL2N5dGhvbi5weQ==) | `43.18% <0.00%> (-38.64%)` | :arrow_down: |
| [compilers/d.py](https://codecov.io/gh/mesonbuild/meson/pull/11114/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-Y29tcGlsZXJzL2QucHk=) | `38.33% <0.00%> (-18.60%)` | :arrow_down: |
| [dependencies/coarrays.py](https://codecov.io/gh/mesonbuild/meson/pull/11114/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-ZGVwZW5kZW5jaWVzL2NvYXJyYXlzLnB5) | `45.00% <0.00%> (-17.50%)` | :arrow_down: |
| [cmake/traceparser.py](https://codecov.io/gh/mesonbuild/meson/pull/11114/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-Y21ha2UvdHJhY2VwYXJzZXIucHk=) | `71.11% <0.00%> (-9.10%)` | :arrow_down: |
| ... and [256 more](https://codecov.io/gh/mesonbuild/meson/pull/11114/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)


Resolving patch:
diff --git a/mesonbuild/modules/cuda.py b/mesonbuild/modules/cuda.py
--- a/mesonbuild/modules/cuda.py
+++ b/mesonbuild/modules/cuda.py
@@ -56,6 +56,8 @@ def min_driver_version(self, state: 'ModuleState',
 
         cuda_version = args[0]
         driver_version_table = [
+            {'cuda_version': '>=11.8.0',   'windows': '522.06', 'linux': '520.61.05'},
+            {'cuda_version': '>=11.7.1',   'windows': '516.31', 'linux': '515.48.07'},
             {'cuda_version': '>=11.7.0',   'windows': '516.01', 'linux': '515.43.04'},
             {'cuda_version': '>=11.6.1',   'windows': '511.65', 'linux': '510.47.03'},
             {'cuda_version': '>=11.6.0',   'windows': '511.23', 'linux': '510.39.01'},
@@ -246,11 +248,20 @@ def _nvcc_arch_flags(self, cuda_version, cuda_arch_list='Auto', detected=''):
                 cuda_hi_limit_gpu_architecture = '8.6'        # noqa: E221
 
         if version_compare(cuda_version, '>=11.1'):
-            cuda_common_gpu_architectures += ['8.6', '8.6+PTX']  # noqa: E221
+            cuda_common_gpu_architectures += ['8.6']             # noqa: E221
             cuda_all_gpu_architectures    += ['8.6']             # noqa: E221
 
-            if version_compare(cuda_version, '<12.0'):
-                cuda_hi_limit_gpu_architecture = '9.0'        # noqa: E221
+            if version_compare(cuda_version, '<11.8'):
+                cuda_common_gpu_architectures += ['8.6+PTX']  # noqa: E221
+                cuda_hi_limit_gpu_architecture = '8.7'        # noqa: E221
+
+        if version_compare(cuda_version, '>=11.8'):
+            cuda_known_gpu_architectures  += ['Orin', 'Lovelace', 'Hopper']  # noqa: E221
+            cuda_common_gpu_architectures += ['8.9', '9.0', '9.0+PTX']       # noqa: E221
+            cuda_all_gpu_architectures    += ['8.7', '8.9', '9.0']           # noqa: E221
+
+            if version_compare(cuda_version, '<12'):
+                cuda_hi_limit_gpu_architecture = '9.1'        # noqa: E221
 
         if not cuda_arch_list:
             cuda_arch_list = 'Auto'
@@ -301,6 +312,9 @@ def _nvcc_arch_flags(self, cuda_version, cuda_arch_list='Auto', detected=''):
                     'Xavier':        (['7.2'],             []),
                     'Turing':        (['7.5'],             ['7.5']),
                     'Ampere':        (['8.0'],             ['8.0']),
+                    'Orin':          (['8.7'],             []),
+                    'Lovelace':      (['8.9'],             ['8.9']),
+                    'Hopper':        (['9.0'],             ['9.0']),
                 }.get(arch_name, (None, None))
 
             if arch_bin is None:
@@ -325,7 +339,7 @@ def _nvcc_arch_flags(self, cuda_version, cuda_arch_list='Auto', detected=''):
 
             if version_compare(arch, '<' + cuda_lo_limit_gpu_architecture):
                 continue
-            if version_compare(arch, '>=' + cuda_hi_limit_gpu_architecture):
+            if cuda_hi_limit_gpu_architecture and version_compare(arch, '>=' + cuda_hi_limit_gpu_architecture):
                 continue
 
             if codev:
@@ -347,7 +361,7 @@ def _nvcc_arch_flags(self, cuda_version, cuda_arch_list='Auto', detected=''):
 
             if version_compare(arch, '<' + cuda_lo_limit_gpu_architecture):
                 continue
-            if version_compare(arch, '>=' + cuda_hi_limit_gpu_architecture):
+            if cuda_hi_limit_gpu_architecture and version_compare(arch, '>=' + cuda_hi_limit_gpu_architecture):
                 continue
 
             arch = arch.replace('.', '')


Test patch: