Skip to content

Commit

Permalink
refactor: mapping: #26: Files are renamed and refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
Aram Markosyan committed Oct 3, 2017
1 parent 70db587 commit df8d67b
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 49 deletions.
8 changes: 0 additions & 8 deletions src/topos/mapping_headers.h

This file was deleted.

17 changes: 8 additions & 9 deletions src/topos/mapping.h → src/topos/topos_mapping.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@

#if ! defined __RUNTIME_TRANSPORT_MAPPING__
#define __RUNTIME_TRANSPORT_MAPPING__
#if !defined INCLUDED_TOPOS_MAPPING
#define INCLUDED_TOPOS_MAPPING

#include <functional>

#include "config.h"
#include "topos_index.h"

#include <functional>

namespace vt { namespace mapping {

// General map function type: contains only the index and number of nodes
template <typename PhysicalType, typename IndexType>
using MapType = std::function<PhysicalType(
IndexType const& idx, NodeType const& num_nodes
IndexType const& idx, NodeType const& num_nodes
)>;
template <typename IndexType>
using NodeMapType = MapType<NodeType, IndexType>;
Expand All @@ -23,14 +23,13 @@ using CoreMapType = MapType<CoreType, IndexType>;
// Dense index map function type: contains index and size of dense region
template <typename PhysicalType, typename IndexType>
using DenseMapType = std::function<PhysicalType(
IndexType const& idx, IndexType const& size, NodeType const& num_nodes
IndexType const& idx, IndexType const& size, NodeType const& num_nodes
)>;
template <typename IndexType>
using DenseNodeMapType = DenseMapType<NodeType, IndexType>;
template <typename IndexType>
using DenseCoreMapType = DenseMapType<CoreType, IndexType>;

}} // end namespace vt::location

}} // end namespace vt::location

#endif /*__RUNTIME_TRANSPORT_MAPPING__*/
#endif /*INCLUDED_TOPOS_MAPPING*/
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@

#include "config.h"
#include "context.h"
#include "topos_index.h"
#include "mapping.h"
#include "dense_mappings.h"

#include <cmath>
#include "topos_mapping_dense.h"

namespace vt { namespace mapping {

Expand Down Expand Up @@ -39,6 +35,5 @@ NodeType dense3DBlockMap(Idx3DRef idx, Idx3DRef max_idx, NodeRef nnodes) {
return denseBlockMap<Index3D, 3>(idx, max_idx, nnodes);
}


}} // end namespace vt::location
}} // end namespace vt::location

22 changes: 11 additions & 11 deletions src/topos/dense_mappings.h → src/topos/topos_mapping_dense.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@

#if ! defined __RUNTIME_TRANSPORT_DENSE_MAPPING__
#define __RUNTIME_TRANSPORT_DENSE_MAPPING__
#if !defined INCLUDED_TOPOS_MAPPING_DENSE
#define INCLUDED_TOPOS_MAPPING_DENSE

#include <functional>

#include "config.h"
#include "topos_index.h"
#include "mapping.h"

#include <functional>
#include "topos_mapping.h"

namespace vt { namespace mapping {

template <typename IndexElmType, typename PhysicalType>
NodeType blockMapDenseFlatIndex(
IndexElmType const& flat_idx, IndexElmType const& num_elems,
PhysicalType const& num_resources
IndexElmType const& flat_idx, IndexElmType const& num_elems,
PhysicalType const& num_resources
);

template <typename Idx, index::NumDimensionsType ndim>
Idx linearizeDenseIndex(
DenseIndex<Idx, ndim> const& idx, DenseIndex<Idx, ndim> const& max_idx
DenseIndex<Idx, ndim> const& idx, DenseIndex<Idx, ndim> const& max_idx
);

template <typename Index>
Expand All @@ -43,8 +43,8 @@ NodeType dense1DBlockMap(Idx1DRef idx, Idx1DRef max_idx, NodeRef nnodes);
NodeType dense2DBlockMap(Idx2DRef idx, Idx2DRef max_idx, NodeRef nnodes);
NodeType dense3DBlockMap(Idx3DRef idx, Idx3DRef max_idx, NodeRef nnodes);

}} // end namespace vt::location
}} // end namespace vt::location

#include "dense_mappings.impl.h"
#include "topos_mapping_dense.impl.h"

#endif /*__RUNTIME_TRANSPORT_DENSE_MAPPING__*/
#endif /*INCLUDED_TOPOS_MAPPING_DENSE*/
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@

#if ! defined __RUNTIME_TRANSPORT_DENSE_MAPPING_IMPL__
#define __RUNTIME_TRANSPORT_DENSE_MAPPING_IMPL__
#if !defined INCLUDED_TOPOS_MAPPING_DENSE_IMPL
#define INCLUDED_TOPOS_MAPPING_DENSE_IMPL

#include <cmath>

#include "config.h"
#include "topos_index.h"
#include "mapping.h"

#include <cmath>
#include "topos_mapping.h"

namespace vt { namespace mapping {

template <typename IndexElmType, typename PhysicalType>
inline NodeType blockMapDenseFlatIndex(
IndexElmType const& flat_idx, IndexElmType const& num_elems,
PhysicalType const& num_resources
IndexElmType const& flat_idx, IndexElmType const& num_elems,
PhysicalType const& num_resources
) {
double const& elms_as_dbl = static_cast<double>(num_elems);
double const& res_as_dbl = static_cast<double>(num_resources);
Expand All @@ -35,29 +35,29 @@ inline NodeType blockMapDenseFlatIndex(

template <typename Idx, index::NumDimensionsType ndim>
Idx linearizeDenseIndex(
DenseIndex<Idx,ndim> const& idx, DenseIndex<Idx,ndim> const& max_idx
DenseIndex <Idx, ndim> const& idx, DenseIndex <Idx, ndim> const& max_idx
) {
Idx val = 0;
Idx dim_size = 1;
for (auto i = ndim-1; i >= 0; i--) {
for (auto i = ndim - 1; i >= 0; i--) {
val += dim_size * idx.dims[i];
dim_size *= max_idx.dims[i];
}
return val;
}

template <typename Idx, index::NumDimensionsType ndim>
NodeType denseBlockMap(IdxRef<Idx> idx, IdxRef<Idx> max_idx, NodeRef nnodes) {
NodeType denseBlockMap(IdxRef <Idx> idx, IdxRef <Idx> max_idx, NodeRef nnodes) {
using IndexElmType = typename Idx::DenseIndexType;

auto const& total_elems = max_idx.getSize();
auto const& flat_idx = linearizeDenseIndex<IndexElmType, ndim>(idx, max_idx);

return blockMapDenseFlatIndex<IndexElmType, NodeType>(
flat_idx, total_elems, nnodes
flat_idx, total_elems, nnodes
);
}

}} // end namespace vt::location
}} // end namespace vt::location

#endif /*__RUNTIME_TRANSPORT_DENSE_MAPPING_IMPL__*/
#endif /*INCLUDED_TOPOS_MAPPING_DENSE_IMPL*/
8 changes: 8 additions & 0 deletions src/topos/topos_mapping_headers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#if !defined INCLUDED_TOPOS_MAPPING_HEADERS
#define INCLUDED_TOPOS_MAPPING_HEADERS

#include "topos_mapping.h"
#include "topos_mapping_dense.h"

#endif /*INCLUDED_TOPOS_MAPPING_HEADERS*/
2 changes: 1 addition & 1 deletion src/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "scheduler.h"
#include "location.h"
#include "topos/topos_index.h"
#include "topos/mapping_headers.h"
#include "topos/topos_mapping_headers.h"
#include "context_vrtheaders.h"

#endif /*__RUNTIME_TRANSPORT__*/

0 comments on commit df8d67b

Please sign in to comment.