Skip to content

Commit

Permalink
Add build instructions for crystfel and set meson.options to generic …
Browse files Browse the repository at this point in the history
…values.
  • Loading branch information
hcstadler committed Jul 8, 2024
1 parent 69e1552 commit 2a7c187
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
63 changes: 63 additions & 0 deletions BUILD_FOR_CRYSTFEL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Building the Fast Feedback Indexer Library for CrystFEL on Linux Systems

Since CrystFEL uses meson as it's build system, the following will assume meson is installed. The code must be compiled with a C++17 and gnu compiler option compatible compiler (like g++-13 or clang++-18). A CUDA installation is also required. The code requires the Eigen library.

The file meson.options contains default values for meson compilation and build options. Such an option can also be set on the commandline with -D option='xxx'.

## Eigen Library (Option eigen-source-dir)

If you have a working installation of the Eigen library, this option can be set to 'ignore'. Otherwise you can set it to 'eigen' after checking out the Eigen library source code with

$ git submodule update --force --recursive

If you manage your own Eigen installation, set the option to the directory that contains the 'Eigen' subdirectory with the header files.

## Collect System Information

The library build uses CPU and GPU architecture specific optimization flags. In order to determine these flags, it's necessary to know what CPU and GPU hardware the library code needs to run on.

### Determine GPU Compute Capability (Option gpu-arch)

In order to determin the compute capability of the GPUs the code should be able to run on, use the nvidia-smi command.

$ nvidia-smi --query-gpu=compute_cap --format=csv,noheader

This information will end up as a single --gencode='xxx' nvidia compiler option, see [nvcc compiler options](https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#options-for-steering-gpu-code-generation). So if the output of the nvidia-smi comand is 8.9, the value of 'xxx' can be set to 'arch=compute_89,code=sm_89'

The value can be set to 'ignore', then no --gencode option will be given to the Nvidia compiler.

### Determine CPU Architecture (Option cpu-arch)

This is a bit tricky, as it requires some knowledge of CPUs. The CPU architecture option 'xxx' will end up in a -march='xxx' g++ compiler option (also valid for clang++), see [gcc cpu architecture options](https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html). There are three ways for setting this.

#### Set to 'ignore'

No -march option will be given to the compiler.

#### Set to 'native'

The value will be set according to the CPU architecture the code is compiled on. If your compilation machine is never than the machines you run the library code on, that will most likely fail with 'illegal instruction' crashes. Make sure you compile the code on the machine with the oldest CPU, that is likely to work, at least for AMD and Intel CPUs.

#### Set to specific architecture

The following command will show the CPU model

$ lscpu

Then the model needs to mapped to the architecture, e.g. with the help of [Wikipedias list of AMD processors](https://en.wikipedia.org/wiki/List_of_AMD_processors) or similar.

## Install

Choose an installation destination, here ${PWD}/install, and once the meson.options file has the desired options, compile and install the library with

$ INSTALL_DIR=${PWD}/install
$ CXX=g++-13 meson setup --reconfigure --buildtype=release --prefix=${INSTALL_DIR} --libdir=lib meson
$ cd meson
$ meson compile
$ meson install

To subsequently use the library, setup an sh compatible shell environment with

$ source ${INSTALL_DIR}/share/ffbidx/setup-env.sh

Amongst others, this sets up the LIBRARY_PATH and PKG_CONFIG_PATH.
6 changes: 3 additions & 3 deletions meson.options
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Compile options, can be set to 'ignore'
option('cpu-arch', type: 'string', value: 'native')
option('gpu-arch', type: 'string', value: 'arch=compute_89,code=sm_89')
option('cpu-arch', type: 'string', value: 'ignore')
option('gpu-arch', type: 'string', value: 'ignore')

# Eigen include directory, can be set to 'ignore'
# If this doesn't have the 'Eigen' subdirectory,
# pkg-config will be tried to find Eigen
option('eigen-source-dir', type: 'string', value: 'eigen')
option('eigen-source-dir', type: 'string', value: 'ignore')

# Build fast indexer library
option('build-ffbidx', type: 'feature', value: 'enabled')
Expand Down

0 comments on commit 2a7c187

Please sign in to comment.