From 4cb818c576d9be0fbe9414375dfe103d1e2b767c Mon Sep 17 00:00:00 2001 From: Sebastian Eibl <sebastian.eibl@fau.de> Date: Tue, 26 Mar 2019 13:47:57 +0100 Subject: [PATCH] fixed shadowing warning for reduce type in walberla::timing --- .../AMRSedimentSettling.cpp | 2 +- .../ComplexGeometry/ComplexGeometry.cpp | 4 +- src/core/timing/ReduceType.h | 41 +++++++++++++++++++ src/core/timing/TimingNode.h | 15 +------ src/core/timing/TimingPool.h | 16 +------- .../basic_exports/BasicExports.cpp | 11 ++--- tests/core/timing/TimingPoolTest.cpp | 10 ++--- 7 files changed, 57 insertions(+), 42 deletions(-) create mode 100644 src/core/timing/ReduceType.h diff --git a/apps/benchmarks/AdaptiveMeshRefinementFluidParticleCoupling/AMRSedimentSettling.cpp b/apps/benchmarks/AdaptiveMeshRefinementFluidParticleCoupling/AMRSedimentSettling.cpp index 8012ac89d..4a8af6662 100644 --- a/apps/benchmarks/AdaptiveMeshRefinementFluidParticleCoupling/AMRSedimentSettling.cpp +++ b/apps/benchmarks/AdaptiveMeshRefinementFluidParticleCoupling/AMRSedimentSettling.cpp @@ -890,7 +890,7 @@ uint_t evaluateEdgeCut(BlockForest & forest) void evaluateTotalSimulationTimePassed(WcTimingPool & timeloopTimingPool, real_t & totalSimTime, real_t & totalLBTime) { - shared_ptr< WcTimingPool> reduced = timeloopTimingPool.getReduced(WcTimingPool::REDUCE_TOTAL, 0); + shared_ptr< WcTimingPool> reduced = timeloopTimingPool.getReduced(timing::REDUCE_TOTAL, 0); std::string simulationString("LBM refinement time step"); auto totalTime = real_t(0); diff --git a/apps/benchmarks/ComplexGeometry/ComplexGeometry.cpp b/apps/benchmarks/ComplexGeometry/ComplexGeometry.cpp index 8a18cbccd..83c6f25c6 100644 --- a/apps/benchmarks/ComplexGeometry/ComplexGeometry.cpp +++ b/apps/benchmarks/ComplexGeometry/ComplexGeometry.cpp @@ -291,7 +291,7 @@ int main( int argc, char * argv[] ) timeloop.run( timingPool ); WALBERLA_LOG_INFO_ON_ROOT( "Timeloop done" ); timingPool.unifyRegisteredTimersAcrossProcesses(); - timingPool.logResultOnRoot( WcTimingPool::REDUCE_TOTAL, true ); + timingPool.logResultOnRoot( timing::REDUCE_TOTAL, true ); return EXIT_SUCCESS; } @@ -302,4 +302,4 @@ int main( int argc, char * argv[] ) int main( int argc, char * argv[] ) { return walberla::main( argc, argv ); -} \ No newline at end of file +} diff --git a/src/core/timing/ReduceType.h b/src/core/timing/ReduceType.h new file mode 100644 index 000000000..3a72fd744 --- /dev/null +++ b/src/core/timing/ReduceType.h @@ -0,0 +1,41 @@ +//====================================================================================================================== +// +// This file is part of waLBerla. waLBerla is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file ReduceType.h +//! \author Sebastian Eibl <sebastian.eibl@fau.de> +// +//====================================================================================================================== + +#pragma once + +namespace walberla { +namespace timing { + +/// The reduce type describes which values are reduced from each process +enum ReduceType +{ + /// Treats each process as one timing sample. For the timing sample the min value is used. + REDUCE_MIN, + /// Treats each process as one timing sample. For the timing sample the average value is used. + REDUCE_AVG, + /// Treats each process as one timing sample. For the timing sample the max value is used. + REDUCE_MAX, + /// Collects all timing samples from all processes and accumulates the data. + /// The number of measurements afterwards are: nrOfProcesses*measurementsPerProcess + REDUCE_TOTAL +}; + +} //namespace timing +} //namespace walberla diff --git a/src/core/timing/TimingNode.h b/src/core/timing/TimingNode.h index 9fa8fab62..acd33ecd2 100644 --- a/src/core/timing/TimingNode.h +++ b/src/core/timing/TimingNode.h @@ -23,6 +23,7 @@ #pragma once #include "Timer.h" +#include "ReduceType.h" #include "core/debug/Debug.h" #include "core/logging/Logging.h" @@ -197,20 +198,6 @@ size_t getHierarchyDepth(const TimingNode<TP>& tn) return depth + maxDepth; } -/// The reduce type describes which values are reduced from each process -enum ReduceType -{ - /// Treats each process as one timing sample. For the timing sample the min value is used. - REDUCE_MIN, - /// Treats each process as one timing sample. For the timing sample the average value is used. - REDUCE_AVG, - /// Treats each process as one timing sample. For the timing sample the max value is used. - REDUCE_MAX, - /// Collects all timing samples from all processes and accumulates the data. - /// The number of measurements afterwards are: nrOfProcesses*measurementsPerProcess - REDUCE_TOTAL -}; - /// Collects all the timing data from different processes /// \attention Will overwrite the current timer data! Multiple calls will accumulate! /// \relates TimingNode diff --git a/src/core/timing/TimingPool.h b/src/core/timing/TimingPool.h index 9d4e671f2..43d1533b5 100644 --- a/src/core/timing/TimingPool.h +++ b/src/core/timing/TimingPool.h @@ -22,6 +22,7 @@ #pragma once #include "Timer.h" +#include "ReduceType.h" #include <iostream> #include <map> @@ -77,21 +78,6 @@ public: //** Reduction ****************************************************************************************************** /*! \name Reduction */ //@{ - - /// The reduce type describes which values are reduced from each process - enum ReduceType - { - /// Treats each process as one timing sample. For the timing sample the min value is used. - REDUCE_MIN, - /// Treats each process as one timing sample. For the timing sample the average value is used. - REDUCE_AVG, - /// Treats each process as one timing sample. For the timing sample the max value is used. - REDUCE_MAX, - /// Collects all timing samples from all processes and accumulates the data. - /// The number of measurements afterwards are: nrOfProcesses*measurementsPerProcess - REDUCE_TOTAL - }; - shared_ptr<TimingPool<TP> > getReduced ( ReduceType rt = REDUCE_TOTAL, int targetWorldRank = 0 ) const; //@} //******************************************************************************************************************* diff --git a/src/python_coupling/basic_exports/BasicExports.cpp b/src/python_coupling/basic_exports/BasicExports.cpp index 28c8c12d3..d43a339f9 100644 --- a/src/python_coupling/basic_exports/BasicExports.cpp +++ b/src/python_coupling/basic_exports/BasicExports.cpp @@ -33,6 +33,7 @@ #include "core/cell/CellInterval.h" #include "core/math/AABB.h" #include "core/mpi/MPIIO.h" +#include "core/timing/ReduceType.h" #include "core/timing/TimingPool.h" #include "core/timing/TimingTree.h" #include "communication/UniformPackInfo.h" @@ -634,11 +635,11 @@ void exportTiming() .def( self_ns::str(self) ) ; - enum_<WcTimingPool::ReduceType>("ReduceType") - .value("min" , WcTimingPool::REDUCE_MIN) - .value("avg" , WcTimingPool::REDUCE_AVG) - .value("max" , WcTimingPool::REDUCE_MAX) - .value("total", WcTimingPool::REDUCE_TOTAL) + enum_<timing::ReduceType>("ReduceType") + .value("min" , timing::REDUCE_MIN) + .value("avg" , timing::REDUCE_AVG) + .value("max" , timing::REDUCE_MAX) + .value("total", timing::REDUCE_TOTAL) .export_values() ; } diff --git a/tests/core/timing/TimingPoolTest.cpp b/tests/core/timing/TimingPoolTest.cpp index 11f5f5b88..aaf7992df 100644 --- a/tests/core/timing/TimingPoolTest.cpp +++ b/tests/core/timing/TimingPoolTest.cpp @@ -102,7 +102,7 @@ void reduction() WcTimer timerBackup = pool["test"]; // Test minimum reduction - auto red = pool.getReduced( WcTimingPool::REDUCE_MIN, 0 ); + auto red = pool.getReduced( timing::REDUCE_MIN, 0 ); WALBERLA_ROOT_SECTION() { WcTimer & t = (*red)["test"]; WALBERLA_CHECK_FLOAT_EQUAL( t.min(), 1.0 ); @@ -114,7 +114,7 @@ void reduction() } // Test maximum reduction - red = pool.getReduced( WcTimingPool::REDUCE_MAX, 0 ); + red = pool.getReduced( timing::REDUCE_MAX, 0 ); WALBERLA_ROOT_SECTION() { WcTimer & t = (*red)["test"]; WALBERLA_CHECK_FLOAT_EQUAL( t.min(), 4.0 ); @@ -126,7 +126,7 @@ void reduction() } // Test complete reduction - red = pool.getReduced( WcTimingPool::REDUCE_TOTAL, 0 ); + red = pool.getReduced( timing::REDUCE_TOTAL, 0 ); WALBERLA_ROOT_SECTION() { WcTimer & t = (*red)["test"]; WALBERLA_CHECK_FLOAT_EQUAL( t.min(), 1.0 ); @@ -137,7 +137,7 @@ void reduction() red.reset(); - red = pool.getReduced( WcTimingPool::REDUCE_TOTAL, -1 ); + red = pool.getReduced( timing::REDUCE_TOTAL, -1 ); WALBERLA_CHECK_NOT_NULLPTR( red ); WALBERLA_CRITICAL_SECTION_START cout << *red << endl; @@ -153,7 +153,7 @@ void reduction() cout << pool << endl; WALBERLA_CRITICAL_SECTION_END - red = pool.getReduced( WcTimingPool::REDUCE_TOTAL, 0 ); + red = pool.getReduced( timing::REDUCE_TOTAL, 0 ); WALBERLA_ROOT_SECTION() { cout << "Reduced System" << endl << *red << endl; } -- GitLab