From 745b680c027f7fcd1ab751d398a50d1801e9b1b2 Mon Sep 17 00:00:00 2001 From: Michael Goldstein Date: Tue, 10 May 2022 13:19:01 -0400 Subject: [PATCH] fix target directory so that it can compile properly without linking in fopenmp change inclusion of omp.h in offload.h and thermo.h to openmp.h add include guards to openmp.h stub functions add omp_get_num_teams, omp_get_team_num, and omp_is_initial_device functions to stubs to ensure compilation --- target/offload.h | 2 +- target/openmp.h | 18 ++++++++++++++---- target/thermo.cpp | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/target/offload.h b/target/offload.h index 12637e7..f952a28 100644 --- a/target/offload.h +++ b/target/offload.h @@ -34,7 +34,7 @@ #include #include #include -#include +#include "openmp.h" #include "util.h" inline const char *get_variant_string() diff --git a/target/openmp.h b/target/openmp.h index ba7da99..9ed9346 100644 --- a/target/openmp.h +++ b/target/openmp.h @@ -39,13 +39,23 @@ OpenMP wrapper for headerfile #ifdef _OPENMP #include #else -inline int omp_get_thread_num() { return 0; } -inline int omp_get_max_threads() { return 1; } -inline void omp_set_num_threads(int num_threads) { return 1; } -inline int __sync_fetch_and_add(int *ptr, int value) + +#ifndef OPENMP_H +#define OPENMP_H + +inline int omp_get_thread_num() { return 0; } +inline int omp_get_max_threads() { return 1; } +inline void omp_set_num_threads(int num_threads) { ; } +inline int omp_get_num_teams(void) { return 1; } +inline int omp_get_team_num(void) { return 0; } +inline int omp_is_initial_device(void) { return 1; } +inline int __sync_fetch_and_add(int *ptr, int value) { int tmp = *ptr; ptr[0] += value; return tmp; } + #endif + +#endif \ No newline at end of file diff --git a/target/thermo.cpp b/target/thermo.cpp index c1837b4..6bfaf01 100644 --- a/target/thermo.cpp +++ b/target/thermo.cpp @@ -37,7 +37,7 @@ #include "stdio.h" #include "stdlib.h" #include "util.h" -#include +#include "openmp.h" Thermo::Thermo() {} Thermo::~Thermo() {}