@@ -68,12 +68,14 @@ function( debug_print_list msg )
6868 message ( "---------- lists: ${msg} " )
6969 message ( "blas_name_list = ${blas_name_list} " )
7070 message ( "blas_libs_list = ${blas_libs_list} " )
71+ message ( "blas_defs_list = ${blas_defs_list} " )
7172
7273 message ( "\n row; ${red} blas_name;${plain} blas_libs" )
7374 set ( i 0 )
7475 foreach (name IN LISTS blas_name_list)
7576 list ( GET blas_libs_list ${i} libs )
76- message ( "${i} ; ${red}${name} ;${plain} ${libs} " )
77+ list ( GET blas_defs_list ${i} defs )
78+ message ( "${i} ; ${red}${name} ;${plain} libs = ${libs} defs = ${defs} " )
7779 math ( EXPR i "${i} + 1" )
7880 endforeach ()
7981 message ( "" )
@@ -119,12 +121,6 @@ else()
119121 )
120122endif ()
121123
122- #---------------------------------------- integer sizes to test
123- set ( int_size_list
124- " " # int (LP64)
125- "-DBLAS_ILP64" # int64_t (ILP64)
126- )
127-
128124#-------------------------------------------------------------------------------
129125# Parse options: BLAS_LIBRARIES, blas, blas_int, blas_threaded, blas_fortran.
130126
@@ -223,11 +219,20 @@ if (CMAKE_CROSSCOMPILING AND test_int AND test_int64)
223219 " `blas_int=int64` (ilp64 convention).${plain} " )
224220endif ()
225221
222+ set ( int_size_list "" )
223+ if (test_int)
224+ list ( APPEND int_size_list " " ) # int (lp64)
225+ endif ()
226+ if (test_int64)
227+ list ( APPEND int_size_list "-DBLAS_ILP64" ) # int64_t (ILP64)
228+ endif ()
229+
226230message ( DEBUG "
227231blas_int = '${blas_int} '
228232blas_int_ = '${blas_int_} '
229233test_int = '${test_int} '
230- test_int64 = '${test_int64} '" )
234+ test_int64 = '${test_int64} '
235+ int_size_list = '${int_size_list} '" )
231236
232237#---------------------------------------- blas_threaded
233238string ( TOLOWER "${blas_threaded} " blas_threaded_ )
@@ -256,6 +261,7 @@ test_sequential = '${test_sequential}'")
256261
257262set ( blas_name_list "" )
258263set ( blas_libs_list "" )
264+ set ( blas_defs_list "" )
259265
260266#---------------------------------------- BLAS_LIBRARIES
261267if (test_blas_libraries)
@@ -266,13 +272,15 @@ if (test_blas_libraries)
266272
267273 list ( APPEND blas_name_list "\$ BLAS_LIBRARIES" )
268274 list ( APPEND blas_libs_list "${BLAS_LIBRARIES_ESC} " )
275+ list ( APPEND blas_defs_list " " )
269276 debug_print_list( "BLAS_LIBRARIES" )
270277endif ()
271278
272279#---------------------------------------- default; Cray libsci
273280if (test_all OR test_default)
274281 list ( APPEND blas_name_list "default (no library)" )
275282 list ( APPEND blas_libs_list " " ) # Use space so APPEND works later.
283+ list ( APPEND blas_defs_list " " )
276284 debug_print_list( "default" )
277285endif ()
278286
@@ -285,33 +293,39 @@ if (test_all OR test_mkl)
285293 if (test_int)
286294 list ( APPEND blas_name_list "Intel MKL lp64, GNU threads (gomp), gfortran" )
287295 list ( APPEND blas_libs_list "-lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core" )
296+ list ( APPEND blas_defs_list " " )
288297 endif ()
289298
290299 if (test_int64)
291300 list ( APPEND blas_name_list "Intel MKL ilp64, GNU threads (gomp), gfortran" )
292301 list ( APPEND blas_libs_list "-lmkl_gf_ilp64 -lmkl_gnu_thread -lmkl_core" )
302+ list ( APPEND blas_defs_list " " )
293303 endif ()
294304
295305 elseif (test_ifort AND intelllvm_compiler)
296306 # IntelLLVM compiler + OpenMP: require intel_thread library.
297307 if (test_int)
298308 list ( APPEND blas_name_list "Intel MKL lp64, Intel threads (iomp5), ifort" )
299309 list ( APPEND blas_libs_list "-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core" )
310+ list ( APPEND blas_defs_list " " )
300311 elseif (test_int64)
301312 list ( APPEND blas_name_list "Intel MKL ilp64, Intel threads (iomp5), ifort" )
302313 list ( APPEND blas_libs_list "-lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core" )
314+ list ( APPEND blas_defs_list " " )
303315 endif ()
304316
305317 elseif (test_ifort AND intel_compiler)
306318 # Intel compiler + OpenMP: require intel_thread library.
307319 if (test_int)
308320 list ( APPEND blas_name_list "Intel MKL lp64, Intel threads (iomp5), ifort" )
309321 list ( APPEND blas_libs_list "-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core" )
322+ list ( APPEND blas_defs_list " " )
310323 endif ()
311324
312325 if (test_int64)
313326 list ( APPEND blas_name_list "Intel MKL ilp64, Intel threads (iomp5), ifort" )
314327 list ( APPEND blas_libs_list "-lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core" )
328+ list ( APPEND blas_defs_list " " )
315329 endif ()
316330
317331 else ()
@@ -327,11 +341,13 @@ if (test_all OR test_mkl)
327341 if (test_int)
328342 list ( APPEND blas_name_list "Intel MKL lp64, sequential, ifort" )
329343 list ( APPEND blas_libs_list "-lmkl_intel_lp64 -lmkl_sequential -lmkl_core" )
344+ list ( APPEND blas_defs_list " " )
330345 endif ()
331346
332347 if (test_int64)
333348 list ( APPEND blas_name_list "Intel MKL ilp64, sequential, ifort" )
334349 list ( APPEND blas_libs_list "-lmkl_intel_ilp64 -lmkl_sequential -lmkl_core" )
350+ list ( APPEND blas_defs_list " " )
335351 endif ()
336352 endif () # ifort
337353
@@ -340,11 +356,13 @@ if (test_all OR test_mkl)
340356 if (test_int)
341357 list ( APPEND blas_name_list "Intel MKL lp64, sequential, gfortran" )
342358 list ( APPEND blas_libs_list "-lmkl_gf_lp64 -lmkl_sequential -lmkl_core" )
359+ list ( APPEND blas_defs_list " " )
343360 endif ()
344361
345362 if (test_int64)
346363 list ( APPEND blas_name_list "Intel MKL ilp64, sequential, gfortran" )
347364 list ( APPEND blas_libs_list "-lmkl_gf_ilp64 -lmkl_sequential -lmkl_core" )
365+ list ( APPEND blas_defs_list " " )
348366 endif ()
349367 endif () # gfortran
350368
@@ -354,11 +372,13 @@ if (test_all OR test_mkl)
354372 if (test_int)
355373 list ( APPEND blas_name_list "Intel MKL lp64, sequential, ifort" )
356374 list ( APPEND blas_libs_list "-lmkl_intel_lp64 -lmkl_sequential -lmkl_core" )
375+ list ( APPEND blas_defs_list " " )
357376 endif ()
358377
359378 if (test_int64)
360379 list ( APPEND blas_name_list "Intel MKL ilp64, sequential, ifort" )
361380 list ( APPEND blas_libs_list "-lmkl_intel_ilp64 -lmkl_sequential -lmkl_core" )
381+ list ( APPEND blas_defs_list " " )
362382 endif ()
363383 endif () # ifort && not intel
364384 endif () # sequential
@@ -387,11 +407,13 @@ if (test_all OR test_essl)
387407 if (test_int)
388408 list ( APPEND blas_name_list "IBM ESSL int (lp64), multi-threaded, with OpenMP" )
389409 list ( APPEND blas_libs_list "-lesslsmp" )
410+ list ( APPEND blas_defs_list " " )
390411 endif ()
391412
392413 if (test_int64)
393414 list ( APPEND blas_name_list "IBM ESSL int64 (ilp64), multi-threaded, with OpenMP" )
394415 list ( APPEND blas_libs_list "-lesslsmp6464" )
416+ list ( APPEND blas_defs_list " " )
395417 endif ()
396418 endif ()
397419 endif () # threaded
@@ -400,11 +422,13 @@ if (test_all OR test_essl)
400422 if (test_int)
401423 list ( APPEND blas_name_list "IBM ESSL int (lp64), sequential" )
402424 list ( APPEND blas_libs_list "-lessl" )
425+ list ( APPEND blas_defs_list " " )
403426 endif ()
404427
405428 if (test_int64)
406429 list ( APPEND blas_name_list "IBM ESSL int64 (ilp64), sequential" )
407430 list ( APPEND blas_libs_list "-lessl6464" )
431+ list ( APPEND blas_defs_list " " )
408432 endif ()
409433 endif () # sequential
410434 debug_print_list( "essl" )
@@ -415,20 +439,28 @@ if (test_all OR test_openblas)
415439 # todo: OPENBLAS_?(ROOT|DIR)
416440 list ( APPEND blas_name_list "OpenBLAS" )
417441 list ( APPEND blas_libs_list "-lopenblas" )
442+ list ( APPEND blas_defs_list " " )
418443 debug_print_list( "openblas" )
419444endif ()
420445
421446#---------------------------------------- Apple Accelerate
422447if (test_all OR test_accelerate)
423- list ( APPEND blas_name_list "Apple Accelerate" )
448+ list ( APPEND blas_name_list "Apple Accelerate (new)" )
449+ list ( APPEND blas_libs_list "-framework Accelerate" )
450+ list ( APPEND blas_defs_list "-DBLAS_HAVE_ACCELERATE -DACCELERATE_NEW_LAPACK" )
451+
452+ list ( APPEND blas_name_list "Apple Accelerate (old, pre 13.3)" )
424453 list ( APPEND blas_libs_list "-framework Accelerate" )
454+ list ( APPEND blas_defs_list "-DBLAS_HAVE_ACCELERATE" )
455+
425456 debug_print_list( "accelerate" )
426457endif ()
427458
428459#---------------------------------------- generic -lblas
429460if (test_all OR test_generic)
430461 list ( APPEND blas_name_list "generic" )
431462 list ( APPEND blas_libs_list "-lblas" )
463+ list ( APPEND blas_defs_list " " )
432464 debug_print_list( "generic" )
433465endif ()
434466
@@ -439,11 +471,13 @@ if (test_all OR test_acml)
439471 if (test_threaded)
440472 list ( APPEND blas_name_list "AMD ACML threaded" )
441473 list ( APPEND blas_libs_list "-lacml_mp" )
474+ list ( APPEND blas_defs_list " " )
442475 endif ()
443476
444477 if (test_sequential)
445478 list ( APPEND blas_name_list "AMD ACML sequential" )
446479 list ( APPEND blas_libs_list "-lacml" )
480+ list ( APPEND blas_defs_list " " )
447481 endif ()
448482 debug_print_list( "acml" )
449483endif ()
@@ -458,14 +492,19 @@ set( i 0 )
458492foreach (blas_name IN LISTS blas_name_list)
459493 message ( TRACE "i: ${i} " )
460494 list ( GET blas_libs_list ${i} blas_libs )
495+ list ( GET blas_defs_list ${i} blas_defs )
461496 math ( EXPR i "${i} +1" )
462497
463498 if (i GREATER 1)
464499 message ( "" )
465500 endif ()
466501 message ( "${blas_name} " )
467502 message ( " libs: ${blas_libs} " )
503+ if (defs MATCHES "[^ ]" ) # non-empty
504+ message ( " defs: ${blas_defs} " )
505+ endif ()
468506
507+ # Split space-separated libs into CMake list.
469508 # Strip to deal with default lib being space, " ".
470509 # Undo escaping \; semi-colons and split on spaces to make list.
471510 # But keep '-framework Accelerate' together as one item.
@@ -488,7 +527,7 @@ foreach (blas_name IN LISTS blas_name_list)
488527 LINK_LIBRARIES
489528 ${blas_libs} ${openmp_lib} # not "..." quoted; screws up OpenMP
490529 COMPILE_DEFINITIONS
491- "${mangling} ${int_size} "
530+ "${mangling} ${int_size} ${blas_defs} "
492531 OUTPUT_VARIABLE
493532 link_output
494533 )
@@ -509,7 +548,7 @@ foreach (blas_name IN LISTS blas_name_list)
509548 LINK_LIBRARIES
510549 ${blas_libs} ${openmp_lib} # not "..." quoted; screws up OpenMP
511550 COMPILE_DEFINITIONS
512- "${mangling} ${int_size} "
551+ "${mangling} ${int_size} ${blas_defs} "
513552 COMPILE_OUTPUT_VARIABLE
514553 compile_output
515554 RUN_OUTPUT_VARIABLE
@@ -533,6 +572,12 @@ foreach (blas_name IN LISTS blas_name_list)
533572 # If it runs and prints ok, we're done, so break all 3 loops.
534573 message ( "${label} ${blue} yes${plain} " )
535574
575+ # Split space-separated defs into CMake list.
576+ message ( DEBUG " blas_defs: '${blas_defs} '" )
577+ string ( STRIP "${blas_defs} " blas_defs )
578+ string ( REGEX REPLACE "([^ ])( +|\\\; )" "\\ 1;" blas_defs "${blas_defs} " )
579+ message ( DEBUG " blas_defs: '${blas_defs} ' (split)" )
580+
536581 set ( BLAS_FOUND true CACHE INTERNAL "" )
537582 set ( BLAS_LIBRARIES "${blas_libs} " CACHE STRING "" FORCE )
538583 if (mangling MATCHES "[^ ]" ) # non-empty
@@ -541,6 +586,9 @@ foreach (blas_name IN LISTS blas_name_list)
541586 if (int_size MATCHES "[^ ]" ) # non-empty
542587 list ( APPEND blaspp_defs_ "${int_size} " )
543588 endif ()
589+ if (blas_defs MATCHES "[^ ]" ) # non-empty
590+ list ( APPEND blaspp_defs_ "${blas_defs} " )
591+ endif ()
544592 break ()
545593 else ()
546594 message ( "${label} ${red} no (didn't run: int mismatch, etc.)${plain} " )
0 commit comments