From bc2959398295ca9d75ba90f5d7c9409e0232b07e Mon Sep 17 00:00:00 2001 From: couriersud Date: Sun, 7 May 2017 21:34:25 +0200 Subject: Netlist refactoring: - OPENMP refactored. All OPENMP operations are now templatized in pomp.h - We don't need thread-safe priority queue. Event code updating analog outputs now runs outside the parallel code. (nw) --- src/lib/netlist/plib/pomp.h | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/lib/netlist/plib/pomp.h (limited to 'src/lib/netlist/plib/pomp.h') diff --git a/src/lib/netlist/plib/pomp.h b/src/lib/netlist/plib/pomp.h new file mode 100644 index 00000000000..6559207f09d --- /dev/null +++ b/src/lib/netlist/plib/pomp.h @@ -0,0 +1,60 @@ +// license:GPL-2.0+ +// copyright-holders:Couriersud +/* + * pomp.h + * + * Wrap all OPENMP stuff here in a hopefully c++ compliant way. + */ + +#ifndef POMP_H_ +#define POMP_H_ + +#include "pconfig.h" + +#if HAS_OPENMP +#include "omp.h" +#endif + +namespace plib { +namespace omp { + +template +void for_static(const int start, const int end, const T &what) +{ +#if HAS_OPENMP && USE_OPENMP + #pragma omp parallel +#endif + { +#if HAS_OPENMP && USE_OPENMP + #pragma omp for schedule(static) +#endif + for (int i = start; i < end; i++) + what(i); + } +} + +inline void set_num_threads(const int threads) +{ +#if HAS_OPENMP && USE_OPENMP + omp_set_num_threads(threads); +#endif +} + +inline int get_max_threads() +{ +#if HAS_OPENMP && USE_OPENMP + return omp_get_max_threads(); +#else + return 1; +#endif +} + + +// ---------------------------------------------------------------------------------------- +// pdynlib: dynamic loading of libraries ... +// ---------------------------------------------------------------------------------------- + +} +} + +#endif /* PSTRING_H_ */ -- cgit v1.2.3-70-g09d2