Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a meson build system #132

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions driver/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if build_gpu and libcuda.found()
binspral_src += files('cuda_helper_gpu.f90')
else
binspral_src += files('cuda_helper_nogpu.f90')
endif

binspral_src += files('spral_ssids.F90')
10 changes: 10 additions & 0 deletions examples/C/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
subdir('rutherford_boeing')
subdir('scaling')
subdir('ssmfe')

spral_c_examples += [['lsmrs_c', files('lsmr.c')],
['randoms_c', files('random.c')],
['random_matrixs_c', files('random_matrix.c')],
['ssidss_c', files('ssids.c')]]

libspral_include += include_directories('ssmfe')
2 changes: 2 additions & 0 deletions examples/C/rutherford_boeing/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
spral_c_examples += [['rb_reads_c', files('rb_read.c')],
['rb_writes_c', files('rb_write.c')]]
6 changes: 6 additions & 0 deletions examples/C/scaling/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
spral_c_examples += [['auction_syms_c', files('auction_sym.c')],
['auction_unsyms_c', files('auction_unsym.c')],
['equilib_syms_c', files('equilib_sym.c')],
['equilib_unsyms_c', files('equilib_unsym.c')],
['hungarian_syms_c', files('hungarian_sym.c')],
['hungarian_unsyms_c', files('hungarian_unsym.c')]]
5 changes: 5 additions & 0 deletions examples/C/ssmfe/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
spral_c_examples += [['hermitians_c', files('hermitian.c')],
['precond_cores_c', files('precond_core.c')],
['precond_experts_c', files('precond_expert.c')],
['precond_ssmfes_c', files('precond_ssmfe.c')],
['shift_inverts_c', files('shift_invert.c')]]
8 changes: 8 additions & 0 deletions examples/Fortran/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
subdir('rutherford_boeing')
subdir('scaling')
subdir('ssmfe')

spral_examples += [['lsmrs', files('lsmr.f90')],
['randoms', files('random.f90')],
['random_matrixs', files('random_matrix.f90')],
['ssidss', files('ssids.f90')]]
2 changes: 2 additions & 0 deletions examples/Fortran/rutherford_boeing/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
spral_examples += [['rb_reads', files('rb_read.f90')],
['rb_writes', files('rb_write.f90')]]
6 changes: 6 additions & 0 deletions examples/Fortran/scaling/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
spral_examples += [['auction_syms', files('auction_sym.f90')],
['auction_unsyms', files('auction_unsym.f90')],
['equilib_syms', files('equilib_sym.f90')],
['equilib_unsyms', files('equilib_unsym.f90')],
['hungarian_syms', files('hungarian_sym.f90')],
['hungarian_unsyms', files('hungarian_unsym.f90')]]
5 changes: 5 additions & 0 deletions examples/Fortran/ssmfe/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
spral_examples += [['hermitians', files('hermitian.f90')],
['precond_cores', files('precond_core.f90', 'laplace2d.f90')],
['precond_experts', files('precond_expert.f90', 'laplace2d.f90')],
['precond_ssmfes', files('precond_ssmfe.f90', 'laplace2d.f90')],
['shift_inverts', files('shift_invert.f90', 'laplace2d.f90', 'ldltf.f90')]]
2 changes: 2 additions & 0 deletions examples/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
subdir('C')
subdir('Fortran')
10 changes: 10 additions & 0 deletions include/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
spral_headers += files('spral.h',
'spral_complex.h',
'spral_lsmr.h',
'spral_matrix_util.h',
'spral_random.h',
'spral_random_matrix.h',
'spral_rutherford_boeing.h',
'spral_scaling.h',
'spral_ssids.h',
'spral_ssmfe.h')
27 changes: 27 additions & 0 deletions install_modules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3
# Initially proposed by Sebastian Ehlert (@awvwgk)
from os import environ, listdir, makedirs, walk
from os.path import join, isdir, exists
from sys import argv
from shutil import copy

build_dir = environ["MESON_BUILD_ROOT"]
if "MESON_INSTALL_DESTDIR_PREFIX" in environ:
install_dir = environ["MESON_INSTALL_DESTDIR_PREFIX"]
else:
install_dir = environ["MESON_INSTALL_PREFIX"]

include_dir = "modules"
module_dir = join(install_dir, include_dir)

modules = []
# finds $build_dir/**/*.mod and $build_dir/**/*.smod
for root, dirs, files in walk(build_dir):
modules += [join(root, f) for f in files if f.endswith(".mod") or f.endswith(".smod")]

if not exists(module_dir):
makedirs(module_dir)

for mod in modules:
print("Installing", mod, "to", module_dir)
copy(mod, module_dir)
10 changes: 10 additions & 0 deletions interfaces/C/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
libspral_src += files('lsmr.f90',
'matrix_util.f90',
'random.f90',
'random_matrix.f90',
'rutherford_boeing.f90',
'scaling.f90',
'ssids.f90',
'ssmfe.f90',
'ssmfe_core.f90',
'ssmfe_expert.f90')
175 changes: 175 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
project(
'SPRAL',
'c', 'cpp', 'fortran',
version: '2023.8.2',
license: 'BSD-3',
meson_version: '>= 0.63.0',
default_options: [
'buildtype=debug',
'libdir=lib',
'default_library=shared',
'warning_level=0',
'c_std=c99',
'cpp_std=c++17',
],
)

cc = meson.get_compiler('c')
cxx = meson.get_compiler('cpp')
fc = meson.get_compiler('fortran')

# Remove messages about deprecated Intel compilers
if cc.get_id() == 'intel' or cc.get_id() == 'intel-cl'
add_global_arguments('-diag-disable=10441', language : 'c')
add_global_link_arguments('-diag-disable=10441', language : 'c')
endif
if cxx.get_id() == 'intel' or cxx.get_id() == 'intel-cl'
add_global_arguments('-diag-disable=10441', language : 'cpp')
add_global_link_arguments('-diag-disable=10441', language : 'cpp')
endif

# Recognise old non-standard double complex intrinsics
if fc.get_id() == 'nagfor'
add_global_arguments('-dcfuns', language : 'fortran')
endif

# Options
install_modules = get_option('modules')
build_gpu = get_option('gpu')
build_tests = get_option('tests')
build_examples = get_option('examples')

libblas_name = get_option('libblas')
libblas_path = get_option('libblas_path')

liblapack_name = get_option('liblapack')
liblapack_path = get_option('liblapack_path')

libmetis_name = get_option('libmetis')
libmetis_path = get_option('libmetis_path')
libmetis_version = get_option('libmetis_version')

# Dependencies
libblas = fc.find_library(libblas_name, dirs : libblas_path, required : true)
liblapack = fc.find_library(liblapack_name, dirs : liblapack_path, required : true)
libmetis = fc.find_library(libmetis_name, dirs : libmetis_path, required : true)
libhwloc = dependency('hwloc', required : true)
libcuda = dependency('cuda', version : '>=10', modules : ['cublas'], required : false)
# lm = cc.find_library('m', required : false)

libspral_deps = [libblas, liblapack, libmetis, libhwloc, libcuda]

# OpenMP
if fc.get_id() == 'nagfor'
add_global_arguments('-openmp', language : 'fortran')
add_global_link_arguments('-openmp', language : 'fortran')
elif fc.get_id() == 'gcc'
add_global_arguments('-fopenmp', language : 'fortran')
add_global_link_arguments('-fopenmp', language : 'fortran')
elif fc.get_id() == 'intel' or fc.get_id() == 'intel-llvm' or fc.get_id() == 'intel-cl' or fc.get_id() == 'intel-llvm-cl'
add_global_arguments('-qopenmp', language : 'fortran')
add_global_link_arguments('-qopenmp', language : 'fortran')
endif

if cxx.get_id() == 'gcc' or cxx.get_id() == 'clang'
add_global_arguments('-fopenmp', language : 'cpp')
elif cxx.get_id() == 'intel' or cxx.get_id() == 'intel-cl' or cxx.get_id() == 'intel-llvm' or cxx.get_id() == 'intel-llvm-cl'
add_global_arguments('-qopenmp', language : 'cpp')
endif

binspral_src = []
libspral_src = []
libspral_cpp_src = []
libspral_nvcc_src = []

spral_examples = []
spral_c_examples = []

spral_tests = []
spral_c_tests = []

# Headers
spral_headers = []
libspral_include = []
libspral_include += include_directories('include', 'src')

# Sources
subdir('include')
subdir('interfaces/C')
subdir('src')
subdir('driver')
subdir('examples')
subdir('tests')

# Library
libspral = library('spral',
sources : libspral_src + libspral_cpp_src + libspral_nvcc_src,
dependencies : libspral_deps,
link_language : 'fortran',
link_args : '-lstdc++',
include_directories: libspral_include,
install : true)

# Binary
executable('spral_ssids',
sources : binspral_src,
link_with : libspral,
link_language : 'fortran',
install : true)

# Headers
install_headers(spral_headers)

# Fortran modules
if install_modules
script_modules = files('install_modules.py')
meson.add_install_script(script_modules)
endif

# Tests
if build_tests

fortran_tests_folder = 'tests/Fortran'

foreach test: spral_tests
name = test[0]
file = test[1]
test(name,
executable(name, file, link_with : libspral, dependencies : libspral_deps, link_language : 'fortran',
include_directories: libspral_include , install : true, install_dir : fortran_tests_folder),
is_parallel : false)
endforeach

c_tests_folder = 'tests/C'

foreach test: spral_c_tests
name = test[0]
file = test[1]
test(name,
executable(name, file, link_with : libspral, dependencies : libspral_deps, link_language : 'c',
include_directories : libspral_include, install : true, install_dir : c_tests_folder),
is_parallel : false)
endforeach
endif

# Examples
if build_examples

fortran_examples_folder = 'examples/Fortran'

foreach example: spral_examples
name = example[0]
file = example[1]
executable(name, file, link_with : libspral, dependencies : libspral_deps, link_language : 'fortran',
include_directories : libspral_include, install : true, install_dir : fortran_examples_folder)
endforeach

c_examples_folder = 'examples/C'

foreach example: spral_c_examples
name = example[0]
file = example[1]
executable(name, file, link_with : libspral, dependencies : libspral_deps, link_language : 'c',
include_directories : libspral_include, install : true, install_dir : c_examples_folder)
endforeach
endif
55 changes: 55 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
option('modules',
type : 'boolean',
value : true,
description : 'option to install Fortran modules')

option('gpu',
type : 'boolean',
value : true,
description : 'option to compile SPRAL with GPU support')

option('examples',
type : 'boolean',
value : true,
description : 'whether to generate the examples')

option('tests',
type : 'boolean',
value : true,
description : 'whether to generate the tests')

option('libblas',
type : 'string',
value : 'blas',
description : 'BLAS library against which to link')

option('liblapack',
type : 'string',
value : 'lapack',
description : 'LAPACK library against which to link')

option('libmetis',
type : 'string',
value : 'metis',
description : 'METIS library against which to link')

option('libblas_path',
type : 'array',
value : [],
description : 'Additional directories to search for the BLAS library')

option('liblapack_path',
type : 'array',
value : [],
description : 'Additional directories to search for the LAPACK library')

option('libmetis_path',
type : 'array',
value : [],
description : 'Additional directories to search for the METIS library')

option('libmetis_version',
type : 'combo',
choices : ['4', '5'],
value : '5',
description : 'Version of the METIS library')
6 changes: 6 additions & 0 deletions src/cuda/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if build_gpu and libcuda.found()
libspral_src += files('cuda.f90')
libspral_nvcc_src += files('api_wrappers.cu')
else
libspral_src += files('cuda_nocuda.f90')
endif
3 changes: 3 additions & 0 deletions src/hw_topology/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
libspral_src += files('hw_topology.f90')

libspral_cpp_src += files('guess_topology.cxx')
28 changes: 28 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
subdir('cuda')
subdir('hw_topology')
subdir('ssids')
subdir('ssmfe')

libspral_src += files('blas_iface.f90',
'core_analyse.f90',
'lapack_iface.f90',
'lsmr.f90',
'match_order.f90',
'matrix_util.f90',
'pgm.f90',
'random.f90',
'random_matrix.f90',
'rutherford_boeing.f90',
'scaling.f90',
'timer.f90')

libspral_cpp_src += files('compat.cxx',
'omp.cxx')

if libmetis_version == '4'
libspral_src += files('metis4_wrapper.F90')
else
libspral_src += files('metis5_wrapper.F90')
endif

libspral_include += include_directories('cuda', 'hw_topology', 'ssids')
5 changes: 5 additions & 0 deletions src/ssids/cpu/kernels/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
libspral_cpp_src += files('cholesky.cxx',
'ldlt_app.cxx',
'ldlt_nopiv.cxx',
'ldlt_tpp.cxx',
'wrappers.cxx')
Loading