Skip to content

Commit

Permalink
global replace * reductions with && reductions
Browse files Browse the repository at this point in the history
GA has used * over {0,1} to implement logical equality.
doing logical-add directly is better for a variety of reasons.
having previously implemented {logical,bitwise}{and,or} in
ARMCI, COMEX, and TCGMSG, we can now use these in GA.
  • Loading branch information
jeffhammond committed Jun 1, 2017
1 parent d794de8 commit 4bad0bc
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 18 deletions.
3 changes: 2 additions & 1 deletion cca/ga_cca_classic/overload.cxx
Expand Up @@ -79,7 +79,8 @@ GA::GlobalArray::operator==(const GA::GlobalArray &g_a) const {
NGA_Release(g_a.mHandle, blo, bhi);
}

GA_Lgop(&isEqual, 1, (char *)"*");
/* GA_Lgop(&isEqual, 1, (char *)"*"); */
GA_Lgop(&isEqual, 1, (char *)"&&");
if(isEqual == TRUE) return TRUE;
else return FALSE;
}
Expand Down
15 changes: 10 additions & 5 deletions global/src/base.c
Expand Up @@ -2038,9 +2038,11 @@ logical pnga_allocate(Integer g_a)
if(GA_memory_limited){
status = (GA_total_memory >= 0) ? 1 : 0;
if (p_handle > 0) {
pnga_pgroup_gop(p_handle,pnga_type_f2c(MT_F_INT), &status, 1, "*");
/* pnga_pgroup_gop(p_handle,pnga_type_f2c(MT_F_INT), &status, 1, "*"); */
pnga_pgroup_gop(p_handle,pnga_type_f2c(MT_F_INT), &status, 1, "&&");
} else {
pnga_gop(pnga_type_f2c(MT_F_INT), &status, 1, "*");
/* pnga_gop(pnga_type_f2c(MT_F_INT), &status, 1, "*"); */
pnga_gop(pnga_type_f2c(MT_F_INT), &status, 1, "&&");
}
}else status = 1;

Expand Down Expand Up @@ -2472,7 +2474,8 @@ Integer status;
if(GA_memory_limited){
GA_total_memory -= bytes+extra;
status = (GA_total_memory >= 0) ? 1 : 0;
pnga_gop(pnga_type_f2c(MT_F_INT), &status, 1, "*");
/* pnga_gop(pnga_type_f2c(MT_F_INT), &status, 1, "*"); */
pnga_gop(pnga_type_f2c(MT_F_INT), &status, 1, "&&");
if(!status)GA_total_memory +=bytes+extra;
}else status = 1;

Expand Down Expand Up @@ -2665,10 +2668,12 @@ logical pnga_duplicate(Integer g_a, Integer *g_b, char* array_name)
if(GA_memory_limited){
status = (GA_total_memory >= 0) ? 1 : 0;
if (grp_id > 0) {
pnga_pgroup_gop(grp_id, pnga_type_f2c(MT_F_INT), &status, 1, "*");
/* pnga_pgroup_gop(grp_id, pnga_type_f2c(MT_F_INT), &status, 1, "*"); */
pnga_pgroup_gop(grp_id, pnga_type_f2c(MT_F_INT), &status, 1, "&&");
status = (Integer)status;
} else {
pnga_gop(pnga_type_f2c(MT_F_INT), &status, 1, "*");
/* pnga_gop(pnga_type_f2c(MT_F_INT), &status, 1, "*"); */
pnga_gop(pnga_type_f2c(MT_F_INT), &status, 1, "&&");
}
}else status = 1;

