Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single precision on MacOS #155

Open
TobiasDuswald opened this issue Sep 13, 2024 · 7 comments
Open

Single precision on MacOS #155

TobiasDuswald opened this issue Sep 13, 2024 · 7 comments

Comments

@TobiasDuswald
Copy link

I tried installing and testing superlu (v7.0.0) by running the following commands:

git clone https://github.com/xiaoyeli/superlu.git
cd superlu
mkdir build
cd build
cmake ..
make -j
make test

The tests failed for single precision and complex single precision failed:

The following tests FAILED:
	  1 - s_test_9_2_0_LA (Failed)
	  2 - s_test_19_2_0_LA (Failed)
	  3 - s_test_2_0_SP (Failed)
	  4 - s_test_9_2_10000000_LA (Failed)
	  5 - s_test_19_2_10000000_LA (Failed)
	  6 - s_test_2_10000000_SP (Failed)
	 13 - c_test_9_2_0_LA (Failed)
	 14 - c_test_19_2_0_LA (Failed)
	 15 - c_test_2_0_SP (Failed)
	 16 - c_test_9_2_10000000_LA (Failed)
	 17 - c_test_19_2_10000000_LA (Failed)
	 18 - c_test_2_10000000_SP (Failed)
Errors while running CTest

I suppose that this is related to the cmake output

-- The C compiler identification is AppleClang 15.0.0.15000309
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- SuperLU will be built as a static library.
-- Looking for sgemm_
-- Looking for sgemm_ - not found                  <-------------------- here
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Looking for dgemm_
-- Looking for dgemm_ - found
-- Found BLAS: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks/Accelerate.framework
-- Using TPL_BLAS_LIBRARIES='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks/Accelerate.framework'
-- Will not link with METIS.
-- Configuring done (1.3s)
-- Generating done (0.6s)
-- Build files have been written to: /Users/tobiasduswald/Software/superlu/build

I also attach all logs (make , cmake, ctest). Is there a simple fix to get this running?
make.log
test.log
cmake.log

@TobiasDuswald
Copy link
Author

MacOS 14.5, Xcode 15.4

@TobiasDuswald
Copy link
Author

TobiasDuswald commented Sep 13, 2024

I tried to get rid of this the warning in Cmake by adding a case for macOS to sluCnames.h but the failing tests persisted. I ran the tests in debug mode and the address sanitizer complained for the respective tests. The log is from macOS 14.5, Xcode 15.4, with cmake -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_C_FLAGS="-fsanitize=address -fsanitize=undefined -glldb" .. . Commit v7.0.0.
test-debugbuild.log

@xiaoyeli
Copy link
Owner

Can you try using internal BLAS first, with the following cmake definition:
-Denable_internal_blaslib=ON

@TobiasDuswald
Copy link
Author

Compiling the project with cmake -Denable_internal_blaslib=ON .. && make -j && make test compiles successfully and all tests pass. 👍

@xiaoyeli
Copy link
Owner

This is good. However, the internal BLAS is not fast. You need to link with a high performance BLAS.
The one you were using in Xcode does not have single precision.
Alternatively, if you are not using single precision, you can disable it in cmake.

@TobiasDuswald
Copy link
Author

I'll use double precision in any case so I'll think it should be okay. :)

I still find it a bit confusing that it compiles if there is apparently no single precision implementation available, yet yields wrong results in the tests. If it is not available, I expected errors during compilation / linking.

Also It appears to me that Xcode / Apple BLAS provides single precision interfaces (see https://developer.apple.com/documentation/accelerate/blas#1805465) but it wasn't immediately obvious to me how to include this in the library and which changes are necessary to facilitate single precision.

@xiaoyeli
Copy link
Owner

A good public domain BLAS is OpenBLAS: https://www.openblas.net/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants