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

Global pointer arithmetics and pointer distance in global memory #345

Merged
merged 15 commits into from
Mar 28, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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: 0 additions & 2 deletions dash/include/dash/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ class AsyncArrayRef
*/
constexpr const_async_reference operator[](const size_t n) const {
return async_reference(
_array->m_globmem,
(*(_array->begin() + n)).dart_gptr());
}

Expand All @@ -360,7 +359,6 @@ class AsyncArrayRef
*/
async_reference operator[](const size_t n) {
return async_reference(
_array->m_globmem,
(*(_array->begin() + n)).dart_gptr());
}

Expand Down
90 changes: 18 additions & 72 deletions dash/include/dash/GlobAsyncRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,17 @@ class GlobAsyncRef
std::ostream & os,
const GlobAsyncRef<U> & gar);

template <
typename ElementT >
friend class GlobAsyncRef;

private:
typedef GlobAsyncRef<T>
self_t;
typedef GlobStaticMem<T, dash::allocator::SymmetricAllocator<T> >
GlobMem_t;
typedef typename std::remove_const<T>::type
nonconst_value_type;

private:
/// Instance of GlobStaticMem that issued this global reference
GlobMem_t * _globmem;
/// Value of the referenced element, initially not loaded
mutable T _value;
/// Pointer to referenced element in global memory
Expand All @@ -67,26 +69,11 @@ class GlobAsyncRef
mutable bool _has_value = false;

public:
/**
* Conctructor, creates an GlobRefAsync object referencing an element in
* global memory.
*/
GlobAsyncRef(
/// Instance of GlobStaticMem that issued this global reference
GlobMem_t * globmem,
/// Pointer to referenced object in global memory
T * lptr)
: _value(*lptr),
_lptr(lptr),
_is_local(true),
_has_value(true)
{ }

/**
* Conctructor, creates an GlobRefAsync object referencing an element in
* local memory.
*/
GlobAsyncRef(
explicit GlobAsyncRef(
/// Pointer to referenced object in local memory
T * lptr)
: _value(*lptr),
Expand All @@ -99,30 +86,10 @@ class GlobAsyncRef
* Conctructor, creates an GlobRefAsync object referencing an element in
* global memory.
*/
template<class MemSpaceT>
GlobAsyncRef(
/// Instance of GlobStaticMem that issued this global reference
GlobMem_t * globmem,
/// Pointer to referenced object in global memory
GlobPtr<T, MemSpaceT> & gptr)
: _gptr(gptr.dart_gptr())
{
_is_local = gptr.is_local();
if (_is_local) {
_value = *gptr;
_lptr = (T*)(gptr);
_has_value = true;
}
}

/**
* Conctructor, creates an GlobRefAsync object referencing an element in
* global memory.
*/
template<class MemSpaceT>
GlobAsyncRef(
template<class ElementT, class MemSpaceT>
explicit GlobAsyncRef(
/// Pointer to referenced object in global memory
GlobPtr<T, MemSpaceT> & gptr)
GlobPtr<ElementT, MemSpaceT> & gptr)
: _gptr(gptr.dart_gptr())
{
_is_local = gptr.is_local();
Expand All @@ -137,9 +104,7 @@ class GlobAsyncRef
* Conctructor, creates an GlobRefAsync object referencing an element in
* global memory.
*/
GlobAsyncRef(
/// Instance of GlobStaticMem that issued this global reference
GlobMem_t * globmem,
explicit GlobAsyncRef(
/// Pointer to referenced object in global memory
dart_gptr_t dart_gptr)
: _gptr(dart_gptr)
Expand All @@ -154,40 +119,21 @@ class GlobAsyncRef
}

/**
* Conctructor, creates an GlobRefAsync object referencing an element in
* global memory.
* Constructor, creates an GlobRef object referencing an element in global
* memory.
*/
GlobAsyncRef(
template<class ElementT>
explicit GlobAsyncRef(
/// Pointer to referenced object in global memory
dart_gptr_t dart_gptr)
: _gptr(dart_gptr)
{
GlobConstPtr<T> gptr(dart_gptr);
_is_local = gptr.is_local();
if (_is_local) {
_value = *gptr;
_lptr = (T*)(gptr);
_has_value = true;
}
}

/**
* Conctructor, creates an GlobRefAsync object referencing an element in
* global memory.
*/
GlobAsyncRef(
/// Instance of GlobStaticMem that issued this global reference
GlobMem_t * globmem,
/// Pointer to referenced object in global memory
GlobRef<T> & gref)
: GlobAsyncRef(globmem, gref.gptr())
const GlobConstPtr<ElementT> & gptr)
: GlobAsyncRef(gptr.dart_gptr())
{ }

/**
* Conctructor, creates an GlobRefAsync object referencing an element in
* global memory.
*/
GlobAsyncRef(
explicit GlobAsyncRef(
/// Pointer to referenced object in global memory
GlobRef<T> & gref)
: GlobAsyncRef(gref.dart_gptr())
Expand Down
Loading