OpenMPI
0.1.1
|
Mutual exclusion functions. More...
Go to the source code of this file.
Macros | |
#define | opal_using_threads() opal_uses_threads |
Check and see if the process is using multiple threads. More... | |
#define | OPAL_THREAD_LOCK(mutex) |
Lock a mutex if opal_using_threads() says that multiple threads may be active in the process. More... | |
#define | OPAL_THREAD_TRYLOCK(mutex) 0 |
Try to lock a mutex if opal_using_threads() says that multiple threads may be active in the process. More... | |
#define | OPAL_THREAD_UNLOCK(mutex) |
Unlock a mutex if opal_using_threads() says that multiple threads may be active in the process. More... | |
#define | OPAL_THREAD_SCOPED_LOCK(mutex, action) (action) |
Lock a mutex if opal_using_threads() says that multiple threads may be active in the process for the duration of the specified action. More... | |
#define | OPAL_THREAD_ADD32(x, y) (*x += y) |
Use an atomic operation for increment/decrement if opal_using_threads() indicates that threads are in use by the application or library. | |
#define | OPAL_THREAD_ADD64(x, y) (*x += y) |
#define | OPAL_THREAD_ADD_SIZE_T(x, y) (*x += y) |
#define | OPAL_CMPSET(x, y, z) ((*(x) == (y)) ? ((*(x) = (z)), 1) : 0) |
Typedefs | |
typedef struct opal_mutex_t | opal_mutex_t |
Opaque mutex object. | |
Functions | |
static int | opal_mutex_trylock (opal_mutex_t *mutex) |
Try to acquire a mutex. More... | |
static void | opal_mutex_lock (opal_mutex_t *mutex) |
Acquire a mutex. More... | |
static void | opal_mutex_unlock (opal_mutex_t *mutex) |
Release a mutex. More... | |
static int | opal_mutex_atomic_trylock (opal_mutex_t *mutex) |
Try to acquire a mutex using atomic operations. More... | |
static void | opal_mutex_atomic_lock (opal_mutex_t *mutex) |
Acquire a mutex using atomic operations. More... | |
static void | opal_mutex_atomic_unlock (opal_mutex_t *mutex) |
Release a mutex using atomic operations. More... | |
static bool | opal_set_using_threads (bool have) |
Set whether the process is using multiple threads or not. More... | |
Variables | |
OPAL_DECLSPEC bool | opal_uses_threads |
Mutual exclusion functions.
Functions for locking of critical sections.
#define OPAL_THREAD_LOCK | ( | mutex | ) |
Lock a mutex if opal_using_threads() says that multiple threads may be active in the process.
mutex | Pointer to a opal_mutex_t to lock. |
If there is a possibility that multiple threads are running in the process (as determined by opal_using_threads()), this function will block waiting to lock the mutex.
If there is no possibility that multiple threads are running in the process, return immediately.
Referenced by mca_allocator_basic_alloc(), mca_allocator_basic_free(), mca_allocator_bucket_alloc(), mca_allocator_bucket_alloc_align(), mca_allocator_bucket_cleanup(), mca_allocator_bucket_free(), mca_btl_elan_component_progress(), mca_btl_gm_add_procs(), mca_btl_gm_component_init(), mca_btl_gm_component_progress(), mca_btl_gm_finalize(), mca_btl_gm_get(), mca_btl_gm_put(), mca_btl_gm_send(), mca_btl_mx_add_procs(), mca_btl_sctp_add_procs(), mca_btl_tcp_add_procs(), mca_btl_template_add_procs(), mca_btl_ud_add_procs(), mca_btl_ud_component_progress(), mca_btl_udapl_add_procs(), mca_btl_udapl_component_progress(), mca_btl_udapl_put(), mca_mpool_base_tree_find(), mca_mpool_grdma_deregister(), mca_mpool_grdma_finalize(), mca_mpool_grdma_find(), mca_mpool_grdma_register(), mca_mpool_grdma_release_memory(), mca_mpool_rdma_deregister(), mca_mpool_rdma_finalize(), mca_mpool_rdma_find(), mca_mpool_rdma_register(), mca_mpool_rdma_release_memory(), mca_mpool_rgpusm_deregister(), mca_mpool_rgpusm_finalize(), mca_mpool_rgpusm_find(), mca_mpool_rgpusm_register(), mca_oob_tcp_fini(), mca_oob_tcp_msg_complete(), mca_oob_tcp_peer_accept(), mca_oob_tcp_peer_lookup(), mca_oob_tcp_peer_resolved(), mca_oob_tcp_peer_send(), mca_oob_tcp_recv_cancel(), mca_oob_tcp_recv_nb(), mca_oob_tcp_resolve(), mca_oob_tcp_set_addr(), mca_pml_bfo_error_pending_packets(), mca_pml_bfo_recv_frag_callback_match(), mca_pml_bfo_recv_frag_match(), mca_pml_bfo_recv_req_start(), mca_pml_bfo_send_request_restart(), mca_pml_bfo_start(), mca_pml_csum_recv_frag_callback_match(), mca_pml_csum_recv_frag_match(), mca_pml_csum_recv_req_start(), mca_pml_csum_start(), mca_pml_ob1_recv_frag_callback_match(), mca_pml_ob1_recv_frag_match(), mca_pml_ob1_recv_req_start(), mca_pml_ob1_start(), ompi_attr_copy_all(), ompi_attr_delete(), ompi_attr_delete_all(), ompi_attr_free_keyval(), ompi_proc_all(), ompi_proc_complete_init(), ompi_proc_find(), ompi_proc_pack(), ompi_proc_refresh(), ompi_proc_world(), ompi_request_wait_completion(), opal_output_close(), opal_pointer_array_add(), opal_pointer_array_get_item(), opal_pointer_array_remove_all(), opal_pointer_array_set_item(), opal_pointer_array_set_size(), opal_pointer_array_test_and_set_item(), opal_util_keyval_parse(), orte_odls_base_default_signal_local_procs(), orte_plm_submit_launch(), and recv_request_pml_complete().
#define OPAL_THREAD_SCOPED_LOCK | ( | mutex, | |
action | |||
) | (action) |
Lock a mutex if opal_using_threads() says that multiple threads may be active in the process for the duration of the specified action.
mutex | Pointer to a opal_mutex_t to lock. |
action | A scope over which the lock is held. |
If there is a possibility that multiple threads are running in the process (as determined by opal_using_threads()), this function will acquire the lock before invoking the specified action and release it on return.
If there is no possibility that multiple threads are running in the process, invoke the action without acquiring the lock.
#define OPAL_THREAD_TRYLOCK | ( | mutex | ) | 0 |
Try to lock a mutex if opal_using_threads() says that multiple threads may be active in the process.
mutex | Pointer to a opal_mutex_t to trylock |
If there is a possibility that multiple threads are running in the process (as determined by opal_using_threads()), this function will trylock the mutex.
If there is no possibility that multiple threads are running in the process, return immediately without modifying the mutex.
Returns 0 if mutex was locked, non-zero otherwise.
Referenced by mca_btl_elan_component_progress().
#define OPAL_THREAD_UNLOCK | ( | mutex | ) |
Unlock a mutex if opal_using_threads() says that multiple threads may be active in the process.
mutex | Pointer to a opal_mutex_t to unlock. |
If there is a possibility that multiple threads are running in the process (as determined by opal_using_threads()), this function will unlock the mutex.
If there is no possibility that multiple threads are running in the process, return immediately without modifying the mutex.
Referenced by mca_allocator_basic_alloc(), mca_allocator_basic_free(), mca_allocator_bucket_alloc(), mca_allocator_bucket_alloc_align(), mca_allocator_bucket_cleanup(), mca_allocator_bucket_free(), mca_btl_elan_component_progress(), mca_btl_gm_add_procs(), mca_btl_gm_component_init(), mca_btl_gm_component_progress(), mca_btl_gm_finalize(), mca_btl_gm_get(), mca_btl_gm_put(), mca_btl_gm_send(), mca_btl_mx_add_procs(), mca_btl_sctp_add_procs(), mca_btl_tcp_add_procs(), mca_btl_template_add_procs(), mca_btl_ud_add_procs(), mca_btl_ud_component_progress(), mca_btl_udapl_add_procs(), mca_btl_udapl_component_progress(), mca_btl_udapl_put(), mca_mpool_base_tree_find(), mca_mpool_grdma_deregister(), mca_mpool_grdma_finalize(), mca_mpool_grdma_find(), mca_mpool_grdma_register(), mca_mpool_grdma_release_memory(), mca_mpool_rdma_deregister(), mca_mpool_rdma_finalize(), mca_mpool_rdma_find(), mca_mpool_rdma_register(), mca_mpool_rdma_release_memory(), mca_mpool_rgpusm_deregister(), mca_mpool_rgpusm_finalize(), mca_mpool_rgpusm_find(), mca_mpool_rgpusm_register(), mca_oob_tcp_fini(), mca_oob_tcp_msg_complete(), mca_oob_tcp_peer_accept(), mca_oob_tcp_peer_close(), mca_oob_tcp_peer_lookup(), mca_oob_tcp_peer_resolved(), mca_oob_tcp_peer_send(), mca_oob_tcp_recv_cancel(), mca_oob_tcp_recv_nb(), mca_oob_tcp_resolve(), mca_oob_tcp_set_addr(), mca_pml_bfo_error_pending_packets(), mca_pml_bfo_recv_frag_callback_match(), mca_pml_bfo_recv_frag_match(), mca_pml_bfo_recv_req_start(), mca_pml_bfo_send_request_restart(), mca_pml_bfo_start(), mca_pml_csum_recv_frag_callback_match(), mca_pml_csum_recv_frag_match(), mca_pml_csum_recv_req_start(), mca_pml_csum_start(), mca_pml_ob1_recv_frag_callback_match(), mca_pml_ob1_recv_frag_match(), mca_pml_ob1_recv_req_start(), mca_pml_ob1_start(), ompi_attr_copy_all(), ompi_attr_delete(), ompi_attr_delete_all(), ompi_attr_free_keyval(), ompi_proc_all(), ompi_proc_complete_init(), ompi_proc_find(), ompi_proc_pack(), ompi_proc_refresh(), ompi_proc_world(), ompi_request_wait_completion(), opal_output_close(), opal_pointer_array_add(), opal_pointer_array_get_item(), opal_pointer_array_remove_all(), opal_pointer_array_set_item(), opal_pointer_array_set_size(), opal_pointer_array_test_and_set_item(), opal_util_keyval_parse(), orte_odls_base_default_signal_local_procs(), orte_plm_submit_launch(), and recv_request_pml_complete().
#define opal_using_threads | ( | ) | opal_uses_threads |
Check and see if the process is using multiple threads.
true | If the process may have more than one thread. |
false | If the process only has a single thread. |
The value that this function returns is influenced by:
MPI_INIT and MPI_INIT_THREAD (specifically, back-end OMPI startup functions) invoke opal_set_using_threads() to influence the value of this function, depending on their situation. Some examples:
Hence, this function will return false if there is guaranteed to only be one thread in the process. If there is even the possibility that we may have multiple threads, true will be returned.
Referenced by mca_btl_sm_component_progress(), and mca_btl_smcuda_component_progress().
|
inlinestatic |
Acquire a mutex using atomic operations.
mutex | Address of the mutex. |
|
inlinestatic |
Try to acquire a mutex using atomic operations.
mutex | Address of the mutex. |
|
inlinestatic |
Release a mutex using atomic operations.
mutex | Address of the mutex. |
|
inlinestatic |
Acquire a mutex.
mutex | Address of the mutex. |
Referenced by opal_cmd_line_get_ninsts(), opal_cmd_line_get_param(), opal_cmd_line_get_tail(), opal_cmd_line_get_usage_msg(), and opal_cmd_line_parse().
|
inlinestatic |
Try to acquire a mutex.
mutex | Address of the mutex. |
|
inlinestatic |
Release a mutex.
mutex | Address of the mutex. |
Referenced by opal_cmd_line_get_ninsts(), opal_cmd_line_get_param(), opal_cmd_line_get_tail(), opal_cmd_line_get_usage_msg(), and opal_cmd_line_parse().
|
inlinestatic |
Set whether the process is using multiple threads or not.
have | Boolean indicating whether the process is using multiple threads or not. |
opal_using_threads | The new return value from opal_using_threads(). |
This function is used to influence the return value of opal_using_threads(). If configure detected that we have thread support, the return value of future invocations of opal_using_threads() will be the parameter's value. If configure detected that we have no thread support, then the retuen from opal_using_threads() will always be false.
Referenced by ompi_mpi_init().