Arcane allows performing the three classic types of reduction (Min, Max, and Sum) on the accelerator. There are two ways to perform reductions:
Reductions via a loop
The classes ReducerMax2, ReducerMin2, and ReducerSum2 allow performing reductions on accelerators. They are used inside loops such as RUNCOMMAND_LOOP1() or RUNCOMMAND_ENUMERATE() or RUNCOMMAND_MAT_ENUMERATE().
First, you must declare an instance of one of the reduction classes and then pass it as an additional parameter to the loops. For example:
#include "arcane/accelerator/Reduce.h"
{
auto command = makeCommand(queue);
auto in_my_variable = viewIn(command,my_variable);
{
minimum_reducer.combine(in_my_variable[cid]);
};
info() << "MinValue=" << minimum_reducer.reducedValue();
}
Types and macros to manage enumerations of entities on accelerators.
#define RUNCOMMAND_ENUMERATE(ItemTypeName, iter_name, item_group,...)
Macro to iterate over an accelerator on a group of entities.
Class to perform a 'min' reduction.
Execution queue for an accelerator.
MeshVariableScalarRefT< Cell, Real > VariableCellReal
Real type quantity at cell center.
- Warning
- Each instance can only be used once.
It is possible to use multiple reduction instances if you want to perform several reductions at once. For example:
#include "arcane/accelerator/Reduce.h"
{
auto command = makeCommand(queue);
auto in_my_variable = viewIn(command,my_variable);
{
minimum_reducer.combine(in_my_variable[cid]);
maximum_reducer.combine(in_my_variable[cid]);
};
info() << "MinValue=" << minimum_reducer.reducedValue();
info() << "MaxValue=" << maximum_reducer.reducedValue();
}
Class to perform a 'max' reduction.
Direct Reductions
The GenericReducer class allows launching a specific command dedicated to reduction. An instance of GenericReducer can be used multiple times.