Subject: Re: transformation method about function

From: Du_Zhi_hui <[email-masked]>
Date: Wed, 14 May 1997 10:20:47 +0800 (EAT)

> On May 13, 10:15pm, Zheng Gengbin wrote:
> >
> > 	So ,the problem is not to decide where tof77 is to be put , but to
> > judge if the function translations is some kind of the f90 to f77
> > converter or it is needless for a f90 compiler .
> >
> 
> So we can come back to discuss how to compile functions.
> 
> In fact, I don't see why we can not change all function calls as procedure, it
> can deal the most difficult situation in the same way as the simple one.
You misunderstand our method. We do not want to change all function calls to 
procedure 
calls,only those functions whose return value are array.For elemental 
functions,though their return values are array,we still do not change them 
to procedure calls,just keep them as function calls but taking the 
array element as arguments instead of array.It is same as you write in 
following.So our compiler should recognize elemental functions and 
change their arguments from array to array elemental.

> But here is an alternative, let's see what problems may exist:
> 
> First, the intrinsinc elementary functions:
> 
> change them to the function operate on element,
> 
> for example:
> 
> 	A=sin(B)+C
> 
> will be
> 
> 	forall (i=...) A(i)=sin(B(i))+C(i)
We also want to change elemental function calls to this form.But now our 
method is first change
	A=sin(B)+C 
to
	TEMP=sin(B)
	A=TEMP+C
in trans2.then change 
	A=TEMP+C
to
	FORALL(I...) A(I)=TEMP(I)+C(I)
just leave 
	TEMP=sin(B)
there ,The passing of transforming function call should deal with this case. 
Of course we can improve our method in trans2 to transform elemental 
function calls just as what you suggest.Your suggestion is reasonable and 
efficient.

> 
> if there is corresponding function, like "sin", in node fortran compiler, there
> is no need to do anything more, other wise we only need a function operate on
> scalar in run-time.
For elemental function,We only need its implementation of scalar.

> 
> This will be the simplest case, which may even not involve temporary memory.
> 
> If the intrinsic function is not elementary, temporary memory must be added,
> and they should be added on memory heap by using allocate and dellocate if we
> want to save memory.
In trans2 we introduce new temporary variable to save the value of 
function call.This may need big memory but it is easy for data mapping.
> 
> Data mapping derictives for those temporary memory is needed. And run-time will
> based on those data mapping to provide corresponding support for each function.
This is what we have done.
> 
> For user defined function, it should be similiar with the implementation of a
> procedure. Only at this time, changing them to procedure call for function with
> return value as array type may be necessary.
This is our method for transform function calls whose return value are 
array,I think it is easier to implement and more efficient than to change 
function call(return array) to  function call (return array 
element),especial when function has optional dummy (COUNT, MAX).

> Guansong

---

From: Zheng Gengbin <[email-masked]>
Date: Wed, 14 May 1997 10:37:35 +0800 (EAT)

> This will be the simplest case, which may even not involve temporary memory.

	I have considered this case , in elementary functions , we seem
can take this way. But these are the small part of the hundreds of intrinsic 
functions. I don't know if it is worthy to deal them separately.

> return value as array type may be necessary.

	Yes, as to the user defined function,I think we never know whether they 
are elementary functions or not , so the first method cannot apply . 

Zheng