# HG changeset patch # User Doug Simon # Date 1374614694 -7200 # Node ID fa2fe7dd7a548480f821cca221cbbe4403ab8598 # Parent 4ead4f35b91fabdab3468d3f465076cc6cbe618b HSAIL backend changes Contributed-by: Tom Deneau diff -r 4ead4f35b91f -r fa2fe7dd7a54 graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java --- a/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java Tue Jul 23 21:42:24 2013 +0200 +++ b/graal/com.oracle.graal.asm.hsail/src/com/oracle/graal/asm/hsail/HSAILAssembler.java Tue Jul 23 23:24:54 2013 +0200 @@ -108,8 +108,8 @@ emitString(instr + " " + HSAIL.mapRegister(reg) + ", " + mapAddress(addr) + ";"); } - public final void emitLoad(Value dest, HSAILAddress addr) { - emitLoad(dest, addr, getArgType(dest)); + public final void emitLoad(Kind kind, Value dest, HSAILAddress addr) { + emitLoad(dest, addr, getArgTypeFromKind(kind)); } public final void emitLoad(Value dest, HSAILAddress addr, String argTypeStr) { @@ -120,8 +120,8 @@ emitAddrOp("lda_global_u64", dest, addr); } - public final void emitStore(Value src, HSAILAddress addr) { - emitStore(src, addr, getArgType(src)); + public final void emitStore(Kind kind, Value src, HSAILAddress addr) { + emitStore(src, addr, getArgTypeFromKind(kind)); } public final void emitStore(Value dest, HSAILAddress addr, String argTypeStr) { @@ -175,8 +175,12 @@ } public static final String getArgType(Value src) { + return getArgTypeFromKind(src.getKind()); + } + + private static String getArgTypeFromKind(Kind kind) { String prefix = ""; - switch (src.getKind()) { + switch (kind) { case Float: prefix = "f32"; break; @@ -192,6 +196,15 @@ case Object: prefix = "u64"; break; + case Char: + prefix = "u16"; + break; + case Short: + prefix = "s16"; + break; + case Byte: + prefix = "s8"; + break; default: throw GraalInternalError.shouldNotReachHere(); } diff -r 4ead4f35b91f -r fa2fe7dd7a54 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Float2DMatrixMultiplyTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Float2DMatrixMultiplyTest.java Tue Jul 23 21:42:24 2013 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/Float2DMatrixMultiplyTest.java Tue Jul 23 23:24:54 2013 +0200 @@ -29,6 +29,7 @@ * Tests 2D array access for Matrix Multiplication. */ public class Float2DMatrixMultiplyTest extends Float2DMatrixBase { + int range = 20; public void run(int gid) { @@ -40,6 +41,7 @@ outMatrix[gid][j] = sum; } } + @Override public void runTest() { setupArrays(range); diff -r 4ead4f35b91f -r fa2fe7dd7a54 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringContainsAcceptTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringContainsAcceptTest.java Tue Jul 23 23:24:54 2013 +0200 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.oracle.graal.compiler.hsail.test; + +import org.junit.Test; +import static org.junit.Assume.*; + +/** + * Tests codegen for String.contains() but with a wrapper method such as one would get in the + * IntConsumer.accept calls. + */ +public class StringContainsAcceptTest extends StringContainsTest { + + String base = "CDE"; + + // the accept method which "captured" the base + public void run(int gid) { + super.run(base, gid); + } + + @Override + public void runTest() { + setupArrays(); + + dispatchMethodKernel(NUM); + } + + // fails on 3rd workitem + @Test + @Override + public void test() { + assumeTrue(aggressiveInliningEnabled() || canHandleHSAILMethodCalls()); + testGeneratedHsail(); + } + +} diff -r 4ead4f35b91f -r fa2fe7dd7a54 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringContainsTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringContainsTest.java Tue Jul 23 23:24:54 2013 +0200 @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.oracle.graal.compiler.hsail.test; + +import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester; +import org.junit.Test; + +/** + * Tests codegen for String.contains(). + */ +public class StringContainsTest extends GraalKernelTester { + + static final int NUM = 20; + @Result public boolean[] outArray = new boolean[NUM]; + public String[] inArray = new String[NUM]; + + void setupArrays() { + char[] chars = new char[100]; + for (int i = 0; i < chars.length; i++) { + chars[i] = (char) ('A' + i); + } + for (int i = 0; i < NUM; i++) { + inArray[i] = new String(chars, i, 10); + } + } + + public void run(String base, int gid) { + outArray[gid] = inArray[gid].contains(base); + } + + @Override + public void runTest() { + setupArrays(); + String base = "CDE"; + dispatchMethodKernel(NUM, base); + } + + @Test + public void test() { + testGeneratedHsail(); + } + +} diff -r 4ead4f35b91f -r fa2fe7dd7a54 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringIndexOfTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/StringIndexOfTest.java Tue Jul 23 23:24:54 2013 +0200 @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.oracle.graal.compiler.hsail.test; + +import com.oracle.graal.compiler.hsail.test.infra.GraalKernelTester; +import org.junit.Test; + +/** + * Tests codegen for String.indexOf(). + */ +public class StringIndexOfTest extends GraalKernelTester { + + static final int NUM = 20; + @Result public int[] outArray = new int[NUM]; + public String[] inArray = new String[NUM]; + + void setupArrays() { + char[] chars = new char[100]; + for (int i = 0; i < chars.length; i++) { + chars[i] = (char) ('A' + i); + } + for (int i = 0; i < NUM; i++) { + inArray[i] = new String(chars, i, 10); + } + } + + public void run(String base, int gid) { + outArray[gid] = inArray[gid].indexOf(base); + } + + @Override + public void runTest() { + setupArrays(); + String base = "CDE"; + dispatchMethodKernel(NUM, base); + } + + @Test + public void test() { + testGeneratedHsail(); + } +} diff -r 4ead4f35b91f -r fa2fe7dd7a54 graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java Tue Jul 23 21:42:24 2013 +0200 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java Tue Jul 23 23:24:54 2013 +0200 @@ -166,7 +166,7 @@ @Override public void emitMemAccess(HSAILAssembler masm) { HSAILAddress addr = address.toAddress(); - masm.emitLoad(result, addr); + masm.emitLoad(kind, result, addr); } } @@ -183,7 +183,7 @@ public void emitMemAccess(HSAILAssembler masm) { assert isRegister(input); HSAILAddress addr = address.toAddress(); - masm.emitStore(input, addr); + masm.emitStore(kind, input, addr); } } diff -r 4ead4f35b91f -r fa2fe7dd7a54 mx/projects --- a/mx/projects Tue Jul 23 21:42:24 2013 +0200 +++ b/mx/projects Tue Jul 23 23:24:54 2013 +0200 @@ -24,8 +24,8 @@ library@DACAPO_SCALA@path=lib/dacapo-scala-0.1.0-20120216.jar library@DACAPO_SCALA@urls=http://repo.scalabench.org/snapshots/org/scalabench/benchmarks/scala-benchmark-suite/0.1.0-SNAPSHOT/scala-benchmark-suite-0.1.0-20120216.103539-3.jar -library@OKRA@path=lib/okra-1.jar -library@OKRA@urls=http://cr.openjdk.java.net/~tdeneau/okra-1.jar +library@OKRA@path=lib/okra-1.2.jar +library@OKRA@urls=http://cr.openjdk.java.net/~tdeneau/okra-1.2.jar distribution@GRAAL@path=graal.jar distribution@GRAAL@dependencies=com.oracle.graal.hotspot.amd64,com.oracle.graal.truffle,com.oracle.graal.truffle.printer,com.oracle.graal.hotspot.sparc,com.oracle.graal.hotspot,com.oracle.graal.compiler.hsail