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

Make segment IDs unique again! #257

Merged
merged 29 commits into from
Feb 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a13d0f3
NOPE, DEBUGGING WITH -Ofast JUST SIMPLY DOES NOT WORK, DAMNIT!
devreal Jan 30, 2017
b9e895d
Include the team ID in the gptr and make segment lookup dependent on …
devreal Jan 30, 2017
224c5e6
Shave off 8 bit from the unit ID of a gptr for flags
devreal Jan 31, 2017
d79d7ae
Add typesafe equality check to HDF5 test
devreal Jan 31, 2017
73c6942
Set the flags field in the gptr in the call to dart_gptr_setflags (on…
devreal Jan 31, 2017
c94272e
Some minor code cleaning in internal team handling
devreal Jan 31, 2017
5bd231e
Use an encapsulated hash map for team_data management instead of bina…
devreal Feb 1, 2017
00626a3
verify return value of dart__io__hdf5* in HDF5 adapter
fmoessbauer Feb 4, 2017
766e090
Fix building with debug output
devreal Feb 6, 2017
535e8fb
Merge branch 'feat-221-uniqsegid' of github.com:dash-project/dash int…
devreal Feb 6, 2017
997bba5
Merge branch 'development' into feat-221-uniqsegid
fuchsto Feb 6, 2017
1c35797
Adjust ASCII layout of DART gptr
devreal Feb 8, 2017
f2f0f52
Adapt to gptr.unitid now be a team-relative instead of global unit ID
devreal Feb 8, 2017
8318533
Also check for team ID in newly created gptr [skip ci]
devreal Feb 9, 2017
a887a63
Merge branch 'development' into feat-221-uniqsegid
fuchsto Feb 9, 2017
476b935
Merge branch 'development' into feat-221-uniqsegid
fuchsto Feb 9, 2017
ebcb901
Merge branch 'development' into feat-221-uniqsegid
devreal Feb 13, 2017
ed3d147
Fix error and warnings in debug output
devreal Feb 14, 2017
a612adf
Fix initialization of segment counter of TEAM_ALL
devreal Feb 14, 2017
636d268
Small improvements to TransformTest
devreal Feb 14, 2017
84196ef
Merge branch 'development' into feat-221-uniqsegid
devreal Feb 14, 2017
c5f545f
Fix some warnings introduced during merge
devreal Feb 14, 2017
f475787
Include dash/internal/Config.h in TestBase to expose DASH_ENABLE_OPENMP
devreal Feb 14, 2017
177752d
Skip ConcurrentPutGet test if running with less than 2 units
devreal Feb 15, 2017
93a77ef
Fix build error if shared memory windows are disabled
devreal Feb 15, 2017
85331f9
Updated CHANGELOG (reflects earlier chanegs) [noci]
devreal Feb 15, 2017
b99ad37
Merge branch 'development' into feat-221-uniqsegid
devreal Feb 17, 2017
75a294a
Merge branch 'development' into feat-221-uniqsegid
devreal Feb 18, 2017
7e83fe7
Merge branch 'development' into feat-221-uniqsegid
fuchsto Feb 18, 2017
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
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,16 @@ Features:
- Made global memory allocation and communication operations aware of the underlying
data type to improve stability and performance.

- Made DART global pointer globally unique to allow copying of global pointer between
members of the team that allocated the global memory. Note that a global now
contains unit IDs relative to the team that allocated the memory instead of
global unit IDs.

- Extended use of `const` specifier in DART communication interface

- Introduced typed unit IDs to safely distinguish between global IDs
(`dart_global_unit_t`) and IDs that are relative to a team (`dart_team_unit_t`).

- Added interface component `dart_locality` implementing topology discovery
and hierarchical locality description

Expand Down Expand Up @@ -102,7 +110,10 @@ Features:
- `dart__base__locality__unit`

Fixes:
- Added clarification that DART currently does not provide thread-safe access.
- Added clarification which DART functionality provides thread-safe access.
DART functions can be considered thread-safe as long as they do not operate
on the same data structures. In particular, thread-concurrent (collective)
operations on the same team are not guaranteed to be safe.

# DASH 0.2.0 (2016-03-03)

Expand Down
4 changes: 2 additions & 2 deletions CMakeExt/CompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@ set(CMAKE_C_FLAGS_DEBUG
set(CMAKE_C_FLAGS_DEBUG
"${CMAKE_C_FLAGS_DEBUG} ${CC_REPORT_FLAG} ${CC_WARN_FLAG}")
set(CMAKE_C_FLAGS_DEBUG
"${CMAKE_C_FLAGS_DEBUG} -Ofast -DDASH_DEBUG ${CC_GDB_FLAG}")
"${CMAKE_C_FLAGS_DEBUG} -O0 -DDASH_DEBUG ${CC_GDB_FLAG}")

set(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} ${CXX_STD_FLAG} ${CXX_OMP_FLAG}")
set(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} ${CC_REPORT_FLAG} ${CXX_WARN_FLAG}")
set(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} -Ofast -DDASH_DEBUG ${CXX_GDB_FLAG}")
"${CMAKE_CXX_FLAGS_DEBUG} -O0 -DDASH_DEBUG ${CXX_GDB_FLAG}")


