5

I am facing a weird 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 as expected. The issue is that, the version of MOSEK that I'm using is multi-threaded (MOSEK 7.1). MOSEK is supposed to detect the number of cores on the machine, and use all of them. When I use the Makefile as is, MOSEK only detects one core, and uses only one thread:

Computer
  Platform               : Linux/64-X86    
  Cores                  : 1              

However, when i compile without $(LIBS), MOSEK does detect 4 cores:

Computer
  Platform               : Linux/64-X86    
  Cores                  : 4               

The code that I have in lo1.c does not use $(LIBS) for now, but I will need those libraries later on, in lo1.c. How come those libraries are affecting the behavior of MOSEK?

Thank you.

  • Have you tried to find out *which* library is causing this? (Binary search through the list, etc.) – Etan Reisner Jan 13 '16 at 17:11
  • @EtanReisner It seems that the problem is with umfpack and the libraries that come after it, but not in any particular one. I had to remove all of them for it to work. Even letting "$(LIBS) = -umfpack " only didn't work. – Mohammad Fawaz Jan 13 '16 at 17:30
  • So using boost is ok but using any of the libraries from umfpack to the end (even one at a time) breaks this? Or does only umfpack break it? – Etan Reisner Jan 13 '16 at 17:37
  • @EtanReisner So I tried adding the libraries separately, one at a time, and it seems that the problematic ones are umfpack, lapack, and blas. – Mohammad Fawaz Jan 13 '16 at 17:46
  • It might make sense to see if those libraries have communities you can ask about this? And or see is MOSEK does. Someone here will likely have ideas about this but whether they see this question or not is the real question. I don't know anything about any of these pieces so I can't really help anymore, sorry. – Etan Reisner Jan 13 '16 at 17:50
  • @EtanReisner Thank you anyways. – Mohammad Fawaz Jan 13 '16 at 19:37

1 Answers1

1

It turns out that the problem was with BLAS. Some of the libraries from SuiteSparse require BLAS and the BLAS libraries on the server messes up with OpenMP, which is apparently required by MOSEK to parallelize its code. In any case, the solution was to use OpenBLAS, compiled with the flag "USE_OPENMP=1".