Compiling procedure for Multi Threads SPOOLES version:

Nowadays most computers have one socket with several cores, allowing for the calculations to be performed in a parallel way.
CalculiX supports the multithreaded solve option of the spooles sparse solver.
To use the multi-threaded version of SPOOLES create the spoolesMT.a library.
There are two ways to create multithreaded version of SPOOLES:

  • a separate library solely for managing multithreading,
  • a new library that includes multithreading functionality within the main SPOOLES library.
For the first method, navigate to the MT/src folder of SPOOLES and simply type make:

bash
cd /usr/local/SPOOLES.2.2/MT/src
make
cd ../..

Verify the presence of the spoolesMT.a library:

bash
ls -l MT/src/*.a

the output should be:

bash
-rw-r--r-- 1 root root 72156 Dec 23  2021 MT/src/spoolesMT.a

For the second method, in the SPOOLES base folder, modify the makefile by uncommenting the last line and changing the library name in the makeLib file as follows:

bash
sed -i 's|#cd MT/src             ; make -f makeGlobalLib|	cd MT/src             ; make -f makeGlobalLib|' makefile
sed -i 's|../../spooles.a|../../spoolesMT.a|' makeLib

Compiling procedure for CalculiX:

Navigate to the CalculiX source folder:

bash
cd CalculiX/ccx_2.22/src/

Starting with CalculiX Version 2.0 an extra Makefile is included with name Makefile_MT, which takes care of enabling usage of multithreaded version of SPOOLES.
The necessary changes compared to the standard Makefile are highlighted in orange:

Makefile
CFLAGS = -Wall -O3 -fopenmp -I ../../../SPOOLES.2.2 -DARCH="Linux" -DSPOOLES -DARPACK -DMATRIXSTORAGE -DUSE_MT=1
FFLAGS = -Wall -O3 -fopenmp

CC=cc
FC=gfortran

.c.o :
$(CC) $(CFLAGS) -c $<
.f.o :
$(FC) $(FFLAGS) -c $<

include Makefile.inc

SCCXMAIN = ccx_2.22.c

OCCXF = $(SCCXF:.f=.o)
OCCXC = $(SCCXC:.c=.o)
OCCXMAIN = $(SCCXMAIN:.c=.o)

DIR=../../../SPOOLES.2.2

LIBS = \
$(DIR)/MT/src/spoolesMT.a \
$(DIR)/spooles.a \
../../../ARPACK/libarpack_INTEL.a \
-lpthread -lm

ccx_2.22_MT: $(OCCXMAIN) ccx_2.22.a $(LIBS)
./date.pl; $(CC) $(CFLAGS) -c ccx_2.22.c; $(FC) -fopenmp -Wall -O3 -o $@ $(OCCXMAIN) ccx_2.22.a $(LIBS)

ccx_2.22.a: $(OCCXF) $(OCCXC)
ar vr $@ $?

In case you choose the second method, define the LIBS variable as:

Makefile
LIBS = \
$(DIR)/spoolesMT.a \
../../../ARPACK/libarpack_INTEL.a \
-lpthread -lm

To start the compilation process, simply type:

bash
make -j 4

After a while the CalculiX ccx_2.22_MT executable will be created:

bash
ls -l ccx_2.22*

Clean up the source folder and move the executable to a user-accessible bin folder, such as:

bash
rm *.o *.a
mv ccx_2.22_MT /usr/local/bin/
Back to CalculiX compiling procedure