leezu commented on a change in pull request #19174:
URL: https://github.com/apache/incubator-mxnet/pull/19174#discussion_r527974766
##########
File path: cmake/ChooseBlas.cmake
##########
@@ -45,6 +45,26 @@ elseif(BLAS STREQUAL "Open" OR BLAS STREQUAL "open")
add_definitions(-DMSHADOW_USE_CBLAS=1)
add_definitions(-DMSHADOW_USE_MKL=0)
add_definitions(-DMXNET_USE_BLAS_OPEN=1)
+ include(CheckCSourceCompiles)
+ find_package(OpenMP COMPONENTS C)
+ list(APPEND CMAKE_REQUIRED_INCLUDES ${OpenBLAS_INCLUDE_DIR})
+ list(APPEND CMAKE_REQUIRED_LIBRARIES ${OpenBLAS_LIB})
+ check_c_source_compiles(
+ "
+ #include <cblas.h>
+ int main(int argc, char **argv){
+ int n = 1;
+ float* A, B, C;
+ cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 1, 1, n, 1.0, A,
n, B, 1, 0.0, C, 1);
+ return 0;
+ }
+ "
+ OPENBLAS_NO_OMP
+ )
+ if(NOT OPENBLAS_NO_OMP)
+ message("Openblas uses OMP, automatically linking to it")
+ list(APPEND mshadow_LINKER_LIBS "${OpenMP_C_LIBRARIES}")
Review comment:
Should the find_package call be in the if condition?
```suggestion
list(APPEND CMAKE_REQUIRED_INCLUDES ${OpenBLAS_INCLUDE_DIR})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${OpenBLAS_LIB})
check_c_source_compiles(
"
#include <cblas.h>
int main(int argc, char **argv){
int n = 1;
float* A, B, C;
cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 1, 1, n, 1.0,
A, n, B, 1, 0.0, C, 1);
return 0;
}
"
OPENBLAS_NO_OMP
)
if(NOT OPENBLAS_NO_OMP)
message("Openblas uses OMP, automatically linking to it")
find_package(OpenMP REQUIRED COMPONENTS C)
list(APPEND mshadow_LINKER_LIBS "${OpenMP_C_LIBRARIES}")
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]