Skip to content

Commit f8facb1

Browse files
committed
atomically update the refcount on the datatype args.
1 parent 055a3ad commit f8facb1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ompi/datatype/ompi_datatype_args.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,14 @@ int32_t ompi_datatype_copy_args( const ompi_datatype_t* source_data,
373373
{
374374
ompi_datatype_args_t* pArgs = (ompi_datatype_args_t*)source_data->args;
375375

376-
/* If required then increase the reference count of the arguments. This avoid us
377-
* to make one more copy for a read only piece of memory.
376+
/* Increase the reference count of the datatype enveloppe. This
377+
* prevent us from making extra copies for the enveloppe (which is mostly
378+
* a read only memory).
378379
*/
379-
assert( NULL != source_data->args );
380-
pArgs->ref_count++;
381-
dest_data->args = pArgs;
380+
if( NULL != pArgs ) {
381+
OPAL_THREAD_ADD32(&pArgs->ref_count, 1);
382+
dest_data->args = pArgs;
383+
}
382384
return OMPI_SUCCESS;
383385
}
384386

@@ -394,7 +396,7 @@ int32_t ompi_datatype_release_args( ompi_datatype_t* pData )
394396
ompi_datatype_args_t* pArgs = (ompi_datatype_args_t*)pData->args;
395397

396398
assert( 0 < pArgs->ref_count );
397-
pArgs->ref_count--;
399+
OPAL_THREAD_ADD32(&pArgs->ref_count, -1);
398400
if( 0 == pArgs->ref_count ) {
399401
/* There are some duplicated datatypes around that have a pointer to this
400402
* args. We will release them only when the last datatype will dissapear.

0 commit comments

Comments
 (0)