PTX example
Gilles Duboscq
gilwooden at gmail.com
Fri Feb 22 23:24:38 PST 2013
I think we should strip out the original server vm when we copy the jdk
directory in mx so that if you try to do --vm server without building it
first you get an error.
If you really need the original server vm you can then still do --vm server0
On Fri, Feb 22, 2013 at 8:52 PM, Christian Thalinger <
christian.thalinger at oracle.com> wrote:
>
> On Feb 22, 2013, at 11:34 AM, Thomas Wuerthinger <
> thomas.wuerthinger at oracle.com> wrote:
>
> > The error below indicates that you are running on a plain HotSpot VM
> version that does not have Graal enabled.
>
> Ahh, that makes sense. Thanks. -- Chris
>
> > You might be missing "./mx.sh --vm server build" for compiling the
> HotSpot server version that includes the Graal hooks.
> >
> > - thomas
> >
> > On Feb 22, 2013, at 11:25 AM, Christian Thalinger <
> christian.thalinger at oracle.com> wrote:
> >
> >>
> >> On Feb 22, 2013, at 11:05 AM, Thomas Wuerthinger <
> thomas.wuerthinger at oracle.com> wrote:
> >>
> >>> Yes, Graal only supports one instance that is used for compiling the
> methods that are scheduled by HotSpot when running Graal as the default
> compiler for HotSpot. However, in case Graal is running in "hosted mode",
> you can have any number of instances, and you can explicitly invoke the
> compiler with a specific backend as shown in the unit test.
> >>
> >> Btw. I had that problem already last week. When I'm trying to run the
> compiler directly I get this exception:
> >>
> >> java.lang.IllegalAccessError: Runtime does not expose required
> capability com.oracle.graal.nodes.spi.GraalCodeCacheProvider
> >> at
> com.oracle.graal.api.runtime.Graal.getRequiredCapability(Graal.java:57)
> >> at
> com.oracle.graal.compiler.test.GraalCompilerTest.<init>(GraalCompilerTest.java:76)
> >> at
> com.oracle.graal.compiler.ptx.test.BasicPTXTest.<init>(BasicPTXTest.java:42)
> >>
> >> -- Chris
> >>
> >>>
> >>> - thomas
> >>>
> >>> On Feb 22, 2013, at 10:59 AM, Christian Thalinger <
> christian.thalinger at oracle.com> wrote:
> >>>
> >>>>
> >>>> On Feb 22, 2013, at 9:06 AM, "Venkatachalam, Vasanth" <
> Vasanth.Venkatachalam at amd.com> wrote:
> >>>>
> >>>>> Hi Thomas,
> >>>>>
> >>>>> Thanks for this update. I will test your example as soon as I can.
> >>>>>
> >>>>> Can you explain how to switch the ISA that Graal generates code for?
> For example, if I wanted to switch from using x86 as the backend(the
> default) to using SPARC, PTX or my own ISA, what would I have to modify? Is
> there a command line parameter (to be applied at build or run time) for
> specifying the target ISA?
> >>>>
> >>>> Since Graal only supports one compiler instance right now you have to
> instantiate the right GraalCompiler. Something hacky like this:
> >>>>
> >>>> diff --git
> a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java
> b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java
> >>>> ---
> a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java
> >>>> +++
> b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java
> >>>> @@ -141,7 +159,21 @@
> >>>>
> >>>> HotSpotBackend backend = createBackend();
> >>>> GraalOptions.StackShadowPages = config.stackShadowPages;
> >>>> - compiler = new GraalCompiler(getRuntime(), getTarget(),
> backend);
> >>>> +// compiler = new GraalCompiler(getRuntime(), getTarget(),
> backend);
> >>>> + // TODO GraalRuntime needs to support multiple compilers
> >>>> + {
> >>>> + //protected TargetDescription createTarget() {
> >>>> + final int wordSize = 8;
> >>>> + final int stackFrameAlignment = 16;
> >>>> + final int stackBias = 0;
> >>>> + final int implicitNullCheckLimit = 4096;
> >>>> + TargetDescription target = new TargetDescription(new
> PTX(), true, stackFrameAlignment, stackBias, implicitNullCheckLimit,
> config.vmPageSize, wordSize, true, true);
> >>>> +
> >>>> + //protected HotSpotBackend createBackend() {
> >>>> + Backend ptxbackend = new PTXBackend(getRuntime(),
> target);
> >>>> +
> >>>> + compiler = new GraalCompiler(getRuntime(), target,
> ptxbackend);
> >>>> + }
> >>>> if (GraalOptions.CacheGraphs) {
> >>>> cache = new HotSpotGraphCache();
> >>>> }
> >>>>
> >>>> -- Chris
> >>>>
> >>>>>
> >>>>> Vasanth
> >>>>>
> >>>>> -----Original Message-----
> >>>>> From: Thomas Wuerthinger [mailto:thomas.wuerthinger at oracle.com]
> >>>>> Sent: Thursday, February 21, 2013 5:30 PM
> >>>>> To: Venkatachalam, Vasanth
> >>>>> Cc: graal-dev at openjdk.java.net; sumatra-dev at openjdk.java.net
> >>>>> Subject: PTX example
> >>>>>
> >>>>> Vasanth,
> >>>>>
> >>>>> I've committed and pushed the basic PTX example. After running
> "./mx.sh --vm server build" and "./mx.sh --vm server unittest BasicPTXTest"
> you should get the output I pasted in below. The "--vm server" flag means
> that you are using Graal in hosted mode running on top of HotSpot's server
> compiler. You can also start the unit test from within Eclipse after
> generating Eclipse project files with "./mx.sh ideinit".
> >>>>>
> >>>>> Note that the example is still very basic and we'll need more
> restructuring of the compiler backend to nicely work with GPU
> architectures. But we have to start with *something* ;).
> >>>>>
> >>>>> - thomas
> >>>>>
> >>>>> running tests in com.oracle.graal.compiler.ptx.test
> >>>>> JUnit version 4.8
> >>>>> .0: int
> >>>>> .entry test1Snippet (
> >>>>> .param .u32 param0
> >>>>> ) {
> >>>>> .reg .pred %p;
> >>>>> .reg .u32 %r<16>;
> >>>>> L87:
> >>>>> mov.s32 %r0, %r6;
> >>>>> add.s32 %r0, %r0, 1;
> >>>>> exit;
> >>>>> }
> >>>>>
> >>>>> result=com.oracle.graal.api.code.CompilationResult at 665df3c6
> >>>>>
> >>>>> Time: 0.03
> >>>>>
> >>>>> OK (1 test)
> >>>>>
> >>>>
> >>>
> >>
> >
>
>
More information about the sumatra-dev
mailing list