Building and Building Against sbio
Recommendations for Builds and Installs
Section titled “Recommendations for Builds and Installs”Unlike with ncarray, the sbio package is often better built from source. This is because the various components are all optional, and choosing to build and link against a set of components in the environment you are working in is easier than incorporating a pre-built library. E.g., sbio can be built with MPI support (a feature very likely to be used); however, the implementation and version of MPI can vary over a wide range of supported options. If you are interested in sbio you very likely already have a working environment with an MPI installation, in which case building against that may be preferrable. The sbio build is generally quite reasonable in terms of time and computational cost - 5-10 minutes with modest hardware for compilation should generally be sufficient.
Nonetheless, like all XFELPP projects, sbio has releases bundled as wheels available through the XFELPP indices. Currently, only the host builds are released. You can install from the index on the command-line using:
pip install sbio --extra-index-url https://pypi.xfelpp.org/hostThe host-builds are currently configured as follows:
- glibc 2.28 (With GCC 14.2.1) and/or musl 1.2 (With GCC 14.2.0) for x86 only
- Built against
ncarray == 0.7.6 - MPI Support with
MPICH 5.0.1 - XTC2 Data Format Support
- Python Wheels for Python 3.8-3.15t
- msvc 19.44.35228 for x86 only
- Built against
ncarray == 0.7.6 - MPI support with
MS-MPI 10.1.3 - XTC2 Data Format Support
- Python Wheels for Python 3.8-3.15t
- clang 21.0.0 with
MACOSX_DEPLOYMENT_TARGET=11.0for Apple Silicon (AArch64) only - Built against
ncarray == 0.7.6 - MPI support with
MPICH 5.0.1 - XTC2 Data Format Support
- Python Wheels for Python 3.8-3.15t
Releases for the four core library builds (glibc and musl Linux, macOS, Windows) are also uploaded to the GitHub release independently of the Python wheel if that is preferred.
General Information
Section titled “General Information”sbio uses meson as its build system. It will also require a relatively modern compiler for C++23 support. If building with GPU support it then also requires the CUDA toolkit.
In general, the steps for building are:
meson setup $MY_BUILD_DIR # --prefix=$MY_INSTALL_DIR #-Dbuildtype=debug # (or release etc).meson compile -C $MY_BUILD_DIRmeson install -C $MY_BUILD_DIR# For tests:meson test -C $MY_BUILD_DIRRequirements
Section titled “Requirements”In addition to meson the following dependencies are needed:
mesonninjameson-python
The remaining dependencies are vendored through the meson subprojects system. ncarray requires Python >= 3.8. The core dependencies are:
ncarray- the documentation is available here
Additionally, there are further dependencies that are optional given the build options. However, they are likely to be needed to get the most utility from the project:
MPI- MPICH and OpenMPI can both be used directly from the project and have been tested. Any suitable MPI implementation with a conforming specification and support for OSC/shared memory APIs will likely also work. This would need to be provided by your environment, however.CUDA- CUDA Toolkit 12 or 13 would be recommended.
Compiler Matrix
Section titled “Compiler Matrix”sbio requires at least gcc >= 12 (although gcc >= 13 is recommended, if permitted by CUDA version), clang > 15, or msvc >= 19.30. Other compilers may work but are not tested.
If building with CUDA support then for CUDA Version:
CUDA < 12.4you must usegcc > 12 && gcc < 13,clang > 16 && clang < 17,msvc >= 19.30 && msvc < 19.38 (VS 2022 < 17.8)CUDA >= 12.4 && CUDA < 12.8you must usegcc > 12 && gcc < 14,clang > 16 && clang < 19,msvc >= 19.30 && msvc < 19.41 (VS 2022 < 17.11)CUDA >= 12.8you must usegcc > 12 && gcc < 15,clang > 16 && clang < 20,msvc >= 19.30 && msvc < 19.50 (VS 2022 < 18.0)
Buid Options and Setup
Section titled “Buid Options and Setup”There are a number of flags which can be provided when running the meson setup:
build_core: bool flag for whether to build the C++ libraries.sbio_data_formats: string for the core data formats to be built. Currentlyxtc1,xtc2, orall(for bothxtc1andxtc2) are supportedbuild_mpi: string for if and how to build MPI. Passingnonewill disable MPI support.autowill search for an existing MPI installation, then try MPICH and OpenMPI in that order.mpichorompican alternatively be provided to build either of those two options.build_python: bool flag for whether to build the Python bindings.sbio_cuda_archs: A string of architectures for building CUDA fat binaries, or, alternatively, the stringall, in which case architectures75,80,86,89and90are built (withcompute_90at the end for PTX forward compatibility).sbio_as_wheel: bool flag for whether to build as the combined standard wheel.- NOTE: If not using this flag, it is expected that the wheel will built as
build_core=true build_python=falsein one phase, andbuild_core=false build_python=truein a second. - NOTE: It is possible to do two-phase builds with
sbio_as_wheelset totrue. This can be somewhat more error-prone, butbuild.shmay have an example for Linux builds.
- NOTE: If not using this flag, it is expected that the wheel will built as
build_examples: bool flag for whether to build the example programs. These are small executables and in general are not needed. The tests are always built as part ofbuild_core.
Each of these flags is passed as an option during the meson setup stage using the -D prefix. E.g.
meson setup <builddir> -Dbuild_core=true -Dbuild_python=false -Dbuild_mpi=autoYou can use any build directory of your choosing for <builddir>
Compilation
Section titled “Compilation”After running the meson setup command using the choice of options you prefer, compilation can be done using:
meson compile -C <builddir>The number of parallel jobs can be controlled with -j <jobs> during this step. -l <load> can also be used to try and tweak load. By default as many jobs will be launched as independent processors are available.
In general, it is not necessary to override the default for sbio. The most intensive compilation steps are if building a vendored MPI version; however, it will likely be fine to use the defaults, even in this case.
Building via pip
Section titled “Building via pip”You can also run pip install . directly after cloning the repo:
cd sbiopip install . # --prefix=....This will be moderately slow compared to parallel builds with meson directly.