Skip to content

Commit 43d3345

Browse files
samuelkgutierrezrhc54
authored andcommitted
Checkpoint gds/shmem work.
For a single client it appears that the sharing of hash tables and lists works. pmix_gds_shmem_fetch() requires work to accommodate multiple clients. Other notable changes include: * Revert changes introduced in 'TMA: Integrate more custom memory allocator infrastructure'. The base object system doesn't appear to require the changes introduced in that commit. Signed-off-by: Samuel K. Gutierrez <[email protected]>
1 parent 3f7b1d0 commit 43d3345

17 files changed

+3973
-3614
lines changed

src/class/pmix_object.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ static const int increment = 10;
6666
/*
6767
* Local functions
6868
*/
69-
static void save_class(pmix_class_t *cls, pmix_tma_t *tma);
70-
static void expand_array(pmix_tma_t *tma);
69+
static void save_class(pmix_class_t *cls);
70+
static void expand_array(void);
7171

7272
/*
7373
* Lazy initialization of class descriptor.
7474
*/
75-
void pmix_class_initialize(pmix_class_t *cls, pmix_tma_t *tma)
75+
void pmix_class_initialize(pmix_class_t *cls)
7676
{
7777
pmix_class_t *c;
7878
pmix_construct_t *cls_construct_array;
@@ -123,7 +123,7 @@ void pmix_class_initialize(pmix_class_t *cls, pmix_tma_t *tma)
123123
* plus for each a NULL-sentinel
124124
*/
125125

126-
cls->cls_construct_array = (void (**)(pmix_object_t *)) pmix_tma_malloc(tma,
126+
cls->cls_construct_array = (void (**)(pmix_object_t *)) malloc(
127127
(cls_construct_array_count + cls_destruct_array_count + 2) * sizeof(pmix_construct_t));
128128
if (NULL == cls->cls_construct_array) {
129129
perror("Out of memory");
@@ -154,7 +154,7 @@ void pmix_class_initialize(pmix_class_t *cls, pmix_tma_t *tma)
154154
*cls_destruct_array = NULL; /* end marker for the destructors */
155155

156156
cls->cls_initialized = pmix_class_init_epoch;
157-
save_class(cls, tma);
157+
save_class(cls);
158158

159159
/* All done */
160160

@@ -189,25 +189,25 @@ int pmix_class_finalize(void)
189189
return 0;
190190
}
191191

192-
static void save_class(pmix_class_t *cls, pmix_tma_t *tma)
192+
static void save_class(pmix_class_t *cls)
193193
{
194194
if (num_classes >= max_classes) {
195-
expand_array(tma);
195+
expand_array();
196196
}
197197

198198
classes[num_classes] = cls->cls_construct_array;
199199
++num_classes;
200200
}
201201

202-
static void expand_array(pmix_tma_t *tma)
202+
static void expand_array(void)
203203
{
204204
int i;
205205

206206
max_classes += increment;
207207
if (NULL == classes) {
208-
classes = (void **) pmix_tma_calloc(tma, max_classes, sizeof(void *));
208+
classes = (void **) calloc(max_classes, sizeof(void *));
209209
} else {
210-
classes = (void **) pmix_tma_realloc(tma, classes, sizeof(void *) * max_classes);
210+
classes = (void **) realloc(classes, sizeof(void *) * max_classes);
211211
}
212212
if (NULL == classes) {
213213
perror("class malloc failed");

src/class/pmix_object.h

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,11 @@ typedef struct pmix_tma {
233233
void *(*tma_memmove)(struct pmix_tma *tma, const void *src, size_t n);
234234
/** Pointer to the TMA's free() function. */
235235
void (*tma_free)(struct pmix_tma *, void *);
236-
/** Pointer inside the memory allocation arena. */
237-
void *arena;
236+
/**
237+
* Points to generic data used by a TMA. An example includes a pointer to a
238+
* value that maintains the next available address.
239+
*/
240+
void **data_ptr;
238241
} pmix_tma_t;
239242

240243
static inline void *pmix_tma_malloc(pmix_tma_t *tma, size_t size)
@@ -322,7 +325,7 @@ PMIX_EXPORT extern int pmix_class_init_epoch;
322325
.obj_tma.tma_strdup = NULL, \
323326
.obj_tma.tma_memmove = NULL, \
324327
.obj_tma.tma_free = NULL, \
325-
.obj_tma.arena = NULL, \
328+
.obj_tma.data_ptr = NULL, \
326329
.cls_init_file_name = __FILE__, \
327330
.cls_init_lineno = __LINE__ \
328331
}
@@ -338,7 +341,7 @@ PMIX_EXPORT extern int pmix_class_init_epoch;
338341
.obj_tma.tma_strdup = NULL, \
339342
.obj_tma.tma_memmove = NULL, \
340343
.obj_tma.tma_free = NULL, \
341-
.obj_tma.arena = NULL \
344+
.obj_tma.data_ptr = NULL \
342345
}
343346
#endif
344347

@@ -542,7 +545,7 @@ static inline void pmix_obj_construct_tma(pmix_object_t *obj, pmix_tma_t *tma)
542545
obj->obj_tma.tma_strdup = NULL;
543546
obj->obj_tma.tma_memmove = NULL;
544547
obj->obj_tma.tma_free = NULL;
545-
obj->obj_tma.arena = NULL;
548+
obj->obj_tma.data_ptr = NULL;
546549
} else {
547550
obj->obj_tma = *tma;
548551
}
@@ -552,7 +555,7 @@ static inline void pmix_obj_construct_tma(pmix_object_t *obj, pmix_tma_t *tma)
552555
do { \
553556
PMIX_SET_MAGIC_ID((object), PMIX_OBJ_MAGIC_ID); \
554557
if (pmix_class_init_epoch != (type)->cls_initialized) { \
555-
pmix_class_initialize((type), (t)); \
558+
pmix_class_initialize((type)); \
556559
} \
557560
((pmix_object_t *) (object))->obj_class = (type); \
558561
((pmix_object_t *) (object))->obj_reference_count = 1; \
@@ -609,7 +612,7 @@ PMIX_CLASS_DECLARATION(pmix_object_t);
609612
*
610613
* @param class Pointer to class descriptor
611614
*/
612-
PMIX_EXPORT void pmix_class_initialize(pmix_class_t *cls, pmix_tma_t *tma);
615+
PMIX_EXPORT void pmix_class_initialize(pmix_class_t *cls);
613616

614617
/**
615618
* Shut down the class system and release all memory
@@ -686,7 +689,7 @@ static inline pmix_object_t *pmix_obj_new_tma(pmix_class_t *cls, pmix_tma_t *tma
686689
object = (pmix_object_t *) pmix_tma_malloc(tma, cls->cls_sizeof);
687690

688691
if (pmix_class_init_epoch != cls->cls_initialized) {
689-
pmix_class_initialize(cls, tma);
692+
pmix_class_initialize(cls);
690693
}
691694
if (NULL != object) {
692695
#if PMIX_ENABLE_DEBUG
@@ -717,7 +720,7 @@ static inline pmix_object_t *pmix_obj_new_tma(pmix_class_t *cls, pmix_tma_t *tma
717720
object->obj_tma.tma_realloc = NULL;
718721
object->obj_tma.tma_strdup = NULL;
719722
object->obj_tma.tma_free = NULL;
720-
object->obj_tma.arena = NULL;
723+
object->obj_tma.data_ptr = NULL;
721724
} else {
722725
object->obj_tma = *tma;
723726
}
@@ -750,6 +753,22 @@ static inline int pmix_obj_update(pmix_object_t *object, int inc)
750753
return ret;
751754
}
752755

756+
/**
757+
* Get a pointer to a given object's memory allocator. Returns a pointer to the
758+
* TMA, if available. Returns NULL Otherwise.
759+
*/
760+
static inline pmix_tma_t *
761+
pmix_obj_get_tma(
762+
pmix_object_t *obj
763+
) {
764+
// Look for a given function pointer. If it isn't NULL, then assume that
765+
// this object has a custom memory allocator.
766+
if (obj->obj_tma.tma_malloc) {
767+
return &obj->obj_tma;
768+
}
769+
return NULL;
770+
}
771+
753772
END_C_DECLS
754773

755774
#endif

src/mca/gds/shmem/Makefile.am

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,22 @@
2525

2626
AM_CPPFLAGS = $(gds_shmem_CPPFLAGS)
2727

28-
# TODO(skg) Eventually incorporate pmix_hash2.
28+
# TODO(skg) Eventually reincorporate pmix_hash2.
29+
# TODO(skg) Eventually reincorporate pmix_hash_table2.
30+
# TODO(skg) Eventually reincorporate pmix_pointer_array2.
2931

3032
headers = \
33+
pmix_pointer_array2.h \
34+
pmix_hash_table2.h \
3135
pmix_hash2.h \
3236
gds_shmem.h \
3337
gds_shmem_utils.h \
3438
gds_shmem_store.h \
3539
gds_shmem_fetch.h
3640

3741
sources = \
42+
pmix_pointer_array2.c \
43+
pmix_hash_table2.c \
3844
pmix_hash2.c \
3945
gds_shmem_component.c \
4046
gds_shmem.c \

0 commit comments

Comments
 (0)