From 77475a3827b8362977f0eaa4ed2ba5db107e5e49 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sun, 3 Mar 2019 17:29:19 +0100 Subject: [PATCH] configurable tiles per thread also for rcd, #5203 --- rtdata/languages/default | 5 +++-- rtengine/amaze_demosaic_RT.cc | 3 ++- rtengine/dual_demosaic_RT.cc | 4 ++-- rtengine/rawimagesource.cc | 2 +- rtengine/rawimagesource.h | 2 +- rtengine/rcd_demosaic.cc | 5 +++-- rtgui/options.cc | 9 +++++++-- rtgui/options.h | 1 + rtgui/preferences.cc | 26 ++++++++++++++++++++++---- rtgui/preferences.h | 1 + 10 files changed, 43 insertions(+), 15 deletions(-) diff --git a/rtdata/languages/default b/rtdata/languages/default index 3019f49bd..804ae1624 100644 --- a/rtdata/languages/default +++ b/rtdata/languages/default @@ -1064,6 +1064,9 @@ PREFERENCES_CACHECLEAR_SAFETY;Only files in the cache are cleared. Processing pr PREFERENCES_CACHEMAXENTRIES;Maximum number of cache entries PREFERENCES_CACHEOPTS;Cache Options PREFERENCES_CACHETHUMBHEIGHT;Maximum thumbnail height +PREFERENCES_CHUNKSIZES;Tiles per thread +PREFERENCES_CHUNKSIZE_RAW_CA;Raw CA correction +PREFERENCES_CHUNKSIZE_RAW_RCD;RCD demosaic PREFERENCES_CLIPPINGIND;Clipping Indication PREFERENCES_CLUTSCACHE;HaldCLUT Cache PREFERENCES_CLUTSCACHE_LABEL;Maximum number of cached CLUTs @@ -1202,8 +1205,6 @@ PREFERENCES_PRTPROFILE;Color profile PREFERENCES_PSPATH;Adobe Photoshop installation directory PREFERENCES_REMEMBERZOOMPAN;Remember zoom % and pan offset PREFERENCES_REMEMBERZOOMPAN_TOOLTIP;Remember the zoom % and pan offset of the current image when opening a new image.\n\nThis option only works in "Single Editor Tab Mode" and when "Demosaicing method used for the preview at <100% zoom" is set to "As in PP3". -PREFERENCES_RAWCA;Raw CA correction -PREFERENCES_RAWCA_CHUNKSIZE;Tiles per thread PREFERENCES_SAVE_TP_OPEN_NOW;Save tool collapsed/expanded state now PREFERENCES_SELECTLANG;Select language PREFERENCES_SERIALIZE_TIFF_READ;TIFF Read Settings diff --git a/rtengine/amaze_demosaic_RT.cc b/rtengine/amaze_demosaic_RT.cc index 31419022d..3aafbd448 100644 --- a/rtengine/amaze_demosaic_RT.cc +++ b/rtengine/amaze_demosaic_RT.cc @@ -33,6 +33,7 @@ #include "sleef.c" #include "opthelper.h" #include "median.h" +#define BENCHMARK #include "StopWatch.h" namespace rtengine @@ -176,7 +177,7 @@ void RawImageSource::amaze_demosaic_RT(int winx, int winy, int winw, int winh, c // Main algorithm: Tile loop // use collapse(2) to collapse the 2 loops to one large loop, so there is better scaling #ifdef _OPENMP - #pragma omp for schedule(dynamic) collapse(2) nowait + #pragma omp for schedule(dynamic, 8) collapse(2) nowait #endif for (int top = winy - 16; top < winy + height; top += ts - 32) { diff --git a/rtengine/dual_demosaic_RT.cc b/rtengine/dual_demosaic_RT.cc index 790275d7e..e6397fe17 100644 --- a/rtengine/dual_demosaic_RT.cc +++ b/rtengine/dual_demosaic_RT.cc @@ -48,7 +48,7 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const RAWParams &raw, int wi } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::DCBVNG4) ) { dcb_demosaic(raw.bayersensor.dcb_iterations, raw.bayersensor.dcb_enhance); } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::RCDVNG4) ) { - rcd_demosaic(); + rcd_demosaic(options.chunkSizeCA); } } else { if (raw.xtranssensor.method == RAWParams::XTransSensor::getMethodString(RAWParams::XTransSensor::Method::FOUR_PASS) ) { @@ -74,7 +74,7 @@ void RawImageSource::dual_demosaic_RT(bool isBayer, const RAWParams &raw, int wi } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::DCBVNG4) ) { dcb_demosaic(raw.bayersensor.dcb_iterations, raw.bayersensor.dcb_enhance); } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::RCDVNG4) ) { - rcd_demosaic(); + rcd_demosaic(options.chunkSizeCA); } } else { if (raw.xtranssensor.method == RAWParams::XTransSensor::getMethodString(RAWParams::XTransSensor::Method::FOUR_PASS) ) { diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index d567ab671..d6cffda26 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -2103,7 +2103,7 @@ void RawImageSource::demosaic(const RAWParams &raw, bool autoContrast, double &c } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::MONO) ) { nodemosaic(true); } else if (raw.bayersensor.method == RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::RCD) ) { - rcd_demosaic (); + rcd_demosaic(options.chunkSizeRCD); } else { nodemosaic(false); } diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index 34ac1cef3..5fb233c2b 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -277,7 +277,7 @@ protected: void fast_demosaic();//Emil's code for fast demosaicing void dcb_demosaic(int iterations, bool dcb_enhance); void ahd_demosaic(); - void rcd_demosaic(); + void rcd_demosaic(size_t chunkSize = 1); void border_interpolate(unsigned int border, float (*image)[4], unsigned int start = 0, unsigned int end = 0); void border_interpolate2(int winw, int winh, int lborders, const array2D &rawData, array2D &red, array2D &green, array2D &blue); void dcb_initTileLimits(int &colMin, int &rowMin, int &colMax, int &rowMax, int x0, int y0, int border); diff --git a/rtengine/rcd_demosaic.cc b/rtengine/rcd_demosaic.cc index 01430a894..137c98c18 100644 --- a/rtengine/rcd_demosaic.cc +++ b/rtengine/rcd_demosaic.cc @@ -22,6 +22,7 @@ #include "rt_math.h" #include "../rtgui/multilangmgr.h" #include "opthelper.h" +#define BENCHMARK #include "StopWatch.h" using namespace std; @@ -39,7 +40,7 @@ namespace rtengine * Licensed under the GNU GPL version 3 */ // Tiled version by Ingo Weyrich (heckflosse67@gmx.de) -void RawImageSource::rcd_demosaic() +void RawImageSource::rcd_demosaic(size_t chunkSize) { BENCHFUN @@ -72,7 +73,7 @@ void RawImageSource::rcd_demosaic() float *lpf = PQ_Dir; // reuse buffer, they don't overlap in usage #ifdef _OPENMP - #pragma omp for schedule(dynamic) collapse(2) nowait + #pragma omp for schedule(dynamic, chunkSize) collapse(2) nowait #endif for(int tr = 0; tr < numTh; ++tr) { for(int tc = 0; tc < numTw; ++tc) { diff --git a/rtgui/options.cc b/rtgui/options.cc index 01146111d..8f7fbbc50 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -449,6 +449,7 @@ void Options::setDefaults() inspectorDelay = 0; serializeTiffRead = true; chunkSizeCA = 1; + chunkSizeRCD = 1; FileBrowserToolbarSingleRow = false; hideTPVScrollbar = false; whiteBalanceSpotSize = 8; @@ -1080,7 +1081,11 @@ void Options::readFromFile(Glib::ustring fname) } if (keyFile.has_key("Performance", "ChunkSizeCA")) { - chunkSizeCA = keyFile.get_integer("Performance", "ChunkSizeCA"); + chunkSizeCA = std::min(16, std::max(1, keyFile.get_integer("Performance", "ChunkSizeCA"))); + } + + if (keyFile.has_key("Performance", "ChunkSizeRCD")) { + chunkSizeRCD = std::min(16, std::max(1, keyFile.get_integer("Performance", "ChunkSizeRCD"))); } if (keyFile.has_key("Performance", "ThumbnailInspectorMode")) { @@ -1953,7 +1958,7 @@ void Options::saveToFile(Glib::ustring fname) keyFile.set_integer("Performance", "InspectorDelay", inspectorDelay); keyFile.set_integer("Performance", "PreviewDemosaicFromSidecar", prevdemo); keyFile.set_boolean("Performance", "SerializeTiffRead", serializeTiffRead); - keyFile.set_integer("Performance", "ChunkSizeCA", chunkSizeCA); + keyFile.set_integer("Performance", "ChunkSizeRCD", chunkSizeRCD); keyFile.set_integer("Performance", "ThumbnailInspectorMode", int(rtSettings.thumbnail_inspector_mode)); keyFile.set_string("Output", "Format", saveFormat.format); diff --git a/rtgui/options.h b/rtgui/options.h index f325605ab..042889337 100644 --- a/rtgui/options.h +++ b/rtgui/options.h @@ -315,6 +315,7 @@ public: prevdemo_t prevdemo; // Demosaicing method used for the <100% preview bool serializeTiffRead; size_t chunkSizeCA; + size_t chunkSizeRCD; bool menuGroupRank; bool menuGroupLabel; bool menuGroupFileOperations; diff --git a/rtgui/preferences.cc b/rtgui/preferences.cc index 94c9118c3..f9724a15c 100644 --- a/rtgui/preferences.cc +++ b/rtgui/preferences.cc @@ -666,10 +666,11 @@ Gtk::Widget* Preferences::getPerformancePanel () fclut->add (*clutCacheSizeHB); vbPerformance->pack_start (*fclut, Gtk::PACK_SHRINK, 4); - Gtk::Frame* fca = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_RAWCA")) ); + Gtk::Frame* fchunksize = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_CHUNKSIZES")) ); + Gtk::VBox* chunkSizeVB = Gtk::manage ( new Gtk::VBox () ); Gtk::HBox* cachunkSizeHB = Gtk::manage ( new Gtk::HBox () ); cachunkSizeHB->set_spacing (4); - Gtk::Label* CALl = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_RAWCA_CHUNKSIZE") + ":", Gtk::ALIGN_START)); + Gtk::Label* CALl = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_CHUNKSIZE_RAW_CA") + ":", Gtk::ALIGN_START)); chunkSizeCASB = Gtk::manage ( new Gtk::SpinButton () ); chunkSizeCASB->set_digits (0); chunkSizeCASB->set_increments (1, 5); @@ -677,8 +678,23 @@ Gtk::Widget* Preferences::getPerformancePanel () chunkSizeCASB->set_range (1, 16); cachunkSizeHB->pack_start (*CALl, Gtk::PACK_SHRINK, 0); cachunkSizeHB->pack_end (*chunkSizeCASB, Gtk::PACK_SHRINK, 0); - fca->add (*cachunkSizeHB); - vbPerformance->pack_start (*fca, Gtk::PACK_SHRINK, 4); + chunkSizeVB->add(*cachunkSizeHB); + + Gtk::HBox* rcdchunkSizeHB = Gtk::manage ( new Gtk::HBox () ); + rcdchunkSizeHB->set_spacing (4); + Gtk::Label* RCDLl = Gtk::manage ( new Gtk::Label (M ("PREFERENCES_CHUNKSIZE_RAW_RCD") + ":", Gtk::ALIGN_START)); + chunkSizeRCDSB = Gtk::manage ( new Gtk::SpinButton () ); + chunkSizeRCDSB->set_digits (0); + chunkSizeRCDSB->set_increments (1, 5); + chunkSizeRCDSB->set_max_length (2); // Will this be sufficient? :) + chunkSizeRCDSB->set_range (1, 16); + rcdchunkSizeHB->pack_start (*RCDLl, Gtk::PACK_SHRINK, 0); + rcdchunkSizeHB->pack_end (*chunkSizeRCDSB, Gtk::PACK_SHRINK, 0); + chunkSizeVB->add(*rcdchunkSizeHB); + + fchunksize->add (*chunkSizeVB); + + vbPerformance->pack_start (*fchunksize, Gtk::PACK_SHRINK, 4); Gtk::Frame* finspect = Gtk::manage ( new Gtk::Frame (M ("PREFERENCES_INSPECT_LABEL")) ); Gtk::HBox* maxIBuffersHB = Gtk::manage ( new Gtk::HBox () ); @@ -1798,6 +1814,7 @@ void Preferences::storePreferences () moptions.rgbDenoiseThreadLimit = threadsSpinBtn->get_value_as_int(); moptions.clutCacheSize = clutCacheSizeSB->get_value_as_int(); moptions.chunkSizeCA = chunkSizeCASB->get_value_as_int(); + moptions.chunkSizeRCD= chunkSizeRCDSB->get_value_as_int(); moptions.maxInspectorBuffers = maxInspectorBuffersSB->get_value_as_int(); moptions.rtSettings.thumbnail_inspector_mode = static_cast(thumbnailInspectorMode->get_active_row_number()); @@ -2003,6 +2020,7 @@ void Preferences::fillPreferences () threadsSpinBtn->set_value (moptions.rgbDenoiseThreadLimit); clutCacheSizeSB->set_value (moptions.clutCacheSize); chunkSizeCASB->set_value (moptions.chunkSizeCA); + chunkSizeRCDSB->set_value (moptions.chunkSizeRCD); maxInspectorBuffersSB->set_value (moptions.maxInspectorBuffers); thumbnailInspectorMode->set_active(int(moptions.rtSettings.thumbnail_inspector_mode)); diff --git a/rtgui/preferences.h b/rtgui/preferences.h index 2320209d9..60ed04a51 100644 --- a/rtgui/preferences.h +++ b/rtgui/preferences.h @@ -162,6 +162,7 @@ class Preferences : public Gtk::Dialog, public ProfileStoreListener Gtk::SpinButton* threadsSpinBtn; Gtk::SpinButton* clutCacheSizeSB; Gtk::SpinButton* chunkSizeCASB; + Gtk::SpinButton* chunkSizeRCDSB; Gtk::SpinButton* maxInspectorBuffersSB; Gtk::ComboBoxText *thumbnailInspectorMode;