Compilation
The compilation will produce directories IRA/lib and IRA/include, which contain the library and module files respectively. Other directories may be creted, depending on the flavour of build tool used.
Python module via pip
If you just want the ira_mod python module, it can be done by running in IRA/ root directory (this relies on cmake):
python -m pip install .
Then you can directly use it:
>>> import ira_mod
>>> print( ira_mod.version )
>>> ira = ira_mod.IRA()
>>> sofi = ira_mod.SOFI()
conda installation
Using the conda-forge channel, you can download and install the ira_mod python module by:
conda install ira
Other build tools
Other build tools are available, use one of the following:
To install with cmake, execute:
cmake -B builddir
cmake --build builddir
This will produce directories lib and include in the builddir path specified, they will contain
the static library libira.a and the fortran module files, respectively.
If you wish to compile the shared library, configure the build with -DBUILD_SHARED_LIBS=ON:
cmake -B builddir -DBUILD_SHARED_LIBS=ON
cmake --build builddir
The available options are:
-DIRA_BUILD_TESTS: build some simple tests (default OFF);-DIRA_ENABLE_NATIVE_OPTIMIZATIONpass the compiler flags “-march=native -ffast-math” or equivalent (default ON);
The build always compiles lap_local/lap.f into the library. Those routines are prefixed ira_ and built with -O2. libira does not define dgemm_ or the other reference BLAS and LAPACK names, so a program can link -lira and a BLAS such as OpenBLAS in the same binary.
To install the library and module files to a particular location, do:
cmake -B builddir -DCMAKE_INSTALL_PREFIX=your/install/path
cmake --build builddir
cmake --install builddir
This will copy the lib and include directories and their contents to your/install/path, and create files needed for other CMake and/or pkg-config based projects to find the library.
python module ira_mod
To use the python module, you will need to pass the -DIRA_INSTALL_PYTHON=ON, install the
library somewhere, and set the PYTHONPATH variable to that same path with adding /ira_mod:
cmake -B builddir -DIRA_INSTALL_PYTHON=ON -DCMAKE_INSTALL_PREFIX=your/install/path
cmake --build builddir
cmake --install builddir
export PYTHONPATH=your/install/path/ira_mod
On a standard linux machine, it should suffice to type:
cd src/
make all
This will generate the static and shared libraries: libira.a, and libira.so.
make always compiles lap_local/lap.f (routines prefixed ira_, -O2) and links that object into both libraries. No external LAPACK is required.
To compile only one of the libraries, type make lib or make shlib, respectively.
make test-link-blas checks that libira.so exports none of the unprefixed BLAS names and that a program linked with -lira -lopenblas runs.
To clean the build type:
make clean
python module ira_mod
To use the python module, you will need to set the PYTHONPATH variable:
export PYTHONPATH=/path/to/IRA/interface:$PYTHONPATH
For local machines, it is possible to use pixi [pixi-install] to get a working version of the
Python bindings in a fairly automated manner.
curl -fsSL https://pixi.sh/install.sh | bash
# build the library
pixi run build_lib
pixi shell # sets the environment variable
cd examples/IRA
python python_program.py
Installation instructions here: https://pixi.sh/latest/
Required minimum fpm version 0.12.0.
fpm build --flag "-fPIC -fcheck=bounds -ffree-line-length-none -O2"
fpm install --prefix .
python module ira_mod
To use the python module, you will need to set the PYTHONPATH variable:
export PYTHONPATH=/path/to/IRA/interface:$PYTHONPATH
Linking a program to libira
Linking a program to libira is simple, however note that:
The base-level implementations are not placed in modules, therefore all routines are in principle acessible to the caller. Care must be taken to ensure the correct type, kind, shape, etc. of the arguments, i.e. interface matching needs to be checked manually;
The default precision is equivalent to
c_intfor integers, andc_doublefor reals, they are defined in theIRA/src/ira_precision.f90module.
To link your Fortran or C target in CMake with libira, it suffices to add IRA project
into your CMakeLists.txt project by one of the following methods:
To include IRA as part of the build process of your program:
With
FetchContentas:# add IRA via FetchContent: include( FetchContent ) FetchContent_Declare( ira_git GIT_REPOSITORY https://github.com/mammasmias/IterativeRotationsAssignments.git GIT_TAG master GIT_SHALLOW 1 ) FetchContent_MakeAvailable( ira_git ) # link it to your target: target_link_libraries( your-target PRIVATE ira::ira )
With
add_subdirectory()as submodule as:# i.e. IRA is a submodule located in a directory 'path/to/IRA' add_subdirectory( path/to/IRA ) # link it to your target: target_link_libraries( your-target PRIVATE ira::ira )
To include an already-compiled IRA somewhere on your machine:
With
include()to locate the exported targets file. Note, IRA exports a config file during the build step, located in the binary/cmake/ira dir, and during install step located in the install/lib/cmake/ira dir.# using include() with the build directory: include( path-to-ira-build/cmake/ira/ira-BuildConfig.cmake ) # using include() with the install directory: include( path-to-ira-install/lib/cmake/ira/ira-config.cmake ) # link to your target: target_link_libraries( your-target PRIVATE ira::ira )
Or with
find_package()as:# using find_package() with the build directory: find_package( ira HINTS path-to-ira-build/cmake/ira NAMES ira-Build ) # using find_package() with the install directory: find_package( ira HINTS path-to-ira-install ) # link to your target: target_link_libraries( your-target PRIVATE ira::ira )
A program compiled with gcc or gfortran can easily link the IRA library, as-is, by linking either the shared
library libira.so, or the static version libira.a. They are both located in the lib/ directory after
compilation. The module files are located in include/.
Example for fortran program:
gfortran -o caller_program.x caller_program.f90 -L/your/path/to/IRA/lib/ -lira -Wl,-rpath,/your/path/to/IRA/lib
The C-headers are located in the IRA/interface directory, and can be included in compilation by -I/your/path/to/IRA/interface.
When linking the static library libira.a to a C-program, you need to add the math (-lm), and fortran (-lgfortran, or equivalent) to the compilation:
gcc -I/your/path/IRA/interface -o c_prog.x c_prog.c -L/your/path/to/IRA/src -lira -Wl,-rpath,/your/path/to/IRA/src -lm -lgfortran