Nodes removal from the IR
Juan Fumero
juan.fumero at ed.ac.uk
Mon Aug 1 10:02:34 UTC 2016
Hi,
On Mon, 2016-08-01 at 11:43 +0200, Lukas Stadler wrote:
> It depends on what the semantics of your change should be - what does
> it mean that you remove the load? is it not necessary any more,
> because you already know the value?
> If you remove a loadfield, and the loadfield has usages, then these
> usages (e.g., arithmetic operations) need some value to work with.
Yes, that's exactly my case, I know the values for some of the
LoadField nodes (related to scope variables from R) so I do not
actually need to process some of the LoadFields when I generate code
for OpenCL.
>
> The FixedGuardNode is special, in that its usages are guard
> dependencies, and usually can work with a “null” input (i.e., no node
> connected, not a “null” constant).
> FloatingGuardedNode, for example, uses an @OptionalInput, while the
> BinaryNodes use the non-optional @Input.
>
> You can replaceAtUsages with any other node, fixed or floating, but
> its result needs to be available at the point of the loadfield.
> You may get errors from the Scheduler if it isn’t.
Ok, thanks Lukas. This is very useful.
Cheers
Juan
>
> - Lukas
>
> >
> > On 01 Aug 2016, at 11:28, Juan Fumero <juan.fumero at ed.ac.uk> wrote:
> >
> > Hi Lukas,
> >
> > I didn't actually replace LoadFieldNode. I was thinking I could
> > apply something similar to FixedGuard and replace it with null and
> > then
> > remove it.
> >
> > So for these kind of nodes I should replace them with another node?
> > Could I replace it either with a FloatingNode or FixedNode?
> >
> > Thanks
> > Juan
> >
> > On Mon, 2016-08-01 at 10:49 +0200, Lukas Stadler wrote:
> > >
> > > Hi Juan,
> > >
> > > how do you remove the LoadFieldNode?
> > > replaceAtUsages(null) is a problem in this case, because this
> > > node is
> > > supposed to generate a value.
> > > Do you replace it with a constant?
> > >
> > > - Lukas
> > >
> > > >
> > > >
> > > > On 29 Jul 2016, at 12:00, Juan Fumero <juan.fumero at ed.ac.uk>
> > > > wrote:
> > > >
> > > > Hi all,
> > > > I am trying to remove some nodes from the IR that I do not
> > > > need
> > > > for
> > > > the GPU execution.
> > > >
> > > > For instance, to remove some of the FixedGuard I do the
> > > > following:
> > > >
> > > > <code>
> > > > if (node instanceof FixedGuardNode) {
> > > > node.replaceAtUsages(null);
> > > > graph.removeFixed((FixedWithNextNode));
> > > > }
> > > >
> > > > new CanonicalizerPhase().apply(graph, new
> > > > PhaseContext(providers));
> > > > new DeadCodeEliminationPhase().apply(graph);
> > > > </code>
> > > >
> > > > This works fine. However, when I try to remove other kind of
> > > > nodes,
> > > > like UnsafeLoadNode, I get the following error:
> > > >
> > > > [thread:1] scope: main
> > > > [thread:1] scope: main.CleanPhase
> > > > [thread:1] scope: main.CleanPhase.InterceptException
> > > > Exception occurred in scope:
> > > > main.CleanPhase.InterceptException
> > > > Context obj com.oracle.graal.graph.VerificationError:
> > > > cannot
> > > > delete
> > > > node 74|UnsafeLoad because of predecessor: 72|LoadField#locals
> > > > at node: 74|UnsafeLoad
> > > > Context obj
> > > > com.oracle.truffle.r.library.gpu.phases.CleanPhase@
> > > > 32dd
> > > > cca
> > > > internal error: com.oracle.truffle.r.runtime.RInternalError:
> > > > com.oracle.graal.graph.VerificationError: cannot delete node
> > > > 74|UnsafeLoad because of predecessor: 72|LoadField#locals
> > > > at node: 74|UnsafeLoad (see fastr_errors.log)
> > > >
> > > >
> > > > Because there is a dependency with LoadFieldNode. My question
> > > > is,
> > > > how
> > > > could I get rid of these kind of nodes? I am trying also to
> > > > remove
> > > > its
> > > > dependencies but I get the same error. I also tried to removed
> > > > with
> > > > graph.removeFixed(node) but I get the error as well.
> > > >
> > > >
> > > > Many thanks
> > > > Juan
> > > >
> > > >
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
More information about the graal-dev
mailing list