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 2 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
4 changes: 2 additions & 2 deletions CMakeExt/CompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ set(CMAKE_CXX_FLAGS_RELEASE
"${CMAKE_CXX_FLAGS_RELEASE} ${CXX_ENV_SETUP_FLAGS}")

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

set(CMAKE_C_FLAGS_RELEASE
"${CMAKE_C_FLAGS_RELEASE} ${CC_STD_FLAG} ${CXX_OMP_FLAG} ${CXX_LTO_FLAG} ${CC_REPORT_FLAG} ${CC_WARN_FLAG} -Ofast -DDASH_RELEASE")
Expand Down
60 changes: 48 additions & 12 deletions dart-if/v3.2/include/dash/dart/if/dart_globmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ typedef struct
/** The segment ID of the allocation */
int16_t segid;
/** Reserved */
uint16_t flags;
int16_t teamid;
/** Absolute address or relative offset */
union
{
Expand All @@ -90,13 +90,13 @@ 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, 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, \
.segid = 0, \
.teamid = DART_TEAM_NULL, \
.addr_or_offs.offset = 0 }
#endif

/**
Expand All @@ -106,7 +106,8 @@ typedef struct
*/
#define DART_GPTR_ISNULL(gptr_) \
(gptr_.unitid<0 && gptr_.segid==0 && \
gptr_.flags==0 && gptr_.addr_or_offs.addr==0)
gptr_.teamid==DART_TEAM_NULL && \
gptr_.addr_or_offs.addr==0)

/**
* Compare two global pointers
Expand All @@ -115,12 +116,21 @@ typedef struct
*/
#define DART_GPTR_EQUAL(gptr1_, gptr2_ ) \
((gptr1_.unitid == gptr2_.unitid) && \
(gptr1_.segid == gptr2_.segid) && \
(gptr1_.flags == gptr2_.flags) && \
(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 +171,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 @@ -176,6 +186,33 @@ dart_ret_t dart_gptr_incaddr(dart_gptr_t *gptr, int32_t offs);
*/
dart_ret_t dart_gptr_setunit(dart_gptr_t *gptr, dart_global_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.
*
* \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
* address space of the calling unit and returns a global pointer to it.
Expand Down Expand Up @@ -264,7 +301,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 @@ -330,7 +366,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 @@ -207,7 +207,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
69 changes: 48 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,38 @@ 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;

struct dart_seghash_elem {
dart_seghash_elem_t *next;
dart_segment_info_t data;
int32_t seg_id; // use int32_t internally to signal "invalid segment id"
};

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 +65,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 +87,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_ */
15 changes: 15 additions & 0 deletions dart-impl/mpi/include/dash/dart/mpi/dart_team_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
#include <mpi.h>
#include <dash/dart/base/logging.h>
#include <dash/dart/mpi/dart_mem.h>
#include <dash/dart/mpi/dart_segment.h>

extern dart_team_t dart_next_availteamid;

Expand All @@ -159,6 +160,20 @@ typedef struct dart_team_data {
*/
MPI_Win window;

dart_segmentdata_t segdata;

/**
* For DART collective allocation/free: offset in the returned gptr
* represents the displacement relative to the beginning of sub-memory
* spanned by a DART collective allocation.
* For DART local allocation/free: offset in the returned gptr represents
* the displacement relative to the base address of memory region reserved
* for the dart local allocation/free (see dart_buddy_allocator).
* Local allocations are identified by Segment ID DART_SEGMENT_LOCAL.
*/
int16_t dart_memid;
int16_t dart_registermemid;

#if !defined(DART_MPI_DISABLE_SHARED_WINDOWS)
/**
* @brief Store the sub-communicator with regard to certain node, where the units can
Expand Down
Loading