Skip to content

GraphBLAS

Gabor Szarnyas edited this page Mar 28, 2023 · 25 revisions

Compilation

Instructions for using SuiteSparse:GraphBLAS.

Compiling GraphBLAS

Install the following dependencies:

sudo dnf install -y gcc cmake m4

Run:

cd build
cmake ..
make -j`nproc`

SuiteSparse:GraphBLAS development builds

SuiteSparse:GraphBLAS has a number of compiler flags and macros for development builds. Guidelines:

  • When the code is simple and the resources available for building the code (CPU cores, time) are scarce (such as in CI or during hands-on tutorials), use compact mode.
  • When optimizing your GraphBLAS code, use the burble to mode to pinpoint performance bottlenecks.
  • When benchmarking, make sure you turn off the compact/debug/burble modes (which is their default setting).

Compact mode

The GBCOMPACT flag allows quick compilation as it avoids compiling the ~1500 pre-defined semirings.

cd build && cmake -DGBCOMPACT=1 .. && make -j$(nproc)

Debug mode

Debug mode can be activated in Source/GB.h by uncommenting the #define GB_DEBUG line. This mode adds assertions to test invariants, which (unsurprisingly) make the code much slower.

Burble mode

Burble modes provides a detailed output of the operation performed (e.g. which matrix multiplication algorithm is used).

  • Compile-time:

    • In v3.x, edit the CMakeLists.txt file, comment the set ( GB_BURBLE false ) line and uncomment the set ( GB_BURBLE true ) line.

    • Set the GB_BURBLE configuration to 1:

      cd build && cmake -DGB_BURBLE=1 .. && make -j$(nproc)
  • Runtime: the burble mode has to be activated from code after GrB_init():

    • In C, use:

      GxB_set(GxB_BURBLE, true);
    • In C++, use:

      GxB_Global_Option_set(GxB_BURBLE, true);

GCC

Troubleshooting

  • Problem:

    make[3]: *** No rule to make target '/usr/lib/gcc/x86_64-linux-gnu/8/libgomp.so', needed by 'libgraphblas.so.3.0.1'. Stop.
  • Solution: clean the directory and start over with cmake . && make.

ICC

  1. Download the Intel System Studio and get a license.

  2. Configure the silent.cfg file to point to your license and run:

    sudo ./install.sh  -s silent.cfg.
  3. Specify the location of the compiler components:

    . /opt/intel/system_studio_2019/bin/compilervars.sh -arch intel64
    
  4. On my configuration, the compilervars_arch.sh script wasn't readable by the user, so I fixed that using:

    $ chmod 755 /opt/intel/system_studio_2019/compilers_and_libraries_2019/linux/pkg_bin/compilervars_arch.sh
  5. Build GraphBLAS with the following command:

    $ make CC=icc JOBS=$(nproc)
  6. Install GraphBLAS and run the ldconfig tool:

    $ sudo make install
    $ sudo ldconfig

Troubleshooting

  • Problem: Compiling GraphBLAS gives the following error:

    -- The C compiler identification is Intel 19.0.5.20190815
    -- The CXX compiler identification is GNU 7.4.0
    ...
    [ 99%] Linking C executable pthread_demo
    ld: warning: libimf.so, needed by libgraphblasdemo.so, not found (try using -rpath or -rpath-link)
    ld: warning: libsvml.so, needed by libgraphblasdemo.so, not found (try using -rpath or -rpath-link)
    ld: warning: libirng.so, needed by libgraphblasdemo.so, not found (try using -rpath or -rpath-link)
    ld: warning: libintlc.so.5, needed by libgraphblasdemo.so, not found (try using -rpath or -rpath-link)
    ld: pthread_demo: hidden symbol `__intel_cpu_features_init_x' in /opt/intel/system_studio_2019/compilers_and_libraries_2019.5.281/linux/compiler/lib/intel64_lin/libirc.a(cpu_feature_disp.o) is referenced by DSO
    ld: final link failed: Bad value
    CMakeFiles/pthread_demo.dir/build.make:89: recipe for target 'pthread_demo' failed
  • Solution: Just follow the steps above.

How to determine which SuiteSparse version is running

C:

char *date, *compile_date, *compile_time ;
int version [3] ;
GxB_Global_Option_get (GxB_LIBRARY_VERSION, version) ;
GxB_Global_Option_get (GxB_LIBRARY_DATE, &date) ;
GxB_Global_Option_get (GxB_LIBRARY_COMPILE_DATE, &compile_date) ;
GxB_Global_Option_get (GxB_LIBRARY_COMPILE_TIME, &compile_time) ;
fprintf (stderr, "Library version %d.%d.%d\n", version [0], version [1], version [2]) ;
fprintf (stderr, "Library date: %s\n", date) ;
fprintf (stderr, "Compiled at %s on %s\n", compile_time, compile_date) ;

(source)

Bash:

grep -C 5 "define GxB_IMPLEMENTATION_DATE" $(find /usr -name GraphBLAS.h 2>/dev/null) /dev/null

Change between versions

Applies for Fedora with the default setup, might need adjustments on other systems.

Change GraphBLAS version

To change to v3.x, run:

sudo unlink /usr/local/lib64/libgraphblas.so
sudo ln -s /usr/local/lib64/libgraphblas.so.3 /usr/local/lib64/libgraphblas.so

To change to v4.x, run:

sudo unlink /usr/local/lib64/libgraphblas.so
sudo ln -s /usr/local/lib64/libgraphblas.so.4 /usr/local/lib64/libgraphblas.so

Change LAGraph version

If you use LAGraph, also change its version with a similar approach.

LAGRAPH_VERSION_NEW=0.2.0
sudo unlink /usr/local/lib64/libgraphblas.so
sudo ln -s /usr/local/lib64/libgraphblas.so.${LAGRAPH_VERSION_NEW} /usr/local/lib64/libgraphblas.so

cannot open shared object file on Fedora

On Fedora, it can happen that GraphBLAS displays the following error message:

error while loading shared libraries: libgraphblas.so.7: cannot open shared object file: No such file or directory

This occurs despite having run the sudo ldconfig command.

The workaround is to set/adjust the LD_LIBRARY_PATH environment variable and run ldconfig again:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib64
sudo ldconfig
Clone this wiki locally