1
1
openmpi/ompi/mca/osc/sm/osc_sm.h
Mark Allen 482d84b6e5 fixes for Dave's get/set info code
The expected sequence of events for processing info during object creation
is that if there's an incoming info arg, it is opal_info_dup()ed into the obj
at obj->s_info first. Then interested components register callbacks for
keys they want to know about using opal_infosubscribe_infosubscribe().

Inside info_subscribe_subscribe() the specified callback() is called with
whatever matching k/v is in the object's info, or with the default. The
return string from the callback goes into the new k/v stored in info, and
the input k/v is saved as __IN_<key>/<val>. It's saved the same way
whether the input came from info or whether it was a default. A null return
from the callback indicates an ignored key/val, and no k/v is stored for
it, but an __IN_<key>/<val> is still kept so we still have access to the
original.

At MPI_*_set_info() time, opal_infosubscribe_change_info() is used. That
function calls the registered callbacks for each item in the provided info.
If the callback returns non-null, the info is updated with that k/v, or if
the callback returns null, that key is deleted from info. An __IN_<key>/<val>
is saved either way, and overwrites any previously saved value.

When MPI_*_get_info() is called, opal_info_dup_mpistandard() is used, which
allows relatively easy changes in interpretation of the standard, by looking
at both the <key>/<val> and __IN_<key>/<val> in info. Right now it does
  1. includes system extras, eg k/v defaults not expliclty set by the user
  2. omits ignored keys
  3. shows input values, not callback modifications, eg not the internal values

Currently the callbacks are doing things like
    return some_condition ? "true" : "false"
that is, returning static strings that are not to be freed. If the return
strings start becoming more dynamic in the future I don't see how unallocated
strings could support that, so I'd propose a change for the future that
the callback()s registered with info_subscribe_subscribe() do a strdup on
their return, and we change the callers of callback() to free the strings
it returns (there are only two callers).

Rough outline of the smaller changes spread over the less central files:
  comm.c
    initialize comm->super.s_info to NULL
    copy into comm->super.s_info in comm creation calls that provide info
    OBJ_RELEASE comm->super.s_info at free time
  comm_init.c
    initialize comm->super.s_info to NULL
  file.c
    copy into file->super.s_info if file creation provides info
    OBJ_RELEASE file->super.s_info at free time
  win.c
    copy into win->super.s_info if win creation provides info
    OBJ_RELEASE win->super.s_info at free time

  comm_get_info.c
  file_get_info.c
  win_get_info.c
    change_info() if there's no info attached (shouldn't happen if callbacks
      are registered)
    copy the info for the user

The other category of change is generally addressing compiler warnings where
ompi_info_t and opal_info_t were being used a little too interchangably. An
ompi_info_t* contains an opal_info_t*, at &(ompi_info->super)

Also this commit updates the copyrights.

Signed-off-by: Mark Allen <markalle@us.ibm.com>
2017-05-17 01:12:49 -04:00

243 строки
8.9 KiB
C

/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2012 Sandia National Laboratories. All rights reserved.
* Copyright (c) 2014-2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2015-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef OSC_SM_SM_H
#define OSC_SM_SM_H
#include "opal/mca/shmem/base/base.h"
/* data shared across all peers */
struct ompi_osc_sm_global_state_t {
int use_barrier_for_fence;
pthread_mutex_t mtx;
pthread_cond_t cond;
int sense;
int32_t count;
};
typedef struct ompi_osc_sm_global_state_t ompi_osc_sm_global_state_t;
/* this is data exposed to remote nodes */
struct ompi_osc_sm_lock_t {
uint32_t counter;
uint32_t write;
uint32_t read;
};
typedef struct ompi_osc_sm_lock_t ompi_osc_sm_lock_t;
struct ompi_osc_sm_node_state_t {
int32_t complete_count;
ompi_osc_sm_lock_t lock;
opal_atomic_lock_t accumulate_lock;
};
typedef struct ompi_osc_sm_node_state_t ompi_osc_sm_node_state_t;
struct ompi_osc_sm_component_t {
ompi_osc_base_component_t super;
};
typedef struct ompi_osc_sm_component_t ompi_osc_sm_component_t;
OMPI_DECLSPEC extern ompi_osc_sm_component_t mca_osc_sm_component;
enum ompi_osc_sm_locktype_t {
lock_none = 0,
lock_nocheck,
lock_exclusive,
lock_shared
};
struct ompi_osc_sm_module_t {
ompi_osc_base_module_t super;
struct ompi_communicator_t *comm;
int flavor;
opal_shmem_ds_t seg_ds;
void *segment_base;
bool noncontig;
size_t *sizes;
void **bases;
int *disp_units;
ompi_group_t *start_group;
ompi_group_t *post_group;
int my_sense;
enum ompi_osc_sm_locktype_t *outstanding_locks;
/* exposed data */
ompi_osc_sm_global_state_t *global_state;
ompi_osc_sm_node_state_t *my_node_state;
ompi_osc_sm_node_state_t *node_states;
uint64_t **posts;
opal_mutex_t lock;
};
typedef struct ompi_osc_sm_module_t ompi_osc_sm_module_t;
int ompi_osc_sm_shared_query(struct ompi_win_t *win, int rank, size_t *size, int *disp_unit, void *baseptr);
int ompi_osc_sm_attach(struct ompi_win_t *win, void *base, size_t len);
int ompi_osc_sm_detach(struct ompi_win_t *win, const void *base);
int ompi_osc_sm_free(struct ompi_win_t *win);
int ompi_osc_sm_put(const void *origin_addr,
int origin_count,
struct ompi_datatype_t *origin_dt,
int target,
ptrdiff_t target_disp,
int target_count,
struct ompi_datatype_t *target_dt,
struct ompi_win_t *win);
int ompi_osc_sm_get(void *origin_addr,
int origin_count,
struct ompi_datatype_t *origin_dt,
int target,
ptrdiff_t target_disp,
int target_count,
struct ompi_datatype_t *target_dt,
struct ompi_win_t *win);
int ompi_osc_sm_accumulate(const void *origin_addr,
int origin_count,
struct ompi_datatype_t *origin_dt,
int target,
ptrdiff_t target_disp,
int target_count,
struct ompi_datatype_t *target_dt,
struct ompi_op_t *op,
struct ompi_win_t *win);
int ompi_osc_sm_compare_and_swap(const void *origin_addr,
const void *compare_addr,
void *result_addr,
struct ompi_datatype_t *dt,
int target,
ptrdiff_t target_disp,
struct ompi_win_t *win);
int ompi_osc_sm_fetch_and_op(const void *origin_addr,
void *result_addr,
struct ompi_datatype_t *dt,
int target,
ptrdiff_t target_disp,
struct ompi_op_t *op,
struct ompi_win_t *win);
int ompi_osc_sm_get_accumulate(const void *origin_addr,
int origin_count,
struct ompi_datatype_t *origin_datatype,
void *result_addr,
int result_count,
struct ompi_datatype_t *result_datatype,
int target_rank,
MPI_Aint target_disp,
int target_count,
struct ompi_datatype_t *target_datatype,
struct ompi_op_t *op,
struct ompi_win_t *win);
int ompi_osc_sm_rput(const void *origin_addr,
int origin_count,
struct ompi_datatype_t *origin_dt,
int target,
ptrdiff_t target_disp,
int target_count,
struct ompi_datatype_t *target_dt,
struct ompi_win_t *win,
struct ompi_request_t **request);
int ompi_osc_sm_rget(void *origin_addr,
int origin_count,
struct ompi_datatype_t *origin_dt,
int target,
ptrdiff_t target_disp,
int target_count,
struct ompi_datatype_t *target_dt,
struct ompi_win_t *win,
struct ompi_request_t **request);
int ompi_osc_sm_raccumulate(const void *origin_addr,
int origin_count,
struct ompi_datatype_t *origin_dt,
int target,
ptrdiff_t target_disp,
int target_count,
struct ompi_datatype_t *target_dt,
struct ompi_op_t *op,
struct ompi_win_t *win,
struct ompi_request_t **request);
int ompi_osc_sm_rget_accumulate(const void *origin_addr,
int origin_count,
struct ompi_datatype_t *origin_datatype,
void *result_addr,
int result_count,
struct ompi_datatype_t *result_datatype,
int target_rank,
MPI_Aint target_disp,
int target_count,
struct ompi_datatype_t *target_datatype,
struct ompi_op_t *op,
struct ompi_win_t *win,
struct ompi_request_t **request);
int ompi_osc_sm_fence(int assert, struct ompi_win_t *win);
int ompi_osc_sm_start(struct ompi_group_t *group,
int assert,
struct ompi_win_t *win);
int ompi_osc_sm_complete(struct ompi_win_t *win);
int ompi_osc_sm_post(struct ompi_group_t *group,
int assert,
struct ompi_win_t *win);
int ompi_osc_sm_wait(struct ompi_win_t *win);
int ompi_osc_sm_test(struct ompi_win_t *win,
int *flag);
int ompi_osc_sm_lock(int lock_type,
int target,
int assert,
struct ompi_win_t *win);
int ompi_osc_sm_unlock(int target,
struct ompi_win_t *win);
int ompi_osc_sm_lock_all(int assert,
struct ompi_win_t *win);
int ompi_osc_sm_unlock_all(struct ompi_win_t *win);
int ompi_osc_sm_sync(struct ompi_win_t *win);
int ompi_osc_sm_flush(int target,
struct ompi_win_t *win);
int ompi_osc_sm_flush_all(struct ompi_win_t *win);
int ompi_osc_sm_flush_local(int target,
struct ompi_win_t *win);
int ompi_osc_sm_flush_local_all(struct ompi_win_t *win);
int ompi_osc_sm_set_info(struct ompi_win_t *win, struct opal_info_t *info);
int ompi_osc_sm_get_info(struct ompi_win_t *win, struct opal_info_t **info_used);
#endif