STORMM Source Documentation
Loading...
Searching...
No Matches
brickwork.h
1// -*-c++-*-
2#ifndef STORMM_BRICKWORK_H
3#define STORMM_BRICKWORK_H
4
5#include <vector>
6#include "copyright.h"
7#include "Accelerator/gpu_details.h"
8#include "Constants/behavior.h"
9#include "DataTypes/stormm_vector_types.h"
10
11namespace stormm {
12namespace synthesis {
13
14using card::GpuDetails;
15using constants::CartesianDimension;
16using constants::UnitCellAxis;
17
21public:
22
26 VolumePartition(int a_dim_in = 0, int b_dim_in = 0, int c_dim_in = 0, int a_orig_in = 0,
27 int b_orig_in = 0, int c_orig_in = 0, int halo_under_in = 0,
28 int halo_over_in = 0, int system_index_in = 0);
29
37 VolumePartition(const VolumePartition &original) = default;
38 VolumePartition(VolumePartition &&original) = default;
39 VolumePartition& operator=(const VolumePartition &original) = default;
40 VolumePartition& operator=(VolumePartition &&original) = default;
42
51 int3 getLength() const;
52 int getLength(UnitCellAxis dim) const;
53 int getLength(CartesianDimension dim) const;
55
65 int3 getLengthPlusHalo() const;
66 int getLengthPlusHalo(UnitCellAxis dim) const;
67 int getLengthPlusHalo(CartesianDimension dim) const;
69
71 int3 getOrigin() const;
72
75 int getVolumeWithHalo() const;
76
78 int getSystemIndex() const;
79
84 VolumePartition split(int a_dim_update);
85
86private:
87 int a_dim;
88 int b_dim;
89 int c_dim;
90 int a_orig;
92 int b_orig;
93 int c_orig;
94 int halo_under;
96 int halo_over;
98 int system_index;
100};
101
107public:
108
118 Brickwork(const std::vector<int3> &system_dimensions_in = {}, int a_span_max_in = 7,
119 int bc_cross_section_max_in = 16, int halo_under_in = 1, int halo_over_in = 0,
120 int max_nonhalo_volume_in = 48, int target_multiple = 1,
121 const std::vector<int> &preferred_a_lengths = {},
122 const std::vector<int> &discouraged_a_lengths = {});
123
131 Brickwork(const Brickwork &original) = default;
132 Brickwork(Brickwork &&original) = default;
133 Brickwork& operator=(const Brickwork &original) = default;
134 Brickwork& operator=(Brickwork &&original) = default;
136
146 int getBrickCount() const;
147 int getBrickCount(int system_index) const;
149
151 int getSystemCount() const;
152
163 double2 getAverageBrickLength(UnitCellAxis dim) const;
164 double2 getAverageBrickLength(CartesianDimension dim) const;
166
170 int3 getBrickOrigin(int brick_index) const;
171
177 int3 getBrickOriginWithHalo(int brick_index) const;
178
182 int3 getBrickLengths(int brick_index) const;
183
187 int3 getBrickLengthsWithHalo(int brick_index) const;
188
192 int getSystemMembership(int brick_index) const;
193
197 int3 getSystemDimensions(int system_index) const;
198
208 void subdivide(int target_work_unit_multiple = 1,
209 const std::vector<int> &preferred_a_lengths = {},
210 const std::vector<int> &discouraged_a_lengths = {});
211
212private:
213
214 // Store the parameters and metrics for later reference.
215 int a_span_max;
217 int bc_cross_section_max;
220 int halo_under;
226 int halo_over;
228 int max_nonhalo_volume;
234
235 // Store the overall dimensions of each system's grid
236 std::vector<int3> system_dimensions;
237
238 // An array of volume partitions stores the manner in which everything is broken up
239 std::vector<VolumePartition> bricks;
240
245 void validateSystemIndex(int system_index, const char* caller) const;
246
251 void validateBrickIndex(int index, const char* caller) const;
252
258 int countMinimalWorkUnits(int trimmed_bdim, int trimmed_cdim) const;
259};
260
261} // namespace synthesis
262} // namespace stormm
263
264#endif
Brickwork(const std::vector< int3 > &system_dimensions_in={}, int a_span_max_in=7, int bc_cross_section_max_in=16, int halo_under_in=1, int halo_over_in=0, int max_nonhalo_volume_in=48, int target_multiple=1, const std::vector< int > &preferred_a_lengths={}, const std::vector< int > &discouraged_a_lengths={})
The minimum necessary information is a series of tuples indicating the dimensions of each system.
Definition brickwork.cpp:111
int3 getBrickLengths(int brick_index) const
Get the lengths of a volume partition along all sides.
Definition brickwork.cpp:208
int getBrickCount() const
Get the number of bricks, the number of volume partitions spanning one system or all systems.
Definition brickwork.cpp:138
Brickwork(const std::vector< int3 > &system_dimensions_in={}, int a_span_max_in=7, int bc_cross_section_max_in=16, int halo_under_in=1, int halo_over_in=0, int max_nonhalo_volume_in=48, int target_multiple=1, const std::vector< int > &preferred_a_lengths={}, const std::vector< int > &discouraged_a_lengths={})
The minimum necessary information is a series of tuples indicating the dimensions of each system.
Definition brickwork.cpp:111
void subdivide(int target_work_unit_multiple=1, const std::vector< int > &preferred_a_lengths={}, const std::vector< int > &discouraged_a_lengths={})
Subdivide all systems into a series of bricks. This starts by creating the fewest possible bricks and...
Definition brickwork.cpp:232
int3 getBrickOriginWithHalo(int brick_index) const
Get the origin of the volume partition, with the halo to the left along each axis subtracted....
Definition brickwork.cpp:194
int getSystemCount() const
Get the number of individual systems.
Definition brickwork.cpp:154
double2 getAverageBrickLength(UnitCellAxis dim) const
Get the average dimension of all bricks along one unit cell A axis, with its standard deviation....
Definition brickwork.cpp:159
Brickwork(const Brickwork &original)=default
With no pointers to repair, no const members, and any array data members taken from the Standard Temp...
int getSystemMembership(int brick_index) const
Get the system index to which a particular brick pertains.
Definition brickwork.cpp:220
int3 getSystemDimensions(int system_index) const
Get the system dimensions.
Definition brickwork.cpp:226
int3 getBrickLengthsWithHalo(int brick_index) const
Get the lengths of a volume partition along all sides, with accounting for its halo.
Definition brickwork.cpp:214
int3 getBrickOrigin(int brick_index) const
Get the origin of the volume partition, without consideration of the halo volume.
Definition brickwork.cpp:188
VolumePartition(int a_dim_in=0, int b_dim_in=0, int c_dim_in=0, int a_orig_in=0, int b_orig_in=0, int c_orig_in=0, int halo_under_in=0, int halo_over_in=0, int system_index_in=0)
The constructor takes unitless lengths along the unit cell A, B, and C axes plus an origin coordinate...
Definition brickwork.cpp:14
int3 getLength() const
Get the length along a specific dimension, or the lengths along all dimensions.
Definition brickwork.cpp:24
VolumePartition split(int a_dim_update)
Reduce the dimension of the work unit along the unit cell A axis. A new partition is returned with th...
Definition brickwork.cpp:103
int getSystemIndex() const
Get the system index to which the volume partition applies.
Definition brickwork.cpp:98
int3 getLengthPlusHalo() const
Get the length along a specific dimension, or the lengths along all dimensions, plus the halo to give...
Definition brickwork.cpp:60
VolumePartition(const VolumePartition &original)=default
With no pointers to repair, no const members, and any array data members taken from the Standard Temp...
int3 getOrigin() const
Get the origin of the volume partition.
Definition brickwork.cpp:55
int getVolumeWithHalo() const
Get the total volume of the work unit, including the halo which also, presumably, involves computing ...
Definition brickwork.cpp:92
Definition stormm_vector_types.h:112
Definition stormm_vector_types.h:27