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

Dev compile for when M chip exists. #262

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
9 changes: 8 additions & 1 deletion cython/cmisc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <omp.h>

#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 <omp.h>
#endif

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
Expand Down
10 changes: 9 additions & 1 deletion cython/srcsim_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@
#include <string.h>
#include <math.h>
#include <sys/time.h>
#include <omp.h>

#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 <omp.h>
#endif

#include "srcsim_core.h"

// Precompute profile levels down to 1e-10 of the abspeak. Beyond that
Expand Down
12 changes: 11 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,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')
Expand All @@ -18,6 +19,15 @@ 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() 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'

Expand Down
Loading