Nodes in Graal: ParameterNode

Gilles Duboscq duboscq at ssw.jku.at
Wed Mar 19 10:49:11 UTC 2014


Hello,

The graph you present is the code for:

Integer foo(Integer x, Integer y) {
    return x + y;
}

There are no arrays involved and you can not force the parameters to
be arrays, that would just not work.

If you want to work with integer streams you can use IntStream which
will allow you to work without the boxing (even for the lambdas).
I'm not sure what the example should do exactly since map seems to
only accept unary functions.
In any case, this lambda would be the kernel which is the "what to
run" and thus does not/can not contain any information about "what to
run *on*".
This information can only be available in the code which is applying
this lambda to some specific data.

Maybe you can give a small example of what you would like to achieve
from java code to OpenCL code?

-Gilles

On Tue, Mar 18, 2014 at 6:17 PM, Juan Jose Fumero <juan.fumero at ed.ac.uk> wrote:
> Hello,
>    I am working with lambda expression on JDK8 and Graal. My question is
> related with the creation of new nodes in the Graph to update or change
> the information.
>
>
> Given this lambda expression:
>
>     stream.map((x,y) -> x + y);
>
> The StructuredGraph is the following:
>
> 0|StartNode
> 1|Parameter(0)
> 2|Parameter(1)
> 3|FrameState at 0
> 4|MethodCallTarget
> 5|Invoke#intValue
> 6|FrameState at 4
> 8|MethodCallTarget
> 9|Invoke#intValue
> 10|FrameState at 8
> 12|+
> 13|MethodCallTarget
> 14|Invoke#valueOf
> 15|FrameState at 12
> 17|Return
> 13|Invoke#valueOf
>
>
> Parameter(0) and Parameter(1) are Objects in the moment that I get the
> lambda expression. But later on, I know that could be Integer[],
> Double[], etc.
>
> I would like to rewrite this part of the Graph with the new information.
> Is there any utility in Graal to do that?
>
>
> For instance: if I get the parameterNode from the previous graph:
>
> if (((ObjectStamp) parameterNode.stamp()).type().isArray()) {
>  ...
> }
>
>
> The nodes Parameter(0) and Parameter(1) in the lambda expression are not
> arrays. What I want to do is to change or update these nodes. What I am
> using now is a new node (paramNode):
>
>
> IntegerStamp integerStamp = new IntegerStamp(Kind.Int);
> ParameterNode paramNode   = new ParameterNode(index, integerStamp);
> newGraph.unique(paramNode);
>
> But I need also to store the array information (size and dimension). The
> aim is facilitates the OpenCL code generation from this expression.
>
>
> Many thanks
> Juanjo
>
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>


More information about the graal-dev mailing list