Open cyrush opened 1 year ago
Note: One of the key features here is runtime dispatch mapping to a set of concrete templates w/ tags.
These examples do not show how to implement this, but this is compatible with a code strategy I tested for this.
// c++20 generic lambda
dispatch(policy, [&] <typename Exec>(Exec &exec)
{
...
}
// c++14 generic lambda
dispatch(policy, [&] (auto &exec)
{
using Exec = std::remove_reference_t<decltype(exec)>;
...
}
// RAJA current reducer syntax
ReduceMinLoc<reduce_policy,float64> reducer(identity, -1);
forall<for_policy>(0, size,
[=] (int i)
{
const float64 val = 2.0 * acc_src[idx];
reducer.minloc(val,i);
acc_des.set(idx,val);
});
min_val = reducer.get();
min_loc = reducer.getLoc();
// RAJA new reducer syntax
RAJA::expt::ValLoc<float64> reducer(identity, -1);
forall<for_policy>(0, size,
RAJA::expt::Reduce<RAJA::operators::minimum>(&reducer),
[=] (int i, RAJA::expt::ValLoc<float64> &reducer)
{
const float64 val = 2.0 * acc_src[idx];
reducer.min(val,i);
acc_des.set(idx,val);
});
min_val = reducer.getVal();
min_loc = reducer.getLoc();
@MrBurmark thanks for this info!
Notes from discussion:
DataAccessorHostDevice
is ExecutionAccessor
(and also ExecutionArray
).DataAccessorHostDevice::move()
is backwards (std::move
and Node::move
both move the other way). We ought to consider changing the name to replace
.Let's skip move()
/replace()
for now because the cases are scary.
sync copies (or no-ops) the data back to where it came from (the node that we wrapped), calling replace will give node the other_ptr call node.reset() on the node where the data came from. Also change execaccessor so that it seamlessly works. It should look like the simple case where the data was already there.
Maybe assume
is a better name than replace
.