Libraries affecting other libraries in the Makefile

I had a strange problem in the following Makefile:

# Mosek path MOSEKPATH = /autofs/fs1.ece/fs1.eecg.najm/b/b1/power_grid_code/mosek # Include paths INCPATHS = -I$(MOSEKPATH)/7/tools/platform/linux64x86/h -I/usr/include/suitesparse -I../include # Libraries paths LIBPATHS = -L$(MOSEKPATH)/7/tools/platform/linux64x86/bin # Link libraries LIBS = -lboost_timer-mt -lboost_system -lumfpack -lamd -lcolamd -lcholmod -lccolamd -lcamd -lbtf -lcsparse -lcxsparse -lklu -lldl -lspqr -llapack -lblas MOSEKLIB = -lmosek64 LDOPT = -Wl,-rpath-link,$(MOSEKPATH)/7/tools/platform/linux64x86/bin -Wl,-rpath,'/autofs/fs1.ece/fs1.eecg.najm/b/b1/power_grid_code/mosek/7/tools/platform/linux64x86/bin' -pthread -lc -lm # Specify compiler CC = g++-4.7 -m64 # Compiler flags FLAGS = -O3 -Wall -g lo1: lo1.c $(CC) $(FLAGS) -c $(INCPATHS) -o lo1.o lo1.c $(CC) $(FLAGS) $(LIBPATHS) lo1.o $(LIBS) $(MOSEKLIB) $(LDOPT) -o lo1 clean: rm -f lo1 *.o 

I got most of the content from the examples provided by MOSEK . The Makefile works fine and the results are expected. The problem is that the version of MOSEK that I use has multi-threading (MOSEK 7.1). MOSEK must determine the number of cores on the machine and use all of them. When I use the Makefile as is, MOSEK detects only one core and uses only one thread:

 Computer Platform : Linux/64-X86 Cores : 1 

However, when I compile without $ (LIBS), MOSEK detects 4 cores:

 Computer Platform : Linux/64-X86 Cores : 4 

The code I have in lo1.c does not yet use $ (LIBS), but I will need these libraries later in lo1.c. Why do these libraries influence the behavior of MOSEK?

Thanks.

+5
source share
1 answer

Turns out the problem was in BLAS. Some libraries from SuiteSparse require BLAS, and the BLAS libraries on the server are corrupted using OpenMP, which MOSEK apparently requires to parallelize its code. In any case, the solution was to use OpenBLAS compiled with the flag "USE_OPENMP = 1".

0
source

Source: https://habr.com/ru/post/1240549/


All Articles