Skip to content

Commit 68b832c

Browse files
added support for safmex on Apple using new LP64 version
1 parent 4d763cf commit 68b832c

23 files changed

Lines changed: 273 additions & 139 deletions

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if(NOT DEFINED SAF_PERFORMANCE_LIB AND NOT APPLE)
2020
message(FATAL_ERROR "You must define the SAF_PERFORMANCE_LIB environment variable")
2121
endif()
2222
if(NOT DEFINED SAF_PERFORMANCE_LIB AND APPLE)
23-
set(SAF_PERFORMANCE_LIB "SAF_USE_APPLE_ACCELERATE")
23+
set(SAF_PERFORMANCE_LIB "SAF_USE_APPLE_ACCELERATE_LP64")
2424
endif()
2525
#message(STATUS "PERFORMANCE LIB is ${SAF_PERFORMANCE_LIB}")
2626
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
@@ -47,8 +47,10 @@ if(MSVC)
4747
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
4848
elseif(APPLE)
4949
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
50+
message(STATUS "Targeting both arm64 and x86_64.")
5051
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64")
51-
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0")
52+
message(STATUS "Targeting MacOS 12.0.")
53+
set(CMAKE_OSX_DEPLOYMENT_TARGET "12.0")
5254
elseif(UNIX AND NOT APPLE AND NOT ANDROID)
5355
add_definitions(
5456
#-std=c++11

ChangeLog.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,18 @@ Major and/or breaking changes to the Spatial_Audio_Framework are listed here.
99
For descriptions of minor changes and bug fixes, please refer to the git log.
1010

1111
====================================================================================================
12-
v1.3.4
12+
v1.3.5 (5th June 2025)
13+
- Added the ability to select either the LP64 or ILP64 version of Apple Accelerate as the
14+
performance library
15+
- safmex (via SAF_BUILD_EXTRAS) now supports Apple Accelerate
16+
17+
Breaking changes:
18+
19+
The old flag "SAF_USE_APPLE_ACCELERATE" (which was always LP64), should be replaced with
20+
"SAF_USE_APPLE_ACCELERATE_LP64" or "SAF_USE_APPLE_ACCELERATE_ILP64".
21+
22+
====================================================================================================
23+
v1.3.4 (4th October 2025)
1324
- Added atomics support for the SAF examples (GCC and Clang)
1425
- Updated saf_sofa_reader module with latest libmysofa version
1526
- Fixed memory leak in qmf and decor

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ The framework requires the following external libraries:
2323

2424
In order to inform SAF which CBLAS/LAPACK supporting library/libraries you have linked to your project, simply add **one** of the following global pre-processor definitions:
2525
```
26-
SAF_USE_INTEL_MKL_LP64 # great option, but only for x86 architectures (using the LP64 config [int32])
27-
SAF_USE_INTEL_MKL_ILP64 # great option, but only for x86 architectures (using the ILP64 config [int64])
28-
SAF_USE_OPEN_BLAS_AND_LAPACKE # good option, works on everything
29-
SAF_USE_APPLE_ACCELERATE # good option (x86 and ARM), faster than OpenBLAS, but MacOSX only & slower than MKL
30-
SAF_USE_ATLAS # bad option (x86 and ARM), many LAPACK functions are missing
31-
SAF_USE... # please get in touch if you use something else! :-)
26+
SAF_USE_INTEL_MKL_LP64 # great option, but only for x86 architectures (using the LP64 config [int32])
27+
SAF_USE_INTEL_MKL_ILP64 # great option, but only for x86 architectures (using the ILP64 config [int64])
28+
SAF_USE_APPLE_ACCELERATE_LP64 # great option (x86 and ARM), but MacOSX only (using the LP64 config [int32])
29+
SAF_USE_APPLE_ACCELERATE_ILP64 # great option (x86 and ARM), but MacOSX only (using the ILP64 config [int64])
30+
SAF_USE_OPEN_BLAS_AND_LAPACKE # good option, works on everything
31+
SAF_USE_ATLAS # bad option (x86 and ARM), many LAPACK functions are missing
32+
SAF_USE... # please get in touch if you use something else! :-)
3233
```
3334
[Detailed instructions regarding how to build and link these libraries can be found here](docs/PERFORMANCE_LIBRARY_INSTRUCTIONS.md).
3435

docs/FRAMEWORK_STRUCTURE.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,14 @@ For more details, refer to: [**PERFORMANCE_LIBRARY_INSTRUCTIONS.md**](PERFORMANC
5858

5959
In order to use the optional built-in [SOFA](https://www.sofaconventions.org/mediawiki/index.php/SOFA_(Spatially_Oriented_Format_for_Acoustics)) reader module (**saf_sofa_reader**), your project must also link against the [netCDF](https://www.unidata.ucar.edu/software/netcdf/) library (including its dependencies).
6060

61-
For more details, refer to: [**SOFA_READER_MODULE_DEPENDENCIES.md**](SOFA_READER_MODULE_DEPENDENCIES.md)
62-
6361
Optionally, Intel's [Integrated Performance Primitives (IPP)](https://software.intel.com/content/www/us/en/develop/tools/integrated-performance-primitives.html) may be employed for the FFT with the following definition:
6462
```
6563
SAF_USE_INTEL_IPP
6664
```
6765

6866
## Contributing
6967

70-
Contributions are very much welcomed and encouraged. Please feel free to make suggestions, pull-requests, or get in touch (via leo.mccormack(at)aalto.fi or github "issues") if you would like to discuss additions to the framework. These additions can come in many forms; including:
71-
* bug fixes or optimisations to existing code
72-
* adding new functionality (which falls under the scope of an existing module) to an existing module
73-
* adding a new utility to the **saf_utilities** module or an entirely new module (see below)
74-
* using the framework to create new **examples**, **extras**, or unit tests
75-
* documentation improvements
68+
Contributions are very much welcomed and encouraged. Please feel free to make suggestions, pull-requests, or get in touch (via a GitHub "issue") if you would like to discuss additions to the framework.
7669

7770
## Module structure
7871

@@ -170,4 +163,4 @@ Note: your module can only be added as a **core** module if it is free from larg
170163

171164
All core modules must be released under the [ISC License](https://choosealicense.com/licenses/isc/) and only use third-party code that is provided under similar permissive licensing terms (ISC, MIT, BSD etc.).
172165

173-
Optional modules may be released under alternative licenses. If you would prefer (or are required) to release your module under a copyleft license, then you may do so. For example, the **saf_tracker** module is provided under the terms of the copyleft [GNU GPLv2 License](https://choosealicense.com/licenses/gpl-2.0/). However, please discuss with us if you wish to use a license other than ISC or GPLv2.
166+
Optional modules may be released under alternative licenses. If you would prefer (or are required) to release your module under a copyleft license, then you may do so. For example, the **saf_tracker** module is provided under the terms of the copyleft [GNU GPLv2 License](https://choosealicense.com/licenses/gpl-2.0/).

docs/PERFORMANCE_LIBRARY_INSTRUCTIONS.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ The Spatial_Audio_Framework (SAF) requires any library (or combination of librar
55
Currently, SAF supports [Intel MKL](https://software.intel.com/en-us/articles/free-ipsxe-tools-and-libraries), [OpenBLAS](https://github.com/xianyi/OpenBLAS), [Apple Accelerate](https://developer.apple.com/documentation/accelerate), and [ATLAS](http://math-atlas.sourceforge.net/). You may select which option you wish to use by adding one of the following pre-processor definitions:
66

77
```
8-
SAF_USE_INTEL_MKL_LP64 # great option, but only for x86 architectures (using the LP64 config [int32])
9-
SAF_USE_INTEL_MKL_ILP64 # great option, but only for x86 architectures (using the ILP64 config [int64])
10-
SAF_USE_OPEN_BLAS_AND_LAPACKE # good option, works on everything
11-
SAF_USE_APPLE_ACCELERATE # good option (x86 and ARM), faster than OpenBLAS, but MacOSX only & slower than MKL
12-
SAF_USE_ATLAS # bad option (x86 and ARM), many LAPACK functions are missing
13-
SAF_USE... # please get in touch if you use something else! :-)
8+
SAF_USE_INTEL_MKL_LP64 # great option, but only for x86 architectures (using the LP64 config [int32])
9+
SAF_USE_INTEL_MKL_ILP64 # great option, but only for x86 architectures (using the ILP64 config [int64])
10+
SAF_USE_APPLE_ACCELERATE_LP64 # great option (x86 and ARM), but MacOSX only (using the LP64 config [int32])
11+
SAF_USE_APPLE_ACCELERATE_ILP64 # great option (x86 and ARM), but MacOSX only (using the ILP64 config [int64])
12+
SAF_USE_OPEN_BLAS_AND_LAPACKE # good option, works on everything
13+
SAF_USE_ATLAS # bad option (x86 and ARM), many LAPACK functions are missing
14+
SAF_USE... # please get in touch if you use something else! :-)
1415
```
1516

1617
## SAF_USE_INTEL_MKL_LP64 or SAF_USE_INTEL_MKL_ILP64
@@ -139,12 +140,14 @@ cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=0 -DBUILD_WITHOUT_LAPACK
139140
make
140141
```
141142

142-
## SAF_USE_APPLE_ACCELERATE
143+
## SAF_USE_APPLE_ACCELERATE_LP64 or SAF_USE_APPLE_ACCELERATE_ILP64
143144

144145
Only for MacOSX users. Simply link against the [**Accelerate**](https://developer.apple.com/documentation/accelerate) framework and you're good to go.
145146

146147
Note that Accelerate also includes an optimised DFT/FFT implementation and a number of additional vectorised utility functions which SAF is also able to make use of.
147148

149+
Adding ACCELERATE_NEW_LAPACK (supported in MacOS 13.3 or newer) is optional for SAF_USE_APPLE_ACCELERATE_LP64.
150+
However, both ACCELERATE_NEW_LAPACK and ACCELERATE_LAPACK_ILP64 are required for SAF_USE_APPLE_ACCELERATE_ILP64.
148151

149152
## SAF_USE_ATLAS
150153

examples/src/ambi_bin/ambi_bin.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,9 @@ void ambi_bin_process
487487
/* Bake the rotation into the decoding matrix */
488488
for(band = 0; band < HYBRID_BANDS; band++) {
489489
cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, NUM_EARS, nSH, nSH, &calpha,
490-
pars->M_dec[band], MAX_NUM_SH_SIGNALS,
491-
pData->M_rot, MAX_NUM_SH_SIGNALS, &cbeta,
492-
pars->M_dec_rot[band], MAX_NUM_SH_SIGNALS);
490+
(float_complex*)pars->M_dec[band], MAX_NUM_SH_SIGNALS,
491+
(float_complex*)pData->M_rot, MAX_NUM_SH_SIGNALS, &cbeta,
492+
(float_complex*)pars->M_dec_rot[band], MAX_NUM_SH_SIGNALS);
493493
}
494494
pData->recalc_M_rotFLAG = 0;
495495
}
@@ -498,7 +498,7 @@ void ambi_bin_process
498498
/* Apply the decoder to go from SH input to binaural output */
499499
for(band = 0; band < HYBRID_BANDS; band++) {
500500
cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, NUM_EARS, TIME_SLOTS, nSH, &calpha,
501-
enableRot ? pars->M_dec_rot[band] : pars->M_dec[band], MAX_NUM_SH_SIGNALS,
501+
enableRot ? (float_complex*)pars->M_dec_rot[band] : (float_complex*)pars->M_dec[band], MAX_NUM_SH_SIGNALS,
502502
FLATTEN2D(pData->SHframeTF[band]), TIME_SLOTS, &cbeta,
503503
FLATTEN2D(pData->binframeTF[band]), TIME_SLOTS);
504504
}

examples/src/array2sh/array2sh.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ void array2sh_process
240240
/* Apply spherical harmonic transform (SHT) */
241241
for(band=0; band<HYBRID_BANDS; band++){
242242
cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, nSH, TIME_SLOTS, Q, &calpha,
243-
pData->W[band], MAX_NUM_SENSORS,
243+
(float_complex*)pData->W[band], MAX_NUM_SENSORS,
244244
FLATTEN2D(pData->inputframeTF[band]), TIME_SLOTS, &cbeta,
245245
FLATTEN2D(pData->SHframeTF[band]), TIME_SLOTS);
246246
}

examples/src/array2sh/array2sh_internal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ void array2sh_calculate_sht_matrix
353353
cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasTrans, nSH, (arraySpecs->Q), nSH, &calpha,
354354
diag_bN_inv_R, nSH,
355355
pinv_Y_mic_cmplx, nSH, &cbeta,
356-
pData->W[band], MAX_NUM_SENSORS);
356+
(float_complex*)pData->W[band], MAX_NUM_SENSORS);
357357
}
358358
free(diag_bN_inv_R);
359359
}
@@ -509,7 +509,7 @@ void array2sh_calculate_sht_matrix
509509
cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasTrans, nSH, (arraySpecs->Q), nSH, &calpha,
510510
diag_bN_inv_R, nSH,
511511
pinv_Y_mic_cmplx, nSH, &cbeta,
512-
pData->W[band], MAX_NUM_SENSORS);
512+
(float_complex*)pData->W[band], MAX_NUM_SENSORS);
513513
}
514514
free(diag_bN_inv_R);
515515
}

examples/src/panner/panner.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ void panner_process
267267
/* apply panning gains */
268268
for (band = 0; band < HYBRID_BANDS; band++) {
269269
cblas_cgemm(CblasRowMajor, CblasTrans, CblasNoTrans, nLoudspeakers, TIME_SLOTS, nSources, &calpha,
270-
pData->G_src[band], MAX_NUM_OUTPUTS,
271-
FLATTEN2D(pData->inputframeTF[band]), TIME_SLOTS, &cbeta,
272-
outputTemp, TIME_SLOTS);
270+
(float_complex*)pData->G_src[band], MAX_NUM_OUTPUTS,
271+
FLATTEN2D(pData->inputframeTF[band]), TIME_SLOTS, &cbeta,
272+
(float_complex*)outputTemp, TIME_SLOTS);
273273
for (i = 0; i < nLoudspeakers; i++)
274274
for (t = 0; t < TIME_SLOTS; t++)
275275
pData->outputframeTF[band][i][t] = ccaddf(pData->outputframeTF[band][i][t], outputTemp[i][t]);

examples/src/sldoa/sldoa_internal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ void sldoa_estimateDoA
177177
cblas_cgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 4, TIME_SLOTS, nSH, &calpha,
178178
sec_c, nSH,
179179
FLATTEN2D(SHframeTF), TIME_SLOTS, &cbeta,
180-
secSig, TIME_SLOTS);
180+
(float_complex*)secSig, TIME_SLOTS);
181181
}
182182

183183
/* convert N3D to SN3D */

0 commit comments

Comments
 (0)