Subject: New version of 1.73 & new PASS

From: Zheng Gengbin <[email-masked]>
Date: Tue, 18 Feb 1997 14:28:55 +0800 (EAT)

After a winter summer , we finaly can access the internet today.

	Here I have put a new version 1.73 , this version , I made dramatic
changes . Here is a brief introduction :

	1. /include  :  add some lines in *.def to define some tags .

	2. /hpfsc    :  new semantic checks and modification are added .

	3. /xsageop  :  I have improved this xsageop by adding some new 
			methods and correcting some bugs.

	4. /dump     :  found a little bug , and removed .

	and some other minor changes in transG and hppf2dep .

	I  wrote a new pass these days , and put it in this frontend .
This pass which must be done before transG , will solve many problems
of transG , and make the things which should  be considered in tarnsG easier.

	After this new pass , we can assume these things :

1. Every array is aligned directly with a Template .  This means
   the align trees are collapesed to the root ,and default template is 
   created if the align root is not a template.

2. All Templates have been distributed onto certain processors . new
   processors are created if necessary . and all distribute statements
   are made complete (by adding default dist_format or dist_target).

3. All the aign_spec is convert to a*X+b uniform .

4. No unused template exists .

( NO inherit is considered now ! )

	I will improve the align statent analyse in transG next step ,
because I found there are some problems , first transG assume the array
is align one dimension by one ,and no collapse is allowed ,and we cannot 
assume that alignee have same dimension with aligner . 

	Also I have some questions :
1. what 's our method to handle the duplicate align , when a * appears
   in the align with clause ?
2. how can we handle if the align source is an int_expr ?
3. and how we handle the scalar variables ?

thanks .

Zheng

---

From: Zheng Gengbin <[email-masked]>
Date: Wed, 19 Feb 1997 13:24:27 +0800 (EAT)

On Tue, 18 Feb 1997, Xiaoming Li wrote:

> 
> May I assume all the bugs in hpfsc I reported have been fixed in the new 
> version ?
>

	Except the 2 bugs concerned EQUIVALENCE and COMMON , all the bugs
have been fixed .
	I am sorry that that's the only part I am not quite familiar with  
which was written by a student graduated . Anyway I will get in touch with
him .

> On Tue, 18 Feb 1997, Zheng Gengbin wrote:
> 
> For replicated alignment, we impose the following restriction:
> the replicated dimension must be distributed and the corresponding
> extents of both the template dimension and processor dimension must
> be equal.
>

	Have we any Adlib functions to handle the replicated alignment  ?

> Currently, we restrict our selves to align-dummy, *, and : for
> align source.
> 

	Sorry I mean int_expr in align with array spec . You know there
can be subscript , align_subscript_use , * or  int_expr ,totally 4 cases . 
Can I assume we will ignore the dimension of int_expr ?

> Current approach is: for pure scalars, always replicate them by default. For 
> array elements, broadcast them to some pure scalars, then use the scalars
> in assignment statements, subprogram calls, etc.
> 

Zheng

---

From: Zheng Gengbin <[email-masked]>
Date: Wed, 19 Feb 1997 14:00:37 +0800 (EAT)

> >
> 
> Why isn't this pass combined with transBD? It seems they are all format
> transform.
> 
> 

	I think TransBD and TransG are all based on the 8 links provided
by prof.Li .  This pass , which contains 8 small passes in it is somewaht
independent . This pass acts as an intermediate role between transBD and 
transG .   I prefered to separate it apart temparately .

	Also I will say more about the pass ,

1. After the pass , no Combined directives remain . They are transformed
   into several statements .

2. No array which is not aligned remains then .

3. All the align source and the align with 's array spec are converted
   to dummy uniform . for example :

	integer a(100,100,100) , b(100:200,300,100)

	align a(: , * , I ) with b(100:200 , 3*I , *)

	=> (transform to)

	align a(DM1 , DM2 , I ) with b( (DM1-1)*1+100 , 3*I , DM3)

	which is transformed into  1*DM1 + 99 (a*x + b) in the next pass .

Zheng

---

From: Zheng Gengbin <[email-masked]>
Date: Thu, 20 Feb 1997 10:39:02 +0800 (EAT)

On Wed, 19 Feb 1997, Xiaoming Li wrote:

> You mean the stuffs that are allowed as align-subscript. In general,
> we have decided the following for the compiler, while full support is
> provided in the front-end.
> 
> ALIGN:
>    (1) each align-source is one of align-dummy, *, :,
>        where align-dummy is a variable name.

	These are  the constrains of HPF specification , I think . 

>    (2) each align-subscript is one of a linear expression of some
>        align-dummy, such as a*i+b, *, :,

	so , int_expr is not suuported .

>    (3) each align-dummy must appear in align-subscript-list exactly once;
>    (4) an align-subscript may contain at most one align-dummy, a and b
>        must be constants;

	These two are also the constraints of HPF spec .

>    (5) the number of : in align-subscript-list must be equal to that in
>        align-source, thus, the dimensions involving : match from left to 
>        right.

	This is the constariant of HPF , but transG donot seem to  notice
this , it match the align source and align subscript list one by one ,
without consider if they are : or dummy .
	Now in here , transG is improved to solve almost all kind of 
these cases . ( this feature is not include in the 1.73 I put in pact
yet )

>    (6) if a * appears as one of align-subscript, that dimension of the
>        template must be distributed and extent of that template dimension 
>        must be equal to the number of processors in processor grid.

>    (7) At most one level of alignment.

	Yea , this this one of the most work done by the new pass .
	It collapse all the align statement into one level .

>    (8) ALIGN A WITH B is understood as ALIGN A(:) WITH B(:), etc.
> 

	The new pass have transform this kind of align statement just as
so .

