1
/*****************************************************************************\
2
This file contains some data parallel GA operations that are not part of
3
the official GA distribution.
6
Author: Jarek Nieplocha
7
\*****************************************************************************/
14
# define ga_idot_ GA_IDOT
18
/*\ Integer version of ga_ddot
20
Integer ga_idot_(g_a, g_b)
23
Integer atype, adim1, adim2, btype, bdim1, bdim2, ald, bld;
24
Integer ailo,aihi, ajlo, ajhi, bilo, bihi, bjlo, bjhi;
27
Integer index_a, index_b;
28
#define GA_TYPE_GSM 32760 - 6
34
ga_check_handle(g_a, "ga_idot");
35
ga_check_handle(g_b, "ga_idot");
37
ga_inquire_(g_a, &atype, &adim1, &adim2);
38
ga_inquire_(g_b, &btype, &bdim1, &bdim2);
40
if(atype != btype || atype != MT_F_INT)
41
ga_error("ga_idot: types not correct", 0L);
43
if (adim1!=bdim1 || adim2 != bdim2)
44
ga_error("ga_idot: arrays not conformant", 0L);
46
if (DBL_MB == (DoublePrecision*)0 || INT_MB == (Integer*)0)
47
ga_error("ga_idot: null pointer for base array",0L);
49
ga_distribution_(g_a, &me, &ailo, &aihi, &ajlo, &ajhi);
50
ga_distribution_(g_b, &me, &bilo, &bihi, &bjlo, &bjhi);
52
if (ailo!=bilo || aihi != bihi || ajlo!=bjlo || ajhi != bjhi){
54
fprintf(stderr,"\nme =%d: %d-%d %d-%d vs %d-%d %d-%d dim:%dx%d\n",me,
55
ailo,aihi, ajlo, ajhi, bilo, bihi, bjlo, bjhi,adim1,adim2);
57
ga_error("ga_idot: distributions not identical",0L);
61
if ( aihi>0 && ajhi>0 ){
62
ga_access_(g_a, &ailo, &aihi, &ajlo, &ajhi, &index_a, &ald);
64
index_b = index_a; bld =ald;
66
ga_access_(g_b, &bilo, &bihi, &bjlo, &bjhi, &index_b, &bld);
68
index_a --; /* Fortran to C correction of starting address */
69
index_b --; /* Fortran to C correction of starting address */
72
/* compute "local" contribution to the dot product */
73
for(j=0; j<ajhi-ajlo+1; j++)
74
for(i=0; i<aihi-ailo+1; i++)
75
sum += INT_MB[index_a +j*ald + i] *
76
INT_MB[index_b +j*bld + i];
78
/* release access to the data */
79
ga_release_(g_a, &ailo, &aihi, &ajlo, &ajhi);
80
ga_release_(g_b, &bilo, &bihi, &bjlo, &bjhi);
83
ga_igop((Integer)GA_TYPE_GSM, &sum, (Integer)1, "+");