-
Notifications
You must be signed in to change notification settings - Fork 41
Memory Spaces
Naveen Namashivayam Ravichandrasekaran edited this page Nov 1, 2020
·
17 revisions
- Main Issue: Memory Spaces and support for different kinds of memory #195
- Subsection:1 Issue Determining the relationship between Teams, Contexts, and Spaces #455
OLD PROPOSAL: Initial High-level Ideas and APIs- Basic example
- August, 2020 - OpenSHMEM spec Meeting Updates
- October, 2020 - OpenSHMEM spec Meeting Updates
- User examples:
- WG Meeting Notes
- Specification Draft
Spaces are Team-based symmetric heaps. In OpenSHMEM-1.5, we have a single symmetric heap implicitly created by the OpenSHMEM implementation based on the size as input from the users through the SHMEM_SYMMETRIC_SIZE
environment variable.
- Emerging system architectures support different kinds of memory, hence we need to allow users to provide more information to OpenSHMEM implementation while creating a symmetric heap. Information might include memory traits like symmetric heap size, type of memory, NUMA details, hugepage usage, and information specific to special type of memory like FAM, HBM.
- Avoid unnecessarily allocating symmetric data objects across the global PEs, while the application is aware of symmetric data object within the sub-set of global PEs part of an OpenSHMEM Team.
- Allow using the memory buffer used as a symmetric heap between multiple OpenSHMEM jobs
- Allow using OpenSHMEM with other programming models and languages without the notion of PGAS style of programming, specifically no symmetric heap
- Move data through RMA/AMO and Collectives between two different memory kinds
- Device to Host and Host to Device specifically using collectives like all-reduce
- Use FAM as an external memory and allow moving data into and from FAM from an on-node memory kind like DDR/HBM
- Share Memory buffer between two different teams
- Row/Column 2D Teams sharing the data between themselves
- Duplicate Teams for performing multi-threaded collectives
- Allow using the memory buffer used as a symmetric heap between multiple OpenSHMEM jobs
- Using FAM as flat memory shared between independent OpenSHMEM jobs
The proposal is divided into three sub-categories.
- Category:1 - Decide the core space syntax and semantics
- Category:2 - Introduce support for different kinds of memory, specifically FAM and HBM
- Category:3 - Extend FAM usage as a flat-memory
Refer Presentation for more details. The core Memory Space syntax and semantics includes deciding the following:
- Team-Context-Space relationship
- Relationship of the spaces associated with the parent team through which a child team is split
- Memory management operations like
malloc, calloc, align
, andfree
To support the above use-cases, we need to support the following team - space relationships:
- Multiple spaces per team (example: space for each memory kind)
- Multiple teams per space (example: multithreaded collectives)
Parent-Child Team relationship with respect to the spaces associated with the parent team
- Child teams should be able to access the parent team's space
- By default, contexts associated with a particular team should be able to access all the associated spaces
- As an optimization for RMA and AMO, contexts associated with a team can select a particular space on which the data movement operation can be performed. This would avoid using lookup tables or some-sort of space identification process during the RMA and AMO operation. This is not necessary for collectives, as the lookup operation can be performed once for all the internal RMA and AMO involved in the collective operation.
To achieve the above requirements, we can use the following APIs in OpenSHMEM,
typedef shmem_space_t void *;
typedef struct {
size_t sheap_size;
} shmem_space_config_t;
-
shmem_space_t
is a new opaque handle for mapping the space - Different traits of a space will be provided using the
shmem_space_config_t
parameter -
shmem_space_config_t
will be updated with other traits when sub-category:2 of this proposal is discussed. For now,sheap_size
is sufficient
typedef struct {
// existing team configuration parameters
int num_contexts;
// new space-specific configurations
shmem_space_t * spaces;
shmem_space_config_t * space_configs;
shmem_team_t * team_select;
int num_spaces;
} shmem_team_config_t;
- Spaces are created and destroyed with the Teams during the
shmem_team_split_strided
andshmem_team_split_2d
operations - A Space can be created on only a single Team
- All Teams split from a parent team, inherits the spaces accessible on the parent Team. Spaces from the parent team can be used only for RMA, AMO, and Collectives. They cannot be used for memory allocation operations.
- The
team_select
input in the configuration denotes the team to which the space belongs. For strided-split, there is no need for this configuration option, while for a 2D-split there can be only one parent to the space. Hence, users need to set, whether the space belongs to the x-axis/y-axis team - EXTRA (separate proposal): We need to inherit a new Team-split API called
shmem_team_duplicate
to provide similar access guarantees on the spaces to the child Team as the parent Team
Cons:
- We are introducing a new parent-child team hierarchy. To use the parent-teams space for RMA/AMO in the child-team, the parent-team has to be kept active through-out the lifetime of the child-team.
- We need to introduce a new
shmem_team_duplicate
to share a space between two child-teams from the same-parent. Previously, we allowed the following sequence of creation:
parent_team(team_split)->child_1
parent_team(team_split)->child_2
// where child_1 and child_2 have the same set of PEs and can be used for multithreaded collectives.
Now, we need the following sequence:
parent_team(team_split)->child_1->(team_duplicate)child_2
shmem_ctx_config_t {
shmem_team_t team;
shmem_space_t space;
};
int shmem_ext_ctx_create(IN long options, IN shmem_ctx_config_t *config, OUT shmem_ctx_t *ctx);
- Optimization to avoid space lookups during RMA and AMOs
- Any context created using
shmem_ext_ctx_create
can be used only on the associated space buffers - Context created using
shmem_team_create_ctx
andshmem_ctx_create
would inherit access to all spaces asssociated with the corresponding teams. Performance on these variables would depend on the number of attached spaces.
void *shmem_space_malloc(IN shmem_space_t space, IN size_t size);
void *shmem_space_align(IN shmem_space_t space, IN size_t alignment, IN size_t size);
- Malloc and Align operations will take space handle as one of the input in
shmem_space_malloc
andshmem_space_align
. - Space attach would automatically perform a barrier-like operation on the associated parent team
- Allocation operations are always symmetric and follows the existing
shmem_malloc
andshmem_align
semantics - There is no need for a space-based realloc and free operations, as the realloc is always with the same space and free can determine the space associated internally in the implementation
-
Working Groups
-
Errata