CDVM_DD (1158341), страница 2
Текст из файла (страница 2)
Check rank.
Node LX_TEMPL
"Static" template. Compare ranks of DISTRIBUTE-stuff and TEMPLATE-extents.
Nodes LX_SUM, LX_PROD, LX_MAX, LX_MIN, LX_OR, LX_AND, LX_MAXLOC, LX_MINLOC
Modify the name of function to the corresponding Lib-DVM's name. (Function ISWFrf.) Issue an error message if:
-
actual parameter is not identifier or indexed identifier,
-
reduction variable was not defined,
-
location variables undefined,
-
reduction variable has type other than int, long, float or double; simple or array.
Node XXdecl
Save declaration of formal parameters of "main" to pass them to Lib-DVM. (Function getarg.)
Node XXdcltr
Register new object in the current visibility scope. Check that:
-
distributed data are of type int, long, float or double, and not scalar;
-
DVM-pointers are declared as C pointers;
-
arrays of DVM-arrays are 1-dimentional;
-
other DVM-objects are defined as 'void *';
-
ranks of directive and declaration match;
Remember "static" DVM-array. (Function SAadd.)
(Function ISWFdcltr.)
Nodes LXfun, LXfunKR
It may be "A(i,j)", i.e. reference to dynamic DVM-array by means of macro A. So convert it to an indexed expression. (Function ISdinarr.)
Node XXexpr
If it is "<a>=malloc(..)" with distributed <a>, then check syntax of malloc's parameter. (Functions ISmalloc and ISWFmalloc.) Issues an error message if:
-
argument is not a product of dimensions and size of element:
d1*...dn*sizeof(...); -
number of dimensions does not match with rank of array.
Node LXIrg
Check whether it is declared as REDUCTION_GROUP. (Function ISWFrg.)
Node DVMbase
(Function ISWFbase.) Issue an error message if:
-
base is not defined,
-
base is not DVM-array,
-
base is more then identifier,
-
base in CREATE_TEMPLATE is not template, or is "static" template,
-
base in shadow group is template, or is already included into this group.
Node DVMvar
Variables if parallel loop nest are correct. (Function ISWFdvar.) Issues an error message if:
-
variable in loop header is not mentioned in PARALLEL directive,
-
order of variables violated,
-
loop nest is too deep.
Note. For all variables of PARALLEL directive were used it is sufficient that depth of the loop nest is correct.
Node DVMind
This is ALIGN or PARALLEL variables list. They can not duplicate in list. For PARALLEL they must present and should be declared and visible int or long variable. (Function ISWFind.)
Node DVMbind
That is align expression. Should be linear expression of align any variable. Every variable may be used at most once. (Function ISWFbind.)
Node DVMalign
Check rank. (Function ISWFalign.)
Node LXIsg
Check whether it is declared as SHADOW_GROUP. (Function ISWFsg)
Node DVMshw
Verify shadow width list. (Function ISWFshw.) Issue an error message if:
-
rank does not match,
-
width value exceeds declared or default maximum.
Node DVMshad
Verify shadows. (Function ISWFshad.) Issue an error message if:
-
rank does not match,
-
(warning for) useless
CORNERfor 1-dim array.
Node DVMremote
Check REMOTE_ACCESS patterns in directive: arrays must be declared and distributed and rank should match.
3.2 Transformation concerning "main"
Purpose.
Define whether "main" present in the current file. If so, save its formal parameters, convert operator return, mark first operator of "main". Collect list of global and local initializations (for data tracing).
3.2.1 Downward direction actions (mMAIN0)
Node ASS
If in declaration, so it is initializer. Add to local or global list for tracing of initialized variables. (Function DTadd.)
Node XXdecl
If it is declaration of "main", note it.
Node XXlist
Before the first operator of "main" insert
-
DVM_INITmacro, -
allocation of "static" DVM-arrays (function
cSAalloc), -
STV macro for initialized globals (function
cDTinit).
For other functions if necessary create
-
STV macro of initialized locals. (Function
cDTinit.)
3.2.2 Upward direction actions (mMAIN1)
Node RETURN
In "main" convert it to DVM_RETURN macro.
Node XXdecl
After completion of declaration of "main" check whether DVM_RETURN was generated.
Node XXexpr
If it is "p=malloc();" for distributed array p, convert this expression to calls to Lib-DVM. (Function mk_alloc.) Convert malloc for DVM-array to the following sequence declarations and operators (depending on declaration of array). If array is DISTRIBUTEd:
-
define implicit template (
AMViewRef DVM_AM;), -
create it (see function
mk_templ)
Then and if array is ALIGNed:
-
DVM_MALLOC(id,rank,elemsize,dims,lshws,hshws,redistr), -
DVM_ALIGN(id,AM,rank,i-s,a-s,b-s).
3.3 "IS_LOCAL" transformation
Purpose.
Provide access to distributed data in non-parallel branch with checking of data locality.
Node XXoper
If it is assignment operator not in parallel branch and target or assignment is an element of DVM-array than enclose it by the following construct:
{
if (DVM_IS_LOCAL(id,rank,inds,,,))
{
<operator>;
}
DVM_END_LOCAL();
}
(Function mk_local;)
3.4 Access transformation
Purpose.
Access to elements of distributed arrays should be done through array's DVM-handler by means of macro.
As separate pass in upward direction (mACC1).
Node LBK
Access to DVM-arrays should be converted to access through DVM- handler (Lib-DVM macros DAElm<n>), taking into account
-- command line option -d (i.e. data tracing -- use macros DVM_LDV and DVM_STV);
-- possible presence of REMOTE_ACCESS directive (redirect access to remote-access buffer). (Function mk_access.)
Node LXfun
In fact it may be "A(i,j)", i.e. reference to dynamic DVM-array by means of macro A. So it also should be converted. (Function DTdinarr.)
3.5 DVM-directive transformation
Purpose.
Convert non-declarative DVM-directives to appropriate sequence of operators and macros.
In downward direction (mDVM).
Node LX_REDISTR
Create DVM_REDISTRIBUTE macro.
Node LX_REALIGN
Create DVM_REALIGN macro. (Function getInds forms list of dummy variables and align expressions. Function mk_vab forms list of numbers of dummy variables, coefficients and constants if align expressions.)
Node LX_CRTEMP
Convert CREATE_TEMPLATE directive to sequence of macros
DVM_CREATE_TEMPLATE(id,rank,dims...)
DVM_DISTRIBUTE(id,rank,distr-mode...)
(Function mk_templ.) Uses distribution from declaration.
Node LX_PAR
Create operators for parallel loop:
[remote_access environment if necessary]
[DVM_REDUCTION(...)] -- for REDUCTION sub-directive
{
DVM_PARALLEL(loopid, looprank); // define loop handler
[other sub-directives make
DVM_PAR_SHADOW_START(shadow_group)
DVM_PAR_SHADOW_WAIT(shadow_group)
DVM_SHADOW_RENEW(...)
]
DVM_DO_ON(loopid, rank, headers information,
base, loop mapping information);
<DVM_FORs and body created by function cPARbody>
DVM_END_PARALLEL(loopid);
}
[DVM_END_REDUCTION(...)] if necessary
(Function cPARloop.)
Node LX_CRSG
Create DVM_CREATE_SHADOW_GROUP macro.
Node LX_SS
Create DVM_SHADOW_START macro.
Node LX_SW
Create DVM_SHADOW_WAIT macro.
Node LX_CRRG
Create DVM_CREATE_REDUCTION_GROUP macro.
Node LX_RS
Create DVM_REDUCTION_START macro.
Node LX_RW
Create DVM_REDUCTION_WAIT macro.
Node LX_REGION
Create DVM_BINTER and DVM_EINTER macros before and after operator.
Node LX_REMOTE
See function mk_remote.
Node LXfun
If necessary convert free() to DVM_FREE.
3.6 Data tracing transformation
Purpose.
Change references to variables and array elements by macros STV, STVA and LDV to trace access to data. Insert tracing or loop iterations.
Note that generated code contains the same identifier, so downward application of this transformation leads to infinite recursion.
Upward direction actions (mDT)
Nodes LXI, LBK
Depending on type of object and mode of tracing (-d option) create macro. (Function cDT2.)
Node ASS
Create trace macro for assignment. (Function stv2stva.)
Nodes LX_FOR, LX_DO
Create loop iteration trace macro. (Function cSEQloop.) Trace sequential loop (if necessary), i.e. insert macros:
DVM_BSLOOP, DVM_ELOOP for performance analyzer,
DVM_SLOOP, DVM_ITER, DVM_ENDLOOP for data tracer.
DVM_ITER macro into a sequential loop.
3.7 DVM-types and I/O transformation
Purpose. Change types of DVM-objects and rename I/O functions.
This actions may be performed in any direction. Note that in other transformations an initial type of object should be known. So the type may be changed only after all other is done.
Node LX_DISTR
Change type to handler type, i.e. long [rank+1]. (Function cSYSHr). For template type (void*) should be changed to AMRef. (Function cSYSH.)
Node LX_ALIGN
Change type to handler type, i.e. long [rank+1]. (Function cSYSHr).
Node LX_SG
Change void* to ShadowGroupRef. (Function cSYSH.)
Node LX_RG
Change void* to RedGroupRef. (Function cSYSH.)
Node LXI
Find in the list and returns initial or changed code. (Function Rename.) Renaming list is prepared by the function Reninit. Now it contains the following identifiers:
exit DVM_EXIT
FILE DVMFILE
clearerr dvm_clearerr
fclose dvm_fclose
feof dvm_feof
ferror dvm_ferror
fflush dvm_fflush
fgetc dvm_fgetc
fgetpos dvm_fgetpos
fgets dvm_fgets
fopen dvm_fopen
fprintf dvm_void_fprintf
fputc dvm_fputc
fputs dvm_fputs
fread dvm_fread
freopen dvm_freopen
fscanf dvm_fscanf
fseek dvm_fseek
fsetpos dvm_fsetpos
ftell dvm_ftell
fwrite dvm_fwrite
getc dvm_getc
getchar dvm_getchar
gets dvm_gets
printf dvm_void_printf
putc dvm_putc
putchar dvm_putchar
puts dvm_puts
rewind dvm_rewind















