Skip to content

Commit d7264aa

Browse files
committed
osc/pt2pt: various threading fixes
This commit fixes several bugs identified by a new multi-threaded RMA benchmarking suite. The following bugs have been identified and fixed: - The code that signaled the actual start of an access epoch changed the eager_send_active flag on a synchronization object without holding the object's lock. This could cause another thread waiting on eager sends to block indefinitely because the entirety of ompi_osc_pt2pt_sync_expected could exectute between the check of eager_send_active and the conditon wait of ompi_osc_pt2pt_sync_wait. - The bookkeeping of fragments could get screwed up when performing long put/accumulate operations from different threads. This was caused by the fragment flush code at the end of both put and accumulate. This code was put in place to avoid sending a large number of unexpected messages to a peer. To fix the bookkeeping issue we now 1) wait for eager sends to be active before stating any large isend's, and 2) keep track of the number of large isends associated with a fragment. If the number of large isends reaches 32 the active fragment is flushed. - Use atomics to update the large receive/send tag counters. This prevents duplicate tags from being used. The tag space has also been updated to use the entire 16-bits of the tag space. These changes should also fix #1299. Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
1 parent 728a97c commit d7264aa

File tree

8 files changed

+120
-185
lines changed

8 files changed

+120
-185
lines changed

ompi/mca/osc/pt2pt/osc_pt2pt.h

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* University of Stuttgart. All rights reserved.
99
* Copyright (c) 2004-2005 The Regents of the University of California.
1010
* All rights reserved.
11-
* Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights
11+
* Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights
1212
* reserved.
1313
* Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2012-2013 Sandia National Laboratories. All rights reserved.
@@ -149,20 +149,20 @@ struct ompi_osc_pt2pt_module_t {
149149
uint32_t *epoch_outgoing_frag_count;
150150

151151
/** cyclic counter for a unique tage for long messages. */
152-
unsigned int tag_counter;
153-
unsigned int rtag_counter;
152+
uint32_t tag_counter;
153+
uint32_t rtag_counter;
154154

155155
/* Number of outgoing fragments that have completed since the
156156
begining of time */
157-
uint32_t outgoing_frag_count;
157+
volatile uint32_t outgoing_frag_count;
158158
/* Next outgoing fragment count at which we want a signal on cond */
159-
uint32_t outgoing_frag_signal_count;
159+
volatile uint32_t outgoing_frag_signal_count;
160160

161161
/* Number of incoming fragments that have completed since the
162162
begining of time */
163-
uint32_t active_incoming_frag_count;
163+
volatile uint32_t active_incoming_frag_count;
164164
/* Next incoming buffer count at which we want a signal on cond */
165-
uint32_t active_incoming_frag_signal_count;
165+
volatile uint32_t active_incoming_frag_signal_count;
166166

167167
/** Number of targets locked/being locked */
168168
unsigned int passive_target_access_epoch;
@@ -409,14 +409,6 @@ int ompi_osc_pt2pt_component_irecv(ompi_osc_pt2pt_module_t *module,
409409
int tag,
410410
struct ompi_communicator_t *comm);
411411

412-
int ompi_osc_pt2pt_component_isend(ompi_osc_pt2pt_module_t *module,
413-
const void *buf,
414-
size_t count,
415-
struct ompi_datatype_t *datatype,
416-
int dest,
417-
int tag,
418-
struct ompi_communicator_t *comm);
419-
420412
/**
421413
* ompi_osc_pt2pt_progress_pending_acc:
422414
*
@@ -639,8 +631,8 @@ static inline void osc_pt2pt_add_pending (ompi_osc_pt2pt_pending_t *pending)
639631
opal_list_append (&mca_osc_pt2pt_component.pending_operations, &pending->super));
640632
}
641633

642-
#define OSC_PT2PT_FRAG_TAG 0x10000
643-
#define OSC_PT2PT_FRAG_MASK 0x0ffff
634+
#define OSC_PT2PT_FRAG_TAG 0x80000
635+
#define OSC_PT2PT_FRAG_MASK 0x7ffff
644636

645637
/**
646638
* get_tag:
@@ -658,23 +650,17 @@ static inline int get_tag(ompi_osc_pt2pt_module_t *module)
658650
/* the LSB of the tag is used be the receiver to determine if the
659651
message is a passive or active target (ie, where to mark
660652
completion). */
661-
int tmp = module->tag_counter + !!(module->passive_target_access_epoch);
662-
663-
module->tag_counter = (module->tag_counter + 4) & OSC_PT2PT_FRAG_MASK;
664-
665-
return tmp;
653+
int32_t tmp = OPAL_THREAD_ADD32((volatile int32_t *) &module->tag_counter, 4);
654+
return (tmp & OSC_PT2PT_FRAG_MASK) | !!(module->passive_target_access_epoch);
666655
}
667656

668657
static inline int get_rtag(ompi_osc_pt2pt_module_t *module)
669658
{
670659
/* the LSB of the tag is used be the receiver to determine if the
671660
message is a passive or active target (ie, where to mark
672661
completion). */
673-
int tmp = module->rtag_counter + !!(module->passive_target_access_epoch);
674-
675-
module->rtag_counter = (module->rtag_counter + 4) & OSC_PT2PT_FRAG_MASK;
676-
677-
return tmp;
662+
int32_t tmp = OPAL_THREAD_ADD32((volatile int32_t *) &module->rtag_counter, 4);
663+
return (tmp & OSC_PT2PT_FRAG_MASK) | !!(module->passive_target_access_epoch);
678664
}
679665
/**
680666
* ompi_osc_pt2pt_accumulate_lock:

ompi/mca/osc/pt2pt/osc_pt2pt_active_target.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* University of Stuttgart. All rights reserved.
99
* Copyright (c) 2004-2005 The Regents of the University of California.
1010
* All rights reserved.
11-
* Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights
11+
* Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights
1212
* reserved.
1313
* Copyright (c) 2010 IBM Corporation. All rights reserved.
1414
* Copyright (c) 2012-2013 Sandia National Laboratories. All rights reserved.
@@ -211,7 +211,7 @@ int ompi_osc_pt2pt_start (ompi_group_t *group, int assert, ompi_win_t *win)
211211
ompi_osc_pt2pt_module_t *module = GET_MODULE(win);
212212
ompi_osc_pt2pt_sync_t *sync = &module->all_sync;
213213

214-
OPAL_THREAD_LOCK(&sync->lock);
214+
OPAL_THREAD_LOCK(&module->lock);
215215

216216
/* check if we are already in an access epoch */
217217
if (ompi_osc_pt2pt_access_epoch_active (module)) {

0 commit comments

Comments
 (0)