rtsIDe (1158448), страница 26
Текст из файла (страница 26)
length of data dependence for dimension 1 */
lshwdth[1] = FDL2; /* width of low shadow edge for dimension 2 is
length of data dependence for dimension 2 */
hshwdth[0] = ADL1; /* width of high shadow edge for
dimension 1 is length of data
anti-dependence for dimension 1 */
hshwdth[1] = ADL2; /* width of high shadow edge for
dimension 2 is length of data
anti-dependence for dimension 2 */
crtda_ (Ahdr, &ExtHdrSign, NULL, &Rank2, &TypeSize, amdim,
&StaticDA, &ReDistrDA, lshwdth, hshwdth);
axis[0] = 1;
axis[1] = 2;
coeff[0] = 1;
coeff[1] = 1;
cnst[0] = 0;
cnst[1] = 0;
align_ (Ahdr,&mvref,axis,coeff,cnst);
/* Parallel loop of array initialization
with regular data dependence */
plref = crtpl_ (&Rank2);
lvaddr[0] = (AddrType)&j;
lvaddr[1] = (AddrType)&i;
iiniti[0] = 0;
iiniti[1] = 0;
ilasti[0] = k - 1;
ilasti[1] = k - 1;
istep[0] = 1;
istep[1] = 1;
mappl_ (&plref, (PatternRef *)Ahdr, axis, coeff, cnst, lvaddr,
lvtype, iiniti, ilasti, istep, oiniti, olasti, ostep);
while (dopl_ (&plref))
for ( j = oiniti[0]; j <= olasti[0]; j += ostep[0] )
for ( i = oiniti[1]; i <= olasti[1]; i += ostep[1] )
DAElm2(Ahdr, float, j, i) = 1.f;
endpl_ (&plref);
/* Creation of shadow edge group
to support data anti-dependence */
ashgref = crtshg_ (&StaticShG);
lshwdth[0] = 0; /* zero width of low shadow edge for dimension 1 */
lshwdth[1] = 0; /* zero width of low shadow edge for dimension 2 */
hshwdth[0] = ADL1; /* width of high shadow edge for
dimension 1 is length of data anti-dependence
for dimension 1 */
hshwdth[1] = ADL2; /* width of high shadow edge
for dimension 2 is length
of data anti-dependence for dimension 2 */
inssh_ (&ashgref, Ahdr, lshwdth, hshwdth, &FullShd);
/* Initialization of shadow edges to support
data anti-dependence */
strtsh_ (&ashgref);
waitsh_ (&ashgref);
/* Creation of shadow edge group
to support data dependence */
fshgref = crtshg_ (&StaticShG);
lshwdth[0] = FDL1; /* width of low shadow edge for
dimension 1 is length of data
dependence for dimension 1 */
lshwdth[1] = FDL2; /* width of low shadow edge for
dimension 2 is length of data
dependence for dimension 2 */
hshwdth[0] = 0; /* zero width of high shadow
edge for dimension 1 */
hshwdth[1] = 0; /* zero width of high shadow
edge for dimension 2 */
if(f_inssh) /* inssh_ or insshd_ function is used */
{
/* inssh_ is used to registrate array in shadow edge group */
inssh_ (&fshgref, Ahdr, lshwdth, hshwdth, &FullShd);
}
else
{
/* insshd_ is used to registrate array in shadow edge group */
ShdSignArray[0] = 3; /* only low shadow edge is
used for dimension 1 */
ShdSignArray[1] = 3; /* only low shadow edge is
used for dimension 2 */
insshd_ (&fshgref, Ahdr, lshwdth, hshwdth, &MaxShdCount,
ShdSignArray);
}
/* Receiving imported elements to support data dependence */
recvsh_ (&fshgref);
waitsh_ (&fshgref);
/* PARALLEL LOOP WITH DATA DEPENDENCE AND
ANTI-DEPENDENCE BETWEEN ITERATIONS */
plref = crtpl_ (&Rank2);
iiniti[0] = 1;
iiniti[1] = 1;
ilasti[0] = k - 2;
ilasti[1] = k - 2;
mappl_ (&plref, (PatternRef *)Ahdr, axis, coeff, cnst, lvaddr,
lvtype, iiniti, ilasti, istep, oiniti, olasti, ostep);
while (dopl_ (&plref))
for ( j = oiniti[0]; j <= olasti[0]; j += ostep[0] )
for ( i = oiniti[1]; i <= olasti[1]; i += ostep[1] )
DAElm2(Ahdr, float, j, i) =
( DAElm2(Ahdr, float, j, i-FDL2) +
DAElm2(Ahdr, float, j-FDL1, i) +
DAElm2(Ahdr, float, j, i+ADL2) +
DAElm2(Ahdr, float, j+ADL1, i) ) / 4.f;
endpl_ (&plref);
/* Sending exported elements to support data dependence */
sendsh_ (&fshgref);
waitsh_ (&fshgref);
/* Writing result array into the file
and Run-Time System termination */
OutFile = dvm_fopen("across.dat", "w+b");
if(OutFile)
{ dvm_dfwrite(Ahdr, 0, OutFile);
dvm_fclose(OutFile);
}
lexit_ (&UserRes);
return (int)UserRes;
}















