cdvmLDe (1158334), страница 9
Текст из файла (страница 9)
B1[i][j] = 0.f;
} else {
B1[i][j] = 1.f + i + j ;
A1[i][j] = B1[i][j];
}}
DVM(PARALLEL [i][j] ON A2[i][j])
FOR(i,N2+1)
FOR(j,K)
{if(i == N2 || j==0 || j==K-1) {
A2[i][j] = 0.f;
B2[i][j] = 0.f;
} else {
B2[i][j] = 1.f + ( i + N1 - 1 ) + j ;
A2[i][j] = B2[i][j];
}}
DO(it,1,ITMAX,1)
{
eps0 = 0.;
/* exchange bounds */
DVM(PARALLEL [j] ON A1[(N1)][j]; REMOTE_ACCESS B2[1][])
FOR(j,K) A1[N1][j] = B2[1][j];
DVM(PARALLEL [j] ON A2[0][j]; REMOTE_ACCESS B1[N1-1][])
FOR(j,K) A2[0][j] = B1[N1-1][j];
/* Block task region */
DVM(TASK_REGION MB; REDUCTION MAX(eps0))
{
DVM(ON MB[0])
{
double eps=0.; /* private reduction variable */
DVM(PARALLEL [i][j] ON B1[i][j]; SHADOW_RENEW A1[][])
DO(i,1, N1-1, 1)
DO(j,1, K-2, 1)
B1[i][j]=(A1[i-1][j]+A1[i][j-1]+A1[i+1][j]+A1[i][j+1])/4.f;
DVM(PARALLEL [i][j] ON A1[i][j]; REDUCTION MAX(eps))
DO(i,1,N1-1,1)
DO(j,1,K-2,1)
{eps = Max(fabs(B1[i][j]-A1[i][j]),eps);
A1[i][j] = B1[i][j];
}
eps0=Max(eps0,eps);
}
DVM(ON MB[1])
{
double eps=0.; /* private reduction variable */
DVM(PARALLEL [i][j] ON B2[i][j]; SHADOW_RENEW A2[][])
DO(i,1,N2-1,1)
DO(j,1,K-2,1)
B2[i][j]=(A2[i-1][j]+A2[i][j-1]+A2[i+1][j]+A2[i][j+1])/4.f;
DVM(PARALLEL [i][j] ON A2[i][j]; REDUCTION MAX(eps))
DO(i,1,N2-1,1)
DO(j,1,K-2,1)
{eps = Max(fabs(B2[i][j]-A2[i][j]),eps);
A2[i][j] = B2[i][j];
}
eps0=Max(eps0,eps);
}
} /* TASK_REGION */
printf("it=%d eps0=%f\n",it,eps0);
}/* DO IT */
return 0;
}
Appendix 2. Syntax summary
directive | ::= DVM ( DVM-directive [ ; DVM-directive ] ) | ||||||
DVM-directive | ::= specification-directive | ||||||
| executable-directive | |||||||
specification-directive | ::= processors-directive | ||||||
| align-directive | |||||||
| distribute-directive | |||||||
| template-directive | |||||||
| shadow-directive | |||||||
| shadow-group-directive | |||||||
| reduction-group-directive | |||||||
| remote-group-directive | |||||||
| task-directive | |||||||
executable-directive | ::= realign-directive | ||||||
| redistribute-directive | |||||||
| create-template-directive | |||||||
| parallel-directive | |||||||
| remote-access-directive | |||||||
| create-shadow-group-directive | |||||||
| shadow-start-directive | |||||||
| shadow-wait-directive | |||||||
| reduction-start-directive | |||||||
| reduction-wait-directive | |||||||
| prefetch-directive | |||||||
| reset-directive | |||||||
| map-directive | |||||||
| task-region-directive | |||||||
| on-directive | |||||||
processors-directive | ::= PROCESSORS | ||||||
distribute-directive | ::= DISTRIBUTE [ dist-directive-stuff ] | ||||||
redistribute-directive | ::= REDISTRIBUTE distributee dist-directive-stuff [ NEW ] | ||||||
dist-directive-stuff | ::= dist-format... [ dist-onto-clause ] | ||||||
distributee | ::= array-name | ||||||
dist-format | ::= [BLOCK] | ||||||
| [GENBLOCK ( block-array-name )] | |||||||
| [WGTBLOCK ( block-array-name,nblock )] | |||||||
dist-onto-clause | ::= ONTO dist-target | ||||||
dist-target | ::= processors-name [ section-subscript ]… | ||||||
align-directive | ::= ALIGN [ align-directive-stuff ] | ||||||
realign-directive | ::= REALIGN | ||||||
align-directive-stuff | ::= align-source... align-with-clause | ||||||
alignee | ::= array-name | ||||||
align-source | ::= [ ] | ||||||
| [ align-dummy ] | |||||||
align-dummy | ::= scalar-int-variable | ||||||
align-with-clause | ::= WITH align-spec | ||||||
align-spec | ::= align-target [ align-subscript ]… | ||||||
align-target | ::= array-name | ||||||
| template-name | |||||||
align-subscript | ::= [ int-expr ] | ||||||
| [ align-subscript-use ] | |||||||
| [ ] | |||||||
align-subscript-use | ::= [ primary-expr * ] align‑dummy | ||||||
primary-expr | ::= int-constant | ||||||
| int-variable | |||||||
| ( int-expr ) | |||||||
add-op | ::= + | ||||||
| - | |||||||
create-template-directive | ::= CREATE_TEMPLATE | ||||||
parallel-directive | ::= PARALLEL loop-variable... | ||||||
iteration-align-spec | ::= align-target iteration-align-subscript... | ||||||
iteration-align-subscript | ::= [ int-expr ] | ||||||
| [ do-variable-use ] | |||||||
| [] | |||||||
loop-variable | ::= [ do-variable ] | ||||||
do-variable-use | ::= [ primary-expr * ] do-variable | ||||||
reduction-clause | ::= REDUCTION [ group_name : ] reduction-op... | ||||||
reduction-op | ::= reduction-op-name ( reduction-variable ) | ||||||
| reduction-loc-name ( reduction-variable, loc-variable ) | |||||||
reduction-variable | ::= array-name | ||||||
| scalar-variable-name | |||||||
reduction-op-name | ::= SUM | ||||||
| PRODUCT | |||||||
| MAX | |||||||
| MIN | |||||||
| AND | |||||||
| OR | |||||||
reduction-loc-name | ::= MAXLOC | ||||||
| MINLOC | |||||||
across-clause | ::= ACROSS dependent-array... | ||||||
dependent-array | ::= dist-array-name dependence... | ||||||
dependence | ::= [ flow-dep-length : anti-dep-length ] | ||||||
flow-dep-length | ::= int-constant | ||||||
anti-dep-length | ::= int-constant | ||||||
shadow-directive | ::= SHADOW shadow-array... | ||||||
shadow-array | ::= array-name shadow-edge... | ||||||
shadow-edge | ::= [ width ] | ||||||
| [ low-width : high-width ] | |||||||
width | ::= int-expr | ||||||
low-width | ::= int-expr | ||||||
high-width | ::= int-expr | ||||||
shadow-renew-clause | ::= SHADOW_RENEW renewee... | ||||||
renewee | ::= dist-array-name [ shadow-edge ]… [CORNER] | ||||||
remote-access-directive | ::= REMOTE_ACCESS | ||||||
regular-reference | ::= dist-array-name [ regular-subscript ]… | ||||||
regular-subscript | ::= [ int-expr ] | ||||||
| [ do-variable-use ] | |||||||
| [ ] | |||||||
remote-access-clause | ::= remote-access-directive | ||||||
prefetch-directive | ::= PREFETCH group-name | ||||||
reset-directive | ::= RESET group-name | ||||||
shadow-group-directive | ::= CREATE_SHADOW_GROUP | ||||||
shadow-start-directive | ::= SHADOW_START shadow-group-name | ||||||
shadow-wait-directive | ::= SHADOW_WAIT shadow-group-name | ||||||
shadow-renew-clause | ::= . . . | ||||||
| shadow-start-directive | |||||||
| shadow-wait-directive | |||||||
reduction-group-directive | ::= REDUCTION_GROUP | ||||||
reduction-start-directive | ::= REDUCTION_START reduction-group-name | ||||||
reduction-wait-directive | ::= REDUCTION_WAIT reduction-group-name | ||||||
task-directive | ::= TASK | ||||||
map-directive | ::= MAP task-name [ task-index ] | ||||||
ONTO processors-name [ section-subscript ]… | |||||||
dist-target | ::= . . . | ||||||
| task-name [ task-index ] | |||||||
block-task-region | ::= DVM( task-region-directive ) { | ||||||
on-block... | |||||||
} | |||||||
task-region-directive | ::= TASK_REGION task-name [ ; reduction-clause] | ||||||
on-block | ::= DVM( on-directive ) operator | ||||||
on-directive | ::= ON task-name [ task-index ] | ||||||
loop-task-region | ::= DVM( task-region-directive ) { | ||||||
parallel-task-loop | |||||||
} | |||||||
parallel-task-loop | ::= DVM( parallel-task-loop-directive ) | ||||||
do-loop | |||||||
parallel-task-loop-directive | ::= PARALLEL [ do-variable ] |
copy-flag-directive | ::= COPY_FLAG |
copy-start-directive | ::= COPY_START flag_addr |
copy-wait-directive | ::= COPY_WAIT flag_addr |
copy-directive | ::= COPY |