Skip to content

Commit 615b27c

Browse files
committed
Merge pull request #1339 from hjelmn/osc_pt2pt_fixes
osc/pt2pt: various threading fixes
2 parents d812695 + 519fffb commit 615b27c

9 files changed

+123
-186
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)