question about testing arrays

Venkatachalam, Vasanth Vasanth.Venkatachalam at amd.com
Mon Mar 4 14:28:31 PST 2013


Hi Thomas,

Unfortunately I can't reveal the HSAIL spec details yet since it hasn't been released.

However, I can see that the compare instruction is expecting a register but is receiving a constant. 
I'm trying to understand why Graal is passing a constant to that instruction. Is it because there is a part of the LIRGenerator code that I haven't implemented yet, which I need to implement?
You mentioned that the constant needs to be moved into a register using a move instruction. This is why I asked below whether this could be possibly due to the move instruction not being implemented in my platform specific LIRGenerator.

-----Original Message-----
From: Thomas Wuerthinger [mailto:thomas.wuerthinger at oracle.com] 
Sent: Monday, March 04, 2013 4:08 PM
To: Venkatachalam, Vasanth
Cc: graal-dev at openjdk.java.net
Subject: Re: question about testing arrays

No, the issue is caused by the operand to the compare instruction not expecting a constant but a register. This is why I was asking you if an operand to an HSAIL compare instruction may also be a constant directly? Or does HSAIL require the constant be loaded into a register first?

- thomas

On Mar 4, 2013, at 11:03 PM, "Venkatachalam, Vasanth" <Vasanth.Venkatachalam at amd.com> wrote:

> In my LIRGenerator source (which I modeled after the one for the ISA that was recently checked in), I noticed that the createMove instruction hasn't been implemented. 
> Is this what's causing the issue?
> 
> public static class HSAILSpillMoveFactory implements 
> LIR.SpillMoveFactory {
> 
>        @Override
>        public LIRInstruction createMove(Value result, Value input) {
>            throw new InternalError("NYI");
>        }
>    }
> 
> 
> -----Original Message-----
> From: Thomas Wuerthinger [mailto:thomas.wuerthinger at oracle.com]
> Sent: Monday, March 04, 2013 7:20 AM
> To: Venkatachalam, Vasanth
> Cc: graal-dev at openjdk.java.net
> Subject: Re: question about testing arrays
> 
> The issue below is that the instruction is expecting a register "REG" but got a constant as one of its operand. In that case, you need to load the constant into a register using a move first. Do most HSAIL instructions can take an inlined constant as operand?
> 
> - thomas
> 
> On Mar 1, 2013, at 10:21 PM, "Venkatachalam, Vasanth" <Vasanth.Venkatachalam at amd.com> wrote:
> 
>> Thomas,
>> 
>> I'm not proposing that we remove the array bounds check. I'm just trying to understand what I need to do to get the below test case working so that I can see the code being generated, just as in your simple addition test case. From the stack trace I see that Graal is trying to generate a guard node and this in turn emits a CompareBranch node, which seems to be getting some unexpected values. Does this mean I have not implemented the emitCompareBranch method properly? I just modeled it after the implementation that you and Christian checked in. Or is there some other issue here?
>> 
>> Vasanth
>> 
>> -----Original Message-----
>> From: Thomas Wuerthinger [mailto:thomas.wuerthinger at oracle.com]
>> Sent: Friday, March 01, 2013 2:21 PM
>> To: Venkatachalam, Vasanth
>> Cc: graal-dev at openjdk.java.net
>> Subject: Re: question about testing arrays
>> 
>> Vasanth,
>> 
>> Do you want to completely avoid the array bounds check for the example below (i.e., you assume all array accesses are safe), or what would be the desired behavior in case of an out-of-bounds access?
>> 
>> - thomas
>> 
>> 
>> On Mar 1, 2013, at 8:07 PM, "Venkatachalam, Vasanth" <Vasanth.Venkatachalam at amd.com> wrote:
>> 
>>> Hi,
>>> 
>>> My question has to do with arrays. I am implementing a new test harness for my ISA backend, modeling it after the test harness that Christian and Thomas recently checked in.
>>> 
>>> Thomas's test example was doing a simple addition. I would like to try something involving arrays, like:
>>> 
>>> public static int test1Snippet(int array1[], int array2[]) {
>>> 
>>> return array1[0]* array2[0] + array1[1] *array2[1]; }
>>> 
>>> For this type of code, it looks like Graal emits a Guard check which results in the emission of a compare-branch in the LIR, which in turn is getting some unexpected values. Does anyone have more insight into this error and the best way to work around it? Also are there are other array test examples I can look at to see how array operations may have to be implemented?
>>> 
>>> instruction ICMP (x: int[0|0x0], y: v1|i) condition: AE
>>> mode: USE  flags: [REG]
>>> Unexpected value: Constant int[0|0x0]
>>> scope: GraalCompiler.BackEnd.LIRGen.InterceptException
>>> Exception occurred in scope: 
>>> GraalCompiler.BackEnd.LIRGen.InterceptException
>>> Context obj com.oracle.graal.graph.GraalInternalError: should not reach here
>>>      at node: 12|Guard
>>> Context obj
>>> com.oracle.graal.compiler.hsail.HSAILLIRGenerator at 6035b93b<mailto:com.
>>> oracle.graal.compiler.hsail.HSAILLIRGenerator at 6035b93b>
>>> 1) test1(com.oracle.graal.compiler.hsail.test.BasicHSAILTest)
>>> com.oracle.graal.graph.GraalInternalError: should not reach here
>>>      at node: 12|Guard
>>>      at com.oracle.graal.graph.GraalInternalError.shouldNotReachHere(GraalInternalError.java:46)
>>>      at com.oracle.graal.lir.LIRVerifier.allowed(LIRVerifier.java:241)
>>>      at com.oracle.graal.lir.LIRVerifier.access$000(LIRVerifier.java:37)
>>>      at com.oracle.graal.lir.LIRVerifier$1.doValue(LIRVerifier.java:68)
>>>      at com.oracle.graal.lir.LIRInstructionClass.forEach(LIRInstructionClass.java:346)
>>>      at
>>> com.oracle.graal.lir.LIRInstructionClass.forEachUse(LIRInstructionCl
>>> a at 
>>> com.oracle.graal.compiler.gen.LIRGenerator.append(LIRGenerator.java:258)
>>>      at com.oracle.graal.compiler.hsail.HSAILLIRGenerator.emitCompareBranch(HSAILLIRGenerator.java:196)
>>>      at com.oracle.graal.compiler.gen.LIRGenerator.emitCompareBranch(LIRGenerator.java:634)
>>>      at com.oracle.graal.compiler.gen.LIRGenerator.emitBranch(LIRGenerator.java:611)
>>>      at com.oracle.graal.compiler.gen.LIRGenerator.emitGuardCheck(LIRGenerator.java:600)
>>>      at com.oracle.graal.nodes.GuardNode.generate(GuardNode.java:95)
>>>      at com.oracle.graal.compiler.gen.LIRGenerator.emitNode(LIRGenerator.java:460)
>>>      at
>>> com.oracle.graal.compiler.hsail.HSAILLIRGenerator.emitNode(HSAILLIRG
>>> en
>>> erator.java:78)
>>> 
>>> 
>> 
>> 
>> 
> 
> 
> 





More information about the graal-dev mailing list