Skip to content

Commit

Permalink
Merge branch 'feature/nselliott/artificial-load' into release/v-4-3
Browse files Browse the repository at this point in the history
  • Loading branch information
nselliott committed Mar 4, 2024
2 parents 6a62489 + f572762 commit d342fd1
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 44 deletions.
4 changes: 2 additions & 2 deletions source/SAMRAI/mesh/BalanceBoxBreaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1106,8 +1106,8 @@ double BalanceBoxBreaker::TrialBreak::computeBreakOffLoad(
static_cast<double>(d_whole_box.size())) *
static_cast<double>(box.size());

if (breakoff_load < d_pparams->getMinimumLoad()) {
breakoff_load = static_cast<double>(d_pparams->getMinimumLoad());
if (breakoff_load < d_pparams->getArtificialMinimumLoad()) {
breakoff_load = static_cast<double>(d_pparams->getArtificialMinimumLoad());
}
} else {
/*
Expand Down
4 changes: 2 additions & 2 deletions source/SAMRAI/mesh/BoxTransitSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void BoxTransitSet::insertAll(const hier::BoxContainer& other)
}
}

void BoxTransitSet::insertAllWithMinimumLoad(
void BoxTransitSet::insertAllWithArtificialMinimum(
const hier::BoxContainer& other,
double minimum_load)
{
Expand All @@ -152,7 +152,7 @@ void BoxTransitSet::insertAllWithMinimumLoad(
d_sumsize += new_box.getSize();
}
if (d_set.size() != old_size + other.size()) {
TBOX_ERROR("BoxTransitSet's insertAllWithMinimum currently can't weed out duplicates.");
TBOX_ERROR("BoxTransitSet's insertAllWithArtificialMinimum currently can't weed out duplicates.");
}
}

Expand Down
4 changes: 2 additions & 2 deletions source/SAMRAI/mesh/BoxTransitSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ class BoxTransitSet:public TransitLoad
* behavior is desired by the calling code.
*
* @param other box container with boxes to inserted into this object.
* @param minimum_load minimum load value
* @param minimum_load artificial minimum load value
*/
void
insertAllWithMinimumLoad(
insertAllWithArtificialMinimum(
const hier::BoxContainer& box_container,
double minimum_load);

Expand Down
35 changes: 19 additions & 16 deletions source/SAMRAI/mesh/CascadePartitioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ CascadePartitioner::CascadePartitioner(
d_limit_supply_to_surplus(true),
d_reset_obligations(true),
d_flexible_load_tol(0.05),
d_min_load(1,1.0),
d_artificial_minimum(1,1.0),
d_use_vouchers(false),
d_mca(),
// Shared data.
Expand Down Expand Up @@ -197,16 +197,16 @@ CascadePartitioner::loadBalanceBoxLevel(
}

size_t minimum_cells = 1;
double minimum_load = 1.0;
double artificial_minimum = 1.0;

if (hierarchy) {
minimum_cells = hierarchy->getMinimumCellRequest(level_number);
if (static_cast<unsigned int>(level_number) < d_min_load.size()) {
minimum_load = d_min_load[level_number];
if (static_cast<unsigned int>(level_number) < d_artificial_minimum.size()) {
artificial_minimum = d_artificial_minimum[level_number];
} else {
minimum_load = d_min_load.back();
artificial_minimum = d_artificial_minimum.back();
}
TBOX_ASSERT(minimum_load >= 0.0);
TBOX_ASSERT(artificial_minimum >= 0.0);
}

if (d_mpi_is_dupe) {
Expand Down Expand Up @@ -295,7 +295,7 @@ CascadePartitioner::loadBalanceBoxLevel(
balance_box_level.getRefinementRatio(),
min_size, max_size, bad_interval, effective_cut_factor,
minimum_cells,
minimum_load,
artificial_minimum,
d_flexible_load_tol);

LoadType local_load = computeLocalLoad(balance_box_level);
Expand Down Expand Up @@ -588,9 +588,11 @@ CascadePartitioner::partitionByCascade(
local_load->setThresholdWidth(ideal_box_width);
shipment->setThresholdWidth(ideal_box_width);

if (d_pparams->getMinimumLoad() > d_pparams->getMinBoxSizeProduct()) {
local_load->insertAllWithMinimumLoad(balance_box_level.getBoxes(),
d_pparams->getMinimumLoad());
if (d_pparams->getArtificialMinimumLoad() >
d_pparams->getMinBoxSizeProduct()) {
local_load->insertAllWithArtificialMinimum(
balance_box_level.getBoxes(),
d_pparams->getArtificialMinimumLoad());
} else {
local_load->insertAll(balance_box_level.getBoxes());
}
Expand Down Expand Up @@ -837,18 +839,18 @@ CascadePartitioner::LoadType
CascadePartitioner::computeLocalLoad(
const hier::BoxLevel& box_level) const
{
double request_load = 1.0;
double artificial_load = 1.0;
if (d_pparams) {
request_load = d_pparams->getMinimumLoad();
artificial_load = d_pparams->getArtificialMinimumLoad();
}
double load = 0.0;
const hier::BoxContainer& boxes = box_level.getBoxes();
for (hier::BoxContainer::const_iterator ni = boxes.begin();
ni != boxes.end();
++ni) {
double box_load = static_cast<double>(ni->size());
if (box_load < request_load) {
box_load = request_load;
if (box_load < artificial_load) {
box_load = artificial_load;
}
load += box_load;
}
Expand Down Expand Up @@ -939,8 +941,9 @@ CascadePartitioner::getFromInput(
}
}

if (input_db->isDouble("minimum_patch_load")) {
d_min_load = input_db->getDoubleVector("minimum_patch_load");
if (input_db->isDouble("artificial_minimum_load")) {
d_artificial_minimum =
input_db->getDoubleVector("artificial_minimum_load");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/SAMRAI/mesh/CascadePartitioner.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ class CascadePartitioner:
*/
double d_flexible_load_tol;

std::vector<double> d_min_load;
std::vector<double> d_artificial_minimum;

/*!
* @brief Boolean to determine whether to use vouchers for transferring load.
Expand Down
6 changes: 3 additions & 3 deletions source/SAMRAI/mesh/PartitioningParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ PartitioningParams::PartitioningParams(
const hier::IntVector& bad_interval,
const hier::IntVector& cut_factor,
size_t minimum_cells,
double minimum_load,
double artificial_minimum_load,
double flexible_load_tol):
d_min_size(min_size),
d_max_size(max_size),
d_bad_interval(bad_interval, grid_geometry.getNumberBlocks()),
d_cut_factor(cut_factor),
d_minimum_cells(minimum_cells),
d_minimum_load(minimum_load),
d_artificial_minimum_load(artificial_minimum_load),
d_flexible_load_tol(flexible_load_tol),
d_load_comparison_tol(1e-6),
d_using_vouchers(false),
Expand All @@ -51,7 +51,7 @@ PartitioningParams::PartitioningParams(
d_bad_interval(other.d_bad_interval),
d_cut_factor(other.d_cut_factor),
d_minimum_cells(other.d_minimum_cells),
d_minimum_load(other.d_minimum_load),
d_artificial_minimum_load(other.d_artificial_minimum_load),
d_load_comparison_tol(other.d_load_comparison_tol),
d_using_vouchers(other.d_using_vouchers),
d_work_data_id(other.d_work_data_id)
Expand Down
13 changes: 9 additions & 4 deletions source/SAMRAI/mesh/PartitioningParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PartitioningParams
const hier::IntVector& bad_interval,
const hier::IntVector& cut_factor,
size_t minimum_cells,
double minimum_load,
double artificial_minimum_load,
double flexible_load_tol);

PartitioningParams(
Expand Down Expand Up @@ -70,8 +70,8 @@ class PartitioningParams
return d_minimum_cells;
}

double getMinimumLoad() const {
return d_minimum_load;
double getArtificialMinimumLoad() const {
return d_artificial_minimum_load;
}

const tbox::Dimension& getDim() const {
Expand Down Expand Up @@ -130,7 +130,12 @@ class PartitioningParams
*/
size_t d_minimum_cells;

double d_minimum_load;
/*
* @brief An optional artificial load value. If used, new boxes smaller
* than this value are treated as if their load is this value during
* load balancing operations.
*/
double d_artificial_minimum_load;

/*!
* @brief Fraction of ideal load a process can accept over and
Expand Down
4 changes: 2 additions & 2 deletions source/SAMRAI/mesh/TransitLoad.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ class TransitLoad
* ignores the minimum load value and is equivalent to insertAll().
*
* @param other box container with boxes to inserted into this object.
* @param minimum_load minimum load value
* @param minimum_load artificial minimum load value
* (ignored in default implementation)
*/
virtual void
insertAllWithMinimumLoad(
insertAllWithArtificialMinimum(
const hier::BoxContainer& other,
double minimum_load)
{
Expand Down
19 changes: 10 additions & 9 deletions source/SAMRAI/mesh/TreeLoadBalancer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ TreeLoadBalancer::TreeLoadBalancer(
d_comm_graph_writer(),
d_master_workload_data_id(s_default_data_id),
d_flexible_load_tol(0.05),
d_min_load(1,1.0),
d_artificial_minimum(1,1.0),
d_mca(),
// Performance evaluation.
d_barrier_before(false),
Expand Down Expand Up @@ -194,15 +194,15 @@ TreeLoadBalancer::loadBalanceBoxLevel(
}

size_t minimum_cells = 1;
double minimum_load = 1;
double artificial_minimum = 1.0;
if (hierarchy) {
minimum_cells = hierarchy->getMinimumCellRequest(level_number);
if (level_number < static_cast<int>(d_min_load.size())) {
minimum_load = d_min_load[level_number];
if (level_number < static_cast<int>(d_artificial_minimum.size())) {
artificial_minimum = d_artificial_minimum[level_number];
} else {
minimum_load = d_min_load.back();
artificial_minimum = d_artificial_minimum.back();
}
TBOX_ASSERT(minimum_load >= 0.0);
TBOX_ASSERT(artificial_minimum >= 0.0);
}

if (d_mpi_is_dupe) {
Expand Down Expand Up @@ -303,7 +303,7 @@ TreeLoadBalancer::loadBalanceBoxLevel(
*balance_box_level.getGridGeometry(),
balance_box_level.getRefinementRatio(),
min_size, max_size, bad_interval, effective_cut_factor, minimum_cells,
minimum_load,
artificial_minimum,
d_flexible_load_tol);

/*
Expand Down Expand Up @@ -1659,8 +1659,9 @@ TreeLoadBalancer::getFromInput(
}
}

if (input_db->isDouble("minimum_patch_load")) {
d_min_load = input_db->getDoubleVector("minimum_patch_load");
if (input_db->isDouble("artificial_minimum_load")) {
d_artificial_minimum =
input_db->getDoubleVector("artificial_minimum_load");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/SAMRAI/mesh/TreeLoadBalancer.h
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ class TreeLoadBalancer:
*/
double d_flexible_load_tol;

std::vector<double> d_min_load;
std::vector<double> d_artificial_minimum;

/*!
* @brief Metadata operations with timers set according to this object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ BergerRigoutsos {

CascadePartitioner {
flexible_load_tolerance = 0.05
minimum_patch_load = 1500,5000,18000
artificial_minimum_load = 1500,5000,18000
DEV_limit_supply_to_surplus = FALSE
// Debugging options
DEV_report_load_balance = TRUE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ BergerRigoutsos {

CascadePartitioner {
flexible_load_tolerance = 0.05
minimum_patch_load = 1500,5000,12000
artificial_minimum_load = 1500,5000,12000
// Debugging options
DEV_report_load_balance = TRUE
DEV_check_map = TRUE
Expand Down

0 comments on commit d342fd1

Please sign in to comment.