questions on Word operations
Deneau, Tom
tom.deneau at amd.com
Fri Sep 13 11:30:53 PDT 2013
Christian --
Yes, I should have stated the final goal and maybe there is a better way to do what we want to do...
We want to support object allocation from an HSA GPU. (or at least to get an idea whether it is worth supporting it).
At a high level, there would be a bunch of TLABS available for the gpu to use.
For the initial prototype these could be the TLABs from actual java "donor threads" whose only purpose is to supply their TLAB
(the java donor threads wouldn't allocate into their own TLAB).
Since the HSA GPU has the same view of memory as the cpu, we thought perhaps we could
just use the non-atomic pointer bump snippet that is used with HotspotRuntime.
We confirmed this works for small numbers of workitems but the high parallelism of
the gpu means an unreasonably high number of donor threads would be needed for the general case.
So we are now experimenting with multiple GPU workitems sharing a TLAB and allocatin using an atomic pointer bump.
We know the HSAIL code we want to end up with, but I just don't have any experience with
Graal Snippets and such to make graal emit this HSAIL code (as you can tell from my questions).
But maybe there is an easier way to get graal to emit this allocation code?
-- Tom
-----Original Message-----
From: graal-dev-bounces at openjdk.java.net [mailto:graal-dev-bounces at openjdk.java.net] On Behalf Of Christian Wimmer
Sent: Friday, September 13, 2013 12:19 PM
To: graal-dev at openjdk.java.net
Subject: Re: questions on Word operations
All functions on word types (everything implementing the interface
WordBase) are compiler intrinsics. If you use Word in a snippet, and call one of the methods on it, the body of these methods is actually irrelevant. The only thing that matters is how the WordTypeRewriterPhase replaces the method call with low-level compiler nodes. The @Operation annotation is used by the WordTypeRewriterPhase to distinguish what to do.
Word only provides the very basic arithmetic and memory operations (+, -, * , /, read, write). Adding methods for atomic operations like you want is possible, but I don't think it is the easiest way to achieve what you want to do.
Can you explain what your final goal is?
-Christian
On 09/13/2013 09:47 AM, Deneau, Tom wrote:
> I would like to add a new Word method that can be used from an allocation Snippet I am trying to write.
>
> The new method would look like:
>
> public Word atomicGetAndAddWord(int offset, int delta) {
>
> }
>
> So given a Word (address), this would do an atomic get and add of delta on the word located at the address this.rawValue + offset. Like j.u.c.atomic.getAndAdd, it would return the original word value at that address.
>
> A couple of questions:
>
> * Is the following a legal body for such a method? I see that it
> compiles but is it legal to call toObject() on a Word value? As used
> in the snippet the Word value would be the pointer returned by
> thread(). I noticed there is no unsafe.getAndAddLong(long address,
> long delta), only unsafe.getAndAddLong(Object o, long offset, long
> delta)
>
> return box(unsafe.getAndAddLong(toObject(), offset,
> delta));
>
> * I notice all the Word methods have @Operation annotations but I don't really understand the semantics of this annotation. What should be the annotation for this method?
>
>
> * What is the purpose of the locationIdentity parameter on some
> of the word operations such as
>
> @Operation(opcode = Opcode.READ)
> public Word readWord(WordBase offset, LocationIdentity locationIdentity) {
> return box(unsafe.getAddress(add((Word) offset).unbox()));
> }
>
> -- Tom
>
More information about the graal-dev
mailing list