CompilerBackend#

class brainevent.CompilerBackend[source]#

Abstract base class for BE compiler backends.

Each backend encapsulates one compilation toolchain (nvcc, g++, hipcc, …). The high-level pipeline in brainevent._op.kernix_pipeline selects the appropriate backend based on the requested platform.

Subclasses must implement compile_source(). Optionally they can override platform_name() to provide a human-readable identifier.

abstractmethod compile_source(source, output_path, build_dir, *, extra_cflags=None, extra_ldflags=None, extra_include_paths=None, verbose=False, **kwargs)[source]#

Compile preprocessed source code to a shared library.

Parameters:
  • source (str) – Preprocessed C++/CUDA source (user code + auto-generated FFI wrappers, as produced by preprocess_source()).

  • output_path (str) – Desired path for the output shared library.

  • build_dir (str) – Directory for intermediate build artefacts.

  • extra_cflags (list[str] | None) – Additional compiler flags.

  • extra_ldflags (list[str] | None) – Additional linker flags.

  • extra_include_paths (list[str] | None) – Additional header search paths.

  • verbose (bool) – Print the full compiler command.

  • **kwargs (Any) – Backend-specific keyword arguments (e.g. gpu_arch for CUDA, optimization_level, use_fast_math).

Returns:

Absolute path to the compiled shared library.

Return type:

str

platform_name: str = 'unknown'#

Human-readable platform identifier, e.g. "cuda", "cpu", "hip".