Skip to content

Commit dfbf2b7

Browse files
committed
opal/threads: add OPAL_THREAD_SUB_SIZE_T macro
-1 is not a valid size_t, so instead of OPAL_THREAD_ADD_SIZE_T(..., -1), simply OPAL_THREAD_SUB_SIZE_T(..., 1) and keep picky compilers happy
1 parent 799104f commit dfbf2b7

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

ompi/mca/pml/bfo/pml_bfo_recvreq.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* Copyright (c) 2010-2012 Oracle and/or its affiliates. All rights reserved.
1515
* Copyright (c) 2011-2012 Los Alamos National Security, LLC.
1616
* All rights reserved.
17+
* Copyright (c) 2016 Research Organization for Information Science
18+
* and Technology (RIST). All rights reserved.
1719
* $COPYRIGHT$
1820
*
1921
* Additional copyrights may follow
@@ -203,7 +205,7 @@ static void mca_pml_bfo_put_completion( mca_btl_base_module_t* btl,
203205
(void *) des->des_remote,
204206
des->des_remote_count, 0);
205207
}
206-
OPAL_THREAD_ADD_SIZE_T(&recvreq->req_pipeline_depth,-1);
208+
OPAL_THREAD_SUB_SIZE_T(&recvreq->req_pipeline_depth, 1);
207209

208210
#if PML_BFO
209211
btl->btl_free(btl, des);

ompi/mca/pml/bfo/pml_bfo_sendreq.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* Copyright (c) 2010-2012 Oracle and/or its affiliates. All rights reserved.
1515
* Copyright (c) 2011-2012 Los Alamos National Security, LLC.
1616
* All rights reserved.
17+
* Copyright (c) 2016 Research Organization for Information Science
18+
* and Technology (RIST). All rights reserved.
1719
* $COPYRIGHT$
1820
*
1921
* Additional copyrights may follow
@@ -357,7 +359,7 @@ mca_pml_bfo_frag_completion( mca_btl_base_module_t* btl,
357359
des->des_local_count,
358360
sizeof(mca_pml_bfo_frag_hdr_t));
359361

360-
OPAL_THREAD_ADD_SIZE_T(&sendreq->req_pipeline_depth, -1);
362+
OPAL_THREAD_SUB_SIZE_T(&sendreq->req_pipeline_depth, 1);
361363
OPAL_THREAD_ADD_SIZE_T(&sendreq->req_bytes_delivered, req_bytes_delivered);
362364

363365
#if PML_BFO

