Skip to content

Commit dd0c7a1

Browse files
Cleanup some code. (#281)
Signed-off-by: Samuel K. Gutierrez <[email protected]>
1 parent e173b28 commit dd0c7a1

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

src/qvi-group-pthread.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ qvi_group_pthread::self(
3636

3737
int
3838
qvi_group_pthread::split(
39-
int color ,
39+
int color,
4040
int key,
41-
qvi_group ** child
41+
qvi_group **child
4242
) {
4343
qvi_group_pthread *ichild = nullptr;
4444
int rc = qvi_new(&ichild);

src/qvi-pthread.cc

+6-11
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,8 @@ qvi_pthread_group::call_first_from_pthread_create(
7171
const pid_t tidi = group->m_tids[i];
7272
group->m_tid2rank.insert({tidi, i});
7373
}
74-
pthread_barrier_wait(&group->m_barrier);
75-
}
76-
else {
77-
pthread_barrier_wait(&group->m_barrier);
7874
}
75+
pthread_barrier_wait(&group->m_barrier);
7976
// Everyone can now create their task and populate the mapping table.
8077
{
8178
std::lock_guard<std::mutex> guard(group->m_mutex);
@@ -216,7 +213,7 @@ qvi_pthread_group::split(
216213
if (qvi_likely(rc == QV_SUCCESS)) {
217214
rc = qvi_new(&ichild, sginfo.size, sginfo.rank);
218215
}
219-
if (rc != QV_SUCCESS) {
216+
if (qvi_unlikely(rc != QV_SUCCESS)) {
220217
qvi_delete(&ichild);
221218
}
222219
*child = ichild;
@@ -230,9 +227,7 @@ qvi_pthread_group::gather(
230227
qvi_alloc_type_t *shared_alloc,
231228
qvi_bbuff ***rxbuffs
232229
) {
233-
int rank = qvi_pthread_group::rank();
234-
235-
const int rc = qvi_bbuff_copy(*txbuff, m_data_g[rank]);
230+
const int rc = qvi_bbuff_copy(*txbuff, m_data_g[rank()]);
236231
// Need to ensure that all threads have contributed to m_data_g
237232
pthread_barrier_wait(&m_barrier);
238233
*shared_alloc = ALLOC_SHARED_GLOBAL;
@@ -252,15 +247,15 @@ qvi_pthread_group::scatter(
252247
int rootid,
253248
qvi_bbuff **rxbuff
254249
) {
255-
int rank = qvi_pthread_group::rank();
250+
const int myrank = rank();
256251

257-
if(rootid == rank){
252+
if (rootid == myrank) {
258253
*m_data_s = txbuffs;
259254
}
260255
pthread_barrier_wait(&m_barrier);
261256

262257
qvi_bbuff *mybbuff = nullptr;
263-
const int rc = qvi_bbuff_dup( *((*m_data_s)[rank]), &mybbuff);
258+
const int rc = qvi_bbuff_dup( *((*m_data_s)[myrank]), &mybbuff);
264259
pthread_barrier_wait(&m_barrier);
265260

266261
if (qvi_unlikely(rc != QV_SUCCESS)) {

tests/test-pthread-split.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ thread_work(
3333
fprintf(stdout,"[%d] Thread running on %s\n", tid, binds);
3434
free(binds);
3535

36-
int rank = -1;
36+
int rank = 0;
3737
rc = qv_scope_group_rank(thargs->scope, &rank);
3838
if (rc != QV_SUCCESS) {
3939
ers = "qv_scope_group_rank failed";
@@ -42,14 +42,14 @@ thread_work(
4242

4343
fprintf(stdout,"[%d] Thread %d splitting in two pieces\n", tid, rank);
4444

45-
qv_scope_t *out_scope = NULL;
46-
rc = qv_scope_split(thargs->scope, 2, rank, &out_scope);
45+
qv_scope_t *pthread_subscope = NULL;
46+
rc = qv_scope_split(thargs->scope, 2, rank, &pthread_subscope);
4747
if (rc != QV_SUCCESS) {
4848
ers = "qv_scope_split failed";
4949
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
5050
}
5151

52-
rc = qv_scope_free(out_scope);
52+
rc = qv_scope_free(pthread_subscope);
5353
if (rc != QV_SUCCESS) {
5454
ers = "qv_scope_free failed";
5555
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));

0 commit comments

Comments
 (0)