From: <hug...@li...> - 2011-10-13 20:21:45
|
branch: details: http://hugin.hg.sourceforge.net/hgweb/hugin/hugin/hgrepo/h/hu/hugin/hugin/rev/75a8d1bb2a33 changeset: 5619:75a8d1bb2a33 user: tmodes date: Thu Oct 13 22:21:31 2011 +0200 description: Allow setting of number of threads for stitching [678880] diffstat: src/hugin1/base_wx/RunStitchPanel.cpp | 4 +- src/hugin1/hugin/MainFrame.cpp | 3 +- src/hugin1/hugin/PreferencesDialog.cpp | 6 + src/hugin1/hugin/xrc/pref_dialog.xrc | 32 +++++++++- src/hugin_base/algorithms/panorama_makefile/PanoramaMakefilelibExport.cpp | 19 +++++- src/hugin_base/algorithms/panorama_makefile/PanoramaMakefilelibExport.h | 11 ++- src/tools/pto2mk.cpp | 3 +- 7 files changed, 68 insertions(+), 10 deletions(-) diffs (203 lines): diff -r eae49ac5569a -r 75a8d1bb2a33 src/hugin1/base_wx/RunStitchPanel.cpp --- a/src/hugin1/base_wx/RunStitchPanel.cpp Sat Oct 08 11:34:28 2011 +0200 +++ b/src/hugin1/base_wx/RunStitchPanel.cpp Thu Oct 13 22:21:31 2011 +0200 @@ -235,6 +235,7 @@ wxConfigBase* config=wxConfigBase::Get(); std::string tmpDir((config->Read(wxT("tempDir"),wxT(""))).mb_str(HUGIN_CONV_FILENAME)); bool copyMetadata=config->Read(wxT("/output/useExiftool"),1l)==1l; + int nrThreads=config->Read(wxT("/output/NumberOfThreads"),0l); std::vector<std::string> outputFiles; HuginBase::PanoramaMakefilelibExport::createMakefile(pano, @@ -246,7 +247,8 @@ outputFiles, makeFileStream, tmpDir, - copyMetadata); + copyMetadata, + nrThreads); makeFileStream.close(); // cd to output directory, if one is given. diff -r eae49ac5569a -r 75a8d1bb2a33 src/hugin1/hugin/MainFrame.cpp --- a/src/hugin1/hugin/MainFrame.cpp Sat Oct 08 11:34:28 2011 +0200 +++ b/src/hugin1/hugin/MainFrame.cpp Thu Oct 13 22:21:31 2011 +0200 @@ -696,7 +696,8 @@ outputFiles, makefile, tmpDir, - true); + true, + 0); } SetStatusText(wxString::Format(_("saved project %s"), m_filename.c_str()),0); this->SetTitle(scriptName.GetName() + wxT(".") + scriptName.GetExt() + wxT(" - ") + _("Hugin - Panorama Stitcher")); diff -r eae49ac5569a -r 75a8d1bb2a33 src/hugin1/hugin/PreferencesDialog.cpp --- a/src/hugin1/hugin/PreferencesDialog.cpp Sat Oct 08 11:34:28 2011 +0200 +++ b/src/hugin1/hugin/PreferencesDialog.cpp Thu Oct 13 22:21:31 2011 +0200 @@ -570,6 +570,10 @@ t = cfg->Read(wxT("/output/useExiftool"), 1l) == 1; MY_BOOL_VAL("pref_exiftool_metadata", t); + + int nThreads = cfg->Read(wxT("/output/NumberOfThreads"), 0l); + MY_SPIN_VAL("prefs_output_NumberOfThreads", nThreads); + } if (panel==0 || panel == 6){ @@ -730,6 +734,7 @@ cfg->Write(wxT("/Processor/overwrite"), HUGIN_PROCESSOR_OVERWRITE); cfg->Write(wxT("/Processor/verbose"), HUGIN_PROCESSOR_VERBOSE); cfg->Write(wxT("/output/useExiftool"), 1l); + cfg->Write(wxT("/output/NumberOfThreads"), 0l); } if (noteb->GetSelection() == 5) { @@ -861,6 +866,7 @@ cfg->Write(wxT("/Processor/verbose"), MY_G_BOOL_VAL("pref_processor_verbose")); cfg->Write(wxT("/output/useExiftool"), MY_G_BOOL_VAL("pref_exiftool_metadata")); + cfg->Write(wxT("/output/NumberOfThreads"), MY_G_SPIN_VAL("prefs_output_NumberOfThreads")); ///// /// STITCHING cfg->Write(wxT("/Nona/Interpolator"), MY_G_CHOICE_VAL("prefs_nona_interpolator")); diff -r eae49ac5569a -r 75a8d1bb2a33 src/hugin1/hugin/xrc/pref_dialog.xrc --- a/src/hugin1/hugin/xrc/pref_dialog.xrc Sat Oct 08 11:34:28 2011 +0200 +++ b/src/hugin1/hugin/xrc/pref_dialog.xrc Thu Oct 13 22:21:31 2011 +0200 @@ -54,7 +54,7 @@ <object class="wxSpinCtrl" name="prefs_nona_NumberOfThreads"> <value>1</value> <min>1</min> - <tooltip>Nona can use multiple threads for processing.\nSet this to the number of processors or processor cores available in your system</tooltip> + <tooltip>Hugins preview window can use multiple threads for processing.\nSet this to the number of processors or processor cores available in your system</tooltip> </object> <flag>wxALL|wxALIGN_CENTRE_VERTICAL</flag> <border>5</border> @@ -972,6 +972,36 @@ <flag>wxALL|wxEXPAND</flag> <border>5</border> </object> + <object class="sizeritem"> + <object class="wxBoxSizer"> + <object class="sizeritem"> + <object class="wxStaticText"> + <label>Number of threads:</label> + </object> + <flag>wxALL|wxALIGN_CENTRE_VERTICAL</flag> + <border>5</border> + </object> + <object class="sizeritem"> + <object class="wxSpinCtrl" name="prefs_output_NumberOfThreads"> + <value>0</value> + <min>0</min> + <tooltip>Nona and the OpenMP enabled enblend/enfuse can use multiple threads for processing.\nSet this number maximal to the number of processors or processor cores available in your system</tooltip> + </object> + <flag>wxALL|wxALIGN_CENTRE_VERTICAL</flag> + <border>5</border> + </object> + <object class="sizeritem"> + <object class="wxStaticText"> + <label>0 for automatic detection</label> + </object> + <flag>wxALL|wxALIGN_CENTRE_VERTICAL</flag> + <border>5</border> + </object> + <orient>wxHORIZONTAL</orient> + </object> + <flag>wxALL|wxEXPAND</flag> + <border>5</border> + </object> </object> <flag>wxALL|wxEXPAND</flag> <border>5</border> diff -r eae49ac5569a -r 75a8d1bb2a33 src/hugin_base/algorithms/panorama_makefile/PanoramaMakefilelibExport.cpp --- a/src/hugin_base/algorithms/panorama_makefile/PanoramaMakefilelibExport.cpp Sat Oct 08 11:34:28 2011 +0200 +++ b/src/hugin_base/algorithms/panorama_makefile/PanoramaMakefilelibExport.cpp Thu Oct 13 22:21:31 2011 +0200 @@ -217,6 +217,13 @@ mf::Variable* vexiftool = mgr.own(new mf::Variable("EXIFTOOL", progs.exiftool)); vexiftool->getDef().add(); + if(nrThreads>0) + { + //set environment variable for OpenMP enabled enblend/enfuse + mf::Variable* vOpenMPThreads = mgr.own(new mf::Variable("OMP_NUM_THREADS", nrThreads)); + vOpenMPThreads->setExport(true); + vOpenMPThreads->getDef().add(); + }; //---------- // Project parameters mgr.own_add(new Comment("Project parameters")); @@ -249,8 +256,16 @@ vnonaldr = mgr.own(new mf::Variable("NONA_LDR_REMAPPED_COMP", val, Makefile::NONE)); vnonaldr->getDef().add(); - vnonaopts = mgr.own(new mf::Variable("NONA_OPTS", - opts.remapUsingGPU ? "-g " : "", Makefile::NONE)); + valuestream.str(""); + if(opts.remapUsingGPU) + { + valuestream << "-g "; + }; + if(nrThreads>0) + { + valuestream << "-t " << nrThreads; + }; + vnonaopts = mgr.own(new mf::Variable("NONA_OPTS",valuestream.str(), Makefile::NONE)); vnonaopts->getDef().add(); } diff -r eae49ac5569a -r 75a8d1bb2a33 src/hugin_base/algorithms/panorama_makefile/PanoramaMakefilelibExport.h --- a/src/hugin_base/algorithms/panorama_makefile/PanoramaMakefilelibExport.h Sat Oct 08 11:34:28 2011 +0200 +++ b/src/hugin_base/algorithms/panorama_makefile/PanoramaMakefilelibExport.h Thu Oct 13 22:21:31 2011 +0200 @@ -93,6 +93,7 @@ std::ostream & makefile; const std::string& tmpDir; const bool copyMetadata; + const int nrThreads; makefile::Manager mgr; std::ostringstream valuestream; @@ -141,11 +142,12 @@ std::vector<std::string> & outputFiles_, std::ostream & makefile_, const std::string& tmpDir_, - const bool copyMetadata_) + const bool copyMetadata_, + const int nrThreads_) : PanoramaAlgorithm(pano), pano(pano_), ptofile(ptofile_), outputPrefix(outputPrefix_), progs(progs_), includePath(includePath_), outputFiles(outputFiles_), - makefile(makefile_), tmpDir(tmpDir_), copyMetadata(copyMetadata_) + makefile(makefile_), tmpDir(tmpDir_), copyMetadata(copyMetadata_), nrThreads(nrThreads_) { images=getImagesinROI(pano_,images_); valuestream.imbue(makefile::GetMakefileLocale()); @@ -161,11 +163,12 @@ std::vector<std::string> & outputFiles_, std::ostream & makefile_, const std::string& tmpDir_, - const bool copyMetadata_) + const bool copyMetadata_, + const int nrThreads_) { PanoramaMakefilelibExport* instance = new PanoramaMakefilelibExport( pano_, images_, ptofile_, outputPrefix_, progs_, includePath_, - outputFiles_, makefile_, tmpDir_, copyMetadata_); + outputFiles_, makefile_, tmpDir_, copyMetadata_, nrThreads_); instance->createItems(); instance->writeMakefile(); delete instance; diff -r eae49ac5569a -r 75a8d1bb2a33 src/tools/pto2mk.cpp --- a/src/tools/pto2mk.cpp Sat Oct 08 11:34:28 2011 +0200 +++ b/src/tools/pto2mk.cpp Thu Oct 13 22:21:31 2011 +0200 @@ -148,7 +148,8 @@ outputFiles, makeFileStream, "", - true); + true, + 0); return 0; } |