Skip to content

Commit

Permalink
sessions: update to latest OpenSHMEM API proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
davidozog committed Apr 26, 2024
1 parent b84c300 commit 781d881
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 22 deletions.
2 changes: 1 addition & 1 deletion modules/tests-sos
14 changes: 7 additions & 7 deletions mpp/shmem-def.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ typedef struct {
int num_contexts;
} shmem_team_config_t;

typedef struct {
size_t total_ops;
} shmem_session_config_t;

#if SHMEM_HAVE_ATTRIBUTE_VISIBILITY == 1
__attribute__((visibility("default"))) extern shmem_team_t SHMEM_TEAM_WORLD;
__attribute__((visibility("default"))) extern shmem_team_t SHMEM_TEAM_SHARED;
Expand All @@ -116,13 +120,9 @@ typedef struct {
#define SHMEM_SIGNAL_SET 0
#define SHMEM_SIGNAL_ADD 1

#define SHMEM_SESSION_OP_PUT (1l<<0)
#define SHMEM_SESSION_OP_GET (1l<<1)
#define SHMEM_SESSION_OP_PUT_SIGNAL (1l<<2)
#define SHMEM_SESSION_OP_AMO (1l<<3)
#define SHMEM_SESSION_OP_AMO_FETCH (1l<<4)
#define SHMEM_SESSION_CHAIN (1l<<5)
#define SHMEM_SESSION_UNIFORM_AMO (1l<<6)
#define SHMEM_SESSION_TOTAL_OPS (1l<<0)
#define SHMEM_SESSION_BATCH (1l<<0)
#define SHMEM_SESSION_SAME_AMO (1l<<1)

#ifdef __cplusplus
} /* extern "C" */
Expand Down
2 changes: 1 addition & 1 deletion mpp/shmem_c_func.h4
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ define(`SHMEM_C_CTX_FETCH_OR_NBI',
SHMEM_DECLARE_FOR_BITWISE_AMO(`SHMEM_C_CTX_FETCH_OR_NBI')

/* Session Routines */
SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmem_session_start(long options, shmem_ctx_t ctx);
SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmem_session_start(shmem_ctx_t ctx, long options, const shmem_session_config_t *config, long config_mask);
SHMEM_FUNCTION_ATTRIBUTES void SHPRE()shmem_session_stop(shmem_ctx_t ctx);

/* Team Management Routines */
Expand Down
6 changes: 3 additions & 3 deletions src/sessions_c.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- C -*-
*
* Copyright (c) 2022 Intel Corporation. All rights reserved.
* Copyright (c) 2024 Intel Corporation. All rights reserved.
* This software is available to you under the BSD license.
*
* This file is part of the Sandia OpenSHMEM software package. For license
Expand Down Expand Up @@ -28,11 +28,11 @@
#endif /* ENABLE_PROFILING */

SHMEM_FUNCTION_ATTRIBUTES void
shmem_session_start(long options, shmem_ctx_t ctx)
shmem_session_start(shmem_ctx_t ctx, long options, const shmem_session_config_t *config, long config_mask)
{
SHMEM_ERR_CHECK_INITIALIZED();

int ret = shmem_transport_session_start(options, (shmem_transport_ctx_t *) ctx);
int ret = shmem_transport_session_start((shmem_transport_ctx_t *) ctx, options, config, config_mask);
if (0 != ret) {
DEBUG_MSG("Session did not start correctly (%d)\n", ret);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/transport_none.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void shmem_transport_pcntr_get_all(shmem_transport_ctx_t *ctx, shmemx_pcntr_t *p

static inline
int
shmem_transport_session_start(long options, shmem_transport_ctx_t *ctx)
shmem_transport_session_start(shmem_transport_ctx_t *ctx, long options, const shmem_session_config_t *config, long config_mask)
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/transport_ofi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@ void shmem_transport_ctx_destroy(shmem_transport_ctx_t *ctx)
}
}

int shmem_transport_session_start(long options, shmem_transport_ctx_t *ctx)
int shmem_transport_session_start(shmem_transport_ctx_t *ctx, long options, const shmem_session_config_t *config, long config_mask)
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/transport_ofi.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ void shmem_transport_probe(void)
int shmem_transport_ctx_create(struct shmem_internal_team_t *team, long options, shmem_transport_ctx_t **ctx);
void shmem_transport_ctx_destroy(shmem_transport_ctx_t *ctx);

int shmem_transport_session_start(long options, shmem_transport_ctx_t *ctx);
int shmem_transport_session_start(shmem_transport_ctx_t *ctx, long options, const shmem_session_config_t *config, long config_mask);
int shmem_transport_session_stop(shmem_transport_ctx_t *ctx);

int shmem_transport_init(void);
Expand Down
2 changes: 1 addition & 1 deletion src/transport_portals4.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ shmem_transport_ctx_destroy(shmem_transport_ctx_t *ctx)
}

int
shmem_transport_session_start(long options, shmem_transport_ctx_t *ctx)
shmem_transport_session_start(shmem_transport_ctx_t *ctx, long options, const shmem_session_config_t *config, long config_mask)
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/transport_portals4.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ extern shmem_transport_ctx_t shmem_transport_ctx_default;
int shmem_transport_ctx_create(struct shmem_internal_team_t *team, long options, shmem_transport_ctx_t **ctx);
void shmem_transport_ctx_destroy(shmem_transport_ctx_t *ctx);

int shmem_transport_session_start(long options, shmem_transport_ctx_t *ctx);
int shmem_transport_session_start(shmem_transport_ctx_t *ctx, long options, const shmem_session_config_t *config, long config_mask)
int shmem_transport_session_stop(shmem_transport_ctx_t *ctx);

/*
Expand Down
2 changes: 1 addition & 1 deletion src/transport_ucx.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ shmem_transport_ctx_destroy(shmem_transport_ctx_t *ctx)

static inline
int
shmem_transport_session_start(long options, shmem_transport_ctx_t *ctx)
shmem_transport_session_start(shmem_transport_ctx_t *ctx, long options, const shmem_session_config_t *config, long config_mask)
{
return 0;
}
Expand Down
29 changes: 25 additions & 4 deletions test/spec-example/shmem_session_example.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/* * This test program is derived from an example program in the
* OpenSHMEM specification.
*/

#include <shmem.h>
#include <stdint.h>
#include <stdlib.h>

#define N_UPDATES (1lu << 17)
#define N_UPDATES (1lu << 18)
#define N_INDICES (1lu << 10)
#define N_VALUES (1lu << 31)

Expand All @@ -16,17 +20,34 @@ int main(void) {
int npes = shmem_n_pes();
srand(mype);

shmem_session_start(SHMEM_SESSION_UNIFORM_AMO, SHMEM_CTX_DEFAULT);
shmem_ctx_t ctx;
int ret = shmem_ctx_create(0, &ctx);
if (ret != 0) {
printf("%d: Error creating context (%d)\n", mype, ret);
shmem_global_exit(1);
}

shmem_config_t config;
long config_mask;
config.total_ops = N_UPDATES;
config_mask = SHMEM_SESSION_TOTAL_OPS;

shmem_session_start(ctx, SHMEM_SESSION_SAME_AMO, config, config_mask);

for (size_t i = 0; i < N_UPDATES; i++) {
int random_pe = rand() % npes;
size_t random_idx = rand() % N_INDICES;
uint64_t random_val = rand() % N_VALUES;
shmem_uint64_atomic_xor(&table[random_idx], random_val, random_pe);
shmem_uint64_atomic_xor(ctx, &table[random_idx], random_val, random_pe);
}

shmem_session_stop(SHMEM_CTX_DEFAULT);
shmem_session_stop(ctx);
shmem_ctx_quiet(ctx); /* shmem_session_stop() does not quiet the context. */
shmem_sync_all(); /* shmem_session_stop() does not synchronize. */

/* At this point, it is safe to check and/or validate the table result... */

shmem_ctx_destroy(ctx);
shmem_free(table);
shmem_finalize();
return 0;
Expand Down

0 comments on commit 781d881

Please sign in to comment.