ompi/mca/pml/ob1/pml_ob1_recvreq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Copyright (c) 2011-2016 Los Alamos National Security, LLC. All rights
1717
* reserved.
1818
* Copyright (c) 2012 FUJITSU LIMITED. All rights reserved.
19-
* Copyright (c) 2014-2015 Research Organization for Information Science
19+
* Copyright (c) 2014-2016 Research Organization for Information Science
2020
* and Technology (RIST). All rights reserved.
2121
* $COPYRIGHT$
2222
*
@@ -189,7 +189,7 @@ static void mca_pml_ob1_put_completion (mca_pml_ob1_rdma_frag_t *frag, int64_t r
189189
mca_pml_ob1_recv_request_t* recvreq = (mca_pml_ob1_recv_request_t *) frag->rdma_req;
190190
mca_bml_base_btl_t *bml_btl = frag->rdma_bml;
191191

192-
OPAL_THREAD_ADD_SIZE_T(&recvreq->req_pipeline_depth,-1);
192+
OPAL_THREAD_SUB_SIZE_T(&recvreq->req_pipeline_depth, 1);
193193

194194
MCA_PML_OB1_RDMA_FRAG_RETURN(frag);
195195

ompi/mca/pml/ob1/pml_ob1_sendreq.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
* Copyright (c) 2012 NVIDIA Corporation. All rights reserved.
1616
* Copyright (c) 2012-2016 Los Alamos National Security, LLC. All rights
1717
* reserved.
18-
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
18+
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
19+
* Copyright (c) 2016 Research Organization for Information Science
20+
* and Technology (RIST). All rights reserved.
1921
* $COPYRIGHT$
2022
*
2123
* Additional copyrights may follow
@@ -310,7 +312,7 @@ mca_pml_ob1_frag_completion( mca_btl_base_module_t* btl,
310312
des->des_segment_count,
311313
sizeof(mca_pml_ob1_frag_hdr_t));
312314

313-
OPAL_THREAD_ADD_SIZE_T(&sendreq->req_pipeline_depth, -1);
315+
OPAL_THREAD_SUB_SIZE_T(&sendreq->req_pipeline_depth, 1);
314316
OPAL_THREAD_ADD_SIZE_T(&sendreq->req_bytes_delivered, req_bytes_delivered);
315317

316318
if(send_request_pml_complete_check(sendreq) == false) {

opal/threads/thread_usage.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Copyright (c) 2004-2005 The Regents of the University of California.
1212
* All rights reserved.
1313
* Copyright (c) 2007-2014 Cisco Systems, Inc. All rights reserved.
14-
* Copyright (c) 2014 Research Organization for Information Science
14+
* Copyright (c) 2014-2016 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
1616
* Copyright (c) 2015-2016 Los Alamos National Security, LLC. All rights
1717
* reserved.
@@ -103,6 +103,16 @@ static inline type opal_thread_add_ ## suffix (volatile type *addr, type delta)
103103
return (*addr += delta); \
104104
}
105105

106+
#define OPAL_THREAD_DEFINE_ATOMIC_SUB(type, suffix) \
107+
static inline type opal_thread_sub_ ## suffix (volatile type *addr, type delta) \
108+
{ \
109+
if (OPAL_UNLIKELY(opal_using_threads())) { \
110+
return opal_atomic_sub_ ## suffix (addr, delta); \
111+
} \
112+
\
113+
return (*addr -= delta); \
114+
}
115+
106116
#define OPAL_THREAD_DEFINE_ATOMIC_CMPSET(type, addr_type, suffix) \
107117
static inline bool opal_thread_cmpset_bool_ ## suffix (volatile addr_type *addr, type compare, type value) \
108118
{ \
@@ -133,6 +143,7 @@ static inline type opal_thread_swap_ ## suffix (volatile addr_type *ptr, type ne
133143

134144
OPAL_THREAD_DEFINE_ATOMIC_ADD(int32_t, 32)
135145
OPAL_THREAD_DEFINE_ATOMIC_ADD(size_t, size_t)
146+
OPAL_THREAD_DEFINE_ATOMIC_SUB(size_t, size_t)
136147
OPAL_THREAD_DEFINE_ATOMIC_CMPSET(int32_t, int32_t, 32)
137148
OPAL_THREAD_DEFINE_ATOMIC_CMPSET(void *, intptr_t, ptr)
138149
OPAL_THREAD_DEFINE_ATOMIC_SWAP(int32_t, int32_t, 32)
@@ -144,6 +155,9 @@ OPAL_THREAD_DEFINE_ATOMIC_SWAP(void *, intptr_t, ptr)
144155
#define OPAL_THREAD_ADD_SIZE_T opal_thread_add_size_t
145156
#define OPAL_ATOMIC_ADD_SIZE_T opal_thread_add_size_t
146157

158+
#define OPAL_THREAD_SUB_SIZE_T opal_thread_sub_size_t
159+
#define OPAL_ATOMIC_SUB_SIZE_T opal_thread_sub_size_t
160+
147161
#define OPAL_THREAD_CMPSET_32 opal_thread_cmpset_bool_32
148162
#define OPAL_ATOMIC_CMPSET_32 opal_thread_cmpset_bool_32
149163

0 commit comments

Comments
 (0)