Open Vincent-FA opened 4 years ago
We could just pass the number of threads to the functions with a default of 0 which would mean all cores.
Example for rcd
diff --git a/src/demosaic/rcd.cc b/src/demosaic/rcd.cc
index fc02ca9..9c92875 100644
--- a/src/demosaic/rcd.cc
+++ b/src/demosaic/rcd.cc
@@ -18,6 +18,7 @@
*/
#include <cmath>
#include <memory>
+#include <omp.h>
#include "bayerhelper.h"
#include "librtprocess.h"
@@ -35,10 +36,14 @@ using namespace librtprocess;
* Licensed under the GNU GPL version 3
*/
// Tiled version by Ingo Weyrich (heckflosse67@gmx.de)
-rpError rcd_demosaic(int width, int height, const float * const *rawData, float **red, float **green, float **blue, const unsigned cfarray[2][2], const std::function<bool(double)> &setProgCancel, size_t chunkSize, bool measure)
+rpError rcd_demosaic(int width, int height, const float * const *rawData, float **red, float **green, float **blue, const unsigned cfarray[2][2], const std::function<bool(double)> &setProgCancel, size_t chunkSize, bool measure, int numThreads)
{
BENCHFUN
-
+#ifdef _OPENMP
+ if (numThreads <= 0) {
+ numThreads = omp_get_max_threads();
+ }
+#endif
std::unique_ptr<StopWatch> stop;
if (measure) {
@@ -65,7 +70,7 @@ rpError rcd_demosaic(int width, int height, const float * const *rawData, float
static constexpr float epssq = 1e-10f;
#ifdef _OPENMP
-#pragma omp parallel
+#pragma omp parallel num_threads(numThreads)
#endif
{
int progresscounter = 0;
diff --git a/src/include/librtprocess.h b/src/include/librtprocess.h
index 47691a0..84ca868 100644
--- a/src/include/librtprocess.h
+++ b/src/include/librtprocess.h
@@ -31,7 +31,7 @@ rpError amaze_demosaic(int raw_width, int raw_height, int winx, int winy, int wi
rpError bayerfast_demosaic(int width, int height, const float * const *rawData, float **red, float **green, float **blue, const unsigned cfarray[2][2], const std::function<bool(double)> &setProgCancel, double initGain);
rpError dcb_demosaic(int width, int height, const float * const *rawData, float **red, float **green, float **blue, const unsigned cfarray[2][2], const std::function<bool(double)> &setProgCancel, int iterations, bool dcb_enhance);
rpError hphd_demosaic(int width, int height, const float * const *rawData, float **red, float **green, float **blue, const unsigned cfarray[2][2], const std::function<bool(double)> &setProgCancel);
-rpError rcd_demosaic(int width, int height, const float * const *rawData, float **red, float **green, float **blue, const unsigned cfarray[2][2], const std::function<bool(double)> &setProgCancel, size_t chunkSize = 2, bool measure = false);
+rpError rcd_demosaic(int width, int height, const float * const *rawData, float **red, float **green, float **blue, const unsigned cfarray[2][2], const std::function<bool(double)> &setProgCancel, size_t chunkSize = 2, bool measure = false, int numThreads = 0);
rpError markesteijn_demosaic(int width, int height, const float * const *rawdata, float **red, float **green, float **blue, const unsigned xtrans[6][6], const float rgb_cam[3][4], const std::function<bool(double)> &setProgCancel, const int passes, const bool useCieLab, size_t chunkSize = 2, bool measure = false);
rpError xtransfast_demosaic(int width, int height, const float * const *rawData, float **red, float **green, float **blue, const unsigned xtrans[6][6], const std::function<bool(double)> &setProgCancel);
rpError vng4_demosaic (int width, int height, const float * const *rawData, float **red, float **green, float **blue, const unsigned cfarray[2][2], const std::function<bool(double)> &setProgCancel);
Please do not hesitate to make a pull request ;-)
I'll just use -DOPTION_OMP=OFF, no worries.
Hello it's me again. I'd like to have a way to configure how many threads librtprocess will use for demosaicing. For the context, I'm integrating it in siril that already parallelizes the processing of several files, so we can't give all threads to demosaicing, otherwise we'd have to only process one at time and wait for I/O. Thanks