10#include <kernel/adjacency/coloring.hpp>
11#include <kernel/util/memory_arbiter.hpp>
57 template<
typename ColoringType_>
68 ColoringDataHandler(
const ColoringDataHandler&) =
delete;
70 ColoringDataHandler& operator=(
const ColoringDataHandler&) =
delete;
73 ColoringDataHandler(ColoringDataHandler&& other)
noexcept
78 other._coloring_map.release();
79 other._coloring_map_offsets.clear();
80 other._coloring_map_sizes.clear();
83 ColoringDataHandler& operator=(ColoringDataHandler&& other)
noexcept
91 other._coloring_map.release();
92 other._coloring_map_offsets.clear();
93 other._coloring_map_sizes.clear();
108 std::vector<Index>& get_color_offsets()
113 const std::vector<Index>& get_color_offsets()
const
123 std::vector<Index>& get_color_sizes()
128 const std::vector<Index>& get_color_sizes()
const
155 void fill_color(
const std::vector<int>& coloring,
int hint = -1)
157 int num_colors = hint;
160 num_colors = *std::max_element(coloring.begin(), coloring.end()) + 1;
163 std::vector<std::vector<int>> tmp_vector;
164 tmp_vector.resize(
Index(num_colors));
165 for(std::size_t i = 0; i < coloring.size(); ++i)
167 tmp_vector.at(std::size_t(coloring.at(i))).push_back(
int(i));
177 Memory::memcopy_main(&coloring_map_view.
get_w()[offset], tmp_vector.at(i).data(), tmp_vector.at(i).size() *
sizeof(
int));
196 ASSERTM(num_colors == hint,
"Hint and number of colors do not fit!");
200 std::vector<std::vector<int>> tmp_vector;
201 tmp_vector.resize(
Index(num_colors));
202 for(std::size_t i = 0; i < coloring.
size(); ++i)
204 tmp_vector.at(std::size_t(coloring[i])).push_back(
int(i));
213 Memory::memcopy_main(&coloring_map_view.
get_w()[offset], tmp_vector.at(i).data(), tmp_vector.at(i).size() *
sizeof(
int));
227 bool initialized()
const
232 Index get_max_size()
const
#define ASSERTM(expr, msg)
Debug-Assertion macro definition with custom message.
Datahandler for inverse coloring data.
std::vector< Index > _coloring_map_offsets
vector of coloring sizes
Index get_max_color_size() const
Get max size of all colors.
Index get_num_colors() const
Returns the number of colors.
void fill_color(const std::vector< int > &coloring, int hint=-1)
Fill in the coloring array.
Memory::Arbiter _coloring_map
vector of unified memory pointer
void fill_color(const Coloring &coloring, int hint=-1)
Fill in the coloring array.
std::vector< Index > _coloring_map_sizes
vector of coloring sizes
ColoringDataHandler(const ColoringType_ &coloring, int hint=-1)
Constructor receiving coloring data and optional hint.
Coloring object implementation.
auto size() const -> decltype(_coloring.size())
Returns the total number of nodes.
Index get_num_colors() const
Returns the number of colors.
void release()
Releases this arbiter from its associated memory block and frees it if necessary.
View view(Location mem_loc, Access access)
Maps a raw view to a memory block.
TypedView< T_ > typed_view(Location mem_loc, Access access)
Maps a typed view to a memory block.
T_ * get_w()
Returns a typed pointer to the array that grants write (and read) access.
void memcopy_main(void *dst, const void *src, std::size_t bytes)
Copies a region of a main memory block into another main memory block.
Access
Memory access enumeration.
@ write
write-only access (see attention note above)
Location
Memory location enumeration.
std::uint64_t Index
Index data type.