-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathPartitionBase.h
66 lines (55 loc) · 1.83 KB
/
PartitionBase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// SPDX-FileCopyrightText: 2019-2023 Technical University of Munich
//
// SPDX-License-Identifier: BSD-3-Clause
/**
* @file
* This file is part of PUML
*
* For conditions of distribution and use, please see the copyright
* notice in the file 'COPYING' at the root directory of this package
* and the copyright notice at https://github.com/TUM-I5/PUMGen
*
* @author Sebastian Rettenberger <sebastian.rettenberger@tum.de>
* @author David Schneller <david.schneller@tum.de>
*/
#ifndef PUML_PARTITION_BASE_H
#define PUML_PARTITION_BASE_H
#ifdef USE_MPI
#endif // USE_MPI
#include "utils/logger.h"
#include "Topology.h"
#include "PartitionGraph.h"
#include "PartitionTarget.h"
#include <vector>
namespace PUML {
enum class PartitioningResult { SUCCESS = 0, ERROR };
template <TopoType Topo>
class PartitionBase {
public:
PartitionBase() = default;
virtual ~PartitionBase() = default;
#ifdef USE_MPI
auto partition(const PartitionGraph<Topo>& graph, const PartitionTarget& target, int seed = 1)
-> std::vector<int> {
std::vector<int> part(graph.localVertexCount());
auto result = partition(part, graph, target, seed);
if (result != PartitioningResult::SUCCESS) {
logError() << "Partitioning failed.";
}
return part;
}
auto partition(std::vector<int>& part,
const PartitionGraph<Topo>& graph,
const PartitionTarget& target,
int seed = 1) -> PartitioningResult {
return partition(part.data(), graph, target, seed);
}
virtual auto partition(int* part,
const PartitionGraph<Topo>& graph,
const PartitionTarget& target,
int seed = 1) -> PartitioningResult = 0;
#endif // USE_MPI
};
using TETPartitionBase = PartitionBase<TETRAHEDRON>;
} // namespace PUML
#endif // PUML_PARTITION_BASE_H