Skip to content

Commit e46a8c8

Browse files
committed
drop __ACCELERATE, use vecLibFort instead
1 parent 19e08a4 commit e46a8c8

File tree

12 files changed

+49
-33
lines changed

12 files changed

+49
-33
lines changed

.pre-commit-config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,18 @@ repos:
2525
- id: check-yaml
2626
- id: check-symlinks
2727
- id: trailing-whitespace
28+
exclude: >-
29+
(?x)^(
30+
tools/vecLibFort/.*|
31+
)$
2832
- repo: https://github.com/pseewald/fprettify
2933
rev: v0.3.7
3034
hooks:
3135
- id: fprettify
36+
exclude: >-
37+
(?x)^(
38+
tools/vecLibFort/.*|
39+
)$
3240
- repo: https://github.com/cheshirekow/cmake-format-precommit
3341
rev: v0.6.13
3442
hooks:
@@ -64,3 +72,8 @@ repos:
6472
files: \.(c|cc|cxx|cpp|cl|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|mm|proto|textproto|vert)$
6573
args: ['-i', '-fallback-style=none', '--style=file']
6674
additional_dependencies: ['clang-format']
75+
exclude: >-
76+
(?x)^(
77+
tools/vecLibFort/.*|
78+
)$
79+

CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,23 @@ endif ()
163163
find_package(LAPACK REQUIRED) # needed for some of the integrated test routines,
164164
# also calls find_package(BLAS)
165165

166+
if (APPLE
167+
AND (BLAS_LIBRARIES MATCHES "Accelerate"
168+
OR BLAS_LIBRARIES MATCHES "vecLib" # automated search
169+
OR BLA_VENDOR STREQUAL "Accelerate"
170+
OR BLA_VENDOR STREQUAL "NAS" # user override
171+
))
172+
message(CHECK_START "Looking for vecLibFort library")
173+
find_library(VECLIBFORT_LIBRARY vecLibFort)
174+
if (NOT VECLIBFORT_LIBRARY)
175+
message(CHECK_FAIL "not found, building it")
176+
add_subdirectory(tools/vecLibFort)
177+
set(VECLIBFORT_LIBRARY vecLibFort)
178+
else ()
179+
message(CHECK_PASS "found at " ${VECLIBFORT_LIBRARY})
180+
endif ()
181+
endif ()
182+
166183
# =================================== Python this module looks preferably for
167184
# version 3 of Python. If not found, version 2 is searched. In CMake 3.15, if a
168185
# python virtual environment is activated, it will search the virtual

docs/guide/2-user-guide/1-installation/index.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ You need:
99
* [CMake](https://cmake.org/) (3.22+)
1010
* GNU make or Ninja
1111
* Fortran compiler which supports at least Fortran 2008 (including the TS 29113 when using the C-bindings)
12-
* BLAS+LAPACK implementation (reference, OpenBLAS and MKL have been tested. Note: DBCSR linked to OpenBLAS 0.3.6 gives wrong results on Power9 architectures.)
13-
* Python version installed (2.7 or 3.6+ have been tested)
12+
* BLAS+LAPACK implementation
13+
* Reference BLAS/LAPACK, OpenBLAS and MKL have been tested and can be considered supported.
14+
* On macOS [vecLibFort](https://github.com/mcg1969/vecLibFort) is required to use Accelerate and/or vecLib.
15+
The build system will automatically build a bundled version if not found on the system.
16+
* DBCSR linked to OpenBLAS 0.3.6 gives wrong results on Power9 architectures.
17+
* Python version installed (3.6+ have been tested)
1418

1519
Optional:
1620

docs/guide/3-developer-guide/3-programming/1-overview/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ Assumed square matrix with 20x20 matrix with 5x5 blocks and a 2x2 processor grid
4646
| `__NO_STATM_ACCESS`, `__STATM_RESIDENT` or `__STATM_TOTAL` | Toggle memory usage reporting between resident memory and total memory. In particular, macOS users must use `-D__NO_STATM_ACCESS` | Fortran |
4747
| `__NO_ABORT` | Avoid calling abort, but STOP instead (useful for coverage testing, and to avoid core dumps on some systems) | Fortran |
4848
| `__LIBXSMM` | Enable [LIBXSMM](https://github.com/hfp/libxsmm/) link for optimized small matrix multiplications on CPU | Fortran |
49-
| `__ACCELERATE` | Must be defined on macOS when Apple's Accelerate framework is used for BLAS and LAPACK (this is due to some interface incompatibilities between Accelerate and reference BLAS/LAPACK) | Fortran |
5049
| `NDEBUG` | Assertions are stripped ("compiled out"), `NDEBUG` is the ANSI-conforming symbol name (not `__NDEBUG`). Regular release builds may carry assertions for safety | Fortran, C, C++ |
5150
| `__CRAY_PM_ACCEL_ENERGY` or `__CRAY_PM_ENERGY` | Switch on collectin energy profiling on Cray systems | Fortran |
5251
| `__DBCSR_ACC` | Enable Accelerator compilation | Fortran, C, C++ |

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ if (APPLE)
176176
# fix /proc/self/statm can not be opened on macOS
177177
target_compile_definitions(dbcsr PRIVATE __NO_STATM_ACCESS)
178178

179-
if (BLAS_LIBRARIES MATCHES "Accelerate")
180-
target_compile_definitions(dbcsr PRIVATE __ACCELERATE)
179+
if (VECLIBFORT_LIBRARY)
180+
target_link_libraries(dbcsr PRIVATE ${VECLIBFORT_LIBRARY})
181181
endif ()
182182
endif ()
183183

src/mm/dbcsr_mm_common.F

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,11 +579,7 @@ SUBROUTINE calc_norms_${nametype1}$ (norms, nblks, &
579579
INTEGER :: blk, bp, bpe, row, col
580580

581581
REAL(KIND=real_8), EXTERNAL :: DDOT
582-
#if defined (__ACCELERATE)
583-
REAL(KIND=real_8), EXTERNAL :: SDOT
584-
#else
585582
REAL(KIND=real_4), EXTERNAL :: SDOT
586-
#endif
587583

588584
! ---------------------------------------------------------------------------
589585

src/mm/dbcsr_mm_multrec.F

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -707,11 +707,7 @@ SUBROUTINE multrec_filtering_${nametype1}$ (filter_eps, nblks, rowi, coli, blkp,
707707
REAL(kind=real_8) :: nrm
708708

709709
REAL(KIND=real_8), EXTERNAL :: DZNRM2, DDOT
710-
#if defined (__ACCELERATE)
711-
REAL(KIND=real_8), EXTERNAL :: SCNRM2, SDOT
712-
#else
713710
REAL(KIND=real_4), EXTERNAL :: SCNRM2, SDOT
714-
#endif
715711

716712
REAL(kind=real_8) :: filter_eps_opt
717713

src/ops/dbcsr_operations.F

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,11 +1910,7 @@ SUBROUTINE dbcsr_filter_anytype(matrix, eps, method, &
19101910
TYPE(dbcsr_iterator) :: iter
19111911

19121912
REAL(KIND=real_8), EXTERNAL :: DZNRM2
1913-
#if defined (__ACCELERATE)
1914-
REAL(KIND=real_8), EXTERNAL :: SCNRM2
1915-
#else
19161913
REAL(KIND=real_4), EXTERNAL :: SCNRM2
1917-
#endif
19181914

19191915
! ---------------------------------------------------------------------------
19201916

tests/CMakeLists.txt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,20 @@ set(dbcsr_unittest_common_SRCS dbcsr_test_add.F dbcsr_test_multiply.F)
9595
# instead of building a full-blown lib, it would be better to simply build an
9696
# OBJECT lib, but we would need cmake 3.12 to be able to specify
9797
# target_link_libraries on those to get the proper compile flags
98-
add_library(dbcsr_unittest_common STATIC ${dbcsr_unittest_common_SRCS})
98+
add_library(dbcsr_unittest_common OBJECT ${dbcsr_unittest_common_SRCS})
99+
target_link_libraries(dbcsr_unittest_common PUBLIC dbcsr)
99100
target_link_libraries(dbcsr_unittest_common PUBLIC ${BLAS_LIBRARIES}
100101
${LAPACK_LIBRARIES})
101102
if (OpenMP_FOUND)
102103
target_link_libraries(dbcsr_unittest_common PUBLIC OpenMP::OpenMP_Fortran)
103104
endif ()
104105

105-
if (APPLE AND BLAS_LIBRARIES MATCHES "Accelerate")
106-
target_compile_definitions(dbcsr_unittest_common PRIVATE __ACCELERATE)
107-
endif ()
108-
target_link_libraries(dbcsr_unittest_common PUBLIC dbcsr)
109-
110106
# Compile Fortran tests
111107
foreach (dbcsr_test ${DBCSR_TESTS_FTN})
112108
add_executable(${dbcsr_test} ${${dbcsr_test}_SRCS})
113-
target_link_libraries(${dbcsr_test} dbcsr_unittest_common)
109+
target_link_libraries(${dbcsr_test} PUBLIC dbcsr_unittest_common)
114110
set_target_properties(${dbcsr_test} PROPERTIES LINKER_LANGUAGE Fortran)
111+
115112
# register unittest executable with CMake
116113
if (USE_MPI)
117114
separate_arguments(MPIEXEC_PREFLAGS)
@@ -124,7 +121,6 @@ foreach (dbcsr_test ${DBCSR_TESTS_FTN})
124121
add_test(NAME ${dbcsr_test} COMMAND ${dbcsr_test})
125122
endif ()
126123
if (OpenMP_FOUND)
127-
target_link_libraries(${dbcsr_test} OpenMP::OpenMP_Fortran)
128124
set_tests_properties(
129125
${dbcsr_test} PROPERTIES ENVIRONMENT OMP_NUM_THREADS=${TEST_OMP_THREADS})
130126
endif ()

tests/dbcsr_test_add.F

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,7 @@ SUBROUTINE dbcsr_check_add(test_name, matrix_a, dense_a_dbcsr, dense_a, dense_b,
377377

378378
LOGICAL :: valid
379379
REAL(real_4), ALLOCATABLE, DIMENSION(:) :: work_sp
380-
#if defined (__ACCELERATE)
381-
REAL(real_8), EXTERNAL :: clange, slamch, slange
382-
#else
383380
REAL(real_4), EXTERNAL :: clange, slamch, slange
384-
#endif
385381
REAL(real_8) :: a_norm_dbcsr, a_norm_in, a_norm_out, &
386382
b_norm, eps, residual
387383
REAL(real_8), ALLOCATABLE, DIMENSION(:) :: work

tests/dbcsr_test_multiply.F

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,11 +553,7 @@ SUBROUTINE dbcsr_check_multiply(test_name, matrix_c, dense_c_dbcsr, dense_a, den
553553

554554
LOGICAL :: valid
555555
REAL(real_4), ALLOCATABLE, DIMENSION(:) :: work_sp
556-
#if defined (__ACCELERATE)
557-
REAL(real_8), EXTERNAL :: clange, slamch, slange
558-
#else
559556
REAL(real_4), EXTERNAL :: clange, slamch, slange
560-
#endif
561557
REAL(real_8) :: a_norm, b_norm, c_norm_dbcsr, c_norm_in, &
562558
c_norm_out, eps, eps_norm, residual
563559
REAL(real_8), ALLOCATABLE, DIMENSION(:) :: work

tools/vecLibFort/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
add_library(vecLibFort STATIC vecLibFort.c)
2+
3+
install(
4+
TARGETS vecLibFort
5+
EXPORT DBCSRTargets
6+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
7+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")

0 commit comments

Comments
 (0)