diff --git a/src/qvi-group-pthread.cc b/src/qvi-group-pthread.cc index 3dffc66..e3b2365 100644 --- a/src/qvi-group-pthread.cc +++ b/src/qvi-group-pthread.cc @@ -36,9 +36,9 @@ qvi_group_pthread::self( int qvi_group_pthread::split( - int color , + int color, int key, - qvi_group ** child + qvi_group **child ) { qvi_group_pthread *ichild = nullptr; int rc = qvi_new(&ichild); diff --git a/src/qvi-pthread.cc b/src/qvi-pthread.cc index 97f5995..51a6ae1 100644 --- a/src/qvi-pthread.cc +++ b/src/qvi-pthread.cc @@ -71,11 +71,8 @@ qvi_pthread_group::call_first_from_pthread_create( const pid_t tidi = group->m_tids[i]; group->m_tid2rank.insert({tidi, i}); } - pthread_barrier_wait(&group->m_barrier); - } - else { - pthread_barrier_wait(&group->m_barrier); } + pthread_barrier_wait(&group->m_barrier); // Everyone can now create their task and populate the mapping table. { std::lock_guard guard(group->m_mutex); @@ -216,7 +213,7 @@ qvi_pthread_group::split( if (qvi_likely(rc == QV_SUCCESS)) { rc = qvi_new(&ichild, sginfo.size, sginfo.rank); } - if (rc != QV_SUCCESS) { + if (qvi_unlikely(rc != QV_SUCCESS)) { qvi_delete(&ichild); } *child = ichild; @@ -230,9 +227,7 @@ qvi_pthread_group::gather( qvi_alloc_type_t *shared_alloc, qvi_bbuff ***rxbuffs ) { - int rank = qvi_pthread_group::rank(); - - const int rc = qvi_bbuff_copy(*txbuff, m_data_g[rank]); + const int rc = qvi_bbuff_copy(*txbuff, m_data_g[rank()]); // Need to ensure that all threads have contributed to m_data_g pthread_barrier_wait(&m_barrier); *shared_alloc = ALLOC_SHARED_GLOBAL; @@ -252,15 +247,15 @@ qvi_pthread_group::scatter( int rootid, qvi_bbuff **rxbuff ) { - int rank = qvi_pthread_group::rank(); + const int myrank = rank(); - if(rootid == rank){ + if (rootid == myrank) { *m_data_s = txbuffs; } pthread_barrier_wait(&m_barrier); qvi_bbuff *mybbuff = nullptr; - const int rc = qvi_bbuff_dup( *((*m_data_s)[rank]), &mybbuff); + const int rc = qvi_bbuff_dup( *((*m_data_s)[myrank]), &mybbuff); pthread_barrier_wait(&m_barrier); if (qvi_unlikely(rc != QV_SUCCESS)) { diff --git a/tests/test-pthread-split.c b/tests/test-pthread-split.c index 74a6585..1f732dd 100644 --- a/tests/test-pthread-split.c +++ b/tests/test-pthread-split.c @@ -33,7 +33,7 @@ thread_work( fprintf(stdout,"[%d] Thread running on %s\n", tid, binds); free(binds); - int rank = -1; + int rank = 0; rc = qv_scope_group_rank(thargs->scope, &rank); if (rc != QV_SUCCESS) { ers = "qv_scope_group_rank failed"; @@ -42,14 +42,14 @@ thread_work( fprintf(stdout,"[%d] Thread %d splitting in two pieces\n", tid, rank); - qv_scope_t *out_scope = NULL; - rc = qv_scope_split(thargs->scope, 2, rank, &out_scope); + qv_scope_t *pthread_subscope = NULL; + rc = qv_scope_split(thargs->scope, 2, rank, &pthread_subscope); if (rc != QV_SUCCESS) { ers = "qv_scope_split failed"; qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc)); } - rc = qv_scope_free(out_scope); + rc = qv_scope_free(pthread_subscope); if (rc != QV_SUCCESS) { ers = "qv_scope_free failed"; qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));