Skip to content

Commit 6252eca

Browse files
committed
config: search for Apple's new Accelerate
1 parent c0c2d8c commit 6252eca

File tree

2 files changed

+46
-19
lines changed

2 files changed

+46
-19
lines changed

config/blas.cc

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@
1111
//------------------------------------------------------------------------------
1212
#define BLAS_ddot FORTRAN_NAME( ddot, DDOT )
1313

14-
// result return directly
15-
#ifdef __cplusplus
16-
extern "C"
14+
#ifdef ACCELERATE_NEW_LAPACK
15+
#pragma message "Including Accelerate.h"
16+
#include <Accelerate/Accelerate.h>
17+
#else
18+
#pragma message "Defining BLAS_ddot"
19+
// result return directly
20+
#ifdef __cplusplus
21+
extern "C"
22+
#endif
23+
double BLAS_ddot(
24+
const blas_int* n,
25+
const double* x, const blas_int* incx,
26+
const double* y, const blas_int* incy );
1727
#endif
18-
double BLAS_ddot(
19-
const blas_int* n,
20-
const double* x, const blas_int* incx,
21-
const double* y, const blas_int* incy );
2228

2329
//------------------------------------------------------------------------------
2430
int main()

config/lapack.py

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -335,21 +335,23 @@ def blas():
335335

336336
#-------------------- Apple Accelerate
337337
if (test_all or test_accelerate):
338-
# macOS puts cblas.h in weird places.
339-
paths = [
340-
'/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers',
341-
'/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Headers',
342-
]
343-
inc = ''
344-
for p in paths:
345-
if (os.path.exists( p + '/cblas.h' )):
346-
inc = '-I' + p + ' ' + define('HAVE_ACCELERATE_CBLAS_H')
347-
break
338+
choices.append(
339+
['macOS Accelerate (new)',
340+
{'LIBS': '-framework Accelerate',
341+
'CXXFLAGS': define('HAVE_ACCELERATE')
342+
+ ' -DACCELERATE_NEW_LAPACK'}])
343+
344+
# macOS 13.3, g++ 12.2 requires extra flag to parse Apple's headers.
345+
choices.append(
346+
['macOS Accelerate (new, -flax-vector-conversions)',
347+
{'LIBS': '-framework Accelerate',
348+
'CXXFLAGS': define('HAVE_ACCELERATE')
349+
+ ' -DACCELERATE_NEW_LAPACK -flax-vector-conversions'}])
348350

349351
choices.append(
350-
['MacOS Accelerate',
352+
['macOS Accelerate',
351353
{'LIBS': '-framework Accelerate',
352-
'CXXFLAGS': inc + define('HAVE_ACCELERATE')}])
354+
'CXXFLAGS': define('HAVE_ACCELERATE')}])
353355
# end
354356

355357
#-------------------- generic -lblas
@@ -401,6 +403,25 @@ def cblas():
401403
['CBLAS (cblas_ddot) in -lcblas', {'LIBS': '-lcblas'}],
402404
]
403405

406+
LIBS = config.environ['LIBS']
407+
if ('-framework Accelerate' in LIBS):
408+
# macOS puts cblas.h in weird places; add -I for path.
409+
# Insert as 2nd choice, so it won't be used if 1st choice above works.
410+
# On macOS 13, cblas.h seems to be in the compiler's default search
411+
# path, so this is no longer needed.
412+
paths = [
413+
'/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/Headers',
414+
'/System/Library/Frameworks/Accelerate.framework/Frameworks/vecLib.framework/Headers',
415+
'/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Headers',
416+
]
417+
for p in paths:
418+
if (os.path.exists( p + '/cblas.h' )):
419+
inc = '-I' + p + ' ' + define('HAVE_ACCELERATE_CBLAS_H')
420+
choices.insert( 1, ['CBLAS (cblas_ddot) in BLAS library, -I' + p,
421+
{'CXXFLAGS': inc}] )
422+
break
423+
# end
424+
404425
passed = []
405426
for (label, env) in choices:
406427
(rc, out, err) = config.compile_run( 'config/cblas.cc', env, label )

0 commit comments

Comments
 (0)