26 #ifndef TILEDARRAY_CONVERSIONS_TO_NEW_TILE_TYPE_H__INCLUDED 27 #define TILEDARRAY_CONVERSIONS_TO_NEW_TILE_TYPE_H__INCLUDED 29 #include "../dist_array.h" 40 template <
typename Tile,
typename Policy,
typename Op>
41 inline DistArray<typename std::result_of<Op(Tile)>::type, Policy>
43 using OutTileType =
typename std::result_of<Op(Tile)>::type;
46 static_assert(!std::is_same<Tile, OutTileType>::value,
47 "Can't call new tile type if tile type does not change.");
49 auto &world = old_array.
world();
52 OutArray new_array(world, old_array.
trange(), old_array.
shape(), old_array.
pmap());
54 using pmap_iter = decltype(old_array.
pmap()->begin());
55 pmap_iter it = old_array.
pmap()->begin();
56 pmap_iter end = old_array.
pmap()->end();
58 for(; it != end; ++it) {
62 Future<OutTileType> tile = world.taskq.add(op, old_array.
find(*it));
63 new_array.set(*it, tile);
71 #endif // TILEDARRAY_CONVERSIONS_TO_NEW_TILE_TYPE_H__INCLUDED Future< value_type > find(const Index &i) const
Find local or remote tile.
const shape_type & shape() const
Shape accessor.
const trange_type & trange() const
Tiled range accessor.
DistArray< typename std::result_of< Op(Tile)>::type, Policy > to_new_tile_type(DistArray< Tile, Policy > const &old_array, Op &&op)
Function to convert an array to a new array with a different tile type.
bool is_zero(const Index &i) const
Check for zero tiles.
World & world() const
World accessor.
const std::shared_ptr< pmap_interface > & pmap() const
Process map accessor.