Expand Down
12 changes: 8 additions & 4 deletions global/src/elem_alg.c
Expand Up @@ -1823,7 +1823,8 @@ int op; /* operation to be perform between g_a and g_b */
if(pnga_comp_patch(andim, loA, hiA, cndim, loC, hiC) &&
pnga_comp_patch(andim, alo, ahi, cndim, clo, chi)) compatible = 1;
else compatible = 0;
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "*");
/* pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "*"); */
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "&&");
if(!compatible) {
/* either patches or distributions do not match:
* - create a temp array that matches distribution of g_c
Expand All @@ -1849,7 +1850,8 @@ int op; /* operation to be perform between g_a and g_b */
if(pnga_comp_patch(bndim, loB, hiB, cndim, loC, hiC) &&
pnga_comp_patch(bndim, blo, bhi, cndim, clo, chi)) compatible = 1;
else compatible = 0;
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "*");
/* pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "*"); */
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "&&");
if(!compatible) {
/* either patches or distributions do not match:
* - create a temp array that matches distribution of g_c
Expand Down Expand Up @@ -2975,7 +2977,8 @@ void pnga_step_bound_info_patch(
compatible3 = 0;
}
compatible = compatible * compatible2 * compatible3;
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "*");
/* pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "*"); */
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "&&");
if(!compatible) {
pnga_error(" pnga_step_bound_info_patch mismatched patchs ",0);
}
Expand Down Expand Up @@ -3297,7 +3300,8 @@ void pnga_step_max_patch(g_a, alo, ahi, g_b, blo, bhi, result)
/* test if patches match */
if(pnga_comp_patch(andim, alo, ahi, bndim, blo, bhi)) compatible = 1;
else compatible = 0;
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "*");
/* pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "*"); */
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "&&");
if(!compatible) {
pnga_error(" ga_step_max_patch_ mismatched patchs ",0);
}
Expand Down
9 changes: 6 additions & 3 deletions global/src/global.npatch.c
Expand Up @@ -1105,7 +1105,8 @@ void pnga_dot_patch(Integer g_a, char *t_a, Integer *alo, Integer *ahi, Integer
if(pnga_comp_patch(andim, loA, hiA, bndim, loB, hiB) &&
pnga_comp_patch(andim, alo, ahi, bndim, blo, bhi)) compatible = 1;
else compatible = 0;
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "*");
/* pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "*"); */
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "&&");
if(!(compatible && (transp=='n'))) {
/* either patches or distributions do not match:
* - create a temp array that matches distribution of g_a
Expand Down Expand Up @@ -2411,11 +2412,13 @@ void *alpha, *beta;
if(pnga_comp_patch(andim, loA, hiA, cndim, loC, hiC) &&
pnga_comp_patch(andim, alo, ahi, cndim, clo, chi)) compatible_a = 1;
else compatible_a = 0;
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible_a, 1, "*");
/* pnga_gop(pnga_type_f2c(MT_F_INT), &compatible_a, 1, "*"); */
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible_a, 1, "&&");
if(pnga_comp_patch(bndim, loB, hiB, cndim, loC, hiC) &&
pnga_comp_patch(bndim, blo, bhi, cndim, clo, chi)) compatible_b = 1;
else compatible_b = 0;
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible_b, 1, "*");
/* pnga_gop(pnga_type_f2c(MT_F_INT), &compatible_b, 1, "*"); */
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible_b, 1, "&&");
if (compatible_a && compatible_b) {
if(andim > bndim) cndim = bndim;
if(andim < bndim) cndim = andim;
Expand Down
9 changes: 6 additions & 3 deletions global/src/matrix.c
Expand Up @@ -405,7 +405,8 @@ void pnga_median_patch(

if (!pnga_comp_patch (andim, loA, hiA, mndim, loM, hiM)) compatible = 1;
else compatible = 0;
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "*");
/* pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "*"); */
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "&&");
if (!compatible) {
/* either patches or distributions do not match:
* - create a temp array that matches distribution of g_a
Expand All @@ -422,7 +423,8 @@ void pnga_median_patch(

if (!pnga_comp_patch (bndim, loB, hiB, mndim, loM, hiM)) compatible = 1;
else compatible = 0;
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "*");
/* pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "*"); */
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "&&");
if (!compatible) {
/* either patches or distributions do not match:
* - create a temp array that matches distribution of g_a
Expand All @@ -439,7 +441,8 @@ void pnga_median_patch(

if (!pnga_comp_patch (cndim, loC, hiC, mndim, loM, hiM)) compatible = 1;
else compatible = 0;
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "*");
/* pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "*"); */
pnga_gop(pnga_type_f2c(MT_F_INT), &compatible, 1, "&&");
if (!compatible) {
/* either patches or distributions do not match:
* - create a temp array that matches distribution of g_a
Expand Down
6 changes: 4 additions & 2 deletions gparrays/testing/testc.c
Expand Up @@ -701,7 +701,8 @@ void do_work()
idx = 0;
}

GA_Igop(&idx,1,"*");
/* GA_Igop(&idx,1,"*"); */
GA_Igop(&idx,1,"&&");
if (idx == 1 && me == 0) {
printf("\nCompleted check of GP_Set_irreg_distr\n");
} else if (me == 0) {
Expand Down Expand Up @@ -732,7 +733,8 @@ void do_work()
me, hi3[2], dims3[2]-1);
idx = 0;
}
GA_Igop(&idx,1,"*");
/* GA_Igop(&idx,1,"*"); */
GA_Igop(&idx,1,"&&");
if (idx == 1 && me == 0) {
printf("\nCompleted check of GP_Set_chunk\n");
} else if (me == 0) {
Expand Down

0 comments on commit 4bad0bc

Please sign in to comment.