6
* This file contains some data parallel GA operations that are not part of
7
* the official GA distribution.
10
* Author: Jarek Nieplocha
20
#define ga_idot_ F77_FUNC_(ga_idot,GA_IDOT)
22
#define DRA_TYPE_GSM 32760 - 6
25
* Integer version of ga_ddot
27
Integer ga_idot_(Integer *g_a, Integer *g_b)
29
Integer atype, adim1, adim2, btype, bdim1, bdim2, ald, bld;
30
Integer ailo,aihi, ajlo, ajhi, bilo, bihi, bjlo, bjhi;
33
Integer index_a, index_b;
39
ga_check_handle(g_a, "ga_idot");
40
ga_check_handle(g_b, "ga_idot");
42
ga_inquire_(g_a, &atype, &adim1, &adim2);
43
ga_inquire_(g_b, &btype, &bdim1, &bdim2);
45
if(atype != btype || atype != MT_F_INT)
46
ga_error("ga_idot: types not correct", 0L);
48
if (adim1!=bdim1 || adim2 != bdim2)
49
ga_error("ga_idot: arrays not conformant", 0L);
51
if (DBL_MB == (DoublePrecision*)0 || INT_MB == (Integer*)0)
52
ga_error("ga_idot: null pointer for base array",0L);
54
ga_distribution_(g_a, &me, &ailo, &aihi, &ajlo, &ajhi);
55
ga_distribution_(g_b, &me, &bilo, &bihi, &bjlo, &bjhi);
57
if (ailo!=bilo || aihi != bihi || ajlo!=bjlo || ajhi != bjhi){
59
fprintf(stderr,"\nme =%d: %d-%d %d-%d vs %d-%d %d-%d dim:%dx%d\n",me,
60
ailo,aihi, ajlo, ajhi, bilo, bihi, bjlo, bjhi,adim1,adim2);
62
ga_error("ga_idot: distributions not identical",0L);
66
if ( aihi>0 && ajhi>0 ){
67
ga_access_(g_a, &ailo, &aihi, &ajlo, &ajhi, &index_a, &ald);
69
index_b = index_a; bld =ald;
71
ga_access_(g_b, &bilo, &bihi, &bjlo, &bjhi, &index_b, &bld);
73
index_a --; /* Fortran to C correction of starting address */
74
index_b --; /* Fortran to C correction of starting address */
77
/* compute "local" contribution to the dot product */
78
for(j=0; j<ajhi-ajlo+1; j++)
79
for(i=0; i<aihi-ailo+1; i++)
80
sum += INT_MB[index_a +j*ald + i] *
81
INT_MB[index_b +j*bld + i];
83
/* release access to the data */
84
ga_release_(g_a, &ailo, &aihi, &ajlo, &ajhi);
85
ga_release_(g_b, &bilo, &bihi, &bjlo, &bjhi);
88
ga_igop((Integer)DRA_TYPE_GSM, &sum, (Integer)1, "+");