-
Notifications
You must be signed in to change notification settings - Fork 0
Native Acceleration
The display-decay, edge-intensity, and channel-aggregation hot paths live in src/native/c/connectome_kernels.c. They
compile into dll/aibrain.connectome.dll and are loaded through src/native/wrapper/connectome_kernels.py. If the DLL is
missing or cannot be loaded, AIBrain falls back to NumPy implementations so the application remains usable.
The DLL accelerates display-signal bookkeeping. It does not implement the Qt window, OpenGL renderer, or language-model inference.
The remaining computation paths are already backed by optimized native libraries or are not hot numeric kernels: topology
generation and autoencoder training use NumPy operations, hashing uses hashlib, and reporting/UI functions create Python
objects. Converting those paths to handwritten C would add boundary-copying and maintenance cost without a measurable gain,
so the connectome decay, edge, and channel aggregation loops remain the focused native surface.
After changing the C source, run from the project root:
py cli\build_native.pyThe tool is color-coded in an interactive terminal and:
- discovers an explicitly supplied compiler,
$env:CC, GCC, Clang, MSVC, or a common MSYS2 MinGW-w64 GCC location; - compiles the x64 Windows DLL with warnings enabled and optimized release flags;
- checks that the output is a valid-sized
MZ/PE file; - loads it through
ctypes.WinDLL; and - verifies
decay_and_count,edge_activity, andregion_activityare exported.
Useful options:
py cli\build_native.py --debug
py cli\build_native.py --clean
py cli\build_native.py --compiler "C:\path\to\gcc.exe"--debug requests an unoptimized debug build. --clean deletes the existing DLL before compiling. --compiler is
useful when more than one supported toolchain is installed.
Install one of the following when discovery cannot find a compiler: Visual Studio Build Tools with the C++ build tools,
LLVM/Clang, or MSYS2 MinGW-w64 GCC. Open a developer command prompt for MSVC so cl.exe is on PATH, or pass the
compiler's full executable path with --compiler.