24namespace shamrock::patch {
27 MPI_Datatype get_patch_mpi_type();
52 static_assert(
dim < 4,
"the patch object is implemented only up to dim 3");
90 std::array<u64, dim> coord_min;
91 std::array<u64, dim> coord_max;
121 [[nodiscard]] std::array<u64, dim> get_split_coord()
const;
123 [[nodiscard]] std::array<Patch, splts_count> get_split()
const;
125 [[nodiscard]]
static Patch merge_patch(std::array<Patch, splts_count> patches);
138 sycl::vec<u64, 3> src_offset, sycl::vec<T, 3> divfact, sycl::vec<T, 3> offset)
const;
152 sycl::vec<T, 3> val, sycl::vec<T, 3> min_val, sycl::vec<T, 3> max_val);
155 coord_min[0] = pc.coord_min[0];
156 coord_min[1] = pc.coord_min[1];
157 coord_min[2] = pc.coord_min[2];
158 coord_max[0] = pc.coord_max[0];
159 coord_max[1] = pc.coord_max[1];
160 coord_max[2] = pc.coord_max[2];
163 [[nodiscard]]
inline PatchCoord<dim> get_coords()
const {
return {coord_min, coord_max}; }
166 return get_coords().get_patch_range();
184 for (
u32 i = 0; i <
dim; i++) {
185 ret_val = ret_val && (coord_min[i] == rhs.coord_min[i]);
189 for (
u32 i = 0; i <
dim; i++) {
190 ret_val = ret_val && (coord_max[i] == rhs.coord_max[i]);
200 sycl::vec<u64, 3> src_offset, sycl::vec<T, 3> divfact, sycl::vec<T, 3> offset)
const {
204 {src_offset.x(), src_offset.y(), src_offset.z()},
211 sycl::vec<T, 3> val, sycl::vec<T, 3> min_val, sycl::vec<T, 3> max_val) {
213 (min_val.x() <= val.x()) && (val.x() < max_val.x()) && (min_val.y() <= val.y())
214 && (val.y() < max_val.y()) && (min_val.z() <= val.z()) && (val.z() < max_val.z()));
217 [[nodiscard]]
inline auto Patch::get_split_coord() const ->
std::array<
u64, dim> {
221 [[nodiscard]]
inline auto Patch::get_split() const ->
std::array<Patch, splts_count> {
224 Patch p0, p1, p2, p3, p4, p5, p6, p7;
239 = PatchCoord<dim>::get_split(coord_min, coord_max);
241 p0.override_from_coord(splts_c[0]);
242 p1.override_from_coord(splts_c[1]);
243 p2.override_from_coord(splts_c[2]);
244 p3.override_from_coord(splts_c[3]);
245 p4.override_from_coord(splts_c[4]);
246 p5.override_from_coord(splts_c[5]);
247 p6.override_from_coord(splts_c[6]);
248 p7.override_from_coord(splts_c[7]);
250 return {p0, p1, p2, p3, p4, p5, p6, p7};
253 [[nodiscard]]
inline Patch Patch::merge_patch(std::array<Patch, splts_count> patches) {
255 PatchCoord merged_c = PatchCoord<dim>::merge(
256 {patches[0].get_coords(),
257 patches[1].get_coords(),
258 patches[2].get_coords(),
259 patches[3].get_coords(),
260 patches[4].get_coords(),
261 patches[5].get_coords(),
262 patches[6].get_coords(),
263 patches[7].get_coords()});
268 ret.coord_min[0] = merged_c.coord_min[0];
269 ret.coord_min[1] = merged_c.coord_min[1];
270 ret.coord_min[2] = merged_c.coord_min[2];
271 ret.coord_max[0] = merged_c.coord_max[0];
272 ret.coord_max[1] = merged_c.coord_max[1];
273 ret.coord_max[2] = merged_c.coord_max[2];
277 ret.load_value += patches[1].load_value;
278 ret.load_value += patches[2].load_value;
279 ret.load_value += patches[3].load_value;
280 ret.load_value += patches[4].load_value;
281 ret.load_value += patches[5].load_value;
282 ret.load_value += patches[6].load_value;
283 ret.load_value += patches[7].load_value;
This header does the MPI include and wrap MPI calls.
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
constexpr u64 u64_max
u64 max value
constexpr u32 u32_max
u32 max value
Patch object that contain generic patch information.
static constexpr u32 dim
dimension of the patch (only 3 so far)
bool is_err_mode() const
check if a patch is in error mode
u64 pack_node_index
this value mean "to pack with index xxx in the global patch table" and not "to pack with id_pach == x...
static bool is_in_patch_converted(sycl::vec< T, 3 > val, sycl::vec< T, 3 > min_val, sycl::vec< T, 3 > max_val)
check if particle is in the asked range, given the output of @convert_coord
static constexpr u32 splts_count
if a patch splits, this gives the number of childs
void set_err_mode()
Make the patch in error mode (patch struct that will be flushed on sync)
bool operator==(const Patch &rhs) const
check if patch equals
u32 node_owner_id
node rank owner of this patch
std::tuple< sycl::vec< T, 3 >, sycl::vec< T, 3 > > convert_coord(sycl::vec< u64, 3 > src_offset, sycl::vec< T, 3 > divfact, sycl::vec< T, 3 > offset) const
return an open interval of the corresponding patch coordinates given the div & offset
u64 load_value
if synchronized contain the load value of the patch
static constexpr u32 err_node_flag
value of node_owner_id if the patch is invalid
u64 id_patch
unique key that identify the patch