#3634 Regression Test : Use flag to control OpenMP when building geometry

This commit is contained in:
Magne Sjaastad 2018-11-12 07:33:08 +01:00
parent ca07e710c6
commit cfbbcacc23
7 changed files with 91 additions and 45 deletions

View File

@ -1,17 +1,17 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS // Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
@ -22,42 +22,61 @@
#include "cafPdmUiFilePathEditor.h" #include "cafPdmUiFilePathEditor.h"
#include "cafPdmUiTextEditor.h" #include "cafPdmUiTextEditor.h"
CAF_PDM_SOURCE_INIT(RiaRegressionTest, "RiaRegressionTest"); CAF_PDM_SOURCE_INIT(RiaRegressionTest, "RiaRegressionTest");
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiaRegressionTest::RiaRegressionTest(void) RiaRegressionTest::RiaRegressionTest(void)
{ {
CAF_PDM_InitFieldNoDefault(&folderContainingCompareTool, "workingFolder", "Folder containing <b>compare</b>", "", "Location of compare tool from Image Magic suite", ""); CAF_PDM_InitFieldNoDefault(&folderContainingCompareTool,
"workingFolder",
"Folder containing <b>compare</b>",
"",
"Location of compare tool from Image Magic suite",
"");
folderContainingCompareTool.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); folderContainingCompareTool.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&folderContainingDiffTool, "folderContainingDiffTool", "Folder containing <b>diff</b>", "", "Location of diff tool used for text compare", ""); CAF_PDM_InitFieldNoDefault(&folderContainingDiffTool,
"folderContainingDiffTool",
"Folder containing <b>diff</b>",
"",
"Location of diff tool used for text compare",
"");
folderContainingDiffTool.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); folderContainingDiffTool.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&folderContainingGitTool, "folderContainingGitTool", "Folder containing <b>git</b>", "", "Location of git tool used for text compare", ""); CAF_PDM_InitFieldNoDefault(&folderContainingGitTool,
"folderContainingGitTool",
"Folder containing <b>git</b>",
"",
"Location of git tool used for text compare",
"");
folderContainingGitTool.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); folderContainingGitTool.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&regressionTestFolder, "regressionTestFolder", "Regression Test Folder", "", "", ""); CAF_PDM_InitFieldNoDefault(&regressionTestFolder, "regressionTestFolder", "Regression Test Folder", "", "", "");
regressionTestFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); regressionTestFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
CAF_PDM_InitField(&showInteractiveDiffImages, "showInteractiveDiffImages", false, "Interactive Diff Images", "", "", ""); CAF_PDM_InitField(&showInteractiveDiffImages, "showInteractiveDiffImages", false, "Interactive Diff Images", "", "", "");
CAF_PDM_InitField(
CAF_PDM_InitFieldNoDefault(&testFilter, "testFilter", "Test Filter", "", "If empty, all tests are executed.\nTo execute a subset of tests, specify folder names separated by ;", ""); &useOpenMPForGeometryCreation, "useOpenMPForGeometryCreation", true, "Use OpenMP For Geometry Creation", "", "", "");
CAF_PDM_InitFieldNoDefault(
&testFilter,
"testFilter",
"Test Filter",
"",
"If empty, all tests are executed.\nTo execute a subset of tests, specify folder names separated by ;",
"");
testFilter.uiCapability()->setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName()); testFilter.uiCapability()->setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName());
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RiaRegressionTest::~RiaRegressionTest(void) RiaRegressionTest::~RiaRegressionTest(void) {}
{
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiaRegressionTest::writeSettingsToApplicationStore() const void RiaRegressionTest::writeSettingsToApplicationStore() const
{ {
@ -65,7 +84,7 @@ void RiaRegressionTest::writeSettingsToApplicationStore() const
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiaRegressionTest::readSettingsFromApplicationStore() void RiaRegressionTest::readSettingsFromApplicationStore()
{ {
@ -73,11 +92,14 @@ void RiaRegressionTest::readSettingsFromApplicationStore()
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RiaRegressionTest::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) void RiaRegressionTest::defineEditorAttribute(const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute)
{ {
if (field == &folderContainingDiffTool || field == &folderContainingCompareTool || field == &regressionTestFolder || field == &folderContainingGitTool) if (field == &folderContainingDiffTool || field == &folderContainingCompareTool || field == &regressionTestFolder ||
field == &folderContainingGitTool)
{ {
caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>(attribute); caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast<caf::PdmUiFilePathEditorAttribute*>(attribute);
if (myAttr) if (myAttr)

View File

@ -1,28 +1,26 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS // Copyright (C) 2011-2012 Statoil ASA, Ceetron AS
// //
// ResInsight is free software: you can redistribute it and/or modify // ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or // WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. // FITNESS FOR A PARTICULAR PURPOSE.
// //
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html> // See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details. // for more details.
// //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
#pragma once #pragma once
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cafAppEnum.h" #include "cafAppEnum.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
class RiaRegressionTest : public caf::PdmObject class RiaRegressionTest : public caf::PdmObject
{ {
@ -36,13 +34,16 @@ public:
void readSettingsFromApplicationStore(); void readSettingsFromApplicationStore();
public: public:
caf::PdmField<QString> folderContainingCompareTool; caf::PdmField<QString> folderContainingCompareTool;
caf::PdmField<QString> folderContainingDiffTool; caf::PdmField<QString> folderContainingDiffTool;
caf::PdmField<QString> folderContainingGitTool; caf::PdmField<QString> folderContainingGitTool;
caf::PdmField<QString> regressionTestFolder; caf::PdmField<QString> regressionTestFolder;
caf::PdmField<QString> testFilter; caf::PdmField<QString> testFilter;
caf::PdmField<bool> showInteractiveDiffImages; caf::PdmField<bool> showInteractiveDiffImages;
caf::PdmField<bool> useOpenMPForGeometryCreation;
protected: protected:
void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; void defineEditorAttribute(const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute) override;
}; };

View File

@ -630,6 +630,8 @@ void RiaRegressionTestRunner::executeRegressionTests(const QString& regressionTe
mainWnd->setDefaultWindowSize(); mainWnd->setDefaultWindowSize();
m_regressionTestSettings.readSettingsFromApplicationStore();
m_rootPath = regressionTestPath; m_rootPath = regressionTestPath;
m_testFilter = testFilter; m_testFilter = testFilter;
runRegressionTest(); runRegressionTest();
@ -646,6 +648,16 @@ bool RiaRegressionTestRunner::isRunningRegressionTests() const
return m_runningRegressionTests; return m_runningRegressionTests;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaRegressionTestRunner::useOpenMPForGeometryCreation() const
{
if (!m_runningRegressionTests) return false;
return m_regressionTestSettings.useOpenMPForGeometryCreation;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -18,6 +18,8 @@
#pragma once #pragma once
#include "RiaRegressionTest.h"
#include <QFileInfo> #include <QFileInfo>
#include <QSize> #include <QSize>
#include <QStringList> #include <QStringList>
@ -37,6 +39,7 @@ public:
void executeRegressionTests(); void executeRegressionTests();
bool isRunningRegressionTests() const; bool isRunningRegressionTests() const;
bool useOpenMPForGeometryCreation() const;
static void updateRegressionTest(const QString& testRootPath); static void updateRegressionTest(const QString& testRootPath);
static void regressionTestConfigureProject(); static void regressionTestConfigureProject();
@ -63,7 +66,8 @@ private:
QFileInfoList subDirectoriesForTestExecution(const QDir& directory); QFileInfoList subDirectoriesForTestExecution(const QDir& directory);
private: private:
QString m_rootPath; QString m_rootPath;
QStringList m_testFilter; QStringList m_testFilter;
bool m_runningRegressionTests; bool m_runningRegressionTests;
RiaRegressionTest m_regressionTestSettings;
}; };

View File

@ -22,6 +22,7 @@
#include "RiaApplication.h" #include "RiaApplication.h"
#include "RiaPreferences.h" #include "RiaPreferences.h"
#include "RiaRegressionTestRunner.h"
#include "RigCaseCellResultsData.h" #include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h" #include "RigEclipseCaseData.h"
@ -71,7 +72,7 @@
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RivGridPartMgr::RivGridPartMgr(RivCellSetEnum cellSetType, RimEclipseCase* eclipseCase, const RigGridBase* grid, size_t gridIdx) RivGridPartMgr::RivGridPartMgr(RivCellSetEnum cellSetType, RimEclipseCase* eclipseCase, const RigGridBase* grid, size_t gridIdx)
: m_surfaceGenerator(grid) : m_surfaceGenerator(grid, RiaRegressionTestRunner::instance()->useOpenMPForGeometryCreation())
, m_gridIdx(gridIdx) , m_gridIdx(gridIdx)
, m_grid(grid) , m_grid(grid)
, m_surfaceFaceFilter(grid) , m_surfaceFaceFilter(grid)

View File

@ -172,8 +172,9 @@ bool CellRangeFilter::hasIncludeRanges() const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
StructGridGeometryGenerator::StructGridGeometryGenerator(const StructGridInterface* grid) StructGridGeometryGenerator::StructGridGeometryGenerator(const StructGridInterface* grid, bool useOpenMP)
: m_grid(grid) : m_grid(grid),
m_useOpenMP(useOpenMP)
{ {
CVF_ASSERT(grid); CVF_ASSERT(grid);
m_quadMapper = new StructGridQuadToCellFaceMapper; m_quadMapper = new StructGridQuadToCellFaceMapper;
@ -373,7 +374,7 @@ void StructGridGeometryGenerator::computeArrays()
cvf::Vec3d offset = m_grid->displayModelOffset(); cvf::Vec3d offset = m_grid->displayModelOffset();
#pragma omp parallel for schedule(dynamic) #pragma omp parallel for schedule(dynamic) if (m_useOpenMP)
for (int k = 0; k < static_cast<int>(m_grid->cellCountK()); k++) for (int k = 0; k < static_cast<int>(m_grid->cellCountK()); k++)
{ {
size_t j; size_t j;

View File

@ -164,7 +164,7 @@ private:
class StructGridGeometryGenerator : public Object class StructGridGeometryGenerator : public Object
{ {
public: public:
explicit StructGridGeometryGenerator(const StructGridInterface* grid); explicit StructGridGeometryGenerator(const StructGridInterface* grid, bool useOpenMP);
~StructGridGeometryGenerator(); ~StructGridGeometryGenerator();
// Setup methods // Setup methods
@ -209,6 +209,11 @@ private:
// Mappings // Mappings
ref<StructGridQuadToCellFaceMapper> m_quadMapper; ref<StructGridQuadToCellFaceMapper> m_quadMapper;
ref<StuctGridTriangleToCellFaceMapper> m_triangleMapper; ref<StuctGridTriangleToCellFaceMapper> m_triangleMapper;
// Multiple treads can be used when building geometry data structures.
// This causes visual artifacts due to transparency algorithm, and a stable visual image
// can be produced if OpenMP is disabled. Currently used by regression test comparing images
bool m_useOpenMP;
}; };
} }