Nodes in Graal: ParameterNode
Juan Jose Fumero
juan.fumero at ed.ac.uk
Wed Mar 19 14:16:18 UTC 2014
Hello,
Thanks Gilles for your explanation. As you said, map in stream.util is
IntUnaryOperator. What I am using now is BiFunction<T,U,R>. Maybe I
should change to a specific one as IntBinaryOperator.
More specifically I am trying is this (this is an example):
// Vector Addition
Stream<Integer,Integer> stream = new Stream<>();
stream.map((x,y) -> x + y).run(input);
This is now running in CPU with my library. This map does not have side
effects and each operation returns a new Stream. When the run is called,
the pipeline is executed. What I am trying is to generate OpenCL code
from the map lambda expression, but I need to "transform" or replace
Parameters x and y to Arrays for example.
Is there other ways available in Graal?
Thanks
Juanjo
On Wed, 2014-03-19 at 11:49 +0100, Gilles Duboscq wrote:
> 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.
> >
>
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
More information about the graal-dev
mailing list