Skip to content

Commit

Permalink
mapping: #4: simplify mapping interface, no generalizing w/phy. resource
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Oct 8, 2017
1 parent 810f32b commit 9242df1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
6 changes: 4 additions & 2 deletions src/configs/types/types_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

namespace vt {

using NodeType = uint16_t;
using CoreType = uint16_t;
using PhysicalResourceType = uint16_t;
using NodeType = PhysicalResourceType;
using CoreType = PhysicalResourceType;
using SeedType = int64_t;
using HandlerType = int32_t;
using EnvelopeDataType = int8_t;
using EventType = uint64_t;
Expand Down
34 changes: 17 additions & 17 deletions src/topos/mapping/mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@

namespace vt { namespace mapping {

// General map function type: contains only the index and number of nodes
template <typename PhysicalType, typename IndexType>
using MapType = PhysicalType(*)(IndexType*, NodeType);
// General mapping functions: maps indexed collections to hardware
template <typename IndexType>
using MapType = PhysicalResourceType(*)(IndexType*, PhysicalResourceType);

template <typename IndexType>
using NodeMapType = MapType<NodeType, IndexType>;
using NodeMapType = MapType<IndexType>;
template <typename IndexType>
using CoreMapType = MapType<CoreType, IndexType>;

using CoreMapType = MapType<IndexType>;

// Dense index map function type: contains index and size of dense region
template <typename PhysicalType, typename IndexType>
using DenseMapType = PhysicalType(*)(IndexType*, IndexType*, NodeType);
// Dense index mapping functions: maps dense index, with dense regions size, to
// hardware
template <typename IndexType>
using DenseMapType = PhysicalResourceType(*)(
IndexType*, IndexType*, PhysicalResourceType
);

template <typename IndexType>
using DenseNodeMapType = DenseMapType<NodeType, IndexType>;
using DenseNodeMapType = DenseMapType<IndexType>;
template <typename IndexType>
using DenseCoreMapType = DenseMapType<CoreType, IndexType>;

using SeedType = int64_t;
using DenseCoreMapType = DenseMapType<IndexType>;

template <typename PhysicalType>
using SeedMapType = PhysicalType(*)(SeedType seed, PhysicalType nres);
// Seed mapping functions for singleton mapping to hardware
using SeedMapType = PhysicalResourceType(*)(SeedType, PhysicalResourceType);

using NodeSeedMapType = SeedMapType<NodeType>;
using CoreSeedMapType = SeedMapType<CoreType>;
using NodeSeedMapType = SeedMapType;
using CoreSeedMapType = SeedMapType;

}} // end namespace vt::location

Expand Down
3 changes: 3 additions & 0 deletions src/topos/mapping/mapping_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ using SimpleMapFunctionType = NodeType(*)(
template <typename IndexT>
using ActiveMapFunctionType = NodeType(IndexT*, IndexT*, NodeType);

using SimpleSeedMapFunctionType = NodeType(*)(SeedType, NodeType);
using ActiveSeedMapFunctionType = NodeType(SeedType, NodeType);

}} /* end namespace vt::mapping */

#endif /*__RUNTIME_TRANSPORT_MAPPING_FUNCTION__*/
7 changes: 4 additions & 3 deletions src/topos/mapping/mapping_seed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

namespace vt { namespace mapping {

template <typename PhysicalT>
PhysicalT randomSeedMap(SeedType seed, PhysicalT nres) {
PhysicalResourceType randomSeedMap(SeedType seed, PhysicalResourceType nres) {
// @todo: use C++ random number generator instead, these are not thread-safe
// This must run only on the communication thread
srand48(seed);
auto const& map_to = static_cast<PhysicalT>(drand48() * nres);
auto const& map_to = static_cast<PhysicalResourceType>(drand48() * nres);
return map_to;
}

Expand Down

0 comments on commit 9242df1

Please sign in to comment.