Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fixing and improving algorithms with view expressions #410

Open
wants to merge 192 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
192 commits
Select commit Hold shift + click to select a range
eea0c28
Extending n-dim view tests
fuchsto Mar 18, 2017
949fb7b
Fixed rank in cartesian index space, SeqTilePattern.local_blockspec
fuchsto Mar 18, 2017
8586b3f
Skipping WIP test case
fuchsto Mar 18, 2017
92e2a34
Implementing n-dim block views
fuchsto Mar 18, 2017
09c0a77
Implementing n-dim block views
fuchsto Mar 18, 2017
6a7de46
Minor, added notes
fuchsto Mar 20, 2017
b0513c3
Merge branch 'development' of github.com:dash-project/dash into feat-…
fuchsto Mar 20, 2017
3275589
Merge branch 'development' of github.com:dash-project/dash into feat-…
fuchsto Mar 22, 2017
8d61420
Intermediate commit, likely broken
devreal May 10, 2017
1b431e0
Implement global-to-global dash::copy
devreal May 10, 2017
b0b07b3
Honor distribution in dash::transform
devreal May 10, 2017
7fa405e
Make g2g dash::copy work with matrix blocks and adapt test
devreal May 10, 2017
71e62bf
Merge branch 'development' of github.com:dash-project/dash into feat-…
fuchsto May 20, 2017
0245217
Added test on local view of cyclic array
fuchsto May 20, 2017
4f24fb0
Using view expressions in dash::copy, added unit tests, extended rang…
fuchsto May 20, 2017
f7aa958
Added stream operators for unique_ptr, shared_ptr
fuchsto May 23, 2017
9dbd69c
View test: copy blockcyclic local to global
fuchsto May 23, 2017
5d31f88
Cleanup in dash::copy
fuchsto May 23, 2017
90595ea
Cleanup
fuchsto May 23, 2017
f9a9c21
Merge branch 'feat-192-nviews' of github.com:dash-project/dash into f…
fuchsto May 23, 2017
86ec450
Updated CartesianTest
fuchsto May 23, 2017
4e9519c
Documenting the DASH Index Set concept
fuchsto May 24, 2017
2d52c28
Fixing index set of dash::make_range
fuchsto May 25, 2017
a99d710
Minor
fuchsto May 25, 2017
155bd30
Merge branch 'feat-192-nviews' of github.com:dash-project/dash into f…
fuchsto May 25, 2017
19b5939
Fixing index set of dash::make_range
fuchsto May 25, 2017
671f566
Merge branch 'feat-192-nviews' of github.com:dash-project/dash into f…
fuchsto May 25, 2017
f0b18cc
Fixing index set of dash::make_range
fuchsto May 25, 2017
25c93b5
Added ex.02.array-views
fuchsto May 25, 2017
950e25a
Fixing dash::make_range
fuchsto May 26, 2017
a3253c8
Merge branch 'development' into feat-192-nviews
fuchsto May 30, 2017
1bb8fb2
Fixing dash::make_range
fuchsto May 30, 2017
d0f4dfc
Merge branch 'feat-192-nviews' of github.com:dash-project/dash into f…
fuchsto May 30, 2017
f275c06
Fixing dash::make_range
fuchsto May 30, 2017
81f089d
Fixed type definition traits macro
fuchsto May 30, 2017
bd91cd4
Fixed pointer ranges
fuchsto May 30, 2017
c880aab
Fixing dash::make_range
fuchsto May 30, 2017
12ad36b
Fixing dash::make_range
fuchsto May 30, 2017
368de77
Fixed dash::make_range
fuchsto May 30, 2017
f9ee3b1
Cleanup ex.02.array-views (local-to-global copy)
fuchsto May 31, 2017
6ae01cf
Cleanup in ex.02.array-views
fuchsto May 31, 2017
e1f7a72
Update LocalPattern.h
fuchsto May 31, 2017
c1a9219
Added multidimensional block phase views
fuchsto May 31, 2017
f0ad61e
Merge branch 'feat-192-nviews' of github.com:dash-project/dash into f…
fuchsto May 31, 2017
c170d7c
Minor fix in NView test
fuchsto May 31, 2017
8325b0f
Merge branch 'development' into bug-386-transform
fuchsto May 31, 2017
1382b48
Merge branch 'bug-386-transform' of github.com:dash-project/dash into…
fuchsto May 31, 2017
63da3cd
Defining iterator ranges as model of View concept
fuchsto May 31, 2017
9d02589
Defined iterator ranges as model of View concept
fuchsto May 31, 2017
d90ee38
Adding local views for iterator ranges
fuchsto Jun 1, 2017
d5a7b72
Adding local views for iterator ranges
fuchsto Jun 1, 2017
e2a1512
Adding local views for iterator ranges
fuchsto Jun 1, 2017
3877796
Adding local views for iterator ranges
fuchsto Jun 1, 2017
9b5a790
Redefining dash::transform with views/ranges
fuchsto Jun 1, 2017
876f55e
Extended ex.02.array-copy
fuchsto Jun 1, 2017
911851f
Extended ex.02.array-copy
fuchsto Jun 1, 2017
d87c51d
Extended ex.02.array-copy
fuchsto Jun 1, 2017
7e15ff7
Cleanup in view headers
fuchsto Jun 2, 2017
f12b797
Iterator range adapter types
fuchsto Jun 2, 2017
83327b4
Iterator range adapter types
fuchsto Jun 3, 2017
15c9f5d
Iterator range adapter types
fuchsto Jun 3, 2017
e3b0aa1
Range ostream operators
fuchsto Jun 3, 2017
05d77c1
Decouple concepts IndexSet and Pattern
fuchsto Jun 3, 2017
5fce765
extending ex.02.array-copy
fuchsto Jun 3, 2017
85c19ce
Fixed compiler errors
fuchsto Jun 5, 2017
088fff6
Removed view_traits::pattern_type
fuchsto Jun 6, 2017
09ca07f
Removed view_traits::pattern_type
fuchsto Jun 6, 2017
527199c
hscale, fixed compiler error
fuchsto Jun 6, 2017
7701ef4
Fixed index set, passing view/nview tests
fuchsto Jun 6, 2017
6fb2762
Fixing IndexSetLocalOriginBase
fuchsto Jun 6, 2017
32d51f3
Fixed IteratorRangeLocalOrigin
fuchsto Jun 6, 2017
ca6de54
Fixed make_range
fuchsto Jun 6, 2017
514e47c
Fixed make_range
fuchsto Jun 6, 2017
acccf22
Extended nview, copy tests
fuchsto Jun 7, 2017
e869352
Extending view examples, fix in IndexSetBase
fuchsto Jun 7, 2017
50fae61
ShiftTilePattern.local_block_at, ViewIterator.local
fuchsto Jun 8, 2017
c9004ab
Added dash::sub<SDim>(offset, domain)
fuchsto Jun 8, 2017
e46d541
Fixing n-dim make_range
fuchsto Jun 9, 2017
37fc1d6
Intermediate experiments with view iterator ranges
fuchsto Jun 17, 2017
0b99972
Intermediate, adding view iterator ranges
fuchsto Jun 17, 2017
16cad8f
Cleanup dash::origin
fuchsto Jun 19, 2017
d0551b0
Removed cast workaround for dash::origin
fuchsto Jun 19, 2017
767967d
Fixes in iterator range types
fuchsto Jun 19, 2017
ae89a88
Updating nview tests
fuchsto Jun 19, 2017
aeffeca
Updating nview tests
fuchsto Jun 19, 2017
ef50faf
Fixing view iterator range types
fuchsto Jun 19, 2017
3da8a24
Fixing view iterator range types
fuchsto Jun 19, 2017
24bec10
Fixing n-dim. local views
fuchsto Jun 19, 2017
95e16d6
Fixing n-dim. view iterator ranges
fuchsto Jun 22, 2017
bef690a
added unit test for local blocks
Jun 26, 2017
7dde45c
Adding chunked view concepts
fuchsto Jun 29, 2017
95e4934
Adding chunked view concepts
fuchsto Jun 29, 2017
4065273
Merge branch 'feat-192-nviews' of github.com:dash-project/dash into f…
fuchsto Jun 29, 2017
6b34c09
Merge branch 'development' of github.com:dash-project/dash into feat-…
fuchsto Sep 12, 2017
43f14f9
Merge branch 'development' of github.com:dash-project/dash into feat-…
fuchsto Sep 16, 2017
729564b
Tentative switch to c++14
fuchsto Sep 16, 2017
2a7bda3
Merge branch 'feat-192-nviews' of github.com:dash-project/dash into f…
fuchsto Sep 16, 2017
1bc3b41
Deduction of domain index set type via declval
fuchsto Sep 16, 2017
8aab38b
Added LocalMatrixRef.pattern(), returning global pattern
fuchsto Sep 16, 2017
25f1847
Extending matrix halo views example
fuchsto Sep 16, 2017
43e7454
Merge branch 'development' of github.com:dash-project/dash into feat-…
fuchsto Sep 19, 2017
9037281
Added pipe utils
fuchsto Sep 19, 2017
acb61a8
Added local() pipeable
fuchsto Sep 19, 2017
c4f1f0c
Added sub, domain pipeables
fuchsto Sep 19, 2017
393adbe
Added origin, blocks, index, global pipeables
fuchsto Sep 19, 2017
068077c
Minor
fuchsto Sep 19, 2017
cdd90c0
Added missing (c) header
fuchsto Sep 19, 2017
dff4a8b
Cleanup in view examples
fuchsto Sep 20, 2017
c46b3a0
Extending view examples
fuchsto Sep 20, 2017
c23cc85
Extending view examples
fuchsto Sep 20, 2017
c502ef2
Introducing LocalViewIter, extending view examples
fuchsto Sep 20, 2017
d78ac8d
Intermediate fix
fuchsto Sep 20, 2017
b08f6db
Extending view examples
fuchsto Sep 20, 2017
d40995d
Extending view examples
fuchsto Sep 21, 2017
ab20737
Extending view examples
fuchsto Sep 22, 2017
813dc57
Fixing dash::expand view operation for matrix blocks
fuchsto Sep 23, 2017
0abbeac
Fixed dash::expand view operation for matrix blocks
fuchsto Sep 23, 2017
8dbf926
Using type dim_t for dimension template types in views
fuchsto Sep 23, 2017
d460493
Cleanup dash::expand
fuchsto Sep 23, 2017
52b1bce
Cleanup dash::expand
fuchsto Sep 23, 2017
87e3703
Added view operation dash::shift
fuchsto Sep 23, 2017
05be952
Using deduced return type for view.extents, view.offsets
fuchsto Sep 23, 2017
f8840fb
Fixed IndexSetLocal for ndim blocks
fuchsto Sep 23, 2017
d38dd86
Fixed ex.02.matrix-views example
fuchsto Sep 23, 2017
75e7da7
Added dash::intersect view operation
fuchsto Sep 23, 2017
9e7fb8c
Cleanup ex.02.matrix-sub-views example
fuchsto Sep 23, 2017
f038f98
Migrating dash::Matrix to view expressions
fuchsto Sep 24, 2017
75d63ec
Implementing range-based global to global copy
fuchsto Sep 24, 2017
7ab8b40
Adding dash::is_view_region<T>, dash::rank<T>, restructuring headers
fuchsto Sep 25, 2017
daf8cea
Fixed block views on n-dim subspaces
fuchsto Sep 25, 2017
aa12565
Added block view .is_local_at, cleanup
fuchsto Sep 26, 2017
1b064a1
Cleanup
fuchsto Sep 26, 2017
0631e79
Fixing Matrix.local
fuchsto Sep 26, 2017
d54a020
Fixed MatrixTest.CopyRow
fuchsto Sep 26, 2017
83a3e71
Fixed typo in dash::copy
fuchsto Sep 26, 2017
d417278
Fixed matrix unit tests
fuchsto Sep 26, 2017
b68573b
Intermediate, fixing matrix local block views
fuchsto Sep 26, 2017
5e32fa0
Fixed IndexSetBlock.rel for local domain
fuchsto Sep 26, 2017
9d013cd
Fixed Local-/GlobalViewIter operator[] offsets
fuchsto Sep 26, 2017
c76907e
Fixed LocalViewIter operator[] local offsets
fuchsto Sep 26, 2017
a4460c2
Further fixes in LocalViewIter
fuchsto Sep 26, 2017
8184295
Fixed IndexSetBlock.rel for local views
fuchsto Sep 26, 2017
1b929af
Cleanup in example ex.02.matrix-copy
fuchsto Sep 26, 2017
7043632
Fixing n-dim local sub-views
fuchsto Sep 26, 2017
f2d8197
Renamed example
fuchsto Sep 26, 2017
f8a5d6f
Fixed macro usage in dart_communication
fuchsto Sep 26, 2017
a2cf66f
Adding examples, fixes in ViewBlocksMod, LocalMatrixRef
fuchsto Sep 27, 2017
4ea390e
Extending examples, fixed viewspecs in local matrix
fuchsto Sep 27, 2017
fb919fa
Extending examples
fuchsto Sep 27, 2017
81b88a9
Fixing matrix | sub | local
fuchsto Sep 27, 2017
2d7d283
Extending examples
fuchsto Sep 27, 2017
34205b8
Merge branch 'feat-192-nviews' of coreglit.ch:/opt/git/dash into feat…
fuchsto Sep 27, 2017
3a5b9e9
Cleanup in examples
fuchsto Sep 29, 2017
0ab4cb7
Cleanup in examples
fuchsto Sep 29, 2017
0900d1d
Cleanup in examples
fuchsto Sep 29, 2017
8de7bf6
Cleanup in examples
fuchsto Sep 29, 2017
285dea4
Cleanup in examples
fuchsto Sep 29, 2017
d3de745
Fixes for SuperMIC
fuchsto Oct 2, 2017
dd591ab
clean-up of root directory, build-scripts in build-tools
ddiefenthaler Oct 3, 2017
056a436
made build scripts independant of working directory
ddiefenthaler Oct 3, 2017
96614c7
unified build scripts, parameter can be used to change build type
ddiefenthaler Oct 5, 2017
d2b3211
minor fix to use specified cmake command
ddiefenthaler Oct 5, 2017
82710d9
Merge branch 'development' of github.com:dash-project/dash into feat-…
fuchsto Oct 6, 2017
944b275
Adding matrix view tests
fuchsto Oct 6, 2017
a49cb64
Merge branch 'feat-192-nviews' of coreglit.ch:/opt/git/dash into feat…
fuchsto Oct 6, 2017
57f8a35
Adding matrix view tests
fuchsto Oct 7, 2017
14cfcc6
Adding matrix view tests
fuchsto Oct 7, 2017
5f23f01
Adding matrix view tests
fuchsto Oct 7, 2017
2571daf
Adding matrix view tests
fuchsto Oct 7, 2017
60b074e
Merge branch 'development' of github.com:dash-project/dash into feat-…
fuchsto Oct 10, 2017
9904630
Merge branch 'sup-build-supermic' of github.com:dash-project/dash int…
fuchsto Oct 10, 2017
55f584c
Merge branch 'sup-build-tools-directory' of github.com:dash-project/d…
fuchsto Oct 10, 2017
9fddf12
Cleanup in examples
fuchsto Oct 10, 2017
d2e6b73
Merge branch 'feat-192-nviews' of coreglit.ch:/opt/git/dash into feat…
fuchsto Oct 10, 2017
345e008
Fixes for clang c++14 compliance
fuchsto Oct 10, 2017
3e1f92f
Fixes for clang
fuchsto Oct 10, 2017
3d0e030
Specify C++ standard version via CMake built-in option
fuchsto Oct 11, 2017
829422c
Specify C++ standard version via CMake built-in option
fuchsto Oct 11, 2017
e95cb75
Intermediate
fuchsto Oct 16, 2017
55ac8f4
Merge branch 'development' of github.com:dash-project/dash into feat-…
fuchsto Oct 16, 2017
4f88c99
Merge branch 'development' of github.com:dash-project/dash into feat-…
fuchsto Oct 16, 2017
c82b403
Merge branch 'feat-192-nviews' of coreglit.ch:/opt/git/dash into feat…
fuchsto Oct 16, 2017
79d9553
Merge branch 'feat-192-nviews' of github.com:dash-project/dash into f…
fuchsto Oct 16, 2017
1c1647f
Merge branch 'development' of github.com:dash-project/dash into feat-…
fuchsto Dec 10, 2017
0c0961f
Fixed build errors from incomplete merge
fuchsto Dec 14, 2017
c67bde2
Fixed build errors from incomplete merge
fuchsto Dec 14, 2017
30f40b0
Merge branch 'development' of github.com:dash-project/dash into feat-…
fuchsto Mar 21, 2018
6bed0a9
Merge branch 'development' of github.com:dash-project/dash into feat-…
fuchsto Mar 21, 2018
b157125
Merge branch 'feat-192-nviews' of github.com:dash-project/dash into f…
fuchsto Mar 21, 2018
ead6e72
Fixing build after merge
fuchsto Mar 21, 2018
f5bcd07
Rollback of pathological concept changes on development branch after …
fuchsto Mar 21, 2018
3dab958
Outlining pattern concept separation
fuchsto Mar 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dash/include/dash/util/StaticConfig.h
*.log
*.out
ipm/*/GEN.*
my.*.sh
my.*
.syntastic*
.clang*
tags
Expand Down
36 changes: 21 additions & 15 deletions dash/include/dash/Cartesian.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,16 @@ class CartesianIndexSpace
typedef SizeType size_type;
typedef std::array<SizeType, NumDimensions> extents_type;

template<dim_t NDim_>
template<dim_t NDim_, MemArrange MA_, typename Ix_>
friend std::ostream & operator<<(
std::ostream & os,
const CartesianIndexSpace<NDim_> & cartesian_space);
std::ostream & os,
const CartesianIndexSpace<NDim_, MA_, Ix_> & cartesian_space);

protected:
/// Number of elements in the cartesian space spanned by this instance.
SizeType _size = 0;
/// Number of dimensions in the cartesian space.
SizeType _rank = NumDimensions;
SizeType _rank = 0;
/// Extents of the cartesian space by dimension.
extents_type _extents = { };
/// Cumulative index offsets of the index space by dimension respective
Expand Down Expand Up @@ -348,12 +348,10 @@ class CartesianIndexSpace
*/
template<typename... Args>
void resize(SizeType arg, Args... args) {
static_assert(
sizeof...(Args) == NumDimensions-1,
"Invalid number of arguments");
std::array<SizeType, NumDimensions> extents =
{{ arg, (SizeType)(args)... }};
resize(extents);
resize(
std::array<SizeType, NumDimensions> {{
arg, (SizeType)(args)...
}} );
}

