pyqcu 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. pyqcu-0.1.0/LICENSE +17 -0
  2. pyqcu-0.1.0/MANIFEST.in +47 -0
  3. pyqcu-0.1.0/PKG-INFO +174 -0
  4. pyqcu-0.1.0/README.md +137 -0
  5. pyqcu-0.1.0/build-dcu.sh +8 -0
  6. pyqcu-0.1.0/build-nv.sh +8 -0
  7. pyqcu-0.1.0/cpp/cuda/qcu/CMakeLists-dcu.txt +24 -0
  8. pyqcu-0.1.0/cpp/cuda/qcu/CMakeLists-nv.txt +104 -0
  9. pyqcu-0.1.0/cpp/cuda/qcu/LICENSE +553 -0
  10. pyqcu-0.1.0/cpp/cuda/qcu/env.sh +81 -0
  11. pyqcu-0.1.0/cpp/cuda/qcu/include/bistabcg.h +63 -0
  12. pyqcu-0.1.0/cpp/cuda/qcu/include/cg.h +37 -0
  13. pyqcu-0.1.0/cpp/cuda/qcu/include/clover_dslash.h +102 -0
  14. pyqcu-0.1.0/cpp/cuda/qcu/include/define.h +625 -0
  15. pyqcu-0.1.0/cpp/cuda/qcu/include/dslash.h +5 -0
  16. pyqcu-0.1.0/cpp/cuda/qcu/include/gauss_gauge.h +6 -0
  17. pyqcu-0.1.0/cpp/cuda/qcu/include/include.h +35 -0
  18. pyqcu-0.1.0/cpp/cuda/qcu/include/laplacian.h +36 -0
  19. pyqcu-0.1.0/cpp/cuda/qcu/include/lattice_clover_bistabcg.h +746 -0
  20. pyqcu-0.1.0/cpp/cuda/qcu/include/lattice_clover_dslash.h +754 -0
  21. pyqcu-0.1.0/cpp/cuda/qcu/include/lattice_clover_multigrid.h +6132 -0
  22. pyqcu-0.1.0/cpp/cuda/qcu/include/lattice_complex.h +140 -0
  23. pyqcu-0.1.0/cpp/cuda/qcu/include/lattice_cuda.h +39 -0
  24. pyqcu-0.1.0/cpp/cuda/qcu/include/lattice_laplacian.h +241 -0
  25. pyqcu-0.1.0/cpp/cuda/qcu/include/lattice_mpi.h +161 -0
  26. pyqcu-0.1.0/cpp/cuda/qcu/include/lattice_multigrid.h +685 -0
  27. pyqcu-0.1.0/cpp/cuda/qcu/include/lattice_sap.h +159 -0
  28. pyqcu-0.1.0/cpp/cuda/qcu/include/lattice_set.h +812 -0
  29. pyqcu-0.1.0/cpp/cuda/qcu/include/lattice_wilson_bistabcg.h +395 -0
  30. pyqcu-0.1.0/cpp/cuda/qcu/include/lattice_wilson_cg.h +394 -0
  31. pyqcu-0.1.0/cpp/cuda/qcu/include/lattice_wilson_dslash.h +776 -0
  32. pyqcu-0.1.0/cpp/cuda/qcu/include/multigrid.h +204 -0
  33. pyqcu-0.1.0/cpp/cuda/qcu/include/qcu.h +21 -0
  34. pyqcu-0.1.0/cpp/cuda/qcu/include/wilson_dslash.h +45 -0
  35. pyqcu-0.1.0/cpp/cuda/qcu/make-dcu.sh +64 -0
  36. pyqcu-0.1.0/cpp/cuda/qcu/make-nv.sh +14 -0
  37. pyqcu-0.1.0/cpp/cuda/qcu/python/pyqcu.h +160 -0
  38. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_clover.cu +74 -0
  39. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_clover_bistabcg.cu +91 -0
  40. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_clover_bistabcg_dslash.cu +142 -0
  41. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_clover_dslash.cu +110 -0
  42. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_clover_multigrid.cu +165 -0
  43. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_clover_multigrid_verify.cu +135 -0
  44. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_clovers.cu +135 -0
  45. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_dslash.cu +79 -0
  46. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_end.cu +72 -0
  47. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_gauss_gauge.cu +25 -0
  48. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_init.cu +76 -0
  49. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_laplacian.cu +42 -0
  50. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_multigrid.cu +168 -0
  51. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_multigrid_strict.cu +5315 -0
  52. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_test.cu +218 -0
  53. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_wilson_bistabcg.cu +46 -0
  54. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_wilson_bistabcg_dslash.cu +36 -0
  55. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_wilson_cg.cu +46 -0
  56. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_wilson_cg_dslash.cu +36 -0
  57. pyqcu-0.1.0/cpp/cuda/qcu/src/apply_wilson_dslash.cu +42 -0
  58. pyqcu-0.1.0/cpp/cuda/qcu/src/bistabcg.cu +445 -0
  59. pyqcu-0.1.0/cpp/cuda/qcu/src/cg.cu +210 -0
  60. pyqcu-0.1.0/cpp/cuda/qcu/src/clover_dslash_comm.cu +627 -0
  61. pyqcu-0.1.0/cpp/cuda/qcu/src/clover_dslash_multi.cu +1613 -0
  62. pyqcu-0.1.0/cpp/cuda/qcu/src/clover_dslash_single.cu +1128 -0
  63. pyqcu-0.1.0/cpp/cuda/qcu/src/gauss_gauge.cu +205 -0
  64. pyqcu-0.1.0/cpp/cuda/qcu/src/laplacian.cu +774 -0
  65. pyqcu-0.1.0/cpp/cuda/qcu/src/lattice_cuda.cu +209 -0
  66. pyqcu-0.1.0/cpp/cuda/qcu/src/lattice_mpi.cu +48 -0
  67. pyqcu-0.1.0/cpp/cuda/qcu/src/lattice_set.cu +14 -0
  68. pyqcu-0.1.0/cpp/cuda/qcu/src/multigrid.cu +2909 -0
  69. pyqcu-0.1.0/cpp/cuda/qcu/src/wilson_dslash.cu +1477 -0
  70. pyqcu-0.1.0/cpp/kupl/qcu/CMakeLists.txt +538 -0
  71. pyqcu-0.1.0/cpp/kupl/qcu/README.md +295 -0
  72. pyqcu-0.1.0/cpp/kupl/qcu/include/kupl/define.h +91 -0
  73. pyqcu-0.1.0/cpp/kupl/qcu/include/kupl/lattice_clover_multigrid.h +26 -0
  74. pyqcu-0.1.0/cpp/kupl/qcu/include/kupl/lattice_complex.h +19 -0
  75. pyqcu-0.1.0/cpp/kupl/qcu/include/kupl/lattice_cpu.h +33 -0
  76. pyqcu-0.1.0/cpp/kupl/qcu/include/kupl/lattice_geometry.h +195 -0
  77. pyqcu-0.1.0/cpp/kupl/qcu/include/kupl/lattice_halo.h +43 -0
  78. pyqcu-0.1.0/cpp/kupl/qcu/include/kupl/lattice_linalg.h +70 -0
  79. pyqcu-0.1.0/cpp/kupl/qcu/include/kupl/lattice_multigrid.h +15 -0
  80. pyqcu-0.1.0/cpp/kupl/qcu/include/kupl/lattice_set.h +475 -0
  81. pyqcu-0.1.0/cpp/kupl/qcu/include/kupl/lattice_strict.h +72 -0
  82. pyqcu-0.1.0/cpp/kupl/qcu/include/kupl/qcu.h +176 -0
  83. pyqcu-0.1.0/cpp/kupl/qcu/make.sh +47 -0
  84. pyqcu-0.1.0/cpp/kupl/qcu/qcu.map +9 -0
  85. pyqcu-0.1.0/cpp/kupl/qcu/src/api_common.hpp +89 -0
  86. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_clover.cpp +16 -0
  87. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_clover_bistabcg.cpp +33 -0
  88. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_clover_bistabcg_dslash.cpp +62 -0
  89. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_clover_dslash.cpp +18 -0
  90. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_clover_multigrid.cpp +44 -0
  91. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_clover_multigrid_verify.cpp +54 -0
  92. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_clovers.cpp +18 -0
  93. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_dslash.cpp +20 -0
  94. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_end.cpp +31 -0
  95. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_gauss_gauge.cpp +15 -0
  96. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_init.cpp +44 -0
  97. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_laplacian.cpp +18 -0
  98. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_multigrid.cpp +314 -0
  99. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_multigrid_strict.cpp +341 -0
  100. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_test.cpp +19 -0
  101. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_wilson_bistabcg.cpp +18 -0
  102. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_wilson_bistabcg_dslash.cpp +19 -0
  103. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_wilson_cg.cpp +18 -0
  104. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_wilson_cg_dslash.cpp +18 -0
  105. pyqcu-0.1.0/cpp/kupl/qcu/src/apply_wilson_dslash.cpp +18 -0
  106. pyqcu-0.1.0/cpp/kupl/qcu/src/backend.cpp +539 -0
  107. pyqcu-0.1.0/cpp/kupl/qcu/src/lattice_clover_dslash.cpp +683 -0
  108. pyqcu-0.1.0/cpp/kupl/qcu/src/lattice_clover_multigrid.cpp +1170 -0
  109. pyqcu-0.1.0/cpp/kupl/qcu/src/lattice_cpu.cpp +901 -0
  110. pyqcu-0.1.0/cpp/kupl/qcu/src/lattice_gauss_gauge.cpp +186 -0
  111. pyqcu-0.1.0/cpp/kupl/qcu/src/lattice_geometry.cpp +253 -0
  112. pyqcu-0.1.0/cpp/kupl/qcu/src/lattice_laplacian.cpp +277 -0
  113. pyqcu-0.1.0/cpp/kupl/qcu/src/lattice_linalg.cpp +140 -0
  114. pyqcu-0.1.0/cpp/kupl/qcu/src/lattice_multigrid.cpp +1185 -0
  115. pyqcu-0.1.0/cpp/kupl/qcu/src/lattice_solver.cpp +820 -0
  116. pyqcu-0.1.0/cpp/kupl/qcu/src/lattice_strict.cpp +1892 -0
  117. pyqcu-0.1.0/cpp/kupl/qcu/src/lattice_wilson_dslash.cpp +1296 -0
  118. pyqcu-0.1.0/env.sh +86 -0
  119. pyqcu-0.1.0/install.sh +90 -0
  120. pyqcu-0.1.0/pyproject.toml +60 -0
  121. pyqcu-0.1.0/pyqcu/__init__.py +5 -0
  122. pyqcu-0.1.0/pyqcu/__main__.py +94 -0
  123. pyqcu-0.1.0/pyqcu/_build_backend.py +25 -0
  124. pyqcu-0.1.0/pyqcu/_multigrid_warnings.py +136 -0
  125. pyqcu-0.1.0/pyqcu/_tilelang.py +47 -0
  126. pyqcu-0.1.0/pyqcu/api/__init__.py +70 -0
  127. pyqcu-0.1.0/pyqcu/api/_compat.py +187 -0
  128. pyqcu-0.1.0/pyqcu/api/config.py +199 -0
  129. pyqcu-0.1.0/pyqcu/api/models.py +373 -0
  130. pyqcu-0.1.0/pyqcu/api/native.py +151 -0
  131. pyqcu-0.1.0/pyqcu/api/operator.py +116 -0
  132. pyqcu-0.1.0/pyqcu/api/protocols.py +148 -0
  133. pyqcu-0.1.0/pyqcu/cann/__init__.py +330 -0
  134. pyqcu-0.1.0/pyqcu/cuda/__init__.py +38 -0
  135. pyqcu-0.1.0/pyqcu/cuda/_logs.py +76 -0
  136. pyqcu-0.1.0/pyqcu/cuda/_multi_gpu.py +824 -0
  137. pyqcu-0.1.0/pyqcu/cuda/_runtime.py +638 -0
  138. pyqcu-0.1.0/pyqcu/cuda/_schur_op.py +258 -0
  139. pyqcu-0.1.0/pyqcu/cuda/_strict_cache.py +1312 -0
  140. pyqcu-0.1.0/pyqcu/cuda/_strict_mpi.py +1139 -0
  141. pyqcu-0.1.0/pyqcu/cuda/_strict_multigrid.py +498 -0
  142. pyqcu-0.1.0/pyqcu/cuda/define.py +228 -0
  143. pyqcu-0.1.0/pyqcu/cuda/krylov.py +30 -0
  144. pyqcu-0.1.0/pyqcu/cuda/linear_operator.py +38 -0
  145. pyqcu-0.1.0/pyqcu/cuda/multigrid/__init__.py +10 -0
  146. pyqcu-0.1.0/pyqcu/cuda/multigrid/legacy_multigrid.py +157 -0
  147. pyqcu-0.1.0/pyqcu/cuda/multigrid/strict_multigrid.py +5 -0
  148. pyqcu-0.1.0/pyqcu/cuda/qcu/qcu.pxd +41 -0
  149. pyqcu-0.1.0/pyqcu/cuda/qcu/qcu.pyi +428 -0
  150. pyqcu-0.1.0/pyqcu/cuda/qcu/qcu.pyx +889 -0
  151. pyqcu-0.1.0/pyqcu/cuda/qcu/qcu_api.pxd +41 -0
  152. pyqcu-0.1.0/pyqcu/cuda/qcu.pyi +428 -0
  153. pyqcu-0.1.0/pyqcu/dslash/__init__.py +43 -0
  154. pyqcu-0.1.0/pyqcu/kupl/__init__.py +24 -0
  155. pyqcu-0.1.0/pyqcu/kupl/define.py +221 -0
  156. pyqcu-0.1.0/pyqcu/kupl/krylov.py +30 -0
  157. pyqcu-0.1.0/pyqcu/kupl/linear_operator.py +37 -0
  158. pyqcu-0.1.0/pyqcu/kupl/multigrid/__init__.py +10 -0
  159. pyqcu-0.1.0/pyqcu/kupl/multigrid/legacy_multigrid.py +180 -0
  160. pyqcu-0.1.0/pyqcu/kupl/multigrid/strict_multigrid.py +228 -0
  161. pyqcu-0.1.0/pyqcu/kupl/qcu.py +603 -0
  162. pyqcu-0.1.0/pyqcu/lattice/__init__.py +213 -0
  163. pyqcu-0.1.0/pyqcu/lattice/_source.py +141 -0
  164. pyqcu-0.1.0/pyqcu/smear/__init__.py +10 -0
  165. pyqcu-0.1.0/pyqcu/solver/__init__.py +82 -0
  166. pyqcu-0.1.0/pyqcu/solver/_native_qcu.py +299 -0
  167. pyqcu-0.1.0/pyqcu/solver/krylov/__init__.py +102 -0
  168. pyqcu-0.1.0/pyqcu/solver/multigrid/__init__.py +158 -0
  169. pyqcu-0.1.0/pyqcu/solver/multigrid/_warnings.py +8 -0
  170. pyqcu-0.1.0/pyqcu/solver/multigrid/cache.py +240 -0
  171. pyqcu-0.1.0/pyqcu/tools/__init__.py +224 -0
  172. pyqcu-0.1.0/pyqcu/tools/_argparse.py +60 -0
  173. pyqcu-0.1.0/pyqcu/tools/_bench_plots.py +400 -0
  174. pyqcu-0.1.0/pyqcu/tools/_budget.py +129 -0
  175. pyqcu-0.1.0/pyqcu/tools/_define.py +517 -0
  176. pyqcu-0.1.0/pyqcu/tools/_env.py +95 -0
  177. pyqcu-0.1.0/pyqcu/tools/_io.py +308 -0
  178. pyqcu-0.1.0/pyqcu/tools/_legacy_mg_cache.py +637 -0
  179. pyqcu-0.1.0/pyqcu/tools/_strict_mg_cache.py +249 -0
  180. pyqcu-0.1.0/pyqcu/torch/__init__.py +24 -0
  181. pyqcu-0.1.0/pyqcu/torch/dslash/__init__.py +20 -0
  182. pyqcu-0.1.0/pyqcu/torch/dslash/_adapter.py +127 -0
  183. pyqcu-0.1.0/pyqcu/torch/dslash/_clover.py +356 -0
  184. pyqcu-0.1.0/pyqcu/torch/dslash/_operator.py +564 -0
  185. pyqcu-0.1.0/pyqcu/torch/dslash/_wilson.py +324 -0
  186. pyqcu-0.1.0/pyqcu/torch/smear/__init__.py +4 -0
  187. pyqcu-0.1.0/pyqcu/torch/smear/_stout.py +204 -0
  188. pyqcu-0.1.0/pyqcu/torch/smear/_wuppertal.py +106 -0
  189. pyqcu-0.1.0/pyqcu/torch/solver/__init__.py +68 -0
  190. pyqcu-0.1.0/pyqcu/torch/solver/_bistabcg.py +116 -0
  191. pyqcu-0.1.0/pyqcu/torch/solver/_cacg.py +117 -0
  192. pyqcu-0.1.0/pyqcu/torch/solver/_gmres.py +204 -0
  193. pyqcu-0.1.0/pyqcu/torch/solver/_krylov_drivers.py +367 -0
  194. pyqcu-0.1.0/pyqcu/torch/solver/_lanczos.py +149 -0
  195. pyqcu-0.1.0/pyqcu/torch/solver/_legacy_multigrid.py +1116 -0
  196. pyqcu-0.1.0/pyqcu/torch/solver/_mr.py +80 -0
  197. pyqcu-0.1.0/pyqcu/torch/solver/_multigrid_core.py +3974 -0
  198. pyqcu-0.1.0/pyqcu/torch/solver/_multishift_cg.py +135 -0
  199. pyqcu-0.1.0/pyqcu/torch/solver/multigrid/__init__.py +6 -0
  200. pyqcu-0.1.0/pyqcu/torch/solver/multigrid/legacy_multigrid.py +5 -0
  201. pyqcu-0.1.0/pyqcu/torch/solver/multigrid/strict_multigrid.py +25 -0
  202. pyqcu-0.1.0/pyqcu/torch/tools/__init__.py +50 -0
  203. pyqcu-0.1.0/pyqcu/torch/tools/_distributed_setup.py +327 -0
  204. pyqcu-0.1.0/pyqcu/torch/tools/_einsum.py +117 -0
  205. pyqcu-0.1.0/pyqcu/torch/tools/_hierarchical.py +268 -0
  206. pyqcu-0.1.0/pyqcu/torch/tools/_linalg.py +110 -0
  207. pyqcu-0.1.0/pyqcu/torch/tools/_matul.py +111 -0
  208. pyqcu-0.1.0/pyqcu/torch/tools/_mpi_roll.py +406 -0
  209. pyqcu-0.1.0/pyqcu/torch/tools/_multigrid.py +1559 -0
  210. pyqcu-0.1.0/pyqcu/torch/tools/_roll.py +1 -0
  211. pyqcu-0.1.0/pyqcu/torch/tools/_strict_galerkin.py +1288 -0
  212. pyqcu-0.1.0/pyqcu.egg-info/PKG-INFO +174 -0
  213. pyqcu-0.1.0/pyqcu.egg-info/SOURCES.txt +217 -0
  214. pyqcu-0.1.0/pyqcu.egg-info/dependency_links.txt +1 -0
  215. pyqcu-0.1.0/pyqcu.egg-info/not-zip-safe +1 -0
  216. pyqcu-0.1.0/pyqcu.egg-info/requires.txt +14 -0
  217. pyqcu-0.1.0/pyqcu.egg-info/top_level.txt +1 -0
  218. pyqcu-0.1.0/setup.cfg +4 -0
  219. pyqcu-0.1.0/setup.py +308 -0
