@@ -315,6 +315,164 @@ dep = dependency('appleframeworks', modules : 'foundation')
315315
316316These dependencies can never be found for non-OSX hosts.
317317
318+ # # BLAS and LAPACK
319+
320+ *(added 1.2.0)*
321+
322+ Enables compiling and linking against BLAS and LAPACK libraries. BLAS and
323+ LAPACK are generic APIs, which can be provided by a number of different
324+ implementations. It is possible to request either any implementation that
325+ provides the API, or a specific implementation like OpenBLAS or MKL.
326+ Furthermore, a preferred order may be specified, as well as the bitness (32 or
327+ 64) of the interface and whether to use the C or Fortran APIs.
328+
329+ Using the generic `'blas'` or `'lapack'` will try to find any matching
330+ implementation. The search order over implementations is not guaranteed; Meson
331+ aims to search them from higher to lower performance.
332+
333+ ` ` ` meson
334+ dependency('blas', interface : 'lp64', cblas : true)
335+ dependency('lapack', interface : 'ilp64', lapacke : false)
336+ ` ` `
337+
338+ Keywords :
339+ - `interface` : options are `lp64` for 32-bit LP64, and `ilp64` for 64-bit
340+ ILP64. Default is `lp64`.
341+ - `cblas` : ` true` or `false`. Default is `true`. (TBD: is `auto` needed?)
342+ - `lapacke` : ` true` or `false`. Default is `false`.
343+
344+ The search order can be controlled by explicitly specifying it :
345+
346+ ` ` ` meson
347+ # Specify what implementations to look for, and in what order
348+ blas_dep = dependency('accelerate', 'mkl', 'openblas', 'blis', 'atlas', 'netlib')
349+ lapack_dep = dependency('accelerate', 'mkl', 'openblas', 'atlas', 'netlib')
350+
351+ # You can also add the generic BLAS or LAPACK as a fallback, this may help
352+ # portability
353+ blas_dep = dependency('openblas', 'mkl', 'blis', 'netlib', 'blas')
354+ lapack_dep = dependency('openblas', 'mkl', 'atlas', 'netlib')
355+ ` ` `
356+
357+ Note that it is not necessary to specify both `'lapack'` and `'blas'` for the
358+ same build target, because LAPACK itself depends on BLAS. (TBD : is this okay
359+ for libflame?).
360+
361+
362+ # ## Specific BLAS and LAPACK implementations
363+
364+ # ### OpenBLAS
365+
366+ The `version` and `interface` keywords may be passed to request the use of a
367+ specific version and interface, correspondingly :
368+
369+ ` ` ` meson
370+ openblas_dep = dependency('openblas',
371+ version : '>=0.3.21',
372+ language: 'c', # can be c/cpp/fortran
373+ modules: [
374+ 'interface: ilp64', # can be lp64 or ilp64 (or auto?)
375+ 'symbol-suffix: 64_', # check/auto-detect? default to 64_ or no suffix?
376+ 'cblas',
377+ 'lapack', # OpenBLAS can be built without LAPACK support
378+ ]
379+ )
380+
381+ # Query properties as needed:
382+ has_cblas = openblas.get_variable('cblas')
383+ is_ilp64 = openblas_dep.get_variable('interface') == 'ilp64'
384+ blas_symbol_suffix = openblas_dep.get_variable('symbol-suffix')
385+ ` ` `
386+
387+ If OpenBLAS is installed in a nonstandard location *with* pkg-config files,
388+ you can set `PKG_CONFIG_PATH`. Alternatively, you can specify
389+ ` openblas_includedir` and `openblas_librarydir` in your native or cross machine
390+ file, this works also if OpenBLAS is installed *without* pkg-config files :
391+
392+ ` ` ` ini
393+ [properties]
394+ openblas_includedir = '/path/to/include_dir' # should contain openblas_config.h
395+ openblas_librarydir = '/path/to/library_dir'
396+ ` ` `
397+
398+ Note that OpenBLAS can be built with either pthreads or OpenMP. Information on
399+ this is not available through Meson.
400+
401+ # ### MKL
402+
403+ ` ` ` meson
404+ mkl_dep = dependency('mkl',
405+ version: '>=2021.1.0',
406+ modules: [
407+ interface: 'lp64', # options are 'lp64' or 'ilp64'
408+ threading: 'seq', # options are 'seq' or 'omp'
409+ library: 'dynamic', # options are 'dynamic' or 'static'
410+ ]
411+ )
412+ ` ` `
413+
414+ # ### Netlib BLAS and LAPACK
415+
416+ ` ` ` meson
417+ netlib_blas_dep = dependency('netlib-blas', version: '>=3.9.0')
418+ netlib_lapack_dep = dependency('netlib-lapack', version: '>=3.9.0')
419+ ` ` `
420+
421+ Note that this dependency will look for `libblas` or `liblapack`. No attempt is made
422+ to enforce that they're the original Netlib reference libraries; if another library
423+ is built with the same name, it's assumed that the APIs match.
424+
425+ TODO : the Netlib BLAS library typically ships CBLAS as a separate library and a separate
426+ cblas.pc file.
427+
428+
429+ # ### ArmPL
430+
431+ ` ` ` meson
432+ armpl_dep = dependency('armpl',
433+ version: '>=22.1',
434+ modules: [
435+ interface: 'lp64',
436+ threading: 'seq',
437+ library: 'dynamic',
438+ ]
439+ )
440+ ` ` `
441+
442+ The options for the `interface`, `threading` and `library` modules are the same
443+ as for MKL.
444+
445+
446+
447+ # ### ATLAS
448+
449+ TODO
450+
451+ # ### BLIS
452+
453+ TODO
454+
455+ # ## libflame
456+
457+ TODO
458+
459+ # ## Accelerate
460+
461+ Supports the BLAS and LAPACK components of macOS Accelerate, also referred to
462+ as the vecLib framework. ILP64 support is only available on macOS 13.3 and up.
463+ From macOS 13.3, Accelerate ships with two different builds of 32-bit (LP64)
464+ BLAS and LAPACK. Meson will default to the newer of those builds, by defining
465+ ` ACCELERATE_NEW_LAPACK` , unless `MACOS_DEPLOYMENT_TARGET` is set to a version
466+ lower than 13.3.
467+
468+ ` ` ` meson
469+ accelerate_dep = dependency('accelerate',
470+ version: '>818.60', # vecLib version (TODO: can this be determined?)
471+ modules: [interface: 'lp64']
472+ )
473+ ` ` `
474+
475+
318476# # Blocks
319477
320478Enable support for Clang's blocks extension.
0 commit comments