/**
Expand All @@ -363,9 +361,18 @@ class CartesianIndexSpace
void resize(const std::array<SizeType_, NumDimensions> & extents) {
// Update size:
_size = 1;
_rank = 0;
for(auto i = 0; i < NumDimensions; i++ ) {
_extents[i] = static_cast<SizeType>(extents[i]);
_size *= _extents[i];
if (_extents[i] > 1) {
++_rank;
}
}
if (_size == 0) {
_rank = 0;
} else if (_rank == 0) {
_rank = 1;
}
// Update offsets:
_offset_row_major[NumDimensions-1] = 1;
Expand Down Expand Up @@ -805,17 +812,16 @@ std::ostream & operator<<(
return operator<<(os, ss.str());
}

template <
dash::dim_t NumDimensions >
template<dim_t NDim_, MemArrange MA_, typename Ix_>
std::ostream & operator<<(
std::ostream & os,
const dash::CartesianIndexSpace<NumDimensions> & cartesian_space)
std::ostream & os,
const CartesianIndexSpace<NDim_, MA_, Ix_> & cartesian_space)
{
std::ostringstream ss;
ss << dash::typestr(cartesian_space)
<< ": "
<< "extents(";
for (auto dim = 0; dim < NumDimensions; ++dim) {
for (auto dim = 0; dim < NDim_; ++dim) {
if (dim > 0) {
ss << ",";
}
Expand Down
8 changes: 6 additions & 2 deletions dash/include/dash/Exception.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
#ifndef DASH__EXCEPTION_H_
#define DASH__EXCEPTION_H_

#include <dash/internal/Macro.h>
#include <dash/internal/Logging.h>

#include <dash/exception/RuntimeError.h>
#include <dash/exception/InvalidArgument.h>
#include <dash/exception/OutOfRange.h>
#include <dash/exception/NotImplemented.h>
#include <dash/exception/AssertionFailed.h>
#include <dash/exception/StackTrace.h>

#include <dash/internal/Macro.h>
#include <dash/internal/Logging.h>
#include <dash/Init.h>

#include <sstream>
#include <iostream>


#define DASH_STACK_TRACE() do { \
dash__print_stacktrace(); \
Expand Down
130 changes: 56 additions & 74 deletions dash/include/dash/GlobPtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ template <typename T> class GlobConstPtr;

template <typename T, class MemSpaceT> class GlobPtr;

template <typename T1,
typename T2,
class MemSpaceT1,
class MemSpaceT2 >
dash::gptrdiff_t distance(
const GlobPtr<T1, MemSpaceT1> & gbegin,
const GlobPtr<T2, MemSpaceT2> & gend);

/**
* Pointer in global memory space with random access arithmetics.
*
Expand All @@ -72,7 +64,11 @@ class GlobPtr
typedef GlobPtr<const ElementType, MemorySpace> const_type;
typedef typename dash::default_index_t index_type;

typedef value_type * local_type;
typedef self_t global_type;

typedef index_type gptrdiff_t;
typedef index_type difference_type;

public:
template <typename T, class MemSpaceT>
Expand Down Expand Up @@ -269,10 +265,57 @@ class GlobPtr

/**
* Pointer offset difference operator.
*
* Defined with independent value types allow calculation
* of distance between \c GlobPtr<T> and \c GlobPtr<const T>.
* Refernced value types must have identical size.
*
* \todo
* Validate compatibility of memory space types using memory space traits
* once they are available.
*
* \return Global pointer distance between the first and second
* global pointer, corresponds to pointer distance
* \c (gend - gbegin)
*
* \concept{DashMemorySpaceConcept}
*/
constexpr index_type operator-(const self_t & rhs) const noexcept
template <typename TO, class MemSpaceTO >
difference_type operator-(
const GlobPtr<TO, MemSpaceTO> & rhs) const noexcept
{
return dash::distance(rhs, *this);
using val_type_b = typename std::decay<decltype(rhs)>::type::value_type;
using val_type_e = value_type;

static_assert(
sizeof(val_type_b) == sizeof(val_type_e),
"value types of global pointers are not compatible for dash::distance");

// Both pointers in same unit space:
if (rhs._rbegin_gptr.unitid == _rbegin_gptr.unitid ||
rhs._mem_space == nullptr) {
return ( _rbegin_gptr.addr_or_offs.offset -
rhs._rbegin_gptr.addr_or_offs.offset )
/ sizeof(value_type);
}
// If unit of begin pointer is after unit of end pointer,
// return negative distance with swapped argument order:
if (rhs._rbegin_gptr.unitid > _rbegin_gptr.unitid) {
return -(rhs - *this);
}
// Pointers span multiple unit spaces, accumulate sizes of
// local unit memory ranges in the pointer range:
index_type dist = rhs._mem_space->local_size(
dart_team_unit_t { rhs.dart_gptr().unitid })
- (rhs.dart_gptr().addr_or_offs.offset
/ sizeof(value_type))
+ (dart_gptr().addr_or_offs.offset
/ sizeof(value_type));
for (int u = rhs.dart_gptr().unitid+1;
u < dart_gptr().unitid; ++u) {
dist += _mem_space->local_size(dart_team_unit_t { u });
}
return dist;
}

