From 4bad0bc6c26cba738085fee2ae0abc56448060f8 Mon Sep 17 00:00:00 2001 From: Jeff Hammond Date: Thu, 1 Jun 2017 12:58:09 -0700 Subject: [PATCH] global replace * reductions with && reductions 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. --- cca/ga_cca_classic/overload.cxx | 3 ++- global/src/base.c | 15 ++++++++++----- global/src/elem_alg.c | 12 ++++++++---- global/src/global.npatch.c | 9 ++++++--- global/src/matrix.c | 9 ++++++--- gparrays/testing/testc.c | 6 ++++-- 6 files changed, 36 insertions(+), 18 deletions(-) diff --git a/cca/ga_cca_classic/overload.cxx b/cca/ga_cca_classic/overload.cxx index b1680f4fa..73784fd78 100644 --- a/cca/ga_cca_classic/overload.cxx +++ b/cca/ga_cca_classic/overload.cxx @@ -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; } diff --git a/global/src/base.c b/global/src/base.c index 92e80db67..5a9f6684a 100644 --- a/global/src/base.c +++ b/global/src/base.c @@ -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; @@ -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; @@ -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; diff --git a/global/src/elem_alg.c b/global/src/elem_alg.c index 9c002ba40..2b3522ffe 100644 --- a/global/src/elem_alg.c +++ b/global/src/elem_alg.c @@ -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 @@ -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 @@ -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); } @@ -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); } diff --git a/global/src/global.npatch.c b/global/src/global.npatch.c index 0d6a93d41..1995317b6 100644 --- a/global/src/global.npatch.c +++ b/global/src/global.npatch.c @@ -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 @@ -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; diff --git a/global/src/matrix.c b/global/src/matrix.c index f5cb3cc28..67f552f34 100644 --- a/global/src/matrix.c +++ b/global/src/matrix.c @@ -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 @@ -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 @@ -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 diff --git a/gparrays/testing/testc.c b/gparrays/testing/testc.c index a83fb1748..5775049e6 100644 --- a/gparrays/testing/testc.c +++ b/gparrays/testing/testc.c @@ -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) { @@ -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) {