pyqcu-0.1.0/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ MIT License
2
+ Copyright (c) 2024 ZhangXin8069
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+ The above copyright notice and this permission notice shall be included in all
10
+ copies or substantial portions of the Software.
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
+ SOFTWARE.
@@ -0,0 +1,47 @@
1
+ # PyQCU source distribution contents.
2
+ #
3
+ # The sdist must be installable on a machine without a pre-built native
4
+ # library, so the KUPL/CUDA sources and the build scripts are shipped. The
5
+ # installer builds KUPL unconditionally (when a toolchain exists) and CUDA/DCU
6
+ # opportunistically; test trees and build products never enter the sdist.
7
+
8
+ include LICENSE
9
+ include README.md
10
+ include pyproject.toml
11
+ include setup.py
12
+ include MANIFEST.in
13
+
14
+ include env.sh
15
+ include build-nv.sh
16
+ include build-dcu.sh
17
+ include install.sh
18
+
19
+ recursive-include pyqcu *.py *.pyi *.pyx *.pxd
20
+
21
+ recursive-include cpp/kupl/qcu *.txt *.sh *.map *.md *.h *.hpp *.cpp
22
+ prune cpp/kupl/qcu/tests
23
+ prune cpp/kupl/qcu/build
24
+ prune cpp/kupl/qcu/build-lto
25
+ include cpp/cuda/qcu/LICENSE
26
+ include cpp/cuda/qcu/CMakeLists-nv.txt
27
+ include cpp/cuda/qcu/CMakeLists-dcu.txt
28
+ include cpp/cuda/qcu/make-nv.sh
29
+ include cpp/cuda/qcu/make-dcu.sh
30
+ include cpp/cuda/qcu/env.sh
31
+ recursive-include cpp/cuda/qcu/python *.h
32
+ recursive-include cpp/cuda/qcu/include *.h *.hpp
33
+ recursive-include cpp/cuda/qcu/src *.cu *.cpp *.h *.hpp
34
+
35
+ prune pyqcu/testing
36
+ prune build
37
+ prune dist
38
+ prune data
39
+ prune docs
40
+ prune logs
41
+ prune refer
42
+ prune skills
43
+
44
+ global-exclude *.so *.so.* *.o *.pyc *.pyo *.pyd
45
+ global-exclude __pycache__ *.egg-info
46
+ global-exclude CMakeCache.txt cmake_install.cmake CTestTestfile.cmake Makefile
47
+ global-exclude AGENTS.md
pyqcu-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,174 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyqcu
3
+ Version: 0.1.0
4
+ Summary: CUDA/DCU/KUPL-accelerated lattice-QCD Dirac operators and multigrid solvers.
5
+ Author-email: ZhangXin8069 <zhangxin8069@qq.com>
6
+ License-Expression: MIT
7
+ Project-URL: Documentation, https://pyqcu.readthedocs.io/
8
+ Project-URL: Homepage, https://gitlab.itp.ac.cn/ZhangXin8069/PyQCU
9
+ Project-URL: Issues, https://gitlab.itp.ac.cn/ZhangXin8069/PyQCU/-/issues
10
+ Keywords: lattice-qcd,dirac-operator,multigrid,bistabcg,cuda,dcu,kupl,mpi
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Programming Language :: C++
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Scientific/Engineering :: Physics
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: numpy>=1.23
26
+ Requires-Dist: torch>=2.0
27
+ Requires-Dist: mpi4py>=3.1
28
+ Requires-Dist: h5py>=3.0
29
+ Provides-Extra: plot
30
+ Requires-Dist: matplotlib>=3.6; extra == "plot"
31
+ Provides-Extra: monitor
32
+ Requires-Dist: psutil>=5.9; extra == "monitor"
33
+ Provides-Extra: all
34
+ Requires-Dist: matplotlib>=3.6; extra == "all"
35
+ Requires-Dist: psutil>=5.9; extra == "all"
36
+ Dynamic: license-file
37
+
38
+ # PyQCU
39
+
40
+ PyQCU is a lattice-QCD operator and solver toolkit with three execution
41
+ paths:
42
+
43
+ * a Torch/CANN backend for CPU, CUDA, and Ascend NPU;
44
+ * an independent C++17 MPI+OpenMP CPU backend (KUPL);
45
+ * a CUDA/DCU C++ backend exposed through a Cython bridge.
46
+
47
+ It provides Wilson and Clover Dirac operators, stout and Wuppertal smearing,
48
+ BiCGStab/CG/FGMRES solvers, Legacy and Strict multigrid hierarchies, HDF5
49
+ helpers, and a four-dimensional MPI rank grid.
50
+
51
+ ## Install
52
+
53
+ ```bash
54
+ pip install pyqcu
55
+ ```
56
+
57
+ Requirements: Python 3.10+, Linux, `numpy`, `torch`, `mpi4py`, and `h5py`
58
+ (installed automatically). A C++17 compiler, CMake, and MPI are needed to
59
+ build the KUPL CPU library; `nvcc` is needed for the optional CUDA library.
60
+
61
+ The package is distributed as a source archive. The first install builds KUPL
62
+ when the toolchain is available and tries CUDA/DCU opportunistically; a
63
+ missing toolchain leaves the pure-Torch paths usable and does not fail the
64
+ install.
65
+
66
+ ```bash
67
+ # CPU-only
68
+ PYQCU_BUILD_BACKEND=kupl pip install pyqcu
69
+
70
+ # Require the KUPL build
71
+ PYQCU_BUILD_BACKEND=kupl PYQCU_REQUIRE_NATIVE=1 pip install pyqcu
72
+
73
+ # Build KUPL and CUDA on a machine with nvcc
74
+ PYQCU_BUILD_BACKEND=cuda pip install pyqcu
75
+ ```
76
+
77
+ Verify the installation:
78
+
79
+ ```bash
80
+ python -m pyqcu
81
+ python -m pyqcu --json
82
+ ```
83
+
84
+ ## Quick start
85
+
86
+ ```python
87
+ import torch
88
+ from pyqcu import lattice
89
+ from pyqcu.torch import dslash
90
+
91
+ shape = (8, 8, 8, 8)
92
+ U = torch.zeros((3, 3, 4, *shape), dtype=torch.complex64)
93
+ lattice.generate_gauge_field(U, seed=7, sigma=0.1)
94
+ assert lattice.check_su3(U, tol=1e-3)
95
+
96
+ src = torch.randn((4, 3, *shape), dtype=torch.complex64)
97
+ kappa = torch.tensor([0.125])
98
+ out = dslash.give_wilson(src=src, U=U, kappa=kappa)
99
+ assert out.shape == src.shape
100
+ assert torch.isfinite(out).all()
101
+ ```
102
+
103
+ The public layers are `pyqcu.api` (backend-neutral contracts), `pyqcu.lattice`
104
+ (gamma/SU(3) and gauge/source generation), `pyqcu.torch` (Torch operators and
105
+ solvers), `pyqcu.kupl` (CPU ctypes binding), `pyqcu.cuda` (CUDA/DCU Cython
106
+ bridge), `pyqcu.solver` (unified Krylov/Multigrid selectors), and `pyqcu.tools`
107
+ (MPI/layout, HDF5, environment, and plotting helpers).
108
+
109
+ ## Native backends
110
+
111
+ `python -m pyqcu` reports the package location and whether the KUPL and CUDA
112
+ libraries are available. The KUPL binding searches `PYQCU_KUPL_LIB`, then the
113
+ installed `pyqcu/kupl/libqcu.so`, then the source checkout. The CUDA bridge is
114
+ built only when `nvcc` and the CUDA library are available; the extension uses
115
+ an `$ORIGIN` rpath so it finds the library inside the installed package.
116
+
117
+ Typical release verification uses a `8x8x16x16` complex64 lattice with a
118
+ Gaussian SU(3) gauge field (`sigma=0.1`, `seed=42`), `mass=0.17`, `csw=1.0`,
119
+ and `atol=1e-6`. On the release machine (WSL2, Intel i7-13620H, RTX 4060
120
+ Laptop sm_89), both the installed KUPL and CUDA paths converged in 26
121
+ iterations with full-lattice true residuals below `3e-7`; the acceptance
122
+ threshold for complex64 is `max(atol, 2048*eps32) ≈ 2.4414e-4`.
123
+
124
+ ## Historical performance
125
+
126
+ The table records measurements on hardware that is not part of this checkout.
127
+ Absolute seconds are not comparable across machines, and CPU/GPU rows are
128
+ never combined into one speed-up. Raw JSON files for these runs are not
129
+ retained in the current tree; the linked report and git tag are the
130
+ provenance.
131
+
132
+ | Case | Platform | Lattice / precision | Result | Comparison | Reproducibility |
133
+ |---|---|---|---|---|---|
134
+ | CUDA BiCGStab vs QUDA | Tesla V100-SXM2-32GB, sm_70 | 24³×64, c64 | 0.147801 s / 18 iterations | QUDA 0.156680 s / 19 iterations → 1.060× | Historical; needs V100 and the `dev103`-era checkout |
135
+ | KUPL parity-Schur BiCGStab | Intel Xeon E5-2696 v3, 18 cores | 24³×64, c64 | 8 ranks×2 threads: 7.532 s / 19 iterations | 1 rank×4 threads 19.229 s → 2.553× | Historical; same CPU class required |
136
+ | CUDA Legacy-MG vs QUDA GCR-MG | A100-PCIE-40GB | 32³×64, c64 | 1/2/4 ranks: 0.2145 / 0.2195 / 0.2183 s | QUDA 0.4824 / 0.3144 / 0.2875 s → 2.2495× / 1.4323× / 1.3166× | Historical; needs A100, L32 LIME, E12 cache |
137
+ | CUDA native BiCGStab | A100-PCIE-40GB | 32³×64, c64 | 1 rank 0.1224 s; 2 ranks 0.1154 s | QUDA 0.1304 / 0.0961 s → 1.065× / **0.833×** | Historical; shows the native solver is not universally faster |
138
+ | CUDA Strict-MG vs QUDA aligned MG | Tesla V100-SXM2-32GB | 8×8×8×16, c64 | 0.021693 s / 10 iterations | QUDA 0.144755 s / 8 outer GCR → 6.673× | Time-point evidence; small-lattice fixed overhead dominates |
139
+ | CUDA(HIP) Legacy-MG | DCU Pre-Wukong D160A1, gfx906 | 24³×64, c64 | 1/2/4 ranks: 0.3017 / 0.4619 / 1.0247 s | QUDA blocked; no ratio | Historical; needs the same DCU and DTK |
140
+
141
+ The full table, including the historical tag-only rows and the local
142
+ `8x8x16x16` measurement, is in the performance documentation.
143
+
144
+ ## Documentation
145
+
146
+ * English: https://pyqcu.readthedocs.io/en/latest/
147
+ * 中文: https://pyqcu.readthedocs.io/zh-cn/latest/
148
+
149
+ The documentation sources live in `docs/en/` and `docs/zh/`. Both sites are
150
+ built with Sphinx and MyST; the release check builds them with `-W`.
151
+
152
+ ## From a source checkout
153
+
154
+ ```bash
155
+ git clone git@gitlab.itp.ac.cn:zhangxin8069/PyQCU.git
156
+ cd PyQCU
157
+ source ./env.sh
158
+
159
+ bash ./install.sh kupl # CPU KUPL backend
160
+ bash ./install.sh cuda # CUDA backend + Cython bridge
161
+ QCU_DCU_CUDA_COMPILER=/path/to/dtk/nvcc bash ./install.sh dcu
162
+ ```
163
+
164
+ Tests and benchmark drivers live under `pyqcu/testing/` and are intentionally
165
+ excluded from the PyPI package:
166
+
167
+ ```bash
168
+ cd pyqcu/testing
169
+ pytest .
170
+ ```
171
+
172
+ ## License
173
+
174
+ MIT. See `LICENSE`.
pyqcu-0.1.0/README.md ADDED
@@ -0,0 +1,137 @@
1
+ # PyQCU
2
+
3
+ PyQCU is a lattice-QCD operator and solver toolkit with three execution
4
+ paths:
5
+
6
+ * a Torch/CANN backend for CPU, CUDA, and Ascend NPU;
7
+ * an independent C++17 MPI+OpenMP CPU backend (KUPL);
8
+ * a CUDA/DCU C++ backend exposed through a Cython bridge.
9
+
10
+ It provides Wilson and Clover Dirac operators, stout and Wuppertal smearing,
11
+ BiCGStab/CG/FGMRES solvers, Legacy and Strict multigrid hierarchies, HDF5
12
+ helpers, and a four-dimensional MPI rank grid.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ pip install pyqcu
18
+ ```
19
+
20
+ Requirements: Python 3.10+, Linux, `numpy`, `torch`, `mpi4py`, and `h5py`
21
+ (installed automatically). A C++17 compiler, CMake, and MPI are needed to
22
+ build the KUPL CPU library; `nvcc` is needed for the optional CUDA library.
23
+
24
+ The package is distributed as a source archive. The first install builds KUPL
25
+ when the toolchain is available and tries CUDA/DCU opportunistically; a
26
+ missing toolchain leaves the pure-Torch paths usable and does not fail the
27
+ install.
28
+
29
+ ```bash
30
+ # CPU-only
31
+ PYQCU_BUILD_BACKEND=kupl pip install pyqcu
32
+
33
+ # Require the KUPL build
34
+ PYQCU_BUILD_BACKEND=kupl PYQCU_REQUIRE_NATIVE=1 pip install pyqcu
35
+
36
+ # Build KUPL and CUDA on a machine with nvcc
37
+ PYQCU_BUILD_BACKEND=cuda pip install pyqcu
38
+ ```
39
+
40
+ Verify the installation:
41
+
42
+ ```bash
43
+ python -m pyqcu
44
+ python -m pyqcu --json
45
+ ```
46
+
47
+ ## Quick start
48
+
49
+ ```python
50
+ import torch
51
+ from pyqcu import lattice
52
+ from pyqcu.torch import dslash
53
+
54
+ shape = (8, 8, 8, 8)
55
+ U = torch.zeros((3, 3, 4, *shape), dtype=torch.complex64)
56
+ lattice.generate_gauge_field(U, seed=7, sigma=0.1)
57
+ assert lattice.check_su3(U, tol=1e-3)
58
+
59
+ src = torch.randn((4, 3, *shape), dtype=torch.complex64)
60
+ kappa = torch.tensor([0.125])
61
+ out = dslash.give_wilson(src=src, U=U, kappa=kappa)
62
+ assert out.shape == src.shape
63
+ assert torch.isfinite(out).all()
64
+ ```
65
+
66
+ The public layers are `pyqcu.api` (backend-neutral contracts), `pyqcu.lattice`
67
+ (gamma/SU(3) and gauge/source generation), `pyqcu.torch` (Torch operators and
68
+ solvers), `pyqcu.kupl` (CPU ctypes binding), `pyqcu.cuda` (CUDA/DCU Cython
69
+ bridge), `pyqcu.solver` (unified Krylov/Multigrid selectors), and `pyqcu.tools`
70
+ (MPI/layout, HDF5, environment, and plotting helpers).
71
+
72
+ ## Native backends
73
+
74
+ `python -m pyqcu` reports the package location and whether the KUPL and CUDA
75
+ libraries are available. The KUPL binding searches `PYQCU_KUPL_LIB`, then the
76
+ installed `pyqcu/kupl/libqcu.so`, then the source checkout. The CUDA bridge is
77
+ built only when `nvcc` and the CUDA library are available; the extension uses
78
+ an `$ORIGIN` rpath so it finds the library inside the installed package.
79
+
80
+ Typical release verification uses a `8x8x16x16` complex64 lattice with a
81
+ Gaussian SU(3) gauge field (`sigma=0.1`, `seed=42`), `mass=0.17`, `csw=1.0`,
82
+ and `atol=1e-6`. On the release machine (WSL2, Intel i7-13620H, RTX 4060
83
+ Laptop sm_89), both the installed KUPL and CUDA paths converged in 26
84
+ iterations with full-lattice true residuals below `3e-7`; the acceptance
85
+ threshold for complex64 is `max(atol, 2048*eps32) ≈ 2.4414e-4`.
86
+
87
+ ## Historical performance
88
+
89
+ The table records measurements on hardware that is not part of this checkout.
90
+ Absolute seconds are not comparable across machines, and CPU/GPU rows are
91
+ never combined into one speed-up. Raw JSON files for these runs are not
92
+ retained in the current tree; the linked report and git tag are the
93
+ provenance.
94
+
95
+ | Case | Platform | Lattice / precision | Result | Comparison | Reproducibility |
96
+ |---|---|---|---|---|---|
97
+ | CUDA BiCGStab vs QUDA | Tesla V100-SXM2-32GB, sm_70 | 24³×64, c64 | 0.147801 s / 18 iterations | QUDA 0.156680 s / 19 iterations → 1.060× | Historical; needs V100 and the `dev103`-era checkout |
98
+ | KUPL parity-Schur BiCGStab | Intel Xeon E5-2696 v3, 18 cores | 24³×64, c64 | 8 ranks×2 threads: 7.532 s / 19 iterations | 1 rank×4 threads 19.229 s → 2.553× | Historical; same CPU class required |
99
+ | CUDA Legacy-MG vs QUDA GCR-MG | A100-PCIE-40GB | 32³×64, c64 | 1/2/4 ranks: 0.2145 / 0.2195 / 0.2183 s | QUDA 0.4824 / 0.3144 / 0.2875 s → 2.2495× / 1.4323× / 1.3166× | Historical; needs A100, L32 LIME, E12 cache |
100
+ | CUDA native BiCGStab | A100-PCIE-40GB | 32³×64, c64 | 1 rank 0.1224 s; 2 ranks 0.1154 s | QUDA 0.1304 / 0.0961 s → 1.065× / **0.833×** | Historical; shows the native solver is not universally faster |
101
+ | CUDA Strict-MG vs QUDA aligned MG | Tesla V100-SXM2-32GB | 8×8×8×16, c64 | 0.021693 s / 10 iterations | QUDA 0.144755 s / 8 outer GCR → 6.673× | Time-point evidence; small-lattice fixed overhead dominates |
102
+ | CUDA(HIP) Legacy-MG | DCU Pre-Wukong D160A1, gfx906 | 24³×64, c64 | 1/2/4 ranks: 0.3017 / 0.4619 / 1.0247 s | QUDA blocked; no ratio | Historical; needs the same DCU and DTK |
103
+
104
+ The full table, including the historical tag-only rows and the local
105
+ `8x8x16x16` measurement, is in the performance documentation.
106
+
107
+ ## Documentation
108
+
109
+ * English: https://pyqcu.readthedocs.io/en/latest/
110
+ * 中文: https://pyqcu.readthedocs.io/zh-cn/latest/
111
+
112
+ The documentation sources live in `docs/en/` and `docs/zh/`. Both sites are
113
+ built with Sphinx and MyST; the release check builds them with `-W`.
114
+
115
+ ## From a source checkout
116
+
117
+ ```bash
118
+ git clone git@gitlab.itp.ac.cn:zhangxin8069/PyQCU.git
119
+ cd PyQCU
120
+ source ./env.sh
121
+
122
+ bash ./install.sh kupl # CPU KUPL backend
123
+ bash ./install.sh cuda # CUDA backend + Cython bridge
124
+ QCU_DCU_CUDA_COMPILER=/path/to/dtk/nvcc bash ./install.sh dcu
125
+ ```
126
+
127
+ Tests and benchmark drivers live under `pyqcu/testing/` and are intentionally
128
+ excluded from the PyPI package:
129
+
130
+ ```bash
131
+ cd pyqcu/testing
132
+ pytest .
133
+ ```
134
+
135
+ ## License
136
+
137
+ MIT. See `LICENSE`.
@@ -0,0 +1,8 @@
1
+ # BUGFIX 2026-07-28 R3: add set -e so build failures stop the pipeline.
2
+ set -e
3
+ echo "=== PyQCU build.sh ==="
4
+ source ./env.sh
5
+ pushd ./cpp/cuda/qcu
6
+ bash ./make-dcu.sh
7
+ popd
8
+ echo "=== PyQCU build.sh: SUCCESS ==="
@@ -0,0 +1,8 @@
1
+ # BUGFIX 2026-07-28 R3: add set -e so build failures stop the pipeline.
2
+ set -e
3
+ echo "=== PyQCU build.sh ==="
4
+ source ./env.sh
5
+ pushd ./cpp/cuda/qcu
6
+ bash ./make-nv.sh
7
+ popd
8
+ echo "=== PyQCU build.sh: SUCCESS ==="
@@ -0,0 +1,24 @@
1
+ cmake_minimum_required(VERSION 3.8)
2
+ if(POLICY CMP0104)
3
+ # DTK's nvcc-compatible wrapper owns target selection; an empty CMake CUDA
4
+ # architecture list is valid for this compatibility build.
5
+ cmake_policy(SET CMP0104 OLD)
6
+ endif()
7
+ project(qcu LANGUAGES C CXX CUDA)
8
+ # DTK 23.10's nvcc-compatible wrapper rejects CMake's --options-file syntax.
9
+ set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_INCLUDES 0)
10
+ set(CMAKE_CXX_STANDARD 11)
11
+ set(CMAKE_CUDA_STANDARD 11)
12
+ message(STATUS "PATH is: $ENV{PATH}")
13
+ message(STATUS "LD_LIBRARY_PATH is: $ENV{LD_LIBRARY_PATH}")
14
+ find_package(MPI REQUIRED COMPONENTS C CXX)
15
+ include(GNUInstallDirs)
16
+ include_directories(./include)
17
+ aux_source_directory(./src SOURCE_FILE)
18
+ add_library(qcu SHARED ${SOURCE_FILE})
19
+ find_package(CUDA REQUIRED)
20
+ target_include_directories(qcu PRIVATE ${MPI_C_INCLUDE_DIRS})
21
+ target_link_libraries(qcu ${MPI_C_LIBRARIES})
22
+ target_link_libraries(qcu ${CUDA_LIBRARIES})
23
+ target_link_libraries(qcu curand)
24
+ target_link_libraries(qcu cublas)
@@ -0,0 +1,104 @@
1
+ cmake_minimum_required(VERSION 3.8)
2
+ project(qcu LANGUAGES C CXX CUDA)
3
+ set(CMAKE_CXX_STANDARD 11)
4
+ option(QCU_ENABLE_NVSHMEM "Enable the optional NVSHMEM coarse-grid transport" OFF)
5
+ message(STATUS "PATH is: $ENV{PATH}")
6
+ message(STATUS "LD_LIBRARY_PATH is: $ENV{LD_LIBRARY_PATH}")
7
+ # Architecture precedence: explicit CMake/environment override, env.sh's
8
+ # detected sm_arch, then the compute capability of the active GPU. Auto
9
+ # detected values are emitted as cubin + PTX so they remain portable across a
10
+ # minor driver/toolkit mismatch; an explicit override is passed through
11
+ # unchanged.
12
+ set(_QCU_AUTO_CUDA_ARCHITECTURES "")
13
+ if(DEFINED QCU_CUDA_ARCHITECTURES AND NOT "${QCU_CUDA_ARCHITECTURES}" STREQUAL "")
14
+ set(_QCU_CUDA_ARCHITECTURES "${QCU_CUDA_ARCHITECTURES}")
15
+ elseif(DEFINED CMAKE_CUDA_ARCHITECTURES AND NOT "${CMAKE_CUDA_ARCHITECTURES}" STREQUAL "")
16
+ set(_QCU_CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}")
17
+ elseif(DEFINED ENV{QCU_CUDA_ARCHITECTURES} AND NOT "$ENV{QCU_CUDA_ARCHITECTURES}" STREQUAL "")
18
+ set(_QCU_CUDA_ARCHITECTURES "$ENV{QCU_CUDA_ARCHITECTURES}")
19
+ elseif(DEFINED ENV{sm_arch} AND NOT "$ENV{sm_arch}" STREQUAL "")
20
+ set(_QCU_AUTO_CUDA_ARCHITECTURES "$ENV{sm_arch}")
21
+ message(STATUS "QCU CUDA architecture auto-detected from env.sh: sm_${_QCU_AUTO_CUDA_ARCHITECTURES}")
22
+ else()
23
+ find_program(_QCU_NVIDIA_SMI NAMES nvidia-smi)
24
+ if(_QCU_NVIDIA_SMI)
25
+ execute_process(
26
+ COMMAND "${_QCU_NVIDIA_SMI}" --query-gpu=compute_cap --format=csv,noheader
27
+ RESULT_VARIABLE _QCU_NVIDIA_SMI_RESULT
28
+ OUTPUT_VARIABLE _QCU_NVIDIA_SMI_OUTPUT
29
+ ERROR_QUIET
30
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
31
+ if(_QCU_NVIDIA_SMI_RESULT EQUAL 0 AND NOT "${_QCU_NVIDIA_SMI_OUTPUT}" STREQUAL "")
32
+ string(REPLACE "\n" ";" _QCU_GPU_CAPS "${_QCU_NVIDIA_SMI_OUTPUT}")
33
+ list(GET _QCU_GPU_CAPS 0 _QCU_GPU_CAP)
34
+ string(STRIP "${_QCU_GPU_CAP}" _QCU_GPU_CAP)
35
+ string(REGEX MATCH "^([0-9]+)\\.([0-9]+)$" _QCU_GPU_CAP_MATCH "${_QCU_GPU_CAP}")
36
+ if(_QCU_GPU_CAP_MATCH)
37
+ set(_QCU_AUTO_CUDA_ARCHITECTURES "${CMAKE_MATCH_1}${CMAKE_MATCH_2}")
38
+ message(STATUS "QCU CUDA architecture auto-detected from nvidia-smi: sm_${_QCU_AUTO_CUDA_ARCHITECTURES}")
39
+ endif()
40
+ endif()
41
+ endif()
42
+ endif()
43
+
44
+ if(_QCU_AUTO_CUDA_ARCHITECTURES)
45
+ set(_QCU_CUDA_ARCHITECTURES
46
+ "${_QCU_AUTO_CUDA_ARCHITECTURES}-real;${_QCU_AUTO_CUDA_ARCHITECTURES}-virtual")
47
+ endif()
48
+
49
+ if(NOT DEFINED _QCU_CUDA_ARCHITECTURES OR "${_QCU_CUDA_ARCHITECTURES}" STREQUAL "")
50
+ message(FATAL_ERROR
51
+ "Unable to determine CUDA architecture. Set QCU_CUDA_ARCHITECTURES "
52
+ "(for example 70-real;70-virtual), pass -DCMAKE_CUDA_ARCHITECTURES, "
53
+ "or source env.sh on a machine with nvidia-smi.")
54
+ endif()
55
+
56
+ set(QCU_CUDA_ARCHITECTURES "${_QCU_CUDA_ARCHITECTURES}")
57
+ set(CMAKE_CUDA_ARCHITECTURES "${_QCU_CUDA_ARCHITECTURES}")
58
+ set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -O3 --expt-relaxed-constexpr")
59
+ message(STATUS "QCU CUDA architectures: ${QCU_CUDA_ARCHITECTURES}")
60
+ set(MPI_INCLUDE_PATH $ENV{mpi_home}/include)
61
+ set(MPI_CXX_LIBRARIES $ENV{mpi_home}/lib/libmpi.so)
62
+ include(GNUInstallDirs)
63
+ include_directories(${LD_LIBRARY_PATH})
64
+ include_directories(${MPI_INCLUDE_PATH})
65
+ include_directories(./include)
66
+ aux_source_directory(./src SOURCE_FILE)
67
+ add_library(qcu SHARED ${SOURCE_FILE})
68
+ find_package(MPI REQUIRED)
69
+ find_package(CUDA REQUIRED)
70
+ target_link_libraries(qcu ${MPI_C_LIBRARIES})
71
+ target_link_libraries(qcu ${CUDA_LIBRARIES})
72
+ target_link_libraries(qcu curand)
73
+ target_link_libraries(qcu cublas)
74
+
75
+ # NVSHMEM is deliberately opt-in. A normal CUDA/MPI build must not need the
76
+ # headers or library, while an explicit request must fail during configure
77
+ # instead of producing a binary whose optional transport silently disappears.
78
+ if(QCU_ENABLE_NVSHMEM)
79
+ find_path(QCU_NVSHMEM_INCLUDE_DIR
80
+ NAMES nvshmem.h
81
+ HINTS $ENV{NVSHMEM_HOME} $ENV{NVSHMEM_ROOT}
82
+ PATH_SUFFIXES include)
83
+ find_path(QCU_NVSHMEMX_INCLUDE_DIR
84
+ NAMES nvshmemx.h
85
+ HINTS $ENV{NVSHMEM_HOME} $ENV{NVSHMEM_ROOT}
86
+ PATH_SUFFIXES include)
87
+ find_library(QCU_NVSHMEM_LIBRARY
88
+ NAMES nvshmem
89
+ HINTS $ENV{NVSHMEM_HOME} $ENV{NVSHMEM_ROOT}
90
+ PATH_SUFFIXES lib lib64)
91
+ if(NOT QCU_NVSHMEM_INCLUDE_DIR OR
92
+ NOT QCU_NVSHMEMX_INCLUDE_DIR OR
93
+ NOT QCU_NVSHMEM_LIBRARY)
94
+ message(FATAL_ERROR
95
+ "QCU_ENABLE_NVSHMEM=ON requires nvshmem.h, nvshmemx.h and libnvshmem")
96
+ endif()
97
+ target_include_directories(qcu PRIVATE
98
+ ${QCU_NVSHMEM_INCLUDE_DIR} ${QCU_NVSHMEMX_INCLUDE_DIR})
99
+ target_compile_definitions(qcu PRIVATE QCU_HAVE_NVSHMEM=1)
100
+ target_link_libraries(qcu ${QCU_NVSHMEM_LIBRARY})
101
+ message(STATUS "NVSHMEM enabled: ${QCU_NVSHMEM_LIBRARY}")
102
+ else()
103
+ message(STATUS "NVSHMEM disabled (set -DQCU_ENABLE_NVSHMEM=ON to enable)")
104
+ endif()