home *** CD-ROM | disk | FTP | other *** search
- # include "Broadcas.h"
- # include "yyABroad.w"
- # include <stdio.h>
- # if defined __STDC__ | defined __cplusplus
- # include <stdlib.h>
- # else
- extern void exit ();
- # endif
- # include "Tree.h"
- # include "Definiti.h"
-
- # ifndef NULL
- # define NULL 0L
- # endif
- # ifndef false
- # define false 0
- # endif
- # ifndef true
- # define true 1
- # endif
-
- # ifdef yyInline
- # define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) \
- if ((ptr = (tree) free) >= (tree) max) ptr = alloc (); \
- free += nodesize [kind]; \
- ptr->yyHead.yyMark = 0; \
- ptr->Kind = kind;
- # else
- # define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) ptr = make (kind);
- # endif
-
- # define yyWrite(s) (void) fputs (s, yyf)
- # define yyWriteNl (void) fputc ('\n', yyf)
-
- # line 29 "AdaptBroadcast.puma"
-
-
- # include <stdio.h>
-
- # include "Idents.h"
- # include "StringMe.h"
-
- # include "protocol.h"
-
- # include "Types.h"
- # include "Expressi.h" /* MakeSliceExp */
- # include "Movement.h" /* FirstArrayElement */
- # include "Transfor.h" /* IsHost, MakeUsedVar... */
- # include "Dalib.h" /* IsHost, MakeUsedVar... */
- # include "Shapes.h" /* MakeFullShape */
-
-
- static FILE * yyf = stdout;
-
- static void yyAbort
- # ifdef __cplusplus
- (char * yyFunction)
- # else
- (yyFunction) char * yyFunction;
- # endif
- {
- (void) fprintf (stderr, "Error: module AdaptBroadcast, routine %s failed\n", yyFunction);
- exit (1);
- }
-
- tTree MakeParamBroadcast ARGS((tTree t));
- tTree MakeReadSpecBroadcast ARGS((tTree t));
- tTree MakeBroadcast ARGS((tTree t));
- static tTree Overlapping ARGS((tTree t));
- static tTree TakeWholeVar ARGS((tTree v));
-
- tTree MakeParamBroadcast
- # if defined __STDC__ | defined __cplusplus
- (register tTree t)
- # else
- (t)
- register tTree t;
- # endif
- {
- # line 56 "AdaptBroadcast.puma"
-
- tTree h, newacf;
- int dist;
-
- if (t->Kind == kBTP_LIST) {
- # line 61 "AdaptBroadcast.puma"
- return CombineACF (MakeParamBroadcast (t->BTP_LIST.Elem), MakeParamBroadcast (t->BTP_LIST.Next));
-
- }
- if (t->Kind == kBTP_EMPTY) {
- # line 65 "AdaptBroadcast.puma"
- return (NoTree);
-
- }
- if (t->Kind == kVAR_PARAM) {
- if (t->VAR_PARAM.V->Kind == kADDR) {
- # line 69 "AdaptBroadcast.puma"
- return NoTree;
-
- }
- # line 77 "AdaptBroadcast.puma"
- {
- # line 78 "AdaptBroadcast.puma"
- if (! ((target_model == UNI_PROC))) goto yyL4;
- }
- return NoTree;
- yyL4:;
-
- if (t->VAR_PARAM.V->Kind == kUSED_VAR) {
- if (t->VAR_PARAM.V->USED_VAR.VARNAME->VAR_OBJ.Object->Kind == kVarObject) {
- if (t->VAR_PARAM.V->USED_VAR.VARNAME->VAR_OBJ.Object->VarObject.Kind->Kind == kVarConstant) {
- # line 82 "AdaptBroadcast.puma"
- return NoTree;
-
- }
- }
- }
- # line 89 "AdaptBroadcast.puma"
- {
- # line 90 "AdaptBroadcast.puma"
- dist = TreeDistribution (t->VAR_PARAM.V);
- if (dist == -1)
- {
- newacf = NoTree;
- }
- else if (dist == 0)
- {
- newacf = MakeBroadcast (t->VAR_PARAM.V);
- }
- else
- { printf ("Illegal Distribution in MakeParamBroadcast\n");
- exit (-1);
- }
-
- }
- return newacf;
-
- }
- if (t->Kind == kFUNC_PARAM) {
- # line 113 "AdaptBroadcast.puma"
- return NoTree;
-
- }
- if (t->Kind == kPROC_PARAM) {
- # line 117 "AdaptBroadcast.puma"
- return NoTree;
-
- }
- # line 121 "AdaptBroadcast.puma"
- {
- # line 122 "AdaptBroadcast.puma"
- failure_protocol ("AdaptBroadcast", "MakeParamBroadcast", t);
- }
- return NoTree;
-
- }
-
- tTree MakeReadSpecBroadcast
- # if defined __STDC__ | defined __cplusplus
- (register tTree t)
- # else
- (t)
- register tTree t;
- # endif
- {
-
- switch (t->Kind) {
- case kBTP_LIST:
- # line 138 "AdaptBroadcast.puma"
- return CombineACF (MakeReadSpecBroadcast (t->BTP_LIST.Elem), MakeReadSpecBroadcast (t->BTP_LIST.Next));
-
- case kBTP_EMPTY:
- # line 143 "AdaptBroadcast.puma"
- return NoTree;
-
- case kNAMED_PARAM:
- # line 147 "AdaptBroadcast.puma"
- return MakeReadSpecBroadcast (t->NAMED_PARAM.VAL);
-
- case kVAR_PARAM:
- # line 151 "AdaptBroadcast.puma"
- {
- # line 152 "AdaptBroadcast.puma"
- if (! ((target_model == UNI_PROC))) goto yyL4;
- }
- return NoTree;
- yyL4:;
-
- if (t->VAR_PARAM.V->Kind == kUSED_VAR) {
- if (t->VAR_PARAM.V->USED_VAR.VARNAME->VAR_OBJ.Object->Kind == kNameListObject) {
- if (t->VAR_PARAM.V->USED_VAR.VARNAME->VAR_OBJ.Object->NameListObject.decl->Kind == kNAMELIST_DECL) {
- # line 156 "AdaptBroadcast.puma"
- return MakeReadSpecBroadcast (t->VAR_PARAM.V->USED_VAR.VARNAME->VAR_OBJ.Object->NameListObject.decl->NAMELIST_DECL.IDS);
-
- }
- }
- }
- # line 163 "AdaptBroadcast.puma"
- return NoTree;
-
- case kDECL_LIST:
- # line 167 "AdaptBroadcast.puma"
- return CombineACF (MakeReadSpecBroadcast (t->DECL_LIST.Elem), MakeReadSpecBroadcast (t->DECL_LIST.Next));
-
- case kDECL_EMPTY:
- # line 172 "AdaptBroadcast.puma"
- return NoTree;
-
- case kVAR_DECL:
- # line 176 "AdaptBroadcast.puma"
- {
- int dist;
- tDefinitions Obj;
- tTree var;
- {
- # line 180 "AdaptBroadcast.puma"
-
- # line 181 "AdaptBroadcast.puma"
-
- # line 182 "AdaptBroadcast.puma"
-
- # line 184 "AdaptBroadcast.puma"
- Obj = GetLocalDecl (t->VAR_DECL.Name);
- # line 186 "AdaptBroadcast.puma"
- dist = VarDistribution (Obj);
- if (dist == -1)
- {
- var = NoTree;
- }
- else if (dist == 0)
- {
- var = mVAR_OBJ (t->VAR_DECL.Pos, t->VAR_DECL.Name);
- var->VAR_OBJ.Object = Obj;
- var = MakeBroadcast (mUSED_VAR (var));
- }
- else
- { printf ("Illegal Distribution in MakeReadSpecBroadcast\n");
- exit (-1);
- }
-
- }
- {
- return var;
- }
- }
-
- }
-
- # line 205 "AdaptBroadcast.puma"
- {
- # line 206 "AdaptBroadcast.puma"
- failure_protocol ("AdaptBroadcast", "MakeReadSpecBroadcast", t);
- }
- return NoTree;
-
- }
-
- tTree MakeBroadcast
- # if defined __STDC__ | defined __cplusplus
- (register tTree t)
- # else
- (t)
- register tTree t;
- # endif
- {
- # line 220 "AdaptBroadcast.puma"
-
- tTree from, size, stat, broadcast_var;
- tIdent pname;
- int sends;
-
- # line 228 "AdaptBroadcast.puma"
- {
- # line 229 "AdaptBroadcast.puma"
- broadcast_var = Overlapping (t);
-
- if (TreeRank(broadcast_var) >= 1)
- broadcast_var = MakeFullShape (broadcast_var);
- if (target_model == ONLY_NODE)
- sends = 1;
- else
- sends = 0;
- from = mVAR_PARAM (mADDR (mCONST_EXP (mINT_CONSTANT (sends))));
- size = ExpToVarParam (MakeSizeExp (broadcast_var));
- if (TreeRank(broadcast_var) >= 1)
- broadcast_var = FirstArrayElement (broadcast_var);
- pname = MakeDalibId ("broadcast");
- stat = mCALL_STMT (
- mPROC_OBJ (pname),
- mBTP_LIST (mVAR_PARAM (broadcast_var),
- mBTP_LIST (size,
- mBTP_LIST (from,
- mBTP_EMPTY ()))));
- stat = mACF_BASIC (stat);
-
- }
- return stat;
-
- }
-
- static tTree Overlapping
- # if defined __STDC__ | defined __cplusplus
- (register tTree t)
- # else
- (t)
- register tTree t;
- # endif
- {
- if (t->Kind == kDO_VAR) {
- if (t->DO_VAR.BODY->Kind == kBTV_LIST) {
- if (t->DO_VAR.BODY->BTV_LIST.Next->Kind == kBTV_EMPTY) {
- # line 263 "AdaptBroadcast.puma"
- return TakeWholeVar (t->DO_VAR.BODY->BTV_LIST.Elem);
-
- }
- # line 270 "AdaptBroadcast.puma"
- {
- # line 272 "AdaptBroadcast.puma"
- error_protocol ("Broadcast: Too many variables in the variable list");
- }
- return TakeWholeVar (t->DO_VAR.BODY->BTV_LIST.Elem);
-
- }
- }
- if (t->Kind == kINDEXED_VAR) {
- # line 276 "AdaptBroadcast.puma"
- {
- # line 277 "AdaptBroadcast.puma"
- if (! (IsContiguousSection (t) == true)) goto yyL3;
- }
- return t;
- yyL3:;
-
- # line 283 "AdaptBroadcast.puma"
- return t->INDEXED_VAR.IND_VAR;
-
- }
- if (t->Kind == kUSED_VAR) {
- # line 288 "AdaptBroadcast.puma"
- return t;
-
- }
- # line 292 "AdaptBroadcast.puma"
- {
- # line 293 "AdaptBroadcast.puma"
- failure_protocol ("AdaptBroadcast", "Overlapping", t);
- }
- return t;
-
- }
-
- static tTree TakeWholeVar
- # if defined __STDC__ | defined __cplusplus
- (register tTree v)
- # else
- (v)
- register tTree v;
- # endif
- {
- if (v->Kind == kINDEXED_VAR) {
- # line 305 "AdaptBroadcast.puma"
- return v->INDEXED_VAR.IND_VAR;
-
- }
- if (v->Kind == kUSED_VAR) {
- # line 309 "AdaptBroadcast.puma"
- return v;
-
- }
- if (v->Kind == kDO_VAR) {
- if (v->DO_VAR.BODY->Kind == kBTV_LIST) {
- if (v->DO_VAR.BODY->BTV_LIST.Next->Kind == kBTV_EMPTY) {
- # line 313 "AdaptBroadcast.puma"
- return TakeWholeVar (v->DO_VAR.BODY->BTV_LIST.Elem);
-
- }
- # line 320 "AdaptBroadcast.puma"
- {
- # line 322 "AdaptBroadcast.puma"
- error_protocol ("Broadcast: Too many variables in the variable list");
- }
- return TakeWholeVar (v->DO_VAR.BODY->BTV_LIST.Elem);
-
- }
- }
- # line 326 "AdaptBroadcast.puma"
- {
- # line 327 "AdaptBroadcast.puma"
- failure_protocol ("AdaptBroadcast", "TakeWholeVar", v);
- }
- return v;
-
- }
-
- void BeginAdaptBroadcast ()
- {
- }
-
- void CloseAdaptBroadcast ()
- {
- }