Download PARRAY User`s Manual (v1.2)

Transcript
19
$parray {dmem int #DAT} DMEM
20
int *a ,*b ,*c1 ,* c2;
21
$main {
22
$malloc DAT(a,b,c1 ,c2)
23
$for DAT(a,b,c1 ,c2) { *a=rand ()%10; *b=rand ()%10; *c1 =0; *c2 =0; }
24
$for pthd [4] {
25
$gemm (a,$MAT ,b,$MAT ,c1 ,$MAT)
26
}
27
_PA_INIT_GPU (0);
28
$create DMEM(da ,db ,dc)
29
$copy DAT(a),DAT(b),DAT(c2) to DMEM(da),DMEM(db),DMEM(dc)
30
$for cuda [2][8] as(int* da , int* db , int* dc ){
31
$gemm (da ,$MAT ,db ,$MAT ,dc ,$MAT)
32
}
33
$copy DMEM(dc) to DAT(c2)
34
$for DAT(c1 ,c2) { if ((* c1 )!=(* c2 )) { printf (" ERROR \n"); exit (1);} }
35
$destroy DMEM(da ,db ,dc), DAT(a,b,c1 ,c2)
36
}
6.2
PARRAYIncluded Library (include)
A PARRAY library is a file containing PARRAY code. The command to incorporate a PARRAY library has
the following command:
$include ’’filename’’
where filename is the name of the library file. The library file is included in the program text during PARRAY
preprocessing. That means the PARRAY commands in a library file are parsed and compiled. The similar C
directive command “#include”, however, is a pure C notation and will be ignored by the preprocessor and only
processed during C compilation. As a convention, a PARRAY library usually has suffix extension “.pa”.
The inclusion of the system-pre-defined library “parray.pa” is obligatory before the C’s main function. It
contains the basic array types and basic sub-programs such as “ PA Copy”. User’s own libraries can be included
anywhere in a program.
6.3
Preprocessed Expressions (eval)
During preprocessing, PARRAY can evaluate some integer expressions with the command:
$eval(parray exp).
57