raptor-eagle 0.4.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 (159) hide show
  1. raptor_eagle-0.4.0/CMakeLists.txt +344 -0
  2. raptor_eagle-0.4.0/LICENSE +202 -0
  3. raptor_eagle-0.4.0/NOTICE +2 -0
  4. raptor_eagle-0.4.0/PKG-INFO +343 -0
  5. raptor_eagle-0.4.0/conftest.py +114 -0
  6. raptor_eagle-0.4.0/eagle/__init__.py +120 -0
  7. raptor_eagle-0.4.0/eagle/_active_set.py +676 -0
  8. raptor_eagle-0.4.0/eagle/_backend.py +27 -0
  9. raptor_eagle-0.4.0/eagle/_conditional.py +245 -0
  10. raptor_eagle-0.4.0/eagle/_counters.py +69 -0
  11. raptor_eagle-0.4.0/eagle/_device_props.py +79 -0
  12. raptor_eagle-0.4.0/eagle/_host_loop.py +582 -0
  13. raptor_eagle-0.4.0/eagle/_launch_policy.py +399 -0
  14. raptor_eagle-0.4.0/eagle/_layout.py +314 -0
  15. raptor_eagle-0.4.0/eagle/_member_enable.py +210 -0
  16. raptor_eagle-0.4.0/eagle/_plan_binding.py +620 -0
  17. raptor_eagle-0.4.0/eagle/_plan_deploy.py +403 -0
  18. raptor_eagle-0.4.0/eagle/_plan_pack.py +190 -0
  19. raptor_eagle-0.4.0/eagle/_plan_planes.py +529 -0
  20. raptor_eagle-0.4.0/eagle/_simulate.py +627 -0
  21. raptor_eagle-0.4.0/eagle/_until_done.py +1287 -0
  22. raptor_eagle-0.4.0/eagle/abi.py +107 -0
  23. raptor_eagle-0.4.0/eagle/compose.py +636 -0
  24. raptor_eagle-0.4.0/eagle/cuda.py +38 -0
  25. raptor_eagle-0.4.0/eagle/dtypes.py +16 -0
  26. raptor_eagle-0.4.0/eagle/exec.py +345 -0
  27. raptor_eagle-0.4.0/eagle/frameworks/__init__.py +10 -0
  28. raptor_eagle-0.4.0/eagle/frameworks/torch.py +489 -0
  29. raptor_eagle-0.4.0/eagle/gemm/__init__.py +121 -0
  30. raptor_eagle-0.4.0/eagle/gemm/capture.py +488 -0
  31. raptor_eagle-0.4.0/eagle/gemm/contraction.py +100 -0
  32. raptor_eagle-0.4.0/eagle/gemm/plan.py +773 -0
  33. raptor_eagle-0.4.0/eagle/host_launch.py +389 -0
  34. raptor_eagle-0.4.0/eagle/interop.py +671 -0
  35. raptor_eagle-0.4.0/eagle/launch.py +739 -0
  36. raptor_eagle-0.4.0/eagle/loaded.py +344 -0
  37. raptor_eagle-0.4.0/eagle/marshal.py +459 -0
  38. raptor_eagle-0.4.0/eagle/pipeline.py +719 -0
  39. raptor_eagle-0.4.0/eagle/plan.py +540 -0
  40. raptor_eagle-0.4.0/eagle/py.typed +0 -0
  41. raptor_eagle-0.4.0/eagle/registry.py +316 -0
  42. raptor_eagle-0.4.0/eagle/roles.py +391 -0
  43. raptor_eagle-0.4.0/eagle/sidecar.py +292 -0
  44. raptor_eagle-0.4.0/pyproject.toml +152 -0
  45. raptor_eagle-0.4.0/src/eagle_core.cpp +1242 -0
  46. raptor_eagle-0.4.0/src/eagle_mpi.cpp +299 -0
  47. raptor_eagle-0.4.0/src/interop_binding.h +246 -0
  48. raptor_eagle-0.4.0/src/plugin/cuda_driver.cpp +1294 -0
  49. raptor_eagle-0.4.0/src/plugin/cuda_driver.h +27 -0
  50. raptor_eagle-0.4.0/src/plugin/eagle_cuda.cu +1205 -0
  51. raptor_eagle-0.4.0/src/plugin/eagle_cuda.map +11 -0
  52. raptor_eagle-0.4.0/src/seam/DeviceKernel.h +50 -0
  53. raptor_eagle-0.4.0/src/seam/Groups.h +118 -0
  54. raptor_eagle-0.4.0/src/seam/Loader.h +445 -0
  55. raptor_eagle-0.4.0/src/seam/Status.h +116 -0
  56. raptor_eagle-0.4.0/src/seam/eagle_backend.h +457 -0
  57. raptor_eagle-0.4.0/tests/_device_file.py +100 -0
  58. raptor_eagle-0.4.0/tests/_graph_dot.py +26 -0
  59. raptor_eagle-0.4.0/tests/backend_wall.py +240 -0
  60. raptor_eagle-0.4.0/tests/cpp_demo.py +158 -0
  61. raptor_eagle-0.4.0/tests/expected_backend_symbols.txt +53 -0
  62. raptor_eagle-0.4.0/tests/expected_backend_x_symbols.txt +18 -0
  63. raptor_eagle-0.4.0/tests/fixtures/bump.cu +31 -0
  64. raptor_eagle-0.4.0/tests/fixtures/bump.json +41 -0
  65. raptor_eagle-0.4.0/tests/fixtures/bump.ptx +63 -0
  66. raptor_eagle-0.4.0/tests/fixtures/drag_ps.cu +45 -0
  67. raptor_eagle-0.4.0/tests/fixtures/drag_ps.json +50 -0
  68. raptor_eagle-0.4.0/tests/fixtures/drag_ps.ptx +103 -0
  69. raptor_eagle-0.4.0/tests/fixtures/gravity.cu +41 -0
  70. raptor_eagle-0.4.0/tests/fixtures/gravity.json +40 -0
  71. raptor_eagle-0.4.0/tests/fixtures/gravity.ptx +93 -0
  72. raptor_eagle-0.4.0/tests/fixtures/manifest.json +31 -0
  73. raptor_eagle-0.4.0/tests/mpi/check_rank_bed.sh +397 -0
  74. raptor_eagle-0.4.0/tests/mpi/expected_tests_rank_bed.txt +9 -0
  75. raptor_eagle-0.4.0/tests/mpi/test_rank_bed.py +469 -0
  76. raptor_eagle-0.4.0/tests/rank_singleton_cases.py +176 -0
  77. raptor_eagle-0.4.0/tests/test_abi_version.py +122 -0
  78. raptor_eagle-0.4.0/tests/test_active_set.py +653 -0
  79. raptor_eagle-0.4.0/tests/test_arg_classify.py +291 -0
  80. raptor_eagle-0.4.0/tests/test_auto_kernels.py +425 -0
  81. raptor_eagle-0.4.0/tests/test_backend_driver_only.py +205 -0
  82. raptor_eagle-0.4.0/tests/test_backend_seam_rows.py +97 -0
  83. raptor_eagle-0.4.0/tests/test_backend_unavailable.py +270 -0
  84. raptor_eagle-0.4.0/tests/test_backend_wall.py +93 -0
  85. raptor_eagle-0.4.0/tests/test_card_no_absolute_paths.py +92 -0
  86. raptor_eagle-0.4.0/tests/test_conditional.py +281 -0
  87. raptor_eagle-0.4.0/tests/test_conformance_corpus.py +265 -0
  88. raptor_eagle-0.4.0/tests/test_core_needs_no_driver.py +45 -0
  89. raptor_eagle-0.4.0/tests/test_cpp_host.py +170 -0
  90. raptor_eagle-0.4.0/tests/test_derivative_sidecar.py +98 -0
  91. raptor_eagle-0.4.0/tests/test_doc_includes.py +70 -0
  92. raptor_eagle-0.4.0/tests/test_engine_hardening_launch.py +680 -0
  93. raptor_eagle-0.4.0/tests/test_engine_hardening_pipeline.py +627 -0
  94. raptor_eagle-0.4.0/tests/test_engine_hardening_small_caches.py +323 -0
  95. raptor_eagle-0.4.0/tests/test_exec_contract_rows.py +280 -0
  96. raptor_eagle-0.4.0/tests/test_frameworks_torch.py +394 -0
  97. raptor_eagle-0.4.0/tests/test_gc_capture_invalidation_guard.py +226 -0
  98. raptor_eagle-0.4.0/tests/test_gemm_capture.py +831 -0
  99. raptor_eagle-0.4.0/tests/test_graph_plugin.py +107 -0
  100. raptor_eagle-0.4.0/tests/test_gref_layout.py +99 -0
  101. raptor_eagle-0.4.0/tests/test_handle_layout.py +109 -0
  102. raptor_eagle-0.4.0/tests/test_host_launch_torch.py +153 -0
  103. raptor_eagle-0.4.0/tests/test_installed_header_layout.py +74 -0
  104. raptor_eagle-0.4.0/tests/test_int_uniform.py +520 -0
  105. raptor_eagle-0.4.0/tests/test_interop.py +52 -0
  106. raptor_eagle-0.4.0/tests/test_interop_buffer.py +401 -0
  107. raptor_eagle-0.4.0/tests/test_interop_matrix.py +369 -0
  108. raptor_eagle-0.4.0/tests/test_interop_matrix_conformance.py +91 -0
  109. raptor_eagle-0.4.0/tests/test_interop_warp.py +292 -0
  110. raptor_eagle-0.4.0/tests/test_launch_parity_corpus.py +318 -0
  111. raptor_eagle-0.4.0/tests/test_launch_policy.py +484 -0
  112. raptor_eagle-0.4.0/tests/test_launch_policy_gate_b.py +308 -0
  113. raptor_eagle-0.4.0/tests/test_launch_policy_gate_c.py +312 -0
  114. raptor_eagle-0.4.0/tests/test_layout.py +381 -0
  115. raptor_eagle-0.4.0/tests/test_netsparse_compose.py +455 -0
  116. raptor_eagle-0.4.0/tests/test_netsparse_compose_parity.py +325 -0
  117. raptor_eagle-0.4.0/tests/test_netsparse_device_props.py +99 -0
  118. raptor_eagle-0.4.0/tests/test_netsparse_intent_guard.py +333 -0
  119. raptor_eagle-0.4.0/tests/test_netsparse_member_enable.py +538 -0
  120. raptor_eagle-0.4.0/tests/test_neural_block_one_implementation.py +79 -0
  121. raptor_eagle-0.4.0/tests/test_neural_block_road_equality.py +109 -0
  122. raptor_eagle-0.4.0/tests/test_perf_card_table.py +806 -0
  123. raptor_eagle-0.4.0/tests/test_pipeline_concurrent.py +225 -0
  124. raptor_eagle-0.4.0/tests/test_pipeline_parity.py +169 -0
  125. raptor_eagle-0.4.0/tests/test_pipeline_stream_ptr.py +36 -0
  126. raptor_eagle-0.4.0/tests/test_plan_bind_launch.py +1217 -0
  127. raptor_eagle-0.4.0/tests/test_plan_kwarg_shadow.py +225 -0
  128. raptor_eagle-0.4.0/tests/test_plan_packer_e2.py +625 -0
  129. raptor_eagle-0.4.0/tests/test_plan_run_device_inputs.py +146 -0
  130. raptor_eagle-0.4.0/tests/test_plan_run_out.py +321 -0
  131. raptor_eagle-0.4.0/tests/test_plan_run_outputs.py +86 -0
  132. raptor_eagle-0.4.0/tests/test_plugin_registry.py +190 -0
  133. raptor_eagle-0.4.0/tests/test_rank_partition.py +224 -0
  134. raptor_eagle-0.4.0/tests/test_raptor_golden_conformance.py +89 -0
  135. raptor_eagle-0.4.0/tests/test_readme_cards.py +100 -0
  136. raptor_eagle-0.4.0/tests/test_registry_load_memo.py +216 -0
  137. raptor_eagle-0.4.0/tests/test_registry_pattern_loader.py +149 -0
  138. raptor_eagle-0.4.0/tests/test_reorder.py +354 -0
  139. raptor_eagle-0.4.0/tests/test_repeat_while.py +464 -0
  140. raptor_eagle-0.4.0/tests/test_reserved_words.py +328 -0
  141. raptor_eagle-0.4.0/tests/test_rk78_card.py +142 -0
  142. raptor_eagle-0.4.0/tests/test_roles_raptor_repoint.py +169 -0
  143. raptor_eagle-0.4.0/tests/test_roles_vocab.py +348 -0
  144. raptor_eagle-0.4.0/tests/test_schema_hardening.py +467 -0
  145. raptor_eagle-0.4.0/tests/test_schema_v2_load_path.py +143 -0
  146. raptor_eagle-0.4.0/tests/test_simulate.py +709 -0
  147. raptor_eagle-0.4.0/tests/test_simulate_api_freeze.py +120 -0
  148. raptor_eagle-0.4.0/tests/test_single_sample.py +398 -0
  149. raptor_eagle-0.4.0/tests/test_static_graph_counters.py +279 -0
  150. raptor_eagle-0.4.0/tests/test_u2_interim_error_check.py +119 -0
  151. raptor_eagle-0.4.0/tests/test_until_done.py +571 -0
  152. raptor_eagle-0.4.0/tests/test_until_done_auto.py +1875 -0
  153. raptor_eagle-0.4.0/tests/test_until_done_host.py +533 -0
  154. raptor_eagle-0.4.0/tests/test_until_done_host_whole.py +263 -0
  155. raptor_eagle-0.4.0/tests/test_until_done_steps.py +215 -0
  156. raptor_eagle-0.4.0/tests/test_wide_arg_classification.py +162 -0
  157. raptor_eagle-0.4.0/tests/test_wide_capturable_launch.py +486 -0
  158. raptor_eagle-0.4.0/tests/test_wide_device_coercions.py +303 -0
  159. raptor_eagle-0.4.0/tests/v2_artifact.py +391 -0
@@ -0,0 +1,344 @@
1
+ # Copyright 2026 Alessandro Masat
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ # Builds the eagle Python package's compiled artifacts (scikit-build-core):
5
+ #
6
+ # eagle/_core.*.so the nanobind module, one per Python version
7
+ # eagle/libeagle_cuda.so the CUDA backend plugin (eagle-backend/1 C seam),
8
+ # no Python dependency: built ONCE and copied into every
9
+ # per-Python wheel
10
+ #
11
+ # EAGLE_PYTHON_CUDA_PLUGIN selects where the plugin comes from:
12
+ # BUILD (default) build it here with nvcc
13
+ # OFF no plugin (the GPU-less leg); every CUDA entry point raises
14
+ # eagle.BackendUnavailable
15
+ # <path> install that prebuilt libeagle_cuda.so (the per-Python phase)
16
+ # EAGLE_PYTHON_SKIP_CORE=ON builds the plugin alone (phase 1, no Python needed).
17
+ cmake_minimum_required(VERSION 3.20)
18
+ project(eagle_python LANGUAGES CXX)
19
+
20
+ set(EAGLE_PYTHON_CUDA_PLUGIN "BUILD" CACHE STRING
21
+ "Where libeagle_cuda.so comes from: BUILD | OFF | <path to a prebuilt plugin>")
22
+ option(EAGLE_PYTHON_SKIP_CORE "Build only the CUDA plugin, not eagle._core" OFF)
23
+ option(EAGLE_BACKEND_INJECT_MISSING
24
+ "Export one seam symbol under a wrong name (symbol-gate injection build only)" OFF)
25
+
26
+ string(TOUPPER "${EAGLE_PYTHON_CUDA_PLUGIN}" _eagle_plugin_mode)
27
+ if(NOT _eagle_plugin_mode STREQUAL "BUILD" AND NOT _eagle_plugin_mode STREQUAL "OFF")
28
+ set(_eagle_plugin_mode "PATH")
29
+ if(NOT EXISTS "${EAGLE_PYTHON_CUDA_PLUGIN}")
30
+ message(FATAL_ERROR
31
+ "EAGLE_PYTHON_CUDA_PLUGIN must be BUILD, OFF or the path of a prebuilt "
32
+ "libeagle_cuda.so; '${EAGLE_PYTHON_CUDA_PLUGIN}' does not exist")
33
+ endif()
34
+ endif()
35
+ if(EAGLE_PYTHON_SKIP_CORE AND NOT _eagle_plugin_mode STREQUAL "BUILD")
36
+ message(FATAL_ERROR "EAGLE_PYTHON_SKIP_CORE=ON builds nothing unless EAGLE_PYTHON_CUDA_PLUGIN=BUILD")
37
+ endif()
38
+
39
+ # Bundle libstdc++/libgcc when the toolchain has their static archives (the
40
+ # wheel then loads in envs whose system libstdc++ predates the build
41
+ # toolchain's GLIBCXX); a toolchain without them (a distribution gcc without
42
+ # its libstdc++-static package) links them dynamically instead.
43
+ include(CheckLinkerFlag)
44
+ check_linker_flag(CXX "-static-libstdc++" EAGLE_STATIC_LIBSTDCXX)
45
+ if(EAGLE_STATIC_LIBSTDCXX)
46
+ set(_eagle_static_runtime -static-libstdc++ -static-libgcc)
47
+ else()
48
+ set(_eagle_static_runtime "")
49
+ message(WARNING "eagle: no static libstdc++ in this toolchain; linking it dynamically")
50
+ endif()
51
+
52
+ # Only the plugin needs the CUDA toolkit; the core is plain C++.
53
+ if(_eagle_plugin_mode STREQUAL "BUILD")
54
+ # Pascal..Hopper SASS plus PTX at the OLDEST architecture, which every newer
55
+ # device can JIT -- of the architectures this nvcc still compiles (a newer
56
+ # toolkit drops the oldest: each is asked with a one-line compile). Override
57
+ # for a faster local build with a QUOTED list, e.g. -DCMAKE_CUDA_ARCHITECTURES=61.
58
+ if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
59
+ set(_eagle_nvcc "${CMAKE_CUDA_COMPILER}")
60
+ if(NOT _eagle_nvcc)
61
+ find_program(_eagle_nvcc nvcc)
62
+ endif()
63
+ set(_eagle_archs "")
64
+ if(_eagle_nvcc)
65
+ set(_eagle_probe "${CMAKE_CURRENT_BINARY_DIR}/eagle_arch_probe.cu")
66
+ file(WRITE "${_eagle_probe}" "__global__ void k(float* x) { x[0] = 1.f; }\n")
67
+ foreach(_a 61 70 75 80 90 100)
68
+ execute_process(COMMAND "${_eagle_nvcc}" -c -arch=sm_${_a} "${_eagle_probe}"
69
+ -o "${_eagle_probe}.${_a}.o"
70
+ RESULT_VARIABLE _rc OUTPUT_QUIET ERROR_QUIET)
71
+ if(_rc EQUAL 0)
72
+ list(APPEND _eagle_archs ${_a})
73
+ endif()
74
+ endforeach()
75
+ endif()
76
+ if(NOT _eagle_archs) # no nvcc to ask here: CMake finds the compiler later
77
+ set(_eagle_archs 61 70 80 90)
78
+ endif()
79
+ # the default set: Pascal, Volta, Ampere, Hopper (and the oldest a newer
80
+ # toolkit keeps, when it no longer compiles Pascal or Volta)
81
+ set(_eagle_wanted 61 70 80 90)
82
+ list(GET _eagle_archs 0 _eagle_oldest)
83
+ if(NOT _eagle_oldest IN_LIST _eagle_wanted)
84
+ list(INSERT _eagle_wanted 0 ${_eagle_oldest})
85
+ endif()
86
+ set(CMAKE_CUDA_ARCHITECTURES "")
87
+ foreach(_a IN LISTS _eagle_wanted)
88
+ if(_a IN_LIST _eagle_archs)
89
+ list(APPEND CMAKE_CUDA_ARCHITECTURES "${_a}-real")
90
+ endif()
91
+ endforeach()
92
+ if(NOT CMAKE_CUDA_ARCHITECTURES)
93
+ message(FATAL_ERROR "eagle: this nvcc (${_eagle_nvcc}) compiles none of sm_61..sm_100")
94
+ endif()
95
+ list(APPEND CMAKE_CUDA_ARCHITECTURES "${_eagle_oldest}-virtual")
96
+ endif()
97
+ enable_language(CUDA)
98
+ find_package(CUDAToolkit REQUIRED)
99
+ endif()
100
+
101
+ # eagle C++ headers (INTERFACE) + its aether/OpenMP deps.
102
+ #
103
+ # This binding lives INSIDE the eagle repo, so it must compile the eagle headers
104
+ # that sit next to it. A bare find_package would resolve against whatever eagle
105
+ # is installed in the ambient environment prefix, which on a dev box is easily a
106
+ # a different (older) build — and the failure is SILENT: the wrong headers
107
+ # compile perfectly and produce a binding missing the very feature being added.
108
+ # Prefer a repo-local install of the tracked tree; the caller can still override
109
+ # by passing -Deagle_DIR explicitly.
110
+ if(NOT DEFINED eagle_DIR)
111
+ set(_eagle_tracked "${CMAKE_CURRENT_SOURCE_DIR}/../__install_p1/share/eagle/cmake")
112
+ if(EXISTS "${_eagle_tracked}/eagleConfig.cmake")
113
+ set(eagle_DIR "${_eagle_tracked}")
114
+ endif()
115
+ endif()
116
+ find_package(eagle CONFIG REQUIRED)
117
+
118
+ # Prove the resolved eagle is recent enough to contain what this TU binds,
119
+ # rather than discovering it at import time as a missing attribute. Keyed on the
120
+ # header the binding actually needs; a stale install fails the configure loudly.
121
+ get_target_property(_eagle_incs eagle::eagle INTERFACE_INCLUDE_DIRECTORIES)
122
+ set(_eagle_root "")
123
+ foreach(_dir IN LISTS _eagle_incs)
124
+ if(EXISTS "${_dir}/eagle/cuda/CaptureFork.h")
125
+ set(_eagle_root "${_dir}")
126
+ break()
127
+ endif()
128
+ endforeach()
129
+ if(NOT _eagle_root)
130
+ message(FATAL_ERROR
131
+ "The resolved eagle package does not provide eagle/cuda/CaptureFork.h.\n"
132
+ " eagle_DIR = ${eagle_DIR}\n"
133
+ " INTERFACE_INCLUDE_DIRECTORIES = ${_eagle_incs}\n"
134
+ "This binding must compile the TRACKED eagle headers. Install the tracked "
135
+ "tree to a prefix you own and pass -Deagle_DIR=<prefix>/share/eagle/cmake. "
136
+ "Never install into another environment's prefix.")
137
+ endif()
138
+
139
+ # Compile the LIVE tracked headers, not the installed copy. The install supplies
140
+ # the package interface (compile definitions, flags, aether, and the eagle/plugin/
141
+ # prefix that only exists post-install), but its headers are a SNAPSHOT: they go
142
+ # stale the moment someone edits the tree, and the build then silently compiles
143
+ # yesterday's sources — the same silent-staleness failure this whole block
144
+ # exists to prevent, just relocated. Prepending the repo root makes
145
+ # eagle/{cuda,util,cpu,...} resolve live; eagle/plugin/ has no in-tree
146
+ # counterpart under that prefix, so it still falls through to the install.
147
+ get_filename_component(_eagle_src "${CMAKE_CURRENT_SOURCE_DIR}/.." ABSOLUTE)
148
+ if(EXISTS "${_eagle_src}/eagle/cuda/CaptureFork.h")
149
+ set_property(TARGET eagle::eagle PROPERTY
150
+ INTERFACE_INCLUDE_DIRECTORIES "${_eagle_src}" ${_eagle_incs})
151
+ set(_eagle_root "${_eagle_src} (live tree, ahead of ${_eagle_root})")
152
+ endif()
153
+ message(STATUS "> eagle headers (verified to contain CaptureFork.h): ${_eagle_root}")
154
+
155
+ # Both artifacts carry eagle/aether inline and template instantiations; a
156
+ # STB_GNU_UNIQUE copy of one would bind across the two images at load time.
157
+ set(_eagle_no_gnu_unique
158
+ $<$<COMPILE_LANGUAGE:CXX>:-fno-gnu-unique>
159
+ $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-fno-gnu-unique>)
160
+
161
+ # ---------------------------------------------------------------------------
162
+ # libeagle_cuda.so — the CUDA backend plugin.
163
+ #
164
+ # Driver API only: no CUDA runtime is linked (CUDA_RUNTIME_LIBRARY None). The
165
+ # runtime calls eagle's headers make are implemented over the driver by
166
+ # src/plugin/cuda_driver.cpp, which opens libcuda.so.1 at run time, so the only
167
+ # CUDA library the plugin ever loads is the driver's. The plugin's own kernels
168
+ # are compiled ahead of time into the embedded fat binary (the arch list above)
169
+ # and loaded with cuModuleLoadData. Hidden visibility and a version script
170
+ # export the eagle_backend_* C seam and nothing else; libstdc++/libgcc are
171
+ # bundled so the plugin loads next to any core. It is dlopen'd by eagle._core
172
+ # (src/seam/Loader.h), never linked, so nothing else may depend on it.
173
+ # --no-undefined turns a runtime call the translation layer does not implement
174
+ # into a link error instead of a load-time failure.
175
+ # ---------------------------------------------------------------------------
176
+ if(_eagle_plugin_mode STREQUAL "BUILD")
177
+ add_library(eagle_cuda SHARED src/plugin/eagle_cuda.cu src/plugin/cuda_driver.cpp)
178
+ target_compile_features(eagle_cuda PRIVATE cxx_std_20)
179
+ target_include_directories(eagle_cuda PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
180
+ # Headers only (cuda.h, cudaTypedefs.h, cuda_runtime_api.h); nothing from the
181
+ # toolkit is linked.
182
+ target_include_directories(eagle_cuda SYSTEM PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
183
+ target_link_libraries(eagle_cuda PRIVATE eagle::eagle ${CMAKE_DL_LIBS})
184
+ string(REPLACE ";" "," _eagle_plugin_archs "${CMAKE_CUDA_ARCHITECTURES}")
185
+ target_compile_definitions(eagle_cuda PRIVATE
186
+ EAGLE_PYTHON_VERSION="${eagle_VERSION}"
187
+ EAGLE_CUDA_PLUGIN_ARCHS="${_eagle_plugin_archs}"
188
+ $<$<BOOL:${EAGLE_BACKEND_INJECT_MISSING}>:EAGLE_BACKEND_INJECT_MISSING=1>)
189
+ target_compile_options(eagle_cuda PRIVATE ${_eagle_no_gnu_unique})
190
+ set(_eagle_map "${CMAKE_CURRENT_SOURCE_DIR}/src/plugin/eagle_cuda.map")
191
+ target_link_options(eagle_cuda PRIVATE
192
+ "LINKER:--version-script=${_eagle_map}" "LINKER:--no-undefined" ${_eagle_static_runtime})
193
+ set_target_properties(eagle_cuda PROPERTIES
194
+ OUTPUT_NAME eagle_cuda
195
+ # Link through the C++ driver (the one carrying the static libstdc++), not
196
+ # nvcc's host compiler.
197
+ LINKER_LANGUAGE CXX
198
+ LINK_DEPENDS "${_eagle_map}"
199
+ CUDA_RUNTIME_LIBRARY None
200
+ CUDA_VISIBILITY_PRESET "hidden"
201
+ CXX_VISIBILITY_PRESET "hidden"
202
+ POSITION_INDEPENDENT_CODE ON
203
+ # One TU, whole-program device compilation: a relocatable (-rdc) build is
204
+ # device-linked to SASS only, which would drop the 90-virtual PTX the arch
205
+ # list asks for (JIT on newer GPUs). Nothing here needs device linking.
206
+ CUDA_SEPARABLE_COMPILATION OFF)
207
+ install(TARGETS eagle_cuda LIBRARY DESTINATION eagle)
208
+ message(STATUS "> libeagle_cuda.so: built here (archs ${CMAKE_CUDA_ARCHITECTURES})")
209
+ elseif(_eagle_plugin_mode STREQUAL "PATH")
210
+ install(FILES "${EAGLE_PYTHON_CUDA_PLUGIN}" DESTINATION eagle RENAME libeagle_cuda.so)
211
+ message(STATUS "> libeagle_cuda.so: prebuilt ${EAGLE_PYTHON_CUDA_PLUGIN}")
212
+ else()
213
+ message(STATUS "> libeagle_cuda.so: NOT included (EAGLE_PYTHON_CUDA_PLUGIN=OFF)")
214
+ endif()
215
+
216
+ if(EAGLE_PYTHON_SKIP_CORE)
217
+ message(STATUS "> eagle._core: NOT built (EAGLE_PYTHON_SKIP_CORE=ON)")
218
+ return()
219
+ endif()
220
+
221
+ # ---------------------------------------------------------------------------
222
+ # eagle._core — the nanobind module.
223
+ # ---------------------------------------------------------------------------
224
+
225
+ # Python + nanobind from the building interpreter (scikit-build-core provides it;
226
+ # the --cmake_dir fallback also covers a plain `cmake` invocation).
227
+ find_package(Python 3.9 REQUIRED COMPONENTS Interpreter Development.Module)
228
+ find_package(nanobind CONFIG QUIET)
229
+ if(NOT nanobind_FOUND)
230
+ execute_process(
231
+ COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir
232
+ OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE nanobind_ROOT)
233
+ find_package(nanobind CONFIG REQUIRED PATHS "${nanobind_ROOT}" NO_DEFAULT_PATH)
234
+ endif()
235
+
236
+ # The core is plain C++ (EAGLE_CPU_ONLY + AETHER_CPP_MODE): it reaches CUDA only
237
+ # through the plugin, so it needs no CUDA toolkit to build and no driver to load.
238
+ # It takes the eagle/aether HEADERS only — not eagle::eagle / aether::aether, whose
239
+ # exported definitions describe the CUDA-mode package (AETHER_HAS_CUDA, ...).
240
+ find_package(OpenMP REQUIRED COMPONENTS CXX)
241
+ get_target_property(_eagle_core_incs eagle::eagle INTERFACE_INCLUDE_DIRECTORIES)
242
+ get_target_property(_aether_incs aether::aether INTERFACE_INCLUDE_DIRECTORIES)
243
+ nanobind_add_module(_core MODULE src/eagle_core.cpp)
244
+ target_compile_features(_core PRIVATE cxx_std_23)
245
+ # aether's own include directories first: an installed eagle's prefix may also
246
+ # hold an (older) aether copy, and the aether this configure resolved must win.
247
+ target_include_directories(_core PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src" ${_aether_incs} ${_eagle_core_incs})
248
+ target_compile_definitions(_core PRIVATE EAGLE_CPU_ONLY=1 AETHER_CPP_MODE=1 EAGLE_BLOCKSIZE=256 NDEBUG)
249
+ target_link_libraries(_core PRIVATE OpenMP::OpenMP_CXX ${CMAKE_DL_LIBS})
250
+ target_compile_options(_core PRIVATE ${_eagle_no_gnu_unique})
251
+ # libstdc++/libgcc bundled where the toolchain allows (see _eagle_static_runtime).
252
+ target_link_options(_core PRIVATE ${_eagle_static_runtime})
253
+ set_target_properties(_core PROPERTIES
254
+ CXX_VISIBILITY_PRESET "hidden"
255
+ POSITION_INDEPENDENT_CODE ON
256
+ LINKER_LANGUAGE CXX)
257
+ # The wall, asserted where it is decided: no CUDA source reaches the core.
258
+ get_target_property(_core_sources _core SOURCES)
259
+ foreach(_src IN LISTS _core_sources)
260
+ if(_src MATCHES "\\.cu$")
261
+ message(FATAL_ERROR "eagle._core must stay CUDA-free; it lists the CUDA source ${_src}")
262
+ endif()
263
+ endforeach()
264
+
265
+ # scikit-build-core maps this DESTINATION into the wheel's eagle package.
266
+ install(TARGETS _core LIBRARY DESTINATION eagle)
267
+
268
+ # ---------------------------------------------------------------------------
269
+ # eagle._mpi — the OPTIONAL second extension: eagle::exec::RankPartition.
270
+ #
271
+ # WHY IT IS A SECOND MODULE. `eagle/exec/RankPartition.h` refuses to compile
272
+ # without `EAGLE_MPI`, and that define exists so eagle never links libmpi: the C++
273
+ # side puts it PRIVATELY on one test target and nowhere else. Putting the rank
274
+ # surface into `_core` would drag libmpi into the extension every eagle user
275
+ # imports — including everyone with no MPI installed, for whom `import eagle`
276
+ # would simply stop working. `_core` stays MPI-free (an audit row in the Python
277
+ # suite reads its `ldd`), and the rank structure lives here, built only where an
278
+ # MPI is present.
279
+ #
280
+ # EAGLE_PYTHON_MPI is TRI-STATE, not a bool, because "off" and "not available"
281
+ # must stay distinguishable: ON demands an MPI and FAILS THE CONFIGURE without
282
+ # one (a silently skipped module is how a CI job certifies a surface it never
283
+ # built), OFF never looks, and AUTO builds it iff MPI is found. Either way this
284
+ # block prints what it decided — a build whose optional half quietly vanished is
285
+ # the thing the STATUS line exists to prevent.
286
+ # ---------------------------------------------------------------------------
287
+ set(EAGLE_PYTHON_MPI "AUTO" CACHE STRING
288
+ "Build the optional eagle._mpi extension (eagle::exec::RankPartition): ON | OFF | AUTO")
289
+ set_property(CACHE EAGLE_PYTHON_MPI PROPERTY STRINGS ON OFF AUTO)
290
+ string(TOUPPER "${EAGLE_PYTHON_MPI}" _eagle_python_mpi)
291
+
292
+ if(_eagle_python_mpi STREQUAL "OFF")
293
+ message(STATUS "> eagle._mpi: NOT built (EAGLE_PYTHON_MPI=OFF)")
294
+ elseif(_eagle_python_mpi STREQUAL "ON" OR _eagle_python_mpi STREQUAL "AUTO")
295
+ if(_eagle_python_mpi STREQUAL "ON")
296
+ find_package(MPI REQUIRED COMPONENTS CXX)
297
+ else()
298
+ find_package(MPI QUIET COMPONENTS CXX)
299
+ endif()
300
+ if(NOT MPI_CXX_FOUND)
301
+ message(STATUS "> eagle._mpi: NOT built (EAGLE_PYTHON_MPI=AUTO and no MPI found); "
302
+ "eagle.exec.RankPartition will refuse, naming the rule")
303
+ else()
304
+ message(STATUS "> eagle._mpi: building against MPI ${MPI_CXX_VERSION} (${MPI_CXX_COMPILER})")
305
+
306
+ # The library path the module re-opens RTLD_GLOBAL before MPI_Init, so Open
307
+ # MPI's dlopen'ed MCA components can resolve against it (a Python extension is
308
+ # loaded RTLD_LOCAL; see promoteMpiSymbols() in src/eagle_mpi.cpp). Resolved
309
+ # HERE from what MPI::MPI_CXX actually carries — never a guessed SONAME. An
310
+ # imported-target-only MPI leaves it empty and the module skips the promotion.
311
+ set(_eagle_mpi_library "")
312
+ foreach(_lib IN LISTS MPI_CXX_LIBRARIES)
313
+ if(_lib MATCHES "libmpi\\.(so|dylib)")
314
+ set(_eagle_mpi_library "${_lib}")
315
+ break()
316
+ endif()
317
+ endforeach()
318
+ message(STATUS "> eagle._mpi: RTLD_GLOBAL promotion target = "
319
+ "'${_eagle_mpi_library}'")
320
+
321
+ # Plain C++ like _core (its device inner forwards to the CUDA backend).
322
+ nanobind_add_module(_mpi MODULE src/eagle_mpi.cpp)
323
+ target_compile_features(_mpi PRIVATE cxx_std_23)
324
+ target_include_directories(_mpi PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src"
325
+ "${CMAKE_CURRENT_SOURCE_DIR}/.." ${_aether_incs} ${_eagle_core_incs})
326
+ # EAGLE_MPI is PRIVATE to this target, exactly as it is on the C++ bed: it is
327
+ # what makes RankPartition.h compile at all, and it must not leak to anything
328
+ # else in the build.
329
+ target_compile_definitions(_mpi PRIVATE
330
+ EAGLE_CPU_ONLY=1 AETHER_CPP_MODE=1 EAGLE_BLOCKSIZE=256 NDEBUG
331
+ EAGLE_MPI=1 EAGLE_MPI_LIBRARY="${_eagle_mpi_library}")
332
+ target_link_libraries(_mpi PRIVATE OpenMP::OpenMP_CXX MPI::MPI_CXX ${CMAKE_DL_LIBS})
333
+ target_compile_options(_mpi PRIVATE ${_eagle_no_gnu_unique})
334
+ # The same wheel-portability link flags `_core` carries, for the same reason.
335
+ target_link_options(_mpi PRIVATE ${_eagle_static_runtime})
336
+ set_target_properties(_mpi PROPERTIES
337
+ CXX_VISIBILITY_PRESET "hidden"
338
+ POSITION_INDEPENDENT_CODE ON)
339
+ install(TARGETS _mpi LIBRARY DESTINATION eagle)
340
+ endif()
341
+ else()
342
+ message(FATAL_ERROR
343
+ "EAGLE_PYTHON_MPI must be ON, OFF or AUTO; got '${EAGLE_PYTHON_MPI}'")
344
+ endif()
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ eagle
2
+ Copyright 2026 Alessandro Masat