OpenMathLib / OpenBLAS

OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
http://www.openblas.net
BSD 3-Clause "New" or "Revised" License
6.38k stars 1.5k forks source link

Compiling using Homebrew clang on MacOS with CMake and USE_OPENMP #3333

Closed welchr closed 3 years ago

welchr commented 3 years ago

I have a bit of an odd setup here probably, but I'm compiling on MacOS using Homebrew's clang rather than the system clang due to lack of OpenMP support:

Homebrew clang version 12.0.0 Target: x86_64-apple-darwin19.6.0 Thread model: posix InstalledDir: /usr/local/opt/llvm/bin

I have OpenMP installed through Homebrew as well:

> file /usr/local/opt/libomp/lib/*
/usr/local/opt/libomp/lib/libomp.a:     current ar archive
/usr/local/opt/libomp/lib/libomp.dylib: Mach-O 64-bit dynamically linked shared library x86_64

To compile, I run:

#!/bin/bash
export MAKEFLAGS="-j4"
export CPPFLAGS="-I/usr/local/opt/libomp/include -I/usr/local/opt/llvm/include"
export LDFLAGS="-L/usr/local/opt/libomp/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
export CXX="/usr/local/opt/llvm/bin/clang++"
export CC="/usr/local/opt/llvm/bin/clang"

cmake .. -DUSE_OPENMP=1
make VERBOSE=1

I would end up with compile errors, saying it could not find some symbols related to OpenMP, until I added the following to OpenBLAS's CMakeLists.txt:

if (USE_OPENMP)
  find_package(OpenMP)
  if (OpenMP_FOUND)
    target_link_libraries(${OpenBLAS_LIBNAME} OpenMP::OpenMP_C)
  endif()
endif()

Then it compiled successfully, and all test cases passed (though I do not know if the test cases include OpenMP tests...)

Any idea if this is the correct approach here, or might there be another solution that doesn't involve modifying CMakeLists.txt directly?

brada4 commented 3 years ago

Here is another take at the problem tricking Xcode into supportinh -fopenmp: https://mac.r-project.org/openmp/ Tests do test threading in built library, namely those setting _NUM_THREADS variables.

martin-frbg commented 3 years ago

Not reproducible on Azure CI (though setting compiler via -DCMAKE_C_COMPILER and not messing with CPPFLAGS or LDFLAGS at all)

welchr commented 3 years ago

Thanks for looking into this, really appreciate the help. Your test case clued me in to -DNOFORTRAN=1, which seems to be related to the problem. If I include that, it will compile successfully, although it seems as though LAPACK is left out and only one test case is run when ctest is executed:

Test project /Users/welchr/scratch/OpenBLAS/build
    Start 1: openblas_utest
1/1 Test #1: openblas_utest ...................   Passed    0.18 sec

If I remove -DNOFORTRAN=1, then the compile fails with:

/usr/local/bin/gfortran -L/usr/local/opt/libomp/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib   -fopenmp -Wall -frecursive -fno-optimize-sibling-calls -m64 -fdefault-integer-8 -fopenmp -fPIC -fno-tree-vectorize -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk CMakeFiles/zblat2.dir/zblat2.f.o -o zblat2  ../lib/libopenblas_64.a
Undefined symbols for architecture x86_64:
  "___kmpc_for_static_fini", referenced from:
      _.omp_outlined. in libopenblas_64.a(blas_server_omp.c.o)
  "___kmpc_for_static_init_8", referenced from:
      _.omp_outlined. in libopenblas_64.a(blas_server_omp.c.o)
  "___kmpc_fork_call", referenced from:
      _exec_blas in libopenblas_64.a(blas_server_omp.c.o)
  "___kmpc_global_thread_num", referenced from:
      _exec_blas in libopenblas_64.a(blas_server_omp.c.o)
  "___kmpc_push_num_threads", referenced from:
      _exec_blas in libopenblas_64.a(blas_server_omp.c.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[2]: *** [test/zblat1] Error 1
make[1]: *** [test/CMakeFiles/zblat1.dir/all] Error 2

Now if I add back in the modification to CMakeLists.txt (see my first post above) and recompile, it will succeed:

/usr/local/bin/gfortran -L/usr/local/opt/libomp/lib -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib   -fopenmp -Wall -frecursive -fno-optimize-sibling-calls -m64 -fdefault-integer-8 -fopenmp -fPIC -fno-tree-vectorize -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk CMakeFiles/zblat2.dir/zblat2.f.o -o zblat2  ../lib/libopenblas_64.a /usr/local/opt/libomp/lib/libomp.dylib
[ 84%] Built target zblat2

And all the various test cases eventually pass as well:

Test results ```bash Test project /Users/welchr/scratch/OpenBLAS/build Start 1: openblas_utest 1/115 Test #1: openblas_utest .............................................................................. Passed 0.28 sec Start 2: sblas1 2/115 Test #2: sblas1 ...................................................................................... Passed 0.10 sec Start 3: sblas2 3/115 Test #3: sblas2 ...................................................................................... Passed 0.69 sec Start 4: sblas3 4/115 Test #4: sblas3 ...................................................................................... Passed 0.38 sec Start 5: dblas1 5/115 Test #5: dblas1 ...................................................................................... Passed 0.09 sec Start 6: dblas2 6/115 Test #6: dblas2 ...................................................................................... Passed 0.78 sec Start 7: dblas3 7/115 Test #7: dblas3 ...................................................................................... Passed 0.43 sec Start 8: cblas1 8/115 Test #8: cblas1 ...................................................................................... Passed 0.08 sec Start 9: cblas2 9/115 Test #9: cblas2 ...................................................................................... Passed 0.90 sec Start 10: cblas3 10/115 Test #10: cblas3 ...................................................................................... Passed 0.60 sec Start 11: zblas1 11/115 Test #11: zblas1 ...................................................................................... Passed 0.09 sec Start 12: zblas2 12/115 Test #12: zblas2 ...................................................................................... Passed 0.99 sec Start 13: zblas3 13/115 Test #13: zblas3 ...................................................................................... Passed 0.67 sec Start 14: xscblat1 14/115 Test #14: xscblat1 .................................................................................... Passed 0.09 sec Start 15: xscblat2 15/115 Test #15: xscblat2 .................................................................................... Passed 1.14 sec Start 16: xscblat3 16/115 Test #16: xscblat3 .................................................................................... Passed 1.39 sec Start 17: xdcblat1 17/115 Test #17: xdcblat1 .................................................................................... Passed 0.09 sec Start 18: xdcblat2 18/115 Test #18: xdcblat2 .................................................................................... Passed 1.54 sec Start 19: xdcblat3 19/115 Test #19: xdcblat3 .................................................................................... Passed 1.45 sec Start 20: xccblat1 20/115 Test #20: xccblat1 .................................................................................... Passed 0.10 sec Start 21: xccblat2 21/115 Test #21: xccblat2 .................................................................................... Passed 1.31 sec Start 22: xccblat3 22/115 Test #22: xccblat3 .................................................................................... Passed 0.24 sec Start 23: xzcblat1 23/115 Test #23: xzcblat1 .................................................................................... Passed 0.08 sec Start 24: xzcblat2 24/115 Test #24: xzcblat2 .................................................................................... Passed 1.53 sec Start 25: xzcblat3 25/115 Test #25: xzcblat3 .................................................................................... Passed 2.07 sec Start 26: REAL_LAPACK_linear_equation_routines 26/115 Test #26: REAL_LAPACK_linear_equation_routines ........................................................ Passed 7.12 sec Start 27: COMPLEX_LAPACK_linear_equation_routines 27/115 Test #27: COMPLEX_LAPACK_linear_equation_routines ..................................................... Passed 16.38 sec Start 28: DOUBLE_PRECISION_LAPACK_linear_equation_routines 28/115 Test #28: DOUBLE_PRECISION_LAPACK_linear_equation_routines ............................................ Passed 8.30 sec Start 29: COMPLEX16_LAPACK_linear_equation_routines 29/115 Test #29: COMPLEX16_LAPACK_linear_equation_routines ................................................... Passed 14.56 sec Start 30: SINGLE-DOUBLE_PRECISION_LAPACK_prototype_linear_equation_routines 30/115 Test #30: SINGLE-DOUBLE_PRECISION_LAPACK_prototype_linear_equation_routines ........................... Passed 0.87 sec Start 31: Testing_COMPLEX-COMPLEX16_LAPACK_prototype_linear_equation_routines 31/115 Test #31: Testing_COMPLEX-COMPLEX16_LAPACK_prototype_linear_equation_routines ......................... Passed 1.09 sec Start 32: Testing_REAL_LAPACK_RFP_prototype_linear_equation_routines 32/115 Test #32: Testing_REAL_LAPACK_RFP_prototype_linear_equation_routines .................................. Passed 0.56 sec Start 33: Testing_DOUBLE_PRECISION_LAPACK_RFP_prototype_linear_equation_routines 33/115 Test #33: Testing_DOUBLE_PRECISION_LAPACK_RFP_prototype_linear_equation_routines ...................... Passed 0.58 sec Start 34: Testing_COMPLEX_LAPACK_RFP_prototype_linear_equation_routines 34/115 Test #34: Testing_COMPLEX_LAPACK_RFP_prototype_linear_equation_routines ............................... Passed 1.31 sec Start 35: Testing_COMPLEX16_LAPACK_RFP_prototype_linear_equation_routines 35/115 Test #35: Testing_COMPLEX16_LAPACK_RFP_prototype_linear_equation_routines ............................. Passed 1.17 sec Start 36: SNEP:_Testing_Nonsymmetric_Eigenvalue_Problem_routines 36/115 Test #36: SNEP:_Testing_Nonsymmetric_Eigenvalue_Problem_routines ...................................... Passed 0.26 sec Start 37: SSEP:_Testing_Symmetric_Eigenvalue_Problem_routines 37/115 Test #37: SSEP:_Testing_Symmetric_Eigenvalue_Problem_routines ......................................... Passed 0.87 sec Start 38: SSE2:_Testing_Symmetric_Eigenvalue_Problem_routines 38/115 Test #38: SSE2:_Testing_Symmetric_Eigenvalue_Problem_routines ......................................... Passed 0.88 sec Start 39: SSVD:_Testing_Singular_Value_Decomposition_routines 39/115 Test #39: SSVD:_Testing_Singular_Value_Decomposition_routines ......................................... Passed 8.81 sec Start 40: SSEC:_Testing_REAL_Eigen_Condition_Routines 40/115 Test #40: SSEC:_Testing_REAL_Eigen_Condition_Routines ................................................. Passed 0.47 sec Start 41: SSEV:_Testing_REAL_Nonsymmetric_Eigenvalue_Driver 41/115 Test #41: SSEV:_Testing_REAL_Nonsymmetric_Eigenvalue_Driver ........................................... Passed 0.21 sec Start 42: SGG:_Testing_REAL_Nonsymmetric_Generalized_Eigenvalue_Problem_routines 42/115 Test #42: SGG:_Testing_REAL_Nonsymmetric_Generalized_Eigenvalue_Problem_routines ...................... Passed 0.08 sec Start 43: SGD:_Testing_REAL_Nonsymmetric_Generalized_Eigenvalue_Problem_driver_routines 43/115 Test #43: SGD:_Testing_REAL_Nonsymmetric_Generalized_Eigenvalue_Problem_driver_routines ............... Passed 0.33 sec Start 44: SSB:_Testing_REAL_Symmetric_Eigenvalue_Problem_routines 44/115 Test #44: SSB:_Testing_REAL_Symmetric_Eigenvalue_Problem_routines ..................................... Passed 0.06 sec Start 45: SSG:_Testing_REAL_Symmetric_Generalized_Eigenvalue_Problem_routines 45/115 Test #45: SSG:_Testing_REAL_Symmetric_Generalized_Eigenvalue_Problem_routines ......................... Passed 1.49 sec Start 46: SGEBAL:_Testing_the_balancing_of_a_REAL_general_matrix 46/115 Test #46: SGEBAL:_Testing_the_balancing_of_a_REAL_general_matrix ...................................... Passed 0.01 sec Start 47: SGEBAK:_Testing_the_back_transformation_of_a_REAL_balanced_matrix 47/115 Test #47: SGEBAK:_Testing_the_back_transformation_of_a_REAL_balanced_matrix ........................... Passed 0.01 sec Start 48: SGGBAL:_Testing_the_balancing_of_a_pair_of_REAL_general_matrices 48/115 Test #48: SGGBAL:_Testing_the_balancing_of_a_pair_of_REAL_general_matrices ............................ Passed 0.01 sec Start 49: SGGBAK:_Testing_the_back_transformation_of_a_pair_of_REAL_balanced_matrices 49/115 Test #49: SGGBAK:_Testing_the_back_transformation_of_a_pair_of_REAL_balanced_matrices ................. Passed 0.01 sec Start 50: SBB:_Testing_banded_Singular_Value_Decomposition_routines 50/115 Test #50: SBB:_Testing_banded_Singular_Value_Decomposition_routines ................................... Passed 0.05 sec Start 51: SGLM:_Testing_Generalized_Linear_Regression_Model_routines 51/115 Test #51: SGLM:_Testing_Generalized_Linear_Regression_Model_routines .................................. Passed 0.02 sec Start 52: SGQR:_Testing_Generalized_QR_and_RQ_factorization_routines 52/115 Test #52: SGQR:_Testing_Generalized_QR_and_RQ_factorization_routines .................................. Passed 0.03 sec Start 53: SGSV:_Testing_Generalized_Singular_Value_Decomposition_routines 53/115 Test #53: SGSV:_Testing_Generalized_Singular_Value_Decomposition_routines ............................. Passed 0.03 sec Start 54: SCSD:_Testing_CS_Decomposition_routines 54/115 Test #54: SCSD:_Testing_CS_Decomposition_routines ..................................................... Passed 0.02 sec Start 55: SLSE:_Testing_Constrained_Linear_Least_Squares_routines 55/115 Test #55: SLSE:_Testing_Constrained_Linear_Least_Squares_routines ..................................... Passed 0.02 sec Start 56: CNEP:_Testing_Nonsymmetric_Eigenvalue_Problem_routines 56/115 Test #56: CNEP:_Testing_Nonsymmetric_Eigenvalue_Problem_routines ...................................... Passed 0.33 sec Start 57: CSEP:_Testing_Symmetric_Eigenvalue_Problem_routines 57/115 Test #57: CSEP:_Testing_Symmetric_Eigenvalue_Problem_routines ......................................... Passed 0.98 sec Start 58: CSE2:_Testing_Symmetric_Eigenvalue_Problem_routines 58/115 Test #58: CSE2:_Testing_Symmetric_Eigenvalue_Problem_routines ......................................... Passed 0.35 sec Start 59: CSVD:_Testing_Singular_Value_Decomposition_routines 59/115 Test #59: CSVD:_Testing_Singular_Value_Decomposition_routines ......................................... Passed 12.65 sec Start 60: CEC:_Testing_COMPLEX_Eigen_Condition_Routines 60/115 Test #60: CEC:_Testing_COMPLEX_Eigen_Condition_Routines ............................................... Passed 0.06 sec Start 61: CES:_Testing_COMPLEX_Nonsymmetric_Schur_Form_Driver 61/115 Test #61: CES:_Testing_COMPLEX_Nonsymmetric_Schur_Form_Driver ......................................... Passed 0.30 sec Start 62: CGG:_Testing_COMPLEX_Nonsymmetric_Generalized_Eigenvalue_Problem_routines 62/115 Test #62: CGG:_Testing_COMPLEX_Nonsymmetric_Generalized_Eigenvalue_Problem_routines ................... Passed 0.14 sec Start 63: CGD:_Testing_COMPLEX_Nonsymmetric_Generalized_Eigenvalue_Problem_driver_routines 63/115 Test #63: CGD:_Testing_COMPLEX_Nonsymmetric_Generalized_Eigenvalue_Problem_driver_routines ............ Passed 0.44 sec Start 64: CHB:_Testing_Hermitian_Eigenvalue_Problem_routines 64/115 Test #64: CHB:_Testing_Hermitian_Eigenvalue_Problem_routines .......................................... Passed 0.07 sec Start 65: CSG:_Testing_Symmetric_Generalized_Eigenvalue_Problem_routines 65/115 Test #65: CSG:_Testing_Symmetric_Generalized_Eigenvalue_Problem_routines .............................. Passed 0.89 sec Start 66: CGEBAL:_Testing_the_balancing_of_a_COMPLEX_general_matrix 66/115 Test #66: CGEBAL:_Testing_the_balancing_of_a_COMPLEX_general_matrix ................................... Passed 0.02 sec Start 67: CGEBAK:_Testing_the_back_transformation_of_a_COMPLEX_balanced_matrix 67/115 Test #67: CGEBAK:_Testing_the_back_transformation_of_a_COMPLEX_balanced_matrix ........................ Passed 0.02 sec Start 68: CGGBAL:_Testing_the_balancing_of_a_pair_of_COMPLEX_general_matrices 68/115 Test #68: CGGBAL:_Testing_the_balancing_of_a_pair_of_COMPLEX_general_matrices ......................... Passed 0.02 sec Start 69: CGGBAK:_Testing_the_back_transformation_of_a_pair_of_COMPLEX_balanced_matrices 69/115 Test #69: CGGBAK:_Testing_the_back_transformation_of_a_pair_of_COMPLEX_balanced_matrices .............. Passed 0.02 sec Start 70: CBB:_Testing_banded_Singular_Value_Decomposition_routines 70/115 Test #70: CBB:_Testing_banded_Singular_Value_Decomposition_routines ................................... Passed 0.06 sec Start 71: CGLM:_Testing_Generalized_Linear_Regression_Model_routines 71/115 Test #71: CGLM:_Testing_Generalized_Linear_Regression_Model_routines .................................. Passed 0.03 sec Start 72: CGQR:_Testing_Generalized_QR_and_RQ_factorization_routines 72/115 Test #72: CGQR:_Testing_Generalized_QR_and_RQ_factorization_routines .................................. Passed 0.05 sec Start 73: CGSV:_Testing_Generalized_Singular_Value_Decomposition_routines 73/115 Test #73: CGSV:_Testing_Generalized_Singular_Value_Decomposition_routines ............................. Passed 0.04 sec Start 74: CCSD:_Testing_CS_Decomposition_routines 74/115 Test #74: CCSD:_Testing_CS_Decomposition_routines ..................................................... Passed 0.03 sec Start 75: CLSE:_Testing_Constrained_Linear_Least_Squares_routines 75/115 Test #75: CLSE:_Testing_Constrained_Linear_Least_Squares_routines ..................................... Passed 0.02 sec Start 76: DNEP:_Testing_Nonsymmetric_Eigenvalue_Problem_routines 76/115 Test #76: DNEP:_Testing_Nonsymmetric_Eigenvalue_Problem_routines ...................................... Passed 0.27 sec Start 77: DSEP:_Testing_Symmetric_Eigenvalue_Problem_routines 77/115 Test #77: DSEP:_Testing_Symmetric_Eigenvalue_Problem_routines ......................................... Passed 0.90 sec Start 78: DSE2:_Testing_Symmetric_Eigenvalue_Problem_routines 78/115 Test #78: DSE2:_Testing_Symmetric_Eigenvalue_Problem_routines ......................................... Passed 0.54 sec Start 79: DSVD:_Testing_Singular_Value_Decomposition_routines 79/115 Test #79: DSVD:_Testing_Singular_Value_Decomposition_routines ......................................... Passed 10.84 sec Start 80: DEC:_Testing_DOUBLE_PRECISION_Eigen_Condition_Routines 80/115 Test #80: DEC:_Testing_DOUBLE_PRECISION_Eigen_Condition_Routines ...................................... Passed 0.40 sec Start 81: DEV:_Testing_DOUBLE_PRECISION_Nonsymmetric_Eigenvalue_Driver 81/115 Test #81: DEV:_Testing_DOUBLE_PRECISION_Nonsymmetric_Eigenvalue_Driver ................................ Passed 0.24 sec Start 82: DGG:_Testing_DOUBLE_PRECISION_Nonsymmetric_Generalized_Eigenvalue_Problem_routines 82/115 Test #82: DGG:_Testing_DOUBLE_PRECISION_Nonsymmetric_Generalized_Eigenvalue_Problem_routines .......... Passed 0.09 sec Start 83: DGD:_Testing_DOUBLE_PRECISION_Nonsymmetric_Generalized_Eigenvalue_Problem_driver_routines 83/115 Test #83: DGD:_Testing_DOUBLE_PRECISION_Nonsymmetric_Generalized_Eigenvalue_Problem_driver_routines ... Passed 0.42 sec Start 84: DSB:_Testing_DOUBLE_PRECISION_Symmetric_Eigenvalue_Problem_routines 84/115 Test #84: DSB:_Testing_DOUBLE_PRECISION_Symmetric_Eigenvalue_Problem_routines ......................... Passed 0.05 sec Start 85: DSG:_Testing_DOUBLE_PRECISION_Symmetric_Generalized_Eigenvalue_Problem_routines 85/115 Test #85: DSG:_Testing_DOUBLE_PRECISION_Symmetric_Generalized_Eigenvalue_Problem_routines ............. Passed 0.65 sec Start 86: DGEBAL:_Testing_the_balancing_of_a_DOUBLE_PRECISION_general_matrix 86/115 Test #86: DGEBAL:_Testing_the_balancing_of_a_DOUBLE_PRECISION_general_matrix .......................... Passed 0.02 sec Start 87: DGEBAK:_Testing_the_back_transformation_of_a_DOUBLE_PRECISION_balanced_matrix 87/115 Test #87: DGEBAK:_Testing_the_back_transformation_of_a_DOUBLE_PRECISION_balanced_matrix ............... Passed 0.01 sec Start 88: DGGBAL:_Testing_the_balancing_of_a_pair_of_DOUBLE_PRECISION_general_matrices 88/115 Test #88: DGGBAL:_Testing_the_balancing_of_a_pair_of_DOUBLE_PRECISION_general_matrices ................ Passed 0.02 sec Start 89: DGGBAK:_Testing_the_back_transformation_of_a_pair_of_DOUBLE_PRECISION_balanced_matrices 89/115 Test #89: DGGBAK:_Testing_the_back_transformation_of_a_pair_of_DOUBLE_PRECISION_balanced_matrices ..... Passed 0.02 sec Start 90: DBB:_Testing_banded_Singular_Value_Decomposition_routines 90/115 Test #90: DBB:_Testing_banded_Singular_Value_Decomposition_routines ................................... Passed 0.05 sec Start 91: DGLM:_Testing_Generalized_Linear_Regression_Model_routines 91/115 Test #91: DGLM:_Testing_Generalized_Linear_Regression_Model_routines .................................. Passed 0.02 sec Start 92: DGQR:_Testing_Generalized_QR_and_RQ_factorization_routines 92/115 Test #92: DGQR:_Testing_Generalized_QR_and_RQ_factorization_routines .................................. Passed 0.03 sec Start 93: DGSV:_Testing_Generalized_Singular_Value_Decomposition_routines 93/115 Test #93: DGSV:_Testing_Generalized_Singular_Value_Decomposition_routines ............................. Passed 0.03 sec Start 94: DCSD:_Testing_CS_Decomposition_routines 94/115 Test #94: DCSD:_Testing_CS_Decomposition_routines ..................................................... Passed 0.02 sec Start 95: DLSE:_Testing_Constrained_Linear_Least_Squares_routines 95/115 Test #95: DLSE:_Testing_Constrained_Linear_Least_Squares_routines ..................................... Passed 0.02 sec Start 96: ZNEP:_Testing_Nonsymmetric_Eigenvalue_Problem_routines 96/115 Test #96: ZNEP:_Testing_Nonsymmetric_Eigenvalue_Problem_routines ...................................... Passed 0.36 sec Start 97: ZSEP:_Testing_Symmetric_Eigenvalue_Problem_routines 97/115 Test #97: ZSEP:_Testing_Symmetric_Eigenvalue_Problem_routines ......................................... Passed 1.21 sec Start 98: ZSE2:_Testing_Symmetric_Eigenvalue_Problem_routines 98/115 Test #98: ZSE2:_Testing_Symmetric_Eigenvalue_Problem_routines ......................................... Passed 0.44 sec Start 99: ZSVD:_Testing_Singular_Value_Decomposition_routines 99/115 Test #99: ZSVD:_Testing_Singular_Value_Decomposition_routines ......................................... Passed 16.93 sec Start 100: ZEC:_Testing_COMPLEX16_Eigen_Condition_Routines 100/115 Test #100: ZEC:_Testing_COMPLEX16_Eigen_Condition_Routines ............................................. Passed 0.06 sec Start 101: ZES:_Testing_COMPLEX16_Nonsymmetric_Schur_Form_Driver 101/115 Test #101: ZES:_Testing_COMPLEX16_Nonsymmetric_Schur_Form_Driver ....................................... Passed 0.35 sec Start 102: ZGG:_Testing_COMPLEX16_Nonsymmetric_Generalized_Eigenvalue_Problem_routines 102/115 Test #102: ZGG:_Testing_COMPLEX16_Nonsymmetric_Generalized_Eigenvalue_Problem_routines ................. Passed 0.16 sec Start 103: ZGD:_Testing_COMPLEX16_Nonsymmetric_Generalized_Eigenvalue_Problem_driver_routines 103/115 Test #103: ZGD:_Testing_COMPLEX16_Nonsymmetric_Generalized_Eigenvalue_Problem_driver_routines .......... Passed 0.51 sec Start 104: ZHB:_Testing_Hermitian_Eigenvalue_Problem_routines 104/115 Test #104: ZHB:_Testing_Hermitian_Eigenvalue_Problem_routines .......................................... Passed 0.08 sec Start 105: ZSG:_Testing_Symmetric_Generalized_Eigenvalue_Problem_routines 105/115 Test #105: ZSG:_Testing_Symmetric_Generalized_Eigenvalue_Problem_routines .............................. Passed 2.03 sec Start 106: ZGEBAL:_Testing_the_balancing_of_a_COMPLEX16_general_matrix 106/115 Test #106: ZGEBAL:_Testing_the_balancing_of_a_COMPLEX16_general_matrix ................................. Passed 0.02 sec Start 107: ZGEBAK:_Testing_the_back_transformation_of_a_COMPLEX16_balanced_matrix 107/115 Test #107: ZGEBAK:_Testing_the_back_transformation_of_a_COMPLEX16_balanced_matrix ...................... Passed 0.02 sec Start 108: ZGGBAL:_Testing_the_balancing_of_a_pair_of_COMPLEX_general_matrices 108/115 Test #108: ZGGBAL:_Testing_the_balancing_of_a_pair_of_COMPLEX_general_matrices ......................... Passed 0.02 sec Start 109: ZGGBAK:_Testing_the_back_transformation_of_a_pair_of_COMPLEX16_balanced_matrices 109/115 Test #109: ZGGBAK:_Testing_the_back_transformation_of_a_pair_of_COMPLEX16_balanced_matrices ............ Passed 0.02 sec Start 110: ZBB:_Testing_banded_Singular_Value_Decomposition_routines 110/115 Test #110: ZBB:_Testing_banded_Singular_Value_Decomposition_routines ................................... Passed 0.07 sec Start 111: ZGLM:_Testing_Generalized_Linear_Regression_Model_routines 111/115 Test #111: ZGLM:_Testing_Generalized_Linear_Regression_Model_routines .................................. Passed 0.03 sec Start 112: ZGQR:_Testing_Generalized_QR_and_RQ_factorization_routines 112/115 Test #112: ZGQR:_Testing_Generalized_QR_and_RQ_factorization_routines .................................. Passed 0.05 sec Start 113: ZGSV:_Testing_Generalized_Singular_Value_Decomposition_routines 113/115 Test #113: ZGSV:_Testing_Generalized_Singular_Value_Decomposition_routines ............................. Passed 0.05 sec Start 114: ZCSD:_Testing_CS_Decomposition_routines 114/115 Test #114: ZCSD:_Testing_CS_Decomposition_routines ..................................................... Passed 0.03 sec Start 115: Constrained_Linear_Least_Squares_routines 115/115 Test #115: Constrained_Linear_Least_Squares_routines ................................................... Passed 0.02 sec ```

Right at the end of the command there it seems to be including /usr/local/opt/libomp/lib/libomp.dylib and that might be solving the issue.

I also saw this in the Makefile, where -lomp gets tacked on if using clang and gfortran while using -DUSE_OPENMP=1:

https://github.com/xianyi/OpenBLAS/blob/cbc583eb54647f4fcaa4f0bf3a131d76d8d9c5a3/Makefile#L277-L278

I wonder if my CMake change ends up achieving a similar result, where instead of -lomp it is just adding /usr/local/opt/libomp/lib/libomp.dylib directly to the command line.

carlocab commented 3 years ago

Note that the llvm formula includes libomp at $(brew --prefix llvm)/lib/libomp.dylib. It may not be the cause of your problems, but it's probably not great for the compiler to have to choose between two different versions of libomp (and might be what necessitates your having to specify /usr/local/opt/libomp/lib/libomp.dylib).

I believe the libomp formula should also work with the Apple Clang -- that's what it's built and tested with.

Lewiscowles1986 commented 1 year ago

All I had to do was:

export LIBRARY_PATH="$LIBRARY_PATH:$(brew --prefix)/lib"

Mac M1 SDL2 was the culprit, installed via homebrew; which was not in my library path it seems

I did also ensure the LIBRARY_PATH was not empty before running the above command.

[[ -z "${LIBRARY_PATH}" ]] && export LIBRARY_PATH=/usr/local/lib

This might be aesthetic (I'm not sure); but it does prevent unset LIBRARY_PATH materialising :/opt/homebrew/lib vs /opt/homebrew/lib