5

我在以下 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 

我从MOSEK提供的示例中获得了大部分内容。Makefile 工作正常,结果符合预期。问题是,我使用的 MOSEK 版本是多线程的(MOSEK 7.1)。MOSEK 应该检测机器上的核心数量,并使用它们。当我按原样使用 Makefile 时,MOSEK 只检测到一个内核,并且只使用一个线程:

Computer
  Platform               : Linux/64-X86    
  Cores                  : 1              

但是,当我在没有 $(LIBS) 的情况下编译时,MOSEK 确实检测到 4 个内核:

Computer
  Platform               : Linux/64-X86    
  Cores                  : 4               

我在 lo1.c 中的代码暂时不使用 $(LIBS),但我稍后会在 lo1.c 中使用这些库。这些库是如何影响 MOSEK 的行为的?

谢谢你。

4

1 回答 1

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".

于 2016-04-18T20:35:39.953 回答