简体   繁体   English

影响Makefile中其他库的库

[英]Libraries affecting other libraries in a Makefile

I am facing a weird problem in the following Makefile: 我在以下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 . 我从MOSEK提供的示例中获得了大部分内容。 The Makefile works fine and the results are as expected. Makefile工作正常,结果如预期。 The issue is that, the version of MOSEK that I'm using is multi-threaded (MOSEK 7.1). 问题是,我使用的MOSEK版本是多线程的(MOSEK 7.1)。 MOSEK is supposed to detect the number of cores on the machine, and use all of them. MOSEK应该检测机器上的核心数量,并使用它们。 When I use the Makefile as is, MOSEK only detects one core, and uses only one thread: 当我按原样使用Makefile时,MOSEK只检测一个核心,并且只使用一个线程:

Computer
  Platform               : Linux/64-X86    
  Cores                  : 1              

However, when i compile without $(LIBS), MOSEK does detect 4 cores: 但是,当我编译没有$(LIBS)时,MOSEK确实检测到4个核心:

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. 我在lo1.c中的代码现在不使用$(LIBS),但是稍后我会在lo1.c中使用这些库。 How come those libraries are affecting the behavior of MOSEK? 那些图书馆怎么会影响MOSEK的行为呢?

Thank you. 谢谢。

It turns out that the problem was with BLAS. 事实证明问题出在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. SuiteSparse中的一些库需要BLAS和服务器上的BLAS库与OpenMP混淆,这显然是MOSEK要求并行化其代码。 In any case, the solution was to use OpenBLAS, compiled with the flag "USE_OPENMP=1". 在任何情况下,解决方案是使用OpenBLAS,使用标志“USE_OPENMP = 1”编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM