552216f9ba
Passed the below set of symbols into a script that added ompi_ to them all. Note that if processing a symbol named "foo" the script turns foo into ompi_foo but doesn't turn foobar into ompi_foobar But beyond that the script is blind to C syntax, so it hits strings and comments etc as well as vars/functions. coll_base_comm_get_reqs comm_allgather_pml comm_allreduce_pml comm_bcast_pml fcoll_base_coll_allgather_array fcoll_base_coll_allgatherv_array fcoll_base_coll_bcast_array fcoll_base_coll_gather_array fcoll_base_coll_gatherv_array fcoll_base_coll_scatterv_array fcoll_base_sort_iovec mpit_big_lock mpit_init_count mpit_lock mpit_unlock netpatterns_base_err netpatterns_base_verbose netpatterns_cleanup_narray_knomial_tree netpatterns_cleanup_recursive_doubling_tree_node netpatterns_cleanup_recursive_knomial_allgather_tree_node netpatterns_cleanup_recursive_knomial_tree_node netpatterns_init netpatterns_register_mca_params netpatterns_setup_multinomial_tree netpatterns_setup_narray_knomial_tree netpatterns_setup_narray_tree netpatterns_setup_narray_tree_contigous_ranks netpatterns_setup_recursive_doubling_n_tree_node netpatterns_setup_recursive_doubling_tree_node netpatterns_setup_recursive_knomial_allgather_tree_node netpatterns_setup_recursive_knomial_tree_node pml_v_output_close pml_v_output_open intercept_extra_state_t odls_base_default_wait_local_proc _event_debug_mode_on _evthread_cond_fns _evthread_id_fn _evthread_lock_debugging_enabled _evthread_lock_fns cmd_line_option_t cmd_line_param_t crs_base_self_checkpoint_fn crs_base_self_continue_fn crs_base_self_restart_fn event_enable_debug_output event_global_current_base_ event_module_include eventops sync_wait_mt trigger_user_inc_callback var_type_names var_type_sizes Signed-off-by: Mark Allen <markalle@us.ibm.com>
127 строки
4.5 KiB
C
127 строки
4.5 KiB
C
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
|
/*
|
|
* Copyright (c) 2014-2016 The University of Tennessee and The University
|
|
* of Tennessee Research Foundation. All rights
|
|
* reserved.
|
|
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
|
|
* reserved.
|
|
* Copyright (c) 2016 Mellanox Technologies. All rights reserved.
|
|
* Copyright (c) 2016 Research Organization for Information Science
|
|
* and Technology (RIST). All rights reserved.
|
|
* Copyright (c) 2017 IBM Corporation. All rights reserved.
|
|
* $COPYRIGHT$
|
|
*
|
|
* Additional copyrights may follow
|
|
*
|
|
* $HEADER$
|
|
*/
|
|
|
|
#if !defined(OPAL_THREADS_WAIT_SYNC_H)
|
|
#define OPAL_THREADS_WAIT_SYNC_H
|
|
|
|
#include "opal/sys/atomic.h"
|
|
#include "opal/threads/condition.h"
|
|
#include <pthread.h>
|
|
|
|
BEGIN_C_DECLS
|
|
|
|
typedef struct ompi_wait_sync_t {
|
|
int32_t count;
|
|
int32_t status;
|
|
pthread_cond_t condition;
|
|
pthread_mutex_t lock;
|
|
struct ompi_wait_sync_t *next;
|
|
struct ompi_wait_sync_t *prev;
|
|
volatile bool signaling;
|
|
} ompi_wait_sync_t;
|
|
|
|
#define REQUEST_PENDING (void*)0L
|
|
#define REQUEST_COMPLETED (void*)1L
|
|
|
|
#define SYNC_WAIT(sync) (opal_using_threads() ? ompi_sync_wait_mt (sync) : sync_wait_st (sync))
|
|
|
|
/* The loop in release handles a race condition between the signaling
|
|
* thread and the destruction of the condition variable. The signaling
|
|
* member will be set to false after the final signaling thread has
|
|
* finished operating on the sync object. This is done to avoid
|
|
* extra atomics in the signalling function and keep it as fast
|
|
* as possible. Note that the race window is small so spinning here
|
|
* is more optimal than sleeping since this macro is called in
|
|
* the critical path. */
|
|
#define WAIT_SYNC_RELEASE(sync) \
|
|
if (opal_using_threads()) { \
|
|
while ((sync)->signaling) { \
|
|
continue; \
|
|
} \
|
|
pthread_cond_destroy(&(sync)->condition); \
|
|
pthread_mutex_destroy(&(sync)->lock); \
|
|
}
|
|
|
|
#define WAIT_SYNC_RELEASE_NOWAIT(sync) \
|
|
if (opal_using_threads()) { \
|
|
pthread_cond_destroy(&(sync)->condition); \
|
|
pthread_mutex_destroy(&(sync)->lock); \
|
|
}
|
|
|
|
|
|
#define WAIT_SYNC_SIGNAL(sync) \
|
|
if (opal_using_threads()) { \
|
|
pthread_mutex_lock(&(sync->lock)); \
|
|
pthread_cond_signal(&sync->condition); \
|
|
pthread_mutex_unlock(&(sync->lock)); \
|
|
sync->signaling = false; \
|
|
}
|
|
|
|
#define WAIT_SYNC_SIGNALLED(sync){ \
|
|
(sync)->signaling = false; \
|
|
}
|
|
|
|
OPAL_DECLSPEC int ompi_sync_wait_mt(ompi_wait_sync_t *sync);
|
|
static inline int sync_wait_st (ompi_wait_sync_t *sync)
|
|
{
|
|
while (sync->count > 0) {
|
|
opal_progress();
|
|
}
|
|
|
|
return sync->status;
|
|
}
|
|
|
|
|
|
#define WAIT_SYNC_INIT(sync,c) \
|
|
do { \
|
|
(sync)->count = (c); \
|
|
(sync)->next = NULL; \
|
|
(sync)->prev = NULL; \
|
|
(sync)->status = 0; \
|
|
(sync)->signaling = (0 != (c)); \
|
|
if (opal_using_threads()) { \
|
|
pthread_cond_init (&(sync)->condition, NULL); \
|
|
pthread_mutex_init (&(sync)->lock, NULL); \
|
|
} \
|
|
} while(0)
|
|
|
|
/**
|
|
* Update the status of the synchronization primitive. If an error is
|
|
* reported the synchronization is completed and the signal
|
|
* triggered. The status of the synchronization will be reported to
|
|
* the waiting threads.
|
|
*/
|
|
static inline void wait_sync_update(ompi_wait_sync_t *sync, int updates, int status)
|
|
{
|
|
if( OPAL_LIKELY(OPAL_SUCCESS == status) ) {
|
|
if( 0 != (OPAL_THREAD_ADD32(&sync->count, -updates)) ) {
|
|
return;
|
|
}
|
|
} else {
|
|
/* this is an error path so just use the atomic */
|
|
sync->status = OPAL_ERROR;
|
|
opal_atomic_wmb ();
|
|
opal_atomic_swap_32 (&sync->count, 0);
|
|
}
|
|
WAIT_SYNC_SIGNAL(sync);
|
|
}
|
|
|
|
END_C_DECLS
|
|
|
|
#endif /* defined(OPAL_THREADS_WAIT_SYNC_H) */
|