Skip to content

Commit

Permalink
deactivate openmp for windowns/clang-cl
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-urban committed Jul 4, 2024
1 parent 2e42fde commit 1a33277
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 17 deletions.
22 changes: 6 additions & 16 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,12 @@ projectnamespace = 'themachinethatgoesping'

# --- dependencies ---

# system
# if meson.get_compiler('cpp').get_id() == 'clang-cl'
# #omp_dep = dependency('openmp')
# omp_dep = declare_dependency()
# elif meson.get_compiler('cpp').get_id() == 'clang'
# # libomp = meson.get_compiler('cpp').find_library('libomp5')
# # omp_dep = declare_dependency(
# # compile_args : ['-fopenmp'],
# # dependencies : [libomp]
# # )
# omp_dep = declare_dependency()
# else
# omp_dep = dependency('openmp')
# endif

omp_dep = dependency('openmp')
# openmp (not used in clang-cl / windows)
if meson.get_compiler('cpp').get_id() == 'clang-cl'
omp_dep = declare_dependency()
else
omp_dep = dependency('openmp')
endif

# extra compiler args when for the tools target
tools_compile_args = ['-D_USE_MATH_DEFINES', '-fPIC']
Expand Down
2 changes: 1 addition & 1 deletion src/tests/tutorial.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <iostream>
#include <thread>

#include <omp.h>
#include <themachinethatgoesping/tools/helper/omp_helper.hpp>

// using namespace testing;
using namespace std;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//sourcehash: dde3ddcac5c985162f89b5211421b3158f063275d1d62c44b6407d304669c384

/*
This file contains docstrings for use in the Python bindings.
Do not edit! They were automatically extracted by pybind11_mkdoc.
This is a modified version which allows for more than 8 arguments and includes def-guard
*/

#pragma once

#ifndef __DOCSTRINGS_HPP__

#define __EXPAND(x) x
#define __COUNT(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, COUNT, ...) COUNT
#define __VA_SIZE(...) __EXPAND(__COUNT(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1))
#define __CAT1(a, b) a##b
#define __CAT2(a, b) __CAT1(a, b)
#define __DOC1(n1) __doc_##n1
#define __DOC2(n1, n2) __doc_##n1##_##n2
#define __DOC3(n1, n2, n3) __doc_##n1##_##n2##_##n3
#define __DOC4(n1, n2, n3, n4) __doc_##n1##_##n2##_##n3##_##n4
#define __DOC5(n1, n2, n3, n4, n5) __doc_##n1##_##n2##_##n3##_##n4##_##n5
#define __DOC6(n1, n2, n3, n4, n5, n6) __doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6
#define __DOC7(n1, n2, n3, n4, n5, n6, n7) __doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7
#define __DOC8(n1, n2, n3, n4, n5, n6, n7, n8) \
__doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7##_##n8
#define __DOC9(n1, n2, n3, n4, n5, n6, n7, n8, n9) \
__doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7##_##n8##_##n9
#define __DOC10(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10) \
__doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7##_##n8##_##n9##_##n10
#define DOC(...) __EXPAND(__EXPAND(__CAT2(__DOC, __VA_SIZE(__VA_ARGS__)))(__VA_ARGS__))

#endif // NEW_DOC_HEADER_HPP
#if defined(__GNUG__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif


static const char *__doc_omp_get_max_threads = R"doc()doc";

static const char *__doc_omp_get_num_procs = R"doc()doc";

static const char *__doc_omp_get_num_threads = R"doc()doc";

static const char *__doc_omp_get_thread_num = R"doc()doc";

#if defined(__GNUG__)
#pragma GCC diagnostic pop
#endif


19 changes: 19 additions & 0 deletions src/themachinethatgoesping/tools/helper/omp_helper.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-FileCopyrightText: 2024 Peter Urban, Ghent University
//
// SPDX-License-Identifier: MPL-2.0
#pragma once

/* generated doc strings */
#include ".docstrings/omp_helper.doc.hpp"

#if defined(_OPENMP)
// only include OpenMP header if it is defined
#include <omp.h>
#else
// If OpenMP is not defined, provide fallback functions that simulate
// single-threaded behavior
inline int omp_get_num_threads() { return 1; }
inline int omp_get_max_threads() { return 1; }
inline int omp_get_thread_num() { return 0; }
inline int omp_get_num_procs() { return 1; }
#endif
1 change: 1 addition & 0 deletions src/themachinethatgoesping/tools/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ headers = [
'helper/defaultsharedpointermap.hpp',
'helper/enum.hpp',
'helper/isviewstream.hpp',
'helper/omp_helper.hpp',
'helper/.docstrings/defaultmap.doc.hpp',
'helper/.docstrings/defaultsharedpointermap.doc.hpp',
'helper/.docstrings/enum.doc.hpp',
Expand Down

0 comments on commit 1a33277

Please sign in to comment.