diff options
author | 2017-05-07 21:34:25 +0200 | |
---|---|---|
committer | 2017-05-27 00:11:14 +0200 | |
commit | bc2959398295ca9d75ba90f5d7c9409e0232b07e (patch) | |
tree | 44e25f4d15866996c89dfd831228b62dbdbf7afe /src/lib/netlist/plib | |
parent | 01f8ace29685a59e3b1a3fcc0a4dce9c5e1a43b5 (diff) |
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)
Diffstat (limited to 'src/lib/netlist/plib')
-rw-r--r-- | src/lib/netlist/plib/pomp.h | 60 |
1 files changed, 60 insertions, 0 deletions
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 <class T> +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_ */ |