From 6854cd7127c3876c5f945fd2bd30180dcfa7fb75 Mon Sep 17 00:00:00 2001 From: Ioannis Paraskevakos Date: Wed, 10 Jul 2024 16:37:36 -0400 Subject: [PATCH 1/2] disable openmp when Mac with M chip --- cython/cmisc_core.c | 9 ++++++++- cython/srcsim_core.c | 10 +++++++++- meson.build | 8 ++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/cython/cmisc_core.c b/cython/cmisc_core.c index c73a0a1f..b5cf3140 100644 --- a/cython/cmisc_core.c +++ b/cython/cmisc_core.c @@ -3,7 +3,14 @@ #include #include #include -#include + +#ifdef _NOOPENMP + typedef int omp_int_t; + inline omp_int_t omp_get_thread_num() { return 0;} + inline omp_int_t omp_get_max_threads() { return 1;} +#else + #include +#endif int min(int a, int b) { return a < b ? a : b; } int max(int a, int b) { return a > b ? a : b; } diff --git a/cython/srcsim_core.c b/cython/srcsim_core.c index 8b6ff8cb..8e32abd3 100644 --- a/cython/srcsim_core.c +++ b/cython/srcsim_core.c @@ -36,7 +36,15 @@ #include #include #include -#include + +#ifdef _NOOPENMP + typedef int omp_int_t; + inline omp_int_t omp_get_thread_num() { return 0;} + inline omp_int_t omp_get_max_threads() { return 1;} +#else + #include +#endif + #include "srcsim_core.h" // Precompute profile levels down to 1e-10 of the abspeak. Beyond that diff --git a/meson.build b/meson.build index b8d28333..5f9bd10c 100644 --- a/meson.build +++ b/meson.build @@ -19,7 +19,8 @@ py = import('python').find_installation(pure: false) # Dependencies py_dep = py.dependency() -omp_dep = dependency('openmp') +# message('Machine', host_machine.system(), 'CPU type', host_machine.cpu_family()) +omp_dep = dependency('openmp', required : false) # Libraries cc = meson.get_compiler('c') @@ -27,7 +28,10 @@ c_m_dep = cc.find_library('m', required: true) fc = meson.get_compiler('fortran') fortran_m_dep = fc.find_library('m', required: true) - +if not omp_dep.found() + warning('It seems this is a Macbook with M type processor, moving forward without openmp.') + add_project_arguments(['-D_NOOPENMP','-Wno-error=incompatible-function-pointer-types'], language : ['c', 'cpp']) +endif # Directories library_install_dir = py.get_install_dir() / 'pixell' From 98f1de9890ac5dae519fdf04b968553742997d12 Mon Sep 17 00:00:00 2001 From: Ioannis Paraskevakos Date: Thu, 11 Jul 2024 11:50:29 -0400 Subject: [PATCH 2/2] Error messages for when openmp is not there and windows are detected --- meson.build | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 5f9bd10c..58bb758a 100644 --- a/meson.build +++ b/meson.build @@ -28,10 +28,16 @@ c_m_dep = cc.find_library('m', required: true) fc = meson.get_compiler('fortran') fortran_m_dep = fc.find_library('m', required: true) -if not omp_dep.found() + +if not omp_dep.found() and host_machine.system() == 'darwin' and host_machine.cpu_family() == 'aarch64' warning('It seems this is a Macbook with M type processor, moving forward without openmp.') add_project_arguments(['-D_NOOPENMP','-Wno-error=incompatible-function-pointer-types'], language : ['c', 'cpp']) +elif not omp_dep.found() and host_machine.system() != 'windows' + error('OpenMP is required but not found. Please install OpenMP libraries') +elif host_machine.system() == 'windows' + error('Windows systems are not supported') endif + # Directories library_install_dir = py.get_install_dir() / 'pixell'