Skip to content

Commit

Permalink
Cleanup some code. (#281)
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel K. Gutierrez <samuel@lanl.gov>
  • Loading branch information
samuelkgutierrez authored Sep 18, 2024
1 parent e173b28 commit dd0c7a1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/qvi-group-pthread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 6 additions & 11 deletions src/qvi-pthread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::mutex> guard(group->m_mutex);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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)) {
Expand Down
8 changes: 4 additions & 4 deletions tests/test-pthread-split.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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));
Expand Down

0 comments on commit dd0c7a1

Please sign in to comment.