PS , 
	Zhang Guangsong , there is a problem in combin.C in the version 1.73 .
I attach to you a new one here. Please update to it .

Zheng
#include "compilerApi.h"
#include "pass.h"

/*
SgVarDeclStmt * create_dim_stmt(SgStatement *s,SgExpression *dim)
{
	SgVarDeclStmt *decl;
	SgExpression *var_list;
	SgExpression *dimvar,*dimele,*ele;

	dimvar=NULL;
	for (var_list=s->expr(0) ; var_list; var_list=var_list->rhs()) 
	{
		ele=var_list->lhs();
		if (ele->variant() != ARRAY_REF) 
		{
			dimele=new SgExpression(ARRAY_REF,dim,NULL,ele->symbol(),ele->type());
			dimvar=new SgExpression(EXPR_LIST,dimele,dimvar,NULL);
		}
	}
	if (dimvar == NULL) return NULL;

	decl=new SgVarDeclStmt(* dimvar);
	decl->setVariant(DIM_STAT);
	return decl;
}
*/

void	adjust_var_list(SgStatement *s,SgExpression *dim)
{
	SgExpression *var_list,*ele;

	for (var_list=s->expr(0) ; var_list; var_list=var_list->rhs()) 
	{
		ele=var_list->lhs();
		if (ele->variant() != ARRAY_REF) 
		{
			ele->thellnd->variant=ARRAY_REF;
			ele->setLhs(dim);
		}
	}
}

void create_proc_or_temp__stmt(int variant,SgStatement *s)
{
	SgStatement *decl;

	//decl=new SgVarDeclStmt(* s->expr(0),* s->expr(1)->type());
	SgExpression *type_op = new SgExpression(TYPE_OP,NULL,NULL,NULL,s->expr(1)->type());
	decl=new SgStatement(variant,NULL,NULL,s->expr(0),type_op,NULL);
	//decl->setVariant(variant);
	s->insertStmtAfter(*decl,* s->controlParent() );
}

void create_dist_or_align_stmts(int variant,SgStatement *s)
{
	SgStatement *decl;
	SgExpression *var_list,*var,*op,*att;
	SgExpression *src_list=NULL,*spec_list=NULL;

	op=s->expr(2)->lhs()->lhs();       //point to DISTRIBUTE_OP or ALIGN_OP

	// fill in the align_source_list if missed !!
	if (op->variant() == ALIGN_OP)
	{
		SgSymbol *align_target=op->rhs()->rhs()->symbol();
		SgExpression *align_source = op->lhs();
		if (align_source == NULL && align_target->type()->variant()==T_ARRAY)
		{
			for (int i = 0; i<((SgArrayType*)(align_target->type()))->dimension() ; i++)
			{
				SgExpression *node=new SgExpression (DDOT,NULL,NULL,NULL);
				spec_list=new SgExpression(EXPR_LIST,node,spec_list,NULL);
				node=new SgExpression (COLON_OP,NULL,NULL,NULL);
				src_list=new SgExpression(EXPR_LIST,node,src_list,NULL);
			}
		}
	}

	for (var_list=s->expr(0) ; var_list; var_list=var_list->rhs()) 
	{
		var=new SgExpression(EXPR_LIST,var_list->lhs()->copyPtr(),NULL,NULL);
		SgExpression *new_op = op->copyPtr();
		// add  align source list
		if (spec_list) 
		{
			new_op->setLhs(src_list);
			new_op->rhs()->rhs()->setLhs(spec_list);
			new_op->rhs()->rhs()->thellnd->variant = ARRAY_REF;
		}
		att=new SgExpression(EXPR_LIST , new_op,NULL,NULL);
		decl=new SgStatement(variant,NULL,NULL,var, s->expr(1),att);
		s->insertStmtAfter(*decl,* s->controlParent() );
	}
}

int transform_combined(SgStatement *s)
{
	SgExpression  *var_list,*attr_list,*attr;
	SgStatement   *nstmt;

	var_list=s->expr(0);
	attr_list=s->expr(2);

	// deal with dimension first
	for (attr_list=s->expr(2) ; attr_list ; attr_list=attr_list->rhs())
	{
		attr=attr_list->lhs();
		if (attr->variant() == DIMENSION_OP )
		{
			adjust_var_list(s,attr->lhs());
		}
	}

	for (attr_list=s->expr(2) ; attr_list ; attr_list=attr_list->rhs())
	{
		attr=attr_list->lhs();
		switch (attr->variant())
		{
		case PROCESSORS_VAL:
			create_proc_or_temp__stmt(PROCESSORS_STMT,s);
			break;
		case TEMPLATE_VAL:
			create_proc_or_temp__stmt(TEMPLATE_STMT,s);
			break;
		case DISTRIBUTE_ATT:
			create_dist_or_align_stmts(DISTRIBUTE_DECL,s);
			break;
		case ALIGN_ATT:
			create_dist_or_align_stmts(ALIGN_DECL,s);
			break;
		case INHERIT_OP:
		case DYNAMIC_OP:
			// do nothing ?
			break;
		}
	}

	// delete this statement
	s->deleteStmt();
}

---

From: Zheng Gengbin <[email-masked]>
Date: Wed, 26 Feb 1997 10:55:54 +0800 (EAT)

On Tue, 25 Feb 1997, Guansong Zhang wrote:

> void *SgStatement::deleteAllAttribute()
> {
>   while (numberOfAttributes() > 0 )
>     deleteAttribute(0);
> }
> 
> This function is not well defined, it cause a warning on IBM about return
> value. Another one
> 
> void *SgStatement::deleteAllAttribute(int type)
> {
>   while (numberOfAttributes(type) > 0 )
>     deleteAttribute(0,type);
> }
> 
> has the same problem
> 
> I added return NULL; is there problem?
> 

	That's ok.