set(CMAKE_C_FLAGS_RELEASE
Expand Down
100 changes: 73 additions & 27 deletions dart-if/v3.2/include/dash/dart/if/dart_globmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ extern "C" {
PROPOSAL: use 128 bit global pointers with the following layout:


0 1 2 3 4 5 6
0123456789012345678901234567890123456789012345678901234567890123
|------<32 bit unit id>--------|-<segment id>--|--flags/resv---|
|-----------<either a virtual address or an offset>------------|
0 1 2 3 4 5 6 7
0123456701234567012345670123456701234567012345670123456701234567
|----<24 bit unit id>---|-flags-|-<segment id>--|---<team id>--|
|-----------<64 bit virtual address or offset>-----------------|

*/

Expand All @@ -71,13 +71,18 @@ extern "C" {
*/
typedef struct
{
/** The unit holding the memory element */
dart_unit_t unitid;
/** The segment ID of the allocation */
int16_t segid;
/**
* The unit holding the memory element.
* The ID is relative to the team identified by \c teamid.
*/
dart_unit_t unitid : 24;
/** Reserved */
uint16_t flags;
/** Absolute address or relative offset */
unsigned int flags : 8;
/** The segment ID of the allocation. */
int16_t segid;
/** The team associated with the allocation. */
int16_t teamid;
/** Absolute address or relative offset. */
union
{
uint64_t offset;
Expand All @@ -90,37 +95,48 @@ typedef struct
* \ingroup DartGlobMem
*/
#ifdef __cplusplus
#define DART_GPTR_NULL (dart_gptr_t { -1, 0, 0, { 0 } })
#define DART_GPTR_NULL (dart_gptr_t { -1, 0, 0, DART_TEAM_NULL, { 0 } })
#else
#define DART_GPTR_NULL \
((dart_gptr_t)({ .unitid = -1, \
.segid = 0, \
.flags = 0, \
.addr_or_offs.offset = 0 }))
(dart_gptr_t){ .unitid = -1, \
.flags = 0, \
.segid = 0, \
.teamid = DART_TEAM_NULL, \
.addr_or_offs.offset = 0 }
#endif

/**
* Test for NULL global pointer
*
* \ingroup DartGlobMem
*/
#define DART_GPTR_ISNULL(gptr_) \
(gptr_.unitid<0 && gptr_.segid==0 && \
gptr_.flags==0 && gptr_.addr_or_offs.addr==0)
#define DART_GPTR_ISNULL(gptr_) \
(gptr_.unitid<0 && gptr_.segid==0 && \
gptr_.teamid==DART_TEAM_NULL && \
gptr_.addr_or_offs.addr==0)

/**
* Compare two global pointers
*
* \ingroup DartGlobMem
*/
#define DART_GPTR_EQUAL(gptr1_, gptr2_ ) \
((gptr1_.unitid == gptr2_.unitid) && \
(gptr1_.segid == gptr2_.segid) && \
(gptr1_.flags == gptr2_.flags) && \
(gptr1_.addr_or_offs.offset == \
#define DART_GPTR_EQUAL(gptr1_, gptr2_ ) \
((gptr1_.unitid == gptr2_.unitid) && \
(gptr1_.segid == gptr2_.segid) && \
(gptr1_.teamid == gptr2_.teamid) && \
(gptr1_.addr_or_offs.offset == \
gptr2_.addr_or_offs.offset) )


/**
* Segment ID identifying unaligned allocations.
*
* \sa dart_memalloc
* \sa dart_memfree
*/
#define DART_SEGMENT_LOCAL ((int16_t)0)


/**
* Get the local memory address for the specified global pointer
* gptr. I.e., if the global pointer has affinity to the local unit,
Expand Down Expand Up @@ -161,7 +177,7 @@ dart_ret_t dart_gptr_setaddr(dart_gptr_t *gptr, void *addr);
* \threadsafe
* \ingroup DartGlobMem
*/
dart_ret_t dart_gptr_incaddr(dart_gptr_t *gptr, int32_t offs);
dart_ret_t dart_gptr_incaddr(dart_gptr_t *gptr, int64_t offs);

/**
* Set the unit information for the specified global pointer.
Expand All @@ -174,7 +190,38 @@ dart_ret_t dart_gptr_incaddr(dart_gptr_t *gptr, int32_t offs);
* \threadsafe
* \ingroup DartGlobMem
*/
dart_ret_t dart_gptr_setunit(dart_gptr_t *gptr, dart_global_unit_t unit);
dart_ret_t dart_gptr_setunit(dart_gptr_t *gptr, dart_team_unit_t unit);

/**
* Get the flags field for the segment specified by the global pointer.
*
* \param gptr Global Pointer describing a segment.
* \param unit The flags to get for segment in \c gptr
*
* \return \c DART_OK on success, any other of \ref dart_ret_t otherwise.
*
* \threadsafe
* \ingroup DartGlobMem
*/
dart_ret_t dart_gptr_getflags(dart_gptr_t gptr, uint16_t *flags);


/**
* Set the flags field for the segment specified by the global pointer.
* The flags are stored in the segment's meta data. The lower 8 bit of
* the flags are stored in the \c .flags field of the \c gptr for
* fast access. The remaining flags can be queried through
* \ref dart_gptr_getflags.
*
* \param gptr Global Pointer describing a segment.
* \param unit The flags to set for segment in \c gptr
*
* \return \c DART_OK on success, any other of \ref dart_ret_t otherwise.
*
* \threadsafe
* \ingroup DartGlobMem
*/
dart_ret_t dart_gptr_setflags(dart_gptr_t *gptr, uint16_t flags);

/**
* Allocates memory for \c nelem elements of type \c dtype in the global
Expand Down Expand Up @@ -265,7 +312,6 @@ dart_ret_t dart_team_memalloc_aligned(
* \ingroup DartGlobMem
*/
dart_ret_t dart_team_memfree(
dart_team_t teamid,
dart_gptr_t gptr);

/**
Expand Down Expand Up @@ -331,7 +377,7 @@ dart_ret_t dart_team_memregister(
* \threadsafe_none
* \ingroup DartGlobMem
*/
dart_ret_t dart_team_memderegister(dart_team_t teamid, dart_gptr_t gptr);
dart_ret_t dart_team_memderegister(dart_gptr_t gptr);


/** \cond DART_HIDDEN_SYMBOLS */
Expand Down
2 changes: 1 addition & 1 deletion dart-if/v3.2/include/dash/dart/if/dart_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ dart_global_unit_t dart_create_global_unit(dart_unit_t unit)
* Data type for storing a team ID
* \ingroup DartTypes
*/
typedef int32_t dart_team_t;
typedef int16_t dart_team_t;

/**
* Undefined team ID.
Expand Down
3 changes: 1 addition & 2 deletions dart-impl/mpi/include/dash/dart/mpi/dart_globmem_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
do { \
gptr_.unitid = gptrt_.unitid; \
gptr_.segid = gptrt_.segid; \
gptr_.flags = gptrt_.flags; \
gptr_.teamid = gptrt_.teamid; \
gptr_.addr_or_offs.offset = gptrt_.addr_or_offs.offset; \
} while(0)


/* Global object for one-sided communication on memory region allocated with 'local allocation'. */
extern MPI_Win dart_win_local_alloc;
#if !defined(DART_MPI_DISABLE_SHARED_WINDOWS)
Expand Down
2 changes: 1 addition & 1 deletion dart-impl/mpi/include/dash/dart/mpi/dart_mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include <string.h>
#include <inttypes.h>

// forward declaration
struct dart_buddy;

extern char* dart_mempool_localalloc;
extern struct dart_buddy* dart_localpool;

Expand Down
63 changes: 42 additions & 21 deletions dart-impl/mpi/include/dash/dart/mpi/dart_segment.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

typedef int16_t dart_segid_t;

#define DART_SEGMENT_HASH_SIZE 256

typedef struct
{
dart_segid_t seg_id; /* seg_id determines a global pointer uniquely */
Expand All @@ -21,28 +23,32 @@ typedef struct
char ** baseptr;
char * selfbaseptr;
MPI_Win win;
uint16_t flags;
} dart_segment_info_t;

// forward declaration to make the compiler happy
typedef struct dart_seghash_elem dart_seghash_elem_t;

typedef struct {

dart_seghash_elem_t* hashtab[DART_SEGMENT_HASH_SIZE];
dart_team_t team_id;

// TODO: Add free-segment-ID list here

} dart_segmentdata_t;


/**
* @brief Initialize the segment data hash table.
*/
dart_ret_t dart_segment_init();
dart_ret_t dart_segment_init(dart_segmentdata_t *segdata, dart_team_t teamid);

/**
* @brief Allocates a new segment data struct. May be served from a freelist.
*/
dart_ret_t dart_segment_alloc(dart_segid_t segid, uint16_t team_idx);
dart_ret_t dart_segment_alloc(dart_segmentdata_t *segdata, const dart_segment_info_t *item);

/**
* @brief Returns the registered team index for the segment ID.
*/
dart_ret_t dart_segment_get_teamidx(dart_segid_t segid, uint16_t *team_idx);

/**
* @brief Add segment information to the segment hash table.
*/
dart_ret_t dart_segment_add_info(const dart_segment_info_t *item);

#if !defined(DART_MPI_DISABLE_SHARED_WINDOWS)
/** @brief Query the shared memory window object associated with the specified seg_id.
Expand All @@ -53,17 +59,19 @@ dart_ret_t dart_segment_add_info(const dart_segment_info_t *item);
* @retval non-negative integer Search successfully.
* @retval negative integer Failure.
*/
dart_ret_t dart_segment_get_win(int16_t seg_id, MPI_Win * win);
dart_ret_t dart_segment_get_win(dart_segmentdata_t *segdata, int16_t seg_id, MPI_Win * win);

dart_ret_t dart_segment_get_baseptr(
dart_segmentdata_t * segdata,
int16_t seg_id,
dart_team_unit_t rel_unitid,
char ** baseptr_s);
#endif

dart_ret_t dart_segment_get_selfbaseptr(
int16_t seg_id,
char ** baseptr);
dart_segmentdata_t * segdata,
int16_t seg_id,
char ** baseptr);

/** @brief Query the address of the memory location of the specified rel_unit in specified team.
*
Expand All @@ -73,28 +81,41 @@ dart_ret_t dart_segment_get_selfbaseptr(
*
* @retval ditto
*/
dart_ret_t dart_segment_get_disp(int16_t seg_id,
dart_team_unit_t rel_unitid,
MPI_Aint * disp_s);
dart_ret_t dart_segment_get_disp(dart_segmentdata_t * segdata,
int16_t seg_id,
dart_team_unit_t rel_unitid,
MPI_Aint * disp_s);

/** @brief Query the length of the global memory block indicated by the specified seg_id.
*
* @retval ditto
*/
dart_ret_t dart_segment_get_size(
int16_t seg_id,
size_t * size);
dart_segmentdata_t * segdata,
int16_t seg_id,
size_t * size);

dart_ret_t dart_segment_get_flags(
dart_segmentdata_t * segdata,
int16_t seg_id,
uint16_t * flags);

dart_ret_t dart_segment_set_flags(
dart_segmentdata_t * segdata,
int16_t seg_id,
uint16_t flags);

/**
* @brief Deallocates the segment identified by the segment ID.
*/
dart_ret_t dart_segment_free(dart_segid_t segid);
dart_ret_t dart_segment_free(dart_segmentdata_t * segdata,
dart_segid_t segid);


/**
* @brief Clear the segment data hash table.
*/
dart_ret_t dart_segment_fini();
dart_ret_t dart_segment_fini(dart_segmentdata_t *segdata);


#endif /* DART_SEGMENT_H_ */
Loading