2017-12-21 01:18:22 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2017-12-21 01:18:22 +00:00
|
|
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the above copyright notice for more information.
|
|
|
|
//============================================================================
|
2019-09-02 14:38:47 +00:00
|
|
|
#ifndef vtk_m_cont_AssignerPartitionedDataSet_h
|
|
|
|
#define vtk_m_cont_AssignerPartitionedDataSet_h
|
2017-12-21 01:18:22 +00:00
|
|
|
|
2018-02-22 14:59:15 +00:00
|
|
|
#include <vtkm/cont/vtkm_cont_export.h>
|
2017-12-21 01:18:22 +00:00
|
|
|
|
2018-02-22 14:59:15 +00:00
|
|
|
#include <vtkm/Types.h>
|
|
|
|
#include <vtkm/internal/ExportMacros.h>
|
|
|
|
#include <vtkm/thirdparty/diy/Configure.h>
|
|
|
|
|
|
|
|
#include <vector>
|
2017-12-21 01:18:22 +00:00
|
|
|
|
2019-02-05 16:02:29 +00:00
|
|
|
#include <vtkm/thirdparty/diy/diy.h>
|
2018-01-03 19:37:54 +00:00
|
|
|
|
2018-02-27 18:42:52 +00:00
|
|
|
#ifdef VTKM_MSVC
|
|
|
|
#pragma warning(push)
|
|
|
|
// disable C4275: non-dll interface base class warnings
|
|
|
|
#pragma warning(disable : 4275)
|
|
|
|
#endif
|
|
|
|
|
2017-12-21 01:18:22 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
|
|
|
|
2019-09-02 14:38:47 +00:00
|
|
|
class PartitionedDataSet;
|
2018-02-22 14:59:15 +00:00
|
|
|
|
2019-09-02 14:38:47 +00:00
|
|
|
/// \brief Assigner for PartitionedDataSet partitions.
|
2017-12-21 01:18:22 +00:00
|
|
|
///
|
2019-09-02 14:38:47 +00:00
|
|
|
/// `AssignerPartitionedDataSet` is a `vtkmdiy::StaticAssigner` implementation
|
|
|
|
/// that uses `PartitionedDataSet`'s partition distribution to build
|
|
|
|
/// global-id/rank associations needed for several `diy` operations.
|
|
|
|
/// It uses a contiguous assignment strategy to map partitions to global ids,
|
|
|
|
/// i.e. partitions on rank 0 come first, then rank 1, etc. Any rank may have 0
|
|
|
|
/// partitions.
|
2017-12-21 01:18:22 +00:00
|
|
|
///
|
2019-09-02 14:38:47 +00:00
|
|
|
/// AssignerPartitionedDataSet uses collectives in the constructor hence it is
|
2017-12-21 01:18:22 +00:00
|
|
|
/// essential it gets created on all ranks irrespective of whether the rank has
|
2019-09-02 14:38:47 +00:00
|
|
|
/// any partitions.
|
2017-12-21 01:18:22 +00:00
|
|
|
///
|
2019-09-02 14:38:47 +00:00
|
|
|
class VTKM_CONT_EXPORT AssignerPartitionedDataSet : public vtkmdiy::StaticAssigner
|
2017-12-21 01:18:22 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-09-02 14:38:47 +00:00
|
|
|
/// Initialize the assigner using a partitioned dataset.
|
2017-12-21 01:18:22 +00:00
|
|
|
/// This may initialize collective operations to populate the assigner with
|
2019-09-02 14:38:47 +00:00
|
|
|
/// information about partitions on all ranks.
|
2017-12-21 01:18:22 +00:00
|
|
|
VTKM_CONT
|
2019-09-02 14:38:47 +00:00
|
|
|
AssignerPartitionedDataSet(const vtkm::cont::PartitionedDataSet& pds);
|
2017-12-21 01:18:22 +00:00
|
|
|
|
2018-04-09 19:06:27 +00:00
|
|
|
VTKM_CONT
|
2019-09-02 14:38:47 +00:00
|
|
|
AssignerPartitionedDataSet(vtkm::Id num_partitions);
|
2018-04-09 19:06:27 +00:00
|
|
|
|
2020-01-13 20:54:59 +00:00
|
|
|
VTKM_CONT
|
2020-09-10 14:03:18 +00:00
|
|
|
~AssignerPartitionedDataSet() override;
|
2020-01-13 20:54:59 +00:00
|
|
|
|
2017-12-21 01:18:22 +00:00
|
|
|
///@{
|
2019-02-05 16:02:29 +00:00
|
|
|
/// vtkmdiy::Assigner API implementation.
|
2017-12-21 01:18:22 +00:00
|
|
|
VTKM_CONT
|
|
|
|
void local_gids(int rank, std::vector<int>& gids) const override;
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
int rank(int gid) const override;
|
2022-09-09 02:29:48 +00:00
|
|
|
///@}
|
2017-12-21 01:18:22 +00:00
|
|
|
private:
|
2019-09-02 14:38:47 +00:00
|
|
|
std::vector<vtkm::Id> IScanPartitionCounts;
|
2017-12-21 01:18:22 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-27 18:42:52 +00:00
|
|
|
#ifdef VTKM_MSVC
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|
|
|
|
|
2017-12-21 01:18:22 +00:00
|
|
|
#endif
|