sanafe 2.0.20__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 (57) hide show
  1. sanafe-2.0.20/CMakeLists.txt +272 -0
  2. sanafe-2.0.20/LICENSE +674 -0
  3. sanafe-2.0.20/MANIFEST.in +7 -0
  4. sanafe-2.0.20/PKG-INFO +394 -0
  5. sanafe-2.0.20/README.md +375 -0
  6. sanafe-2.0.20/plugins/CMakeLists.txt +12 -0
  7. sanafe-2.0.20/plugins/hodgkin_huxley.cpp +176 -0
  8. sanafe-2.0.20/pyproject.toml +8 -0
  9. sanafe-2.0.20/sanafe/__init__.py +2 -0
  10. sanafe-2.0.20/sanafe/layers.py +325 -0
  11. sanafe-2.0.20/sanafe/tutorial.py +205 -0
  12. sanafe-2.0.20/sanafe.egg-info/PKG-INFO +394 -0
  13. sanafe-2.0.20/sanafe.egg-info/SOURCES.txt +55 -0
  14. sanafe-2.0.20/sanafe.egg-info/dependency_links.txt +1 -0
  15. sanafe-2.0.20/sanafe.egg-info/not-zip-safe +1 -0
  16. sanafe-2.0.20/sanafe.egg-info/top_level.txt +1 -0
  17. sanafe-2.0.20/setup.cfg +4 -0
  18. sanafe-2.0.20/setup.py +86 -0
  19. sanafe-2.0.20/src/arch.cpp +180 -0
  20. sanafe-2.0.20/src/arch.hpp +207 -0
  21. sanafe-2.0.20/src/attribute.hpp +165 -0
  22. sanafe-2.0.20/src/chip.cpp +1720 -0
  23. sanafe-2.0.20/src/chip.hpp +218 -0
  24. sanafe-2.0.20/src/core.cpp +203 -0
  25. sanafe-2.0.20/src/core.hpp +112 -0
  26. sanafe-2.0.20/src/docstrings.hpp +339 -0
  27. sanafe-2.0.20/src/fwd.hpp +70 -0
  28. sanafe-2.0.20/src/main.cpp +329 -0
  29. sanafe-2.0.20/src/mapped.cpp +109 -0
  30. sanafe-2.0.20/src/mapped.hpp +87 -0
  31. sanafe-2.0.20/src/message.cpp +61 -0
  32. sanafe-2.0.20/src/message.hpp +63 -0
  33. sanafe-2.0.20/src/models.cpp +969 -0
  34. sanafe-2.0.20/src/models.hpp +307 -0
  35. sanafe-2.0.20/src/netlist.cpp +871 -0
  36. sanafe-2.0.20/src/netlist.hpp +68 -0
  37. sanafe-2.0.20/src/network.cpp +668 -0
  38. sanafe-2.0.20/src/network.hpp +204 -0
  39. sanafe-2.0.20/src/pipeline.cpp +641 -0
  40. sanafe-2.0.20/src/pipeline.hpp +261 -0
  41. sanafe-2.0.20/src/plugins.cpp +98 -0
  42. sanafe-2.0.20/src/plugins.hpp +24 -0
  43. sanafe-2.0.20/src/print.cpp +28 -0
  44. sanafe-2.0.20/src/print.hpp +111 -0
  45. sanafe-2.0.20/src/pymodule.cpp +1541 -0
  46. sanafe-2.0.20/src/schedule.cpp +636 -0
  47. sanafe-2.0.20/src/schedule.hpp +262 -0
  48. sanafe-2.0.20/src/tile.cpp +35 -0
  49. sanafe-2.0.20/src/tile.hpp +51 -0
  50. sanafe-2.0.20/src/utils.cpp +28 -0
  51. sanafe-2.0.20/src/utils.hpp +48 -0
  52. sanafe-2.0.20/src/yaml_arch.cpp +598 -0
  53. sanafe-2.0.20/src/yaml_arch.hpp +67 -0
  54. sanafe-2.0.20/src/yaml_common.cpp +317 -0
  55. sanafe-2.0.20/src/yaml_common.hpp +102 -0
  56. sanafe-2.0.20/src/yaml_snn.cpp +1361 -0
  57. sanafe-2.0.20/src/yaml_snn.hpp +89 -0
@@ -0,0 +1,272 @@
1
+ cmake_minimum_required(VERSION 3.13)
2
+ include(CMakePrintHelpers)
3
+
4
+ set(CMAKE_CXX_STANDARD 17)
5
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
6
+ set(CMAKE_CXX_EXTENSIONS OFF)
7
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
8
+ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
9
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
10
+ endif()
11
+
12
+ if(NOT CMAKE_BUILD_TYPE)
13
+ set(CMAKE_BUILD_TYPE RelWithDebInfo)
14
+ endif()
15
+ cmake_print_variables(CMAKE_BUILD_TYPE)
16
+
17
+ if(POLICY CMP0148)
18
+ cmake_policy(SET CMP0148 NEW)
19
+ endif()
20
+
21
+ # Set which targets to make, between a standalone executable and a Python lib
22
+ if (NOT DEFINED STANDALONE_BUILD_ENABLED)
23
+ set(STANDALONE_BUILD_ENABLED ON)
24
+ endif()
25
+
26
+ if (NOT DEFINED PYTHON_BUILD_ENABLED)
27
+ set(PYTHON_BUILD_ENABLED ON)
28
+ endif()
29
+
30
+ # Ensure that at least one build target is enabled
31
+ if(NOT STANDALONE_BUILD_ENABLED AND NOT PYTHON_BUILD_ENABLED)
32
+ message(
33
+ FATAL_ERROR
34
+ "No build target enabled: Either STANDALONE_BUILD_ENABLED or PYTHON_BUILD_ENABLED must be ON."
35
+ )
36
+ endif()
37
+
38
+ project(sana-fe)
39
+
40
+ add_compile_options(
41
+ -Wall -pedantic -Werror -g -fopenmp -fPIC -pthread
42
+ )
43
+
44
+ # Set default debug levels for tracing
45
+ if(NOT DEFINED DEBUG_LEVEL_ARCH)
46
+ set(DEBUG_LEVEL_ARCH 0)
47
+ endif()
48
+
49
+ if(NOT DEFINED DEBUG_LEVEL_DESCRIPTION)
50
+ set(DEBUG_LEVEL_DESCRIPTION 0)
51
+ endif()
52
+
53
+ if(NOT DEFINED DEBUG_LEVEL_MODELS)
54
+ set(DEBUG_LEVEL_MODELS 0)
55
+ endif()
56
+
57
+ if(NOT DEFINED DEBUG_LEVEL_NET)
58
+ set(DEBUG_LEVEL_NET 0)
59
+ endif()
60
+
61
+ if(NOT DEFINED DEBUG_LEVEL_PLUGINS)
62
+ set(DEBUG_LEVEL_PLUGINS 0)
63
+ endif()
64
+
65
+ if(NOT DEFINED DEBUG_LEVEL_PYMODULE)
66
+ set(DEBUG_LEVEL_PYMODULE 0)
67
+ endif()
68
+
69
+ if(NOT DEFINED DEBUG_LEVEL_CHIP)
70
+ set(DEBUG_LEVEL_CHIP 0)
71
+ endif()
72
+
73
+ if(NOT DEFINED DEBUG_LEVEL_SCHEDULER)
74
+ set(DEBUG_LEVEL_SCHEDULER 0)
75
+ endif()
76
+
77
+ # Validate debug levels
78
+ foreach(category ARCH CHIP DESCRIPTION MODELS NET PLUGINS PYMODULE SCHEDULER)
79
+ if(NOT DEBUG_LEVEL_${category} MATCHES "^[0-3]$")
80
+ message(FATAL_ERROR "DEBUG_LEVEL_${category} must be between 0 and 3")
81
+ endif()
82
+ # Add compile definitions for each category
83
+ add_compile_definitions(DEBUG_LEVEL_${category}=${DEBUG_LEVEL_${category}})
84
+ endforeach()
85
+
86
+ # Set conditional defaults based on build type
87
+ if(CMAKE_BUILD_TYPE STREQUAL "Release")
88
+ # Release build defaults
89
+ set(DEFAULT_STANDALONE_DEBUG ON)
90
+ set(DEFAULT_STANDALONE_SOURCE OFF) # No source info in release
91
+ set(DEFAULT_PYTHON_DEBUG OFF)
92
+ set(DEFAULT_PYTHON_SOURCE OFF)
93
+ else()
94
+ # Debug/other build defaults
95
+ set(DEFAULT_STANDALONE_DEBUG ON)
96
+ set(DEFAULT_STANDALONE_SOURCE ON)
97
+ set(DEFAULT_PYTHON_DEBUG ON)
98
+ set(DEFAULT_PYTHON_SOURCE ON)
99
+ endif()
100
+
101
+ # Define options with conditional defaults
102
+ option(ENABLE_STANDALONE_DEBUG "Enable debug prints for standalone build" ${DEFAULT_STANDALONE_DEBUG})
103
+ option(ENABLE_SOURCE_INFO_STANDALONE "Include source info in standalone debug prints" ${DEFAULT_STANDALONE_SOURCE})
104
+ option(ENABLE_PYTHON_DEBUG "Enable debug prints for Python build" ${DEFAULT_PYTHON_DEBUG})
105
+ option(ENABLE_SOURCE_INFO_PYTHON "Include source info in standalone debug prints" ${DEFAULT_PYTHON_SOURCE})
106
+
107
+ cmake_print_variables(ENABLE_STANDALONE_DEBUG ENABLE_SOURCE_INFO_STANDALONE ENABLE_PYTHON_DEBUG ENABLE_SOURCE_INFO_PYTHON)
108
+
109
+ set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
110
+ add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/plugins")
111
+ include(CMakePrintHelpers)
112
+ cmake_print_variables(SRC_DIR)
113
+ file (GLOB SOURCE_FILES "${SRC_DIR}/*.cpp")
114
+ file (GLOB HEADER_FILES "${SRC_DIR}/*.hpp")
115
+
116
+ cmake_print_variables(SOURCE_FILES)
117
+ cmake_print_variables(HEADER_FILES)
118
+
119
+ # Get the latest commit hash
120
+ execute_process(
121
+ COMMAND git rev-parse HEAD
122
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
123
+ OUTPUT_VARIABLE GIT_COMMIT
124
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
125
+
126
+ add_compile_definitions(GIT_COMMIT="${GIT_COMMIT}")
127
+
128
+ # Find Python using the new FindPython module
129
+ option(PYTHON_FROM_SETUP "Building via setup.py" OFF)
130
+ if(PYTHON_BUILD_ENABLED)
131
+ if(PYTHON_FROM_SETUP)
132
+ if(NOT DEFINED PYTHON_EXECUTABLE OR NOT DEFINED PYTHON_INCLUDE_DIRS)
133
+ message(FATAL_ERROR "PYTHON_EXECUTABLE and PYTHON_INCLUDE_DIRS must be provided when PYTHON_FROM_SETUP=ON")
134
+ endif()
135
+ else()
136
+ find_package(Python COMPONENTS Interpreter Development REQUIRED)
137
+ endif()
138
+ endif()
139
+
140
+ option(ENABLE_OPENMP "Enable OpenMP support for parallel processing" ON)
141
+ find_package(OpenMP)
142
+ find_package(Threads REQUIRED)
143
+
144
+ # OpenMP i.e. multithreaded builds are optional, but on by default
145
+ if (OpenMP_CXX_FOUND AND ENABLE_OPENMP)
146
+ message(STATUS "OpenMP found: ${OpenMP_CXX_VERSION} and enabled")
147
+ else()
148
+ if(NOT OpenMP_CXX_FOUND)
149
+ message(STATUS "OpenMP not found - parallel code will be disabled")
150
+ else()
151
+ message(STATUS "OpenMP found but explicitly disabled - parallel code will be disabled")
152
+ endif()
153
+ endif()
154
+
155
+ ############## rapid-yaml
156
+ project(ryml-quickstart LANGUAGES CXX)
157
+ set(RYML_VERSION "v0.9.0")
158
+ message(STATUS "FetchContent for tag: ${RYML_VERSION}")
159
+
160
+ include(FetchContent)
161
+ FetchContent_Declare(ryml
162
+ GIT_REPOSITORY https://github.com/biojppm/rapidyaml.git
163
+ GIT_TAG ${RYML_VERSION}
164
+ GIT_SHALLOW FALSE # ensure submodules are checked out
165
+ )
166
+ FetchContent_MakeAvailable(ryml)
167
+ set(RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS ON)
168
+ ##### END OF rapid-yaml
169
+
170
+ ############## booksim2
171
+ project(booksim2-quickstart LANGUAGES CXX)
172
+ set(BOOKSIM_VERSION "110ad1b80e493241f6e57587bc11354ac84f91f8")
173
+ FetchContent_Declare(booksim
174
+ GIT_REPOSITORY https://github.com/SLAM-Lab/booksim2-sanafe.git
175
+ GIT_TAG ${BOOKSIM_VERSION}
176
+ GIT_SHALLOW FALSE
177
+ )
178
+ FetchContent_MakeAvailable(booksim)
179
+ if(NOT booksim_POPULATED)
180
+ FetchContent_Populate(booksim)
181
+ endif()
182
+
183
+ get_target_property(BOOKSIM_INCLUDE_DIRS booksim INTERFACE_INCLUDE_DIRECTORIES)
184
+ if(NOT BOOKSIM_INCLUDE_DIRS)
185
+ # Fallback for older CMake versions
186
+ set(BOOKSIM_INCLUDE_DIRS
187
+ ${booksim_SOURCE_DIR}
188
+ ${booksim_SOURCE_DIR}/src/arbiters
189
+ ${booksim_SOURCE_DIR}/src/allocators
190
+ ${booksim_SOURCE_DIR}/src/routers
191
+ ${booksim_SOURCE_DIR}/src/networks
192
+ ${booksim_SOURCE_DIR}/src/power
193
+ )
194
+ include_directories(${BOOKSIM_INCLUDE_DIRS})
195
+ endif()
196
+ #### END of booksim2
197
+
198
+ include_directories(${PYTHON_INCLUDE_DIRS})
199
+
200
+ cmake_print_variables(PyBind11_DIR)
201
+
202
+ # PyBind specific
203
+ if(PYTHON_BUILD_ENABLED)
204
+ if(PYTHON_FROM_SETUP)
205
+ # Force pybind11 to use the Python from setup.py
206
+ set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
207
+ set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS})
208
+ set(PYBIND11_PYTHON_VERSION "") # Don't let pybind11 override
209
+ message(STATUS "Forcing pybind11 to use Python: ${PYTHON_EXECUTABLE}")
210
+ endif()
211
+
212
+ find_package(pybind11 CONFIG)
213
+ if (NOT PYTHON_EXECUTABLE)
214
+ message("PYTHON_EXECUTABLE not set, default command: 'python3'")
215
+ set(PYTHON_EXECUTABLE "python3")
216
+ endif()
217
+ if(NOT pybind11_FOUND OR pybind11_FOUND STREQUAL "0")
218
+ message("PyBind11 not found, trying to set PYBIND_CMAKE_DIR using Python")
219
+ execute_process(
220
+ COMMAND "${PYTHON_EXECUTABLE}" -c "import pybind11; print(pybind11.get_cmake_dir())"
221
+ OUTPUT_VARIABLE PYBIND11_CMAKE_DIR
222
+ OUTPUT_STRIP_TRAILING_WHITESPACE
223
+ )
224
+ cmake_print_variables(PYBIND11_CMAKE_DIR)
225
+ set(pybind11_DIR ${PYBIND11_CMAKE_DIR})
226
+ find_package(pybind11 CONFIG REQUIRED)
227
+ endif()
228
+ pybind11_add_module(
229
+ sanafecpp
230
+ ${SOURCE_FILES}
231
+ )
232
+
233
+ target_link_libraries(sanafecpp PRIVATE ${PYTHON_LIBRARIES})
234
+ target_link_libraries(sanafecpp PRIVATE pybind11::pybind11)
235
+ target_link_libraries(sanafecpp PUBLIC ryml::ryml)
236
+ target_link_libraries(sanafecpp PUBLIC booksim)
237
+ target_link_libraries(sanafecpp PRIVATE ${CMAKE_DL_LIBS})
238
+ if (OpenMP_CXX_FOUND AND ENABLE_OPENMP)
239
+ target_link_libraries(sanafecpp PRIVATE OpenMP::OpenMP_CXX)
240
+ target_compile_definitions(sanafecpp PRIVATE HAVE_OPENMP)
241
+ endif()
242
+ target_link_libraries(sanafecpp PRIVATE Threads::Threads)
243
+
244
+ if(ENABLE_PYTHON_DEBUG)
245
+ target_compile_definitions(sanafecpp PRIVATE ENABLE_DEBUG_PRINTS)
246
+ if(ENABLE_SOURCE_INFO_PYTHON)
247
+ target_compile_definitions(sanafecpp PRIVATE ENABLE_SOURCE_INFO)
248
+ endif()
249
+ endif()
250
+ endif()
251
+
252
+ if(STANDALONE_BUILD_ENABLED)
253
+ add_executable(sim "${SRC_DIR}/main.cpp")
254
+ list(FILTER SOURCE_FILES EXCLUDE REGEX "pymodule.cpp")
255
+ target_sources(sim PRIVATE ${SOURCE_FILES})
256
+
257
+ target_link_libraries(sim PUBLIC ryml::ryml)
258
+ target_link_libraries(sim PUBLIC booksim)
259
+ target_link_libraries(sim PRIVATE ${CMAKE_DL_LIBS})
260
+ if (OpenMP_CXX_FOUND AND ENABLE_OPENMP)
261
+ target_link_libraries(sim PRIVATE OpenMP::OpenMP_CXX)
262
+ target_compile_definitions(sim PRIVATE HAVE_OPENMP)
263
+ endif()
264
+ target_link_libraries(sim PRIVATE Threads::Threads)
265
+
266
+ if(ENABLE_STANDALONE_DEBUG)
267
+ target_compile_definitions(sim PRIVATE ENABLE_DEBUG_PRINTS)
268
+ if(ENABLE_SOURCE_INFO_STANDALONE)
269
+ target_compile_definitions(sim PRIVATE ENABLE_SOURCE_INFO)
270
+ endif()
271
+ endif()
272
+ endif()