benchmark_executable = [] benchmark_mpi_launcher = '' if get_option('build_benchmarks') if is_wasm error('build_benchmarks requires a native target; use the web demo for Emscripten') endif if not mfem_has_mpi error('build_benchmarks requires -Dmfem_mpi=enabled (and therefore Hypre)') endif benchmark_accelerator_deps = [] if mfem_has_cuda benchmark_nvcc = dependency_has_nvcc ? ( dependency_prefix / 'bin' / 'nvcc' ) : nvcc_program.full_path() benchmark_cuda_root_result = run_command( python_build, '-c', 'import os, sys; print(os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[1]))))', benchmark_nvcc, check: true, ) benchmark_cuda_root = benchmark_cuda_root_result.stdout().strip() benchmark_accelerator_deps += [cpp.find_library( 'cudart', dirs: [ benchmark_cuda_root / 'lib64', benchmark_cuda_root / 'lib', benchmark_cuda_root / 'lib' / 'x64', benchmark_cuda_root / 'targets' / 'x86_64-linux' / 'lib', benchmark_cuda_root / 'targets' / 'aarch64-linux' / 'lib', benchmark_cuda_root / 'targets' / 'ppc64le-linux' / 'lib', ], required: true, )] endif if mfem_has_hip benchmark_hipcc = dependency_has_hipcc ? ( dependency_prefix / 'bin' / 'hipcc' ) : hipcc_program.full_path() benchmark_hip_root_result = run_command( python_build, '-c', 'import os, sys; print(os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[1]))))', benchmark_hipcc, check: true, ) benchmark_hip_root = benchmark_hip_root_result.stdout().strip() benchmark_accelerator_deps += [cpp.find_library( 'amdhip64', dirs: [benchmark_hip_root / 'lib', benchmark_hip_root / 'lib64'], required: true, )] endif benchmark_build_rpath = mfem_runtime_prefix == '' ? '' : mfem_runtime_prefix / 'lib' benchmark_install_rpath = '' if mfem_runtime_prefix != '' and not is_windows benchmark_install_rpath = host_machine.system() == 'darwin' ? '@loader_path/../lib' : '$ORIGIN/../lib' endif benchmark_executable = executable( 'mfem-backend-benchmark', 'backend_operator.cpp', dependencies: [mfem_dep, template_include_dep] + benchmark_accelerator_deps, override_options: ['cpp_std=' + mfem_consumer_cpp_std], build_rpath: benchmark_build_rpath, install_rpath: benchmark_install_rpath, install: true, install_tag: 'benchmarks', ) if mpi_launcher_from_dependency and not wheel_carries_native_bundle benchmark_launcher_program = find_program( dependency_prefix / 'bin' / 'mpiexec', dependency_prefix / 'bin' / 'mpirun', required: true, ) benchmark_mpi_launcher = benchmark_launcher_program.full_path() elif mfem_runtime_prefix != '' benchmark_mpi_launcher = mfem_runtime_prefix / 'bin' / 'mpiexec' else benchmark_launcher_program = find_program('mpiexec', 'mpirun', required: true) benchmark_mpi_launcher = benchmark_launcher_program.full_path() endif benchmark_cases = ['cpu'] if mfem_features.get('ceed') benchmark_cases += ['ceed-cpu'] endif if mfem_has_openmp benchmark_cases += ['omp'] endif benchmark_cases += ['mpi'] if mfem_has_cuda benchmark_cases += ['cuda'] if mfem_features.get('ceed') benchmark_cases += ['ceed-cuda'] endif endif benchmark_environment = environment() if ( mfem_runtime_prefix != '' and dependency_prefix != '' and not wheel_carries_native_bundle ) benchmark_environment.prepend('PATH', dependency_prefix / 'bin') if host_machine.system() == 'darwin' benchmark_environment.prepend('DYLD_LIBRARY_PATH', dependency_prefix / 'lib64') benchmark_environment.prepend('DYLD_LIBRARY_PATH', dependency_prefix / 'lib') elif not is_windows benchmark_environment.prepend('LD_LIBRARY_PATH', dependency_prefix / 'lib64') benchmark_environment.prepend('LD_LIBRARY_PATH', dependency_prefix / 'lib') endif endif if mfem_runtime_prefix != '' benchmark_environment.prepend('PATH', mfem_runtime_prefix / 'bin') if host_machine.system() == 'darwin' benchmark_environment.prepend('DYLD_LIBRARY_PATH', mfem_runtime_prefix / 'lib64') benchmark_environment.prepend('DYLD_LIBRARY_PATH', mfem_runtime_prefix / 'lib') elif not is_windows benchmark_environment.prepend('LD_LIBRARY_PATH', mfem_runtime_prefix / 'lib64') benchmark_environment.prepend('LD_LIBRARY_PATH', mfem_runtime_prefix / 'lib') endif endif benchmark( 'mfem-backend-comparison', python_build, args: [ files('../tools/run_backend_benchmarks.py'), '--executable', benchmark_executable, '--launcher', benchmark_mpi_launcher, '--cases', ','.join(benchmark_cases), '--output-dir', meson.current_build_dir(), ], depends: benchmark_executable, env: benchmark_environment, timeout: 3600, ) endif