/**
Expand Down Expand Up @@ -581,6 +624,9 @@ class GlobConstPtr
typedef typename base_t::index_type index_type;
typedef typename base_t::gptrdiff_t gptrdiff_t;

typedef value_type * local_type;
typedef self_t global_type;

template <typename T_>
friend std::ostream & operator<<(
std::ostream & os,
Expand Down Expand Up @@ -766,70 +812,6 @@ std::ostream & operator<<(

#endif // DOXYGEN

/**
* Specialization of \c dash::distance for \c dash::GlobPtr as default
* definition of pointer distance in global memory spaces.
*
* Equivalent to \c (gend - gbegin).
*
* \note
* Defined with independent value types T1 and T2 to allow calculation
* of distance between \c GlobPtr<T> and \c GlobPtr<const T>.
* The pointer value types must have identical size.
*
* \todo
* Validate compatibility of memory space types using memory space traits
* once they are available.
*
* \return Number of elements in the range between the first and second
* global pointer
*
* \concept{DashMemorySpaceConcept}
*/
template <typename T1,
typename T2,
class MemSpaceT1,
class MemSpaceT2 >
dash::gptrdiff_t distance(
// First global pointer in range
const GlobPtr<T1, MemSpaceT1> & gbegin,
// Final global pointer in range
const GlobPtr<T2, MemSpaceT2> & gend) {
using index_type = dash::gptrdiff_t;
using val_type_b = typename std::decay<decltype(gbegin)>::type::value_type;
using val_type_e = typename std::decay<decltype(gend)>::type::value_type;
using value_type = val_type_b;

static_assert(
sizeof(val_type_b) == sizeof(val_type_e),
"value types of global pointers are not compatible for dash::distance");

// Both pointers in same unit space:
if (gbegin._rbegin_gptr.unitid == gend._rbegin_gptr.unitid ||
gbegin._mem_space == nullptr) {
return ( gend._rbegin_gptr.addr_or_offs.offset -
gbegin._rbegin_gptr.addr_or_offs.offset )
/ sizeof(value_type);
}
// If unit of begin pointer is after unit of end pointer,
// return negative distance with swapped argument order:
if (gbegin._rbegin_gptr.unitid > gend._rbegin_gptr.unitid) {
return -(dash::distance(gend, gbegin));
}
// Pointers span multiple unit spaces, accumulate sizes of
// local unit memory ranges in the pointer range:
index_type dist = gbegin._mem_space->local_size(
dart_team_unit_t { gbegin.dart_gptr().unitid })
- (gbegin.dart_gptr().addr_or_offs.offset
/ sizeof(value_type))
+ (gend.dart_gptr().addr_or_offs.offset
/ sizeof(value_type));
for (int u = gbegin.dart_gptr().unitid+1;
u < gend.dart_gptr().unitid; ++u) {
dist += gend._mem_space->local_size(dart_team_unit_t { u });
}
return dist;
}

/**
* Resolve the number of elements between two global pointers.
Expand Down
6 changes: 6 additions & 0 deletions dash/include/dash/Meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ DASH__META__DEFINE_TRAIT__HAS_TYPE(const_reference);
*/
DASH__META__DEFINE_TRAIT__HAS_TYPE(value_type);

/**
* Definition of type trait \c dash::detail::has_type_pattern_type<T>
* with static member \c value indicating whether type \c T provides
* dependent type \c pattern_type.
*/
DASH__META__DEFINE_TRAIT__HAS_TYPE(pattern_type);

} // namespace dash

Expand Down
Loading