Commit 38e77254 authored by GILLES Sebastien's avatar GILLES Sebastien

#1473 Add an internal class in GodOfDof to tackle the parallelism strategies.

parent d5175529
......@@ -1034,6 +1034,9 @@
BE7E552822EF280E00BEA053 /* Parallelism.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE7E552522EF280E00BEA053 /* Parallelism.hpp */; };
BE7E553A22EF2D0000BEA053 /* Parallelism.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE7E553722EF2D0000BEA053 /* Parallelism.hpp */; };
BE7E553B22EF2D0000BEA053 /* Parallelism.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE7E553822EF2D0000BEA053 /* Parallelism.cpp */; };
BE7E554122EF410200BEA053 /* Parallelism.hxx in Headers */ = {isa = PBXBuildFile; fileRef = BE7E553E22EF410200BEA053 /* Parallelism.hxx */; };
BE7E554222EF410200BEA053 /* Parallelism.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE7E553F22EF410200BEA053 /* Parallelism.hpp */; };
BE7E554922EF44CB00BEA053 /* ParallelismStrategy.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE7E554622EF44CB00BEA053 /* ParallelismStrategy.hpp */; };
BE83582B1FFD779E0009956E /* Sort.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE83582A1FFD779E0009956E /* Sort.hpp */; };
BE83582D1FFD78DE0009956E /* Sort.hxx in Headers */ = {isa = PBXBuildFile; fileRef = BE83582C1FFD78DD0009956E /* Sort.hxx */; };
BE8553A91BBD77BF00DB109E /* DofSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE8553A31BBD77BF00DB109E /* DofSource.cpp */; };
......@@ -4127,6 +4130,9 @@
BE7E552522EF280E00BEA053 /* Parallelism.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Parallelism.hpp; sourceTree = "<group>"; };
BE7E553722EF2D0000BEA053 /* Parallelism.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Parallelism.hpp; sourceTree = "<group>"; };
BE7E553822EF2D0000BEA053 /* Parallelism.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Parallelism.cpp; sourceTree = "<group>"; };
BE7E553E22EF410200BEA053 /* Parallelism.hxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Parallelism.hxx; sourceTree = "<group>"; };
BE7E553F22EF410200BEA053 /* Parallelism.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Parallelism.hpp; sourceTree = "<group>"; };
BE7E554622EF44CB00BEA053 /* ParallelismStrategy.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ParallelismStrategy.hpp; sourceTree = "<group>"; };
BE7E68682065615100AA2FB3 /* InputData.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = InputData.hpp; sourceTree = "<group>"; };
BE7E68692065615100AA2FB3 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
BE7E686A2065615100AA2FB3 /* Model.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Model.hpp; sourceTree = "<group>"; };
......@@ -8637,6 +8643,22 @@
path = Internal;
sourceTree = "<group>";
};
BE7E554322EF44A100BEA053 /* Advanced */ = {
isa = PBXGroup;
children = (
BE7E554A22EF44EC00BEA053 /* GodOfDof */,
);
path = Advanced;
sourceTree = "<group>";
};
BE7E554A22EF44EC00BEA053 /* GodOfDof */ = {
isa = PBXGroup;
children = (
BE7E554622EF44CB00BEA053 /* ParallelismStrategy.hpp */,
);
path = GodOfDof;
sourceTree = "<group>";
};
BE7E68642065615100AA2FB3 /* NonlinearMembrane */ = {
isa = PBXGroup;
children = (
......@@ -9871,6 +9893,7 @@
BE13458A19CC16F4003ED11A /* FEltSpace.cpp */,
BE13458B19CC16F4003ED11A /* FEltSpace.hpp */,
BE13458C19CC16F4003ED11A /* FEltSpace.hxx */,
BE7E554322EF44A100BEA053 /* Advanced */,
BEBEB18219C8429300E4EA1D /* Internal */,
);
path = FiniteElementSpace;
......@@ -9940,6 +9963,8 @@
BEF4A6DD22E1BF0400CD4A6E /* OutputDirectoryStorage.cpp */,
BEF4A6DF22E1BF0400CD4A6E /* OutputDirectoryStorage.hpp */,
BEF4A6DE22E1BF0400CD4A6E /* OutputDirectoryStorage.hxx */,
BE7E553F22EF410200BEA053 /* Parallelism.hpp */,
BE7E553E22EF410200BEA053 /* Parallelism.hxx */,
BEBEB21D19C849C200E4EA1D /* Impl */,
);
path = Internal;
......@@ -11334,6 +11359,7 @@
BE90E0671A2491AE00CCAFDE /* FEltSpace.hpp in Headers */,
BE2B665D1A2778C700E80864 /* RefFEltInFEltSpace.hpp in Headers */,
BE2B66631A2778C700E80864 /* RefLocalFEltSpace.hpp in Headers */,
BE7E554122EF410200BEA053 /* Parallelism.hxx in Headers */,
BE3E664E1ACEB94E00A3F7E2 /* Connectivity.hpp in Headers */,
BE63C1511B21876B00978D05 /* SegmentP0.hpp in Headers */,
BEF4A6E222E1BF0400CD4A6E /* OutputDirectoryStorage.hpp in Headers */,
......@@ -11347,6 +11373,7 @@
BE90E1161A2491AE00CCAFDE /* GaussQuadratureFormula.hpp in Headers */,
BE5100061CCE3EB80034FE28 /* PerDegreeOfExactness.hpp in Headers */,
BE6128881CCE54A600318BB6 /* PerShapeFunctionOrder.hpp in Headers */,
BE7E554922EF44CB00BEA053 /* ParallelismStrategy.hpp in Headers */,
BE9B828A1D81881E00BA174F /* TriangleP1Bubble.hpp in Headers */,
BEFC32E01CB53C3B00C8903C /* RefFEltInLocalOperator.hpp in Headers */,
BE90E06D1A2491AE00CCAFDE /* ComputeMatrixPattern.hpp in Headers */,
......@@ -11376,6 +11403,7 @@
BE510D841CB3D44900E953FE /* Comp1.hpp in Headers */,
BE90E1001A2491AE00CCAFDE /* QuadratureRule.hpp in Headers */,
BE32218B1B4686B100F27D6C /* Local2GlobalStorage.hxx in Headers */,
BE7E554222EF410200BEA053 /* Parallelism.hpp in Headers */,
BE2B663C1A2778C700E80864 /* HexahedronQ2c.hpp in Headers */,
BEFC32E11CB53C3B00C8903C /* RefFEltInLocalOperator.hxx in Headers */,
BE90E0711A2491AE00CCAFDE /* CreateNodeListHelper.hpp in Headers */,
//! \file
//
//
// ParallelismStrategy.hpp
// MoReFEM
//
// Created by sebastien on 29/07/2019.
//Copyright © 2019 Inria. All rights reserved.
//
#ifndef MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_ADVANCED_x_GOD_OF_DOF_x_PARALLELISM_STRATEGY_HPP_
# define MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_ADVANCED_x_GOD_OF_DOF_x_PARALLELISM_STRATEGY_HPP_
namespace MoReFEM::Advanced
{
//! Enum class which specifies the 4 possible behaviour related to parallelism.
enum class parallelism_strategy
{
none,
precompute,
parallel_no_write,
parallel,
run_from_preprocessed
};
} // namespace MoReFEM::Advanced
#endif // MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_ADVANCED_x_GOD_OF_DOF_x_PARALLELISM_STRATEGY_HPP_
### ===================================================================================
### This file is generated automatically by Scripts/generate_cmake_source_list.py.
### Do not edit it manually!
### Convention is that:
### - When a CMake file is manually managed, it is named canonically CMakeLists.txt.
###. - When it is generated automatically, it is named SourceList.cmake.
### ===================================================================================
target_sources(${MOREFEM_FELT}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/ParallelismStrategy.hpp"
)
### ===================================================================================
### This file is generated automatically by Scripts/generate_cmake_source_list.py.
### Do not edit it manually!
### Convention is that:
### - When a CMake file is manually managed, it is named canonically CMakeLists.txt.
###. - When it is generated automatically, it is named SourceList.cmake.
### ===================================================================================
target_sources(${MOREFEM_FELT}
PRIVATE
)
include(${CMAKE_CURRENT_LIST_DIR}/GodOfDof/SourceList.cmake)
......@@ -197,6 +197,8 @@ namespace MoReFEM
// The only quantity not yet reduced is the dofs involved in the boundary conditions.
if (mpi.Nprocessor<int>() > 1)
ReduceToProcessorWise();
// Assign correctly the processor-wise dof indexes.
ComputeProcessorWiseAndGhostDofIndex();
......
......@@ -32,6 +32,7 @@
# include "FiniteElement/FiniteElementSpace/Internal/ComputeMatrixPattern.hpp"
# include "FiniteElement/FiniteElementSpace/Internal/DofProgramWiseIndexListPerVertexCoordIndexListManager.hpp"
# include "FiniteElement/FiniteElementSpace/Internal/OutputDirectoryStorage.hpp"
# include "FiniteElement/FiniteElementSpace/Internal/Parallelism.hpp"
# include "FiniteElement/BoundaryConditions/DirichletBoundaryCondition.hpp"
......@@ -426,6 +427,8 @@ namespace MoReFEM
*/
auto GetIteratorFEltSpace(unsigned int unique_id) const;
//! Accessor to the object which keeps the data related to parallelism strategy.
const Internal::GodOfDofNS::Parallelism& GetParallelism() const noexcept;
private:
......@@ -597,6 +600,9 @@ namespace MoReFEM
//! Path of the file listing the time iterations and the related files.
std::string time_iteration_file_;
//! Object which holds the parallelism strategy to use.
Internal::GodOfDofNS::Parallelism::unique_ptr parallelism_ = nullptr;
# ifndef NDEBUG
/*!
* \brief Whether Init() has already been called or not.
......
......@@ -27,6 +27,8 @@ namespace MoReFEM
DoConsiderProcessorWiseLocal2Global do_consider_proc_wise_local_2_global,
std::string&& output_directory)
{
parallelism_ = std::make_unique<Internal::GodOfDofNS::Parallelism>(input_data);
std::map<unsigned int, std::vector<unsigned int>> dof_list_per_felt_space;
Init1(std::move(output_directory),
......@@ -267,6 +269,13 @@ namespace MoReFEM
}
inline const Internal::GodOfDofNS::Parallelism& GodOfDof::GetParallelism() const noexcept
{
assert(!(!parallelism_));
return *parallelism_;
}
} // namespace MoReFEM
......
//! \file
//
//
// Parallelism.hpp
// MoReFEM
//
// Created by sebastien on 29/07/2019.
//Copyright © 2019 Inria. All rights reserved.
//
#ifndef MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_INTERNAL_x_PARALLELISM_HPP_
# define MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_INTERNAL_x_PARALLELISM_HPP_
# include <memory>
# include <string>
# include <cassert>
# include "Core/InputData/Instances/Parallelism/Parallelism.hpp"
# include "FiniteElement/FiniteElementSpace/Advanced/GodOfDof/ParallelismStrategy.hpp"
namespace MoReFEM::Internal::GodOfDofNS
{
/*!
* \brief Holds the interpreted content of the section 'Parallelism' of the input data file.
*/
class Parallelism
{
public:
//! \copydoc doxygen_hide_alias_self
using self = Parallelism;
//! Alias to unique pointer.
using unique_ptr = std::unique_ptr<self>;
public:
/// \name Special members.
///@{
//! Constructor.
template<class InputDataT>
explicit Parallelism(const InputDataT& input_data);
//! Destructor.
~Parallelism() = default;
//! \copydoc doxygen_hide_copy_constructor
Parallelism(const Parallelism& rhs) = delete;
//! \copydoc doxygen_hide_move_constructor
Parallelism(Parallelism&& rhs) = delete;
//! \copydoc doxygen_hide_copy_affectation
Parallelism& operator=(const Parallelism& rhs) = delete;
//! \copydoc doxygen_hide_move_affectation
Parallelism& operator=(Parallelism&& rhs) = delete;
///@}
//! Get the path of the preprocessed directory. Only for the relevant policy.
const std::string& GetPreprocessedDirectory() const noexcept;
//! Get the parallelism strategy.
::MoReFEM::Advanced::parallelism_strategy GetParallelismStrategy() const noexcept;
private:
//! The chosen parallelism strategy.
::MoReFEM::Advanced::parallelism_strategy parallelism_strategy_ =
::MoReFEM::Advanced::parallelism_strategy::none;
//! Path to the directory in which preprocessed data are stored (for 'run_from_preprocessed' strategy only).
std::string preprocessed_directory_ = "";
};
} // namespace MoReFEM::Internal::GodOfDofNS
# include "FiniteElement/FiniteElementSpace/Internal/Parallelism.hxx"
#endif // MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_INTERNAL_x_PARALLELISM_HPP_
//! \file
//
//
// Parallelism.hxx
// MoReFEM
//
// Created by sebastien on 29/07/2019.
//Copyright © 2019 Inria. All rights reserved.
//
#ifndef MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_INTERNAL_x_PARALLELISM_HXX_
# define MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_INTERNAL_x_PARALLELISM_HXX_
namespace MoReFEM::Internal::GodOfDofNS
{
template<class InputDataT>
Parallelism::Parallelism(const InputDataT& input_data)
{
namespace ipl = Utilities::InputDataNS;
using Parallelism = ::MoReFEM::InputDataNS::Parallelism;
std::string policy = ipl::Extract<Parallelism::Policy>::Value(input_data);
if (policy == "Precompute")
parallelism_strategy_ = ::MoReFEM::Advanced::parallelism_strategy::precompute;
else if (policy == "ParallelNoWrite")
parallelism_strategy_ = ::MoReFEM::Advanced::parallelism_strategy::parallel_no_write;
else if (policy == "Parallel")
parallelism_strategy_ = ::MoReFEM::Advanced::parallelism_strategy::parallel;
else if (policy == "RunFromPreprocessed")
parallelism_strategy_ = ::MoReFEM::Advanced::parallelism_strategy::run_from_preprocessed;
else
{
assert(false && "Constraint in Lua file should have ruled out this case sooner!");
exit(EXIT_FAILURE);
}
if (parallelism_strategy_ == ::MoReFEM::Advanced::parallelism_strategy::run_from_preprocessed)
preprocessed_directory_ = ipl::Extract<Parallelism::Path>::Folder(input_data);
else
{
// Do nothing: just a trick to indicate the field was 'used' in the run of the program.
ipl::Extract<Parallelism::Path>::Value(input_data);
}
}
inline const std::string& Parallelism::GetPreprocessedDirectory() const noexcept
{
assert(parallelism_strategy_ == ::MoReFEM::Advanced::parallelism_strategy::run_from_preprocessed
&& "Should not be called for others strategies...");
return preprocessed_directory_;
}
//! Get the parallelism strategy.
inline ::MoReFEM::Advanced::parallelism_strategy Parallelism::GetParallelismStrategy() const noexcept
{
assert(parallelism_strategy_ != ::MoReFEM::Advanced::parallelism_strategy::none && "Must be initialized!");
return parallelism_strategy_;
}
} // namespace MoReFEM::Internal::GodOfDofNS
#endif // MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_INTERNAL_x_PARALLELISM_HXX_
......@@ -50,6 +50,8 @@ target_sources(${MOREFEM_FELT}
"${CMAKE_CURRENT_LIST_DIR}/NdofHolder.hxx"
"${CMAKE_CURRENT_LIST_DIR}/OutputDirectoryStorage.hpp"
"${CMAKE_CURRENT_LIST_DIR}/OutputDirectoryStorage.hxx"
"${CMAKE_CURRENT_LIST_DIR}/Parallelism.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Parallelism.hxx"
"${CMAKE_CURRENT_LIST_DIR}/Partition.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Partition.hxx"
"${CMAKE_CURRENT_LIST_DIR}/ReduceToProcessorWise.hpp"
......
......@@ -24,4 +24,5 @@ target_sources(${MOREFEM_FELT}
"${CMAKE_CURRENT_LIST_DIR}/GodOfDofManager.hxx"
)
include(${CMAKE_CURRENT_LIST_DIR}/Advanced/SourceList.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/Internal/SourceList.cmake)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment