diff --git a/src/main/java/com/aparapi/Config.java b/src/main/java/com/aparapi/Config.java index 6d04663d298668e683cc55a9a7ad0c9eead69454..06f369a82ad7cb040b7e442031b9d43e5358eeef 100644 --- a/src/main/java/com/aparapi/Config.java +++ b/src/main/java/com/aparapi/Config.java @@ -78,7 +78,7 @@ public class Config extends ConfigJNI{ * Allows the user to request to use a jvmti agent to * access JNI code rather than loading explicitly. * - * Usage -agentpath=/full/path/to/agent.dll -Dcom.aparapi.useAgent=true + * Usage -agentpath=/full/path/to/agent.dll -Dcom.codegen.useAgent=true */ public static final boolean useAgent = Boolean.getBoolean(propPkgName + ".useAgent"); @@ -91,7 +91,7 @@ public class Config extends ConfigJNI{ /** * Allows the user to request a specific Kernel.EXECUTION_MODE enum value for all Kernels. * - * Usage -Dcom.aparapi.executionMode={SEQ|JTP|CPU|GPU|ACC} + * Usage -Dcom.codegen.executionMode={SEQ|JTP|CPU|GPU|ACC} * * @see com.aparapi.Kernel.EXECUTION_MODE */ @@ -100,7 +100,7 @@ public class Config extends ConfigJNI{ /** * Allows the user to request that the execution mode of each kernel invocation be reported to stdout. * - * Usage -Dcom.aparapi.enableExecutionModeReporting={true|false} + * Usage -Dcom.codegen.enableExecutionModeReporting={true|false} * */ public static final boolean enableExecutionModeReporting = Boolean.getBoolean(propPkgName + ".enableExecutionModeReporting"); @@ -108,7 +108,7 @@ public class Config extends ConfigJNI{ /** * Allows the user to request that generated OpenCL code is dumped to standard out. * - * Usage -Dcom.aparapi.enableShowGeneratedOpenCL={true|false} + * Usage -Dcom.codegen.enableShowGeneratedOpenCL={true|false} * */ public static final boolean enableShowGeneratedOpenCL = Boolean.getBoolean(propPkgName + ".enableShowGeneratedOpenCL"); @@ -116,7 +116,7 @@ public class Config extends ConfigJNI{ /** * Upon exiting the JVM, dumps kernel profiling info to standard out. * - * Usage -Dcom.aparapi.dumpProfilesOnExit={true|false} + * Usage -Dcom.codegen.dumpProfilesOnExit={true|false} * */ public static final boolean dumpProfilesOnExit = Boolean.getBoolean(propPkgName + ".dumpProfilesOnExit"); @@ -124,7 +124,7 @@ public class Config extends ConfigJNI{ /** * Dumps profiling info (for a single execution) after every Kernel execution. * - * Usage -Dcom.aparapi.dumpProfileOnExecution={true|false} + * Usage -Dcom.codegen.dumpProfileOnExecution={true|false} * */ public static final boolean dumpProfileOnExecution = Boolean.getBoolean(propPkgName + ".dumpProfileOnExecution"); @@ -228,7 +228,7 @@ public class Config extends ConfigJNI{ System.out.println(propPkgName + ".enableExecutionModeReporting{true|false}=" + enableExecutionModeReporting); System.out.println(propPkgName + ".enableInstructionDecodeViewer{true|false}=" + enableInstructionDecodeViewer); System.out.println(propPkgName - + ".instructionListenerClassName{<class name which extends com.aparapi.Config.InstructionListener>}=" + + ".instructionListenerClassName{<class name which extends com.codegen.Config.InstructionListener>}=" + instructionListenerClassName); } } diff --git a/src/main/java/com/aparapi/Kernel.java b/src/main/java/com/aparapi/Kernel.java index a735cb50e1e327ff97153f3bb5dd0b719c3fbd04..a4a49e4382f82e14c133d7e36675d138500bfb57 100644 --- a/src/main/java/com/aparapi/Kernel.java +++ b/src/main/java/com/aparapi/Kernel.java @@ -373,17 +373,17 @@ public abstract class Kernel implements Cloneable { * kernel.execute(values.length); * </pre></blockquote> * <p> -<<<<<<< HEAD:src/main/java/com/aparapi/Kernel.java - * Alternatively, the property <code>com.aparapi.executionMode</code> can be set to one of <code>JTP,GPU,ACC,CPU,SEQ</code> +<<<<<<< HEAD:src/main/java/com/codegen/Kernel.java + * Alternatively, the property <code>com.codegen.executionMode</code> can be set to one of <code>JTP,GPU,ACC,CPU,SEQ</code> * when an application is launched. * <p><blockquote><pre> - * java -classpath ....;aparapi.jar -Dcom.aparapi.executionMode=GPU MyApplication + * java -classpath ....;codegen.jar -Dcom.codegen.executionMode=GPU MyApplication ======= - * Alternatively, the property <code>com.amd.aparapi.executionMode</code> can be set to one of <code>JTP,GPU,ACC,CPU,SEQ</code> + * Alternatively, the property <code>com.amd.codegen.executionMode</code> can be set to one of <code>JTP,GPU,ACC,CPU,SEQ</code> * when an application is launched. * <p><blockquote><pre> - * java -classpath ....;aparapi.jar -Dcom.amd.aparapi.executionMode=GPU MyApplication ->>>>>>> b118aad... added method to set execution mode without any fallback:com.amd.aparapi/src/java/com/amd/aparapi/Kernel.java + * java -classpath ....;codegen.jar -Dcom.amd.codegen.executionMode=GPU MyApplication +>>>>>>> b118aad... added method to set execution mode without any fallback:com.amd.codegen/src/java/com/amd/codegen/Kernel.java * </pre></blockquote><p> * Generally setting the execution mode is not recommended (it is best to let Aparapi decide automatically) but the option * provides a way to compare a kernel's performance under multiple execution modes. diff --git a/src/main/java/com/aparapi/internal/jni/ConfigJNI.java b/src/main/java/com/aparapi/internal/jni/ConfigJNI.java index 91f4ab4401f6d25b7df18eb30a2d506d5a5e95cf..78050b0b8cb11e61aeaf0fef6e5852bf8619c143 100644 --- a/src/main/java/com/aparapi/internal/jni/ConfigJNI.java +++ b/src/main/java/com/aparapi/internal/jni/ConfigJNI.java @@ -24,14 +24,14 @@ import com.aparapi.internal.annotation.UsedByJNICode; public abstract class ConfigJNI{ /** - * Value defaults to com.aparapi.config if not overridden by extending classes + * Value defaults to com.codegen.config if not overridden by extending classes */ protected static final String propPkgName = Config.class.getPackage().getName(); /** * Allows the user to turn on OpenCL profiling for the JNI/OpenCL layer. * - * Usage -Dcom.aparapi.enableProfiling={true|false} + * Usage -Dcom.codegen.enableProfiling={true|false} * */ @UsedByJNICode public static final boolean enableProfiling = Boolean.getBoolean(propPkgName + ".enableProfiling"); @@ -39,7 +39,7 @@ public abstract class ConfigJNI{ /** * Allows the user to turn on OpenCL profiling for the JNI/OpenCL layer, this information will be written to CSV file * - * Usage -Dcom.aparapi.enableProfiling={true|false} + * Usage -Dcom.codegen.enableProfiling={true|false} * */ @UsedByJNICode public static final boolean enableProfilingCSV = Boolean.getBoolean(propPkgName + ".enableProfilingCSV"); @@ -47,7 +47,7 @@ public abstract class ConfigJNI{ /** * Allows the user to request that verbose JNI messages be dumped to stderr. * - * Usage -Dcom.aparapi.enableVerboseJNI={true|false} + * Usage -Dcom.codegen.enableVerboseJNI={true|false} * */ @UsedByJNICode public static final boolean enableVerboseJNI = Boolean.getBoolean(propPkgName + ".enableVerboseJNI"); @@ -57,7 +57,7 @@ public abstract class ConfigJNI{ * * This is really a debugging option to help locate leaking OpenCL resources, this will be dumped to stderr. * - * Usage -Dcom.aparapi.enableOpenCLResourceTracking={true|false} + * Usage -Dcom.codegen.enableOpenCLResourceTracking={true|false} * */ @UsedByJNICode public static final boolean enableVerboseJNIOpenCLResourceTracking = Boolean.getBoolean(propPkgName diff --git a/src/main/java/com/aparapi/internal/jni/KernelArgJNI.java b/src/main/java/com/aparapi/internal/jni/KernelArgJNI.java index 863e89bea673b20955a35856c3c045e830e2e113..2354334916ed88cce463d22d964a9ef7320ea3fe 100644 --- a/src/main/java/com/aparapi/internal/jni/KernelArgJNI.java +++ b/src/main/java/com/aparapi/internal/jni/KernelArgJNI.java @@ -60,7 +60,7 @@ public abstract class KernelArgJNI{ @UsedByJNICode protected Object javaArray; /** - * If this field represents an aparapi buffer then the instance will be captured here + * If this field represents an codegen buffer then the instance will be captured here */ @UsedByJNICode protected Object javaBuffer; diff --git a/src/main/java/com/aparapi/internal/model/Entrypoint.java b/src/main/java/com/aparapi/internal/model/Entrypoint.java index c956816f0d5627eb54c56d7a69d01b2ab6269350..3a291b2431855b979e9e625507869bf6fa9e80d4 100644 --- a/src/main/java/com/aparapi/internal/model/Entrypoint.java +++ b/src/main/java/com/aparapi/internal/model/Entrypoint.java @@ -602,7 +602,7 @@ public class Entrypoint implements Cloneable { // Add the class model for the referenced obj array if (signature.startsWith("[L")) { - // Turn [Lcom/aparapi/javalabs/opencl/demo/DummyOOA; into com.aparapi.javalabs.opencl.demo.DummyOOA for example + // Turn [Lcom/codegen/javalabs/opencl/demo/DummyOOA; into com.codegen.javalabs.opencl.demo.DummyOOA for example final String className = (signature.substring(2, signature.length() - 1)).replace('/', '.'); final ClassModel arrayFieldModel = getOrUpdateAllClassAccesses(className); if (arrayFieldModel != null) { diff --git a/src/main/java/com/aparapi/internal/model/MethodModel.java b/src/main/java/com/aparapi/internal/model/MethodModel.java index da7702f9b10591ef21ff958caad53e817ce96ca3..4a16a8685c01856a09e181de27afca2e49297f7e 100644 --- a/src/main/java/com/aparapi/internal/model/MethodModel.java +++ b/src/main/java/com/aparapi/internal/model/MethodModel.java @@ -1648,7 +1648,7 @@ public class MethodModel{ logger.warning("Method " + method.getName() + method.getDescriptor() - + " does not contain a LocalVariableTable entry (source not compiled with -g) aparapi will attempt to create a synthetic table based on bytecode. This is experimental!!"); + + " does not contain a LocalVariableTable entry (source not compiled with -g) codegen will attempt to create a synthetic table based on bytecode. This is experimental!!"); } // pass #2 build branch graph diff --git a/src/main/java/com/aparapi/internal/opencl/OpenCLLoader.java b/src/main/java/com/aparapi/internal/opencl/OpenCLLoader.java index 948530a7a2e14cd861fd6b48ac4e144b7356f672..78246cc26aa075a9a1b0226a5e78b23fb9503a3c 100644 --- a/src/main/java/com/aparapi/internal/opencl/OpenCLLoader.java +++ b/src/main/java/com/aparapi/internal/opencl/OpenCLLoader.java @@ -45,7 +45,7 @@ public class OpenCLLoader extends OpenCLJNI{ openCLAvailable = true; } catch (final IOException e) { - logger.log(Level.SEVERE, "Check your environment. Failed to load aparapi native library " + logger.log(Level.SEVERE, "Check your environment. Failed to load codegen native library " + " or possibly failed to locate opencl native library (opencl.dll/opencl.so)." + " Ensure that OpenCL is in your PATH (windows) or in LD_LIBRARY_PATH (linux)."); } diff --git a/src/main/java/com/aparapi/internal/writer/KernelWriter.java b/src/main/java/com/aparapi/internal/writer/KernelWriter.java index 17c37e58b737b8cd599b6a2e08b3b1e2435de6c0..4e5de60917dde89220203a47786a178419b03d4f 100644 --- a/src/main/java/com/aparapi/internal/writer/KernelWriter.java +++ b/src/main/java/com/aparapi/internal/writer/KernelWriter.java @@ -365,7 +365,7 @@ public abstract class KernelWriter extends BlockWriter{ // If it is a converted array of objects, emit the struct param String className = null; if (signature.startsWith("L")) { - // Turn Lcom/aparapi/javalabs/opencl/demo/DummyOOA; into com_amd_javalabs_opencl_demo_DummyOOA for example + // Turn Lcom/codegen/javalabs/opencl/demo/DummyOOA; into com_amd_javalabs_opencl_demo_DummyOOA for example className = (signature.substring(1, signature.length() - 1)).replace('/', '_'); // if (logger.isLoggable(Level.FINE)) { // logger.fine("Examining object parameter: " + signature + " new: " + className); diff --git a/src/test/java/com/aparapi/codegen/CodeGenJUnitBase.java b/src/test/java/com/aparapi/codegen/CodeGenJUnitBase.java new file mode 100644 index 0000000000000000000000000000000000000000..0fee2c0671f683d1eac7ba2f0a18ab7e3265515c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/CodeGenJUnitBase.java @@ -0,0 +1,137 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* +Copyright (c) 2010-2011, Advanced Micro Devices, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following +disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +disclaimer in the documentation and/or other materials provided with the distribution. + +Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +If you use the software (in whole or in part), you shall adhere to all applicable U.S., European, and other export +laws, including but not limited to the U.S. Export Administration Regulations ("EAR"), (15 C.F.R. Sections 730 through +774), and E.U. Council Regulation (EC) No 1334/2000 of 22 June 2000. Further, pursuant to Section 740.6 of the EAR, +you hereby certify that, except pursuant to a license granted by the United States Department of Commerce Bureau of +Industry and Security or as otherwise permitted pursuant to a License Exception under the U.S. Export Administration +Regulations ("EAR"), you will not (1) export, re-export or release to a national of a country in Country Groups D:1, +E:1 or E:2 any restricted technology, software, or source code you receive hereunder, or (2) export to Country Groups +D:1, E:1 or E:2 the direct product of such technology or software, if such foreign produced direct product is subject +to national security controls as identified on the Commerce Control List (currently found in Supplement 1 to Part 774 +of EAR). For the most current Country Group listings, or for additional information about the EAR or your obligations +under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. + +*/ +package com.aparapi.codegen; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.Arrays; + +import com.aparapi.Kernel; +import com.aparapi.internal.exception.AparapiException; +import com.aparapi.internal.model.ClassModel; +import com.aparapi.internal.model.Entrypoint; +import com.aparapi.internal.writer.KernelWriter; + +public class CodeGenJUnitBase { + + protected void test(Class<?> _class, Class<? extends AparapiException> _expectedExceptionType, String[] expectedOpenCL) { + try { + // Source source = new Source(_class, new File("src/java")); + // System.out.println("opencl\n"+source.getOpenCL()); + + // String expected = source.getOpenCLString(); + + ClassModel classModel = ClassModel.createClassModel(_class); + + // construct an artficial instance of our class here + // we assume the specified class will have a null constructor + Object kernelInstance = _class.getConstructor((Class<?>[]) null).newInstance(); + + Entrypoint entrypoint = classModel.getEntrypoint("run", kernelInstance instanceof Kernel ? kernelInstance : null); + String actual = KernelWriter.writeToString(entrypoint); + + if (_expectedExceptionType == null) { + int matched = 0; + if( expectedOpenCL != null ) { + for (String expected : expectedOpenCL) { + if (Diff.same(actual, expected)) { + break; + } + matched++; + } + } + boolean same = (matched < ( expectedOpenCL != null ? expectedOpenCL.length : 0)); + + if (!same) { + System.out.println("---" + _class.getName() + + "------------------------------------------------------------------------------"); + boolean first = true; + if( expectedOpenCL != null ) { + for (String expected : expectedOpenCL) { + if (first) { + first = false; + } else { + System.out.println("}"); + } + System.out.println("Expected {\n" + expected); + } + } + System.out.println("}Actual\n{" + actual); + System.out + .println("}\n------------------------------------------------------------------------------------------------------"); + + } + if (!same) { + assertEquals(_class.getSimpleName(), Arrays.toString(expectedOpenCL), actual); + } + } else { + assertTrue("Expected exception " + _expectedExceptionType + " Instead we got {\n" + actual + "\n}", false); + } + + } catch (AssertionError e) { + throw e; + } catch (Throwable t) { + if (_expectedExceptionType == null || !t.getClass().isAssignableFrom(_expectedExceptionType)) { + t.printStackTrace(); + throw new AssertionError("Unexpected exception " + t, t); + } + } + } + + protected void test(Class<?> _class, String[] expectedOpenCL) { + test(_class, null, expectedOpenCL); + + } + +} diff --git a/src/test/java/com/aparapi/codegen/CreateJUnitTest.java b/src/test/java/com/aparapi/codegen/CreateJUnitTest.java new file mode 100644 index 0000000000000000000000000000000000000000..070ce8bcbf3e71cd689bce195fab2574e02185b4 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/CreateJUnitTest.java @@ -0,0 +1,158 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* +Copyright (c) 2010-2011, Advanced Micro Devices, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following +disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +disclaimer in the documentation and/or other materials provided with the distribution. + +Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +If you use the software (in whole or in part), you shall adhere to all applicable U.S., European, and other export +laws, including but not limited to the U.S. Export Administration Regulations ("EAR"), (15 C.F.R. Sections 730 through +774), and E.U. Council Regulation (EC) No 1334/2000 of 22 June 2000. Further, pursuant to Section 740.6 of the EAR, +you hereby certify that, except pursuant to a license granted by the United States Department of Commerce Bureau of +Industry and Security or as otherwise permitted pursuant to a License Exception under the U.S. Export Administration +Regulations ("EAR"), you will not (1) export, re-export or release to a national of a country in Country Groups D:1, +E:1 or E:2 any restricted technology, software, or source code you receive hereunder, or (2) export to Country Groups +D:1, E:1 or E:2 the direct product of such technology or software, if such foreign produced direct product is subject +to national security controls as identified on the Commerce Control List (currently found in Supplement 1 to Part 774 +of EAR). For the most current Country Group listings, or for additional information about the EAR or your obligations +under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. + +*/ +package com.aparapi.codegen; + +import org.junit.Ignore; +import org.junit.Test; + +import java.io.*; +import java.util.ArrayList; +import java.util.List; + +public class CreateJUnitTest { + @Ignore("We will probably never use this, it just generates test. We probably want to do this by hand.") + @Test + public void test() throws ClassNotFoundException, FileNotFoundException, IOException { + File rootDir = new File(System.getProperty("root", ".")); + + String rootPackageName = CreateJUnitTest.class.getPackage().getName(); + String testPackageName = rootPackageName + ".test"; + File sourceDir = new File(rootDir, "src/test/java"); + System.out.println(sourceDir.getCanonicalPath()); + File testDir = new File(sourceDir, testPackageName.replace(".", "/")); + System.out.println(testDir.getCanonicalPath()); + + List<String> classNames = new ArrayList<String>(); + for (File sourceFile : testDir.listFiles(new FilenameFilter() { + + @Override + public boolean accept(File dir, String name) { + return (name.endsWith(".java")); + } + })) { + String fileName = sourceFile.getName(); + String className = fileName.substring(0, fileName.length() - ".java".length()); + classNames.add(className); + } + + File genSourceDir = new File(rootDir, "src/genjava"); + File codeGenDir = new File(genSourceDir, rootPackageName.replace(".", "/") + "/test/junit/codegen/"); + codeGenDir.mkdirs(); + + for (String className : classNames) { + + Source source = new Source(Class.forName(testPackageName + "." + className), sourceDir); + + final String testName = className + "Test"; + + StringBuilder sb = new StringBuilder(); + sb.append("package com.codegen.test.junit.codegen;\n"); + sb.append("import org.junit.Test;\n"); + String doc = source.getDocString(); + if (doc.length() > 0) { + sb.append("/**\n"); + sb.append(doc); + sb.append("\n */\n"); + } + sb.append("public class " + testName + " extends com.codegen.CodeGenJUnitBase{\n"); + appendExpectedOpenCL(source, sb); + appendExpectedExceptions(source, sb); + appendTest(testPackageName, testName, "", sb); + appendTest(testPackageName, testName, "WorksWithCaching", sb); + sb.append("}\n"); + // System.out.println(sb.toString()); + + File generatedFile = new File(codeGenDir, testName + ".java"); + PrintStream out = new PrintStream(generatedFile); + out.append(sb.toString()); + out.close(); + + } + + } + + private static void appendTest(String testPackageName, String className, String suffix, StringBuilder sb) { + sb.append(" @Test public void " + className + suffix + "(){\n"); + sb.append(" test(" + testPackageName + "." + className + ".class, expectedException, expectedOpenCL);\n"); + sb.append(" }\n"); + } + + private static void appendExpectedExceptions(Source source, StringBuilder sb) { + String exceptions = source.getExceptionsString(); + if (exceptions.length() > 0) { + sb.append(" private static final Class<? extends com.codegen.internal.exception.AparapiException> expectedException = "); + + sb.append("com.codegen.internal.exception." + exceptions + ".class"); + sb.append(";\n"); + } else { + sb.append(" private static final Class<? extends com.codegen.internal.exception.AparapiException> expectedException = null;\n"); + } + } + + private static void appendExpectedOpenCL(Source source, StringBuilder sb) { + if (source.getOpenCLSectionCount() > 0) { + + sb.append(" private static final String[] expectedOpenCL = new String[]{\n"); + for (List<String> opencl : source.getOpenCL()) { + sb.append(" \"\"\n"); + for (String line : opencl) { + sb.append(" +\"" + line + "\\n\"\n"); + } + sb.append(" ,\n"); + } + sb.append(" };\n"); + } else { + sb.append(" private static final String[] expectedOpenCL = null;\n"); + } + } +} diff --git a/src/test/java/com/aparapi/codegen/Diff.java b/src/test/java/com/aparapi/codegen/Diff.java new file mode 100644 index 0000000000000000000000000000000000000000..5a48f63371be93d51b10d494202176f29cf85f6d --- /dev/null +++ b/src/test/java/com/aparapi/codegen/Diff.java @@ -0,0 +1,282 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* +Copyright (c) 2010-2011, Advanced Micro Devices, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following +disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +disclaimer in the documentation and/or other materials provided with the distribution. + +Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +If you use the software (in whole or in part), you shall adhere to all applicable U.S., European, and other export +laws, including but not limited to the U.S. Export Administration Regulations ("EAR"), (15 C.F.R. Sections 730 through +774), and E.U. Council Regulation (EC) No 1334/2000 of 22 June 2000. Further, pursuant to Section 740.6 of the EAR, +you hereby certify that, except pursuant to a license granted by the United States Department of Commerce Bureau of +Industry and Security or as otherwise permitted pursuant to a License Exception under the U.S. Export Administration +Regulations ("EAR"), you will not (1) export, re-export or release to a national of a country in Country Groups D:1, +E:1 or E:2 any restricted technology, software, or source code you receive hereunder, or (2) export to Country Groups +D:1, E:1 or E:2 the direct product of such technology or software, if such foreign produced direct product is subject +to national security controls as identified on the Commerce Control List (currently found in Supplement 1 to Part 774 +of EAR). For the most current Country Group listings, or for additional information about the EAR or your obligations +under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. + +*/ +package com.aparapi.codegen; + +import java.awt.Point; +import java.util.ArrayList; +import java.util.List; + +public class Diff{ + + static int[] hash(String[] lines) { + int[] val = new int[lines.length]; + for (int i = 0; i < lines.length; i++) { + val[i] = lines[i].hashCode(); + } + return (val); + } + + static void costDiag(List<Point>[][] flags, int x, int y) { + if (x == 0 || y == 0 || flags[x - 1][y - 1] == null) { + if (x < (flags.length - 2) && y < (flags[0].length - 2)) { + flags[x][y] = new ArrayList<Point>(); + flags[x][y].add(new Point(x, y)); + } + } else { + flags[x - 1][y - 1].add(new Point(x, y)); + flags[x][y] = flags[x - 1][y - 1]; + } + } + + static void cleanIslands(List<Point>[][] flags, int x, int y) { + flags[x][y] = null; + if (x > 0 && y > 0 && flags[x - 1][y - 1] != null && flags[x - 1][y - 1].size() == 1) { + flags[x - 1][y - 1] = null; + } + } + + public static class DiffResult{ + + public static enum TYPE { + SAME, + LEFT, + RIGHT + }; + + public static class Block{ + int lhsFrom; + + int rhsFrom; + + int lhsTo; + + int rhsTo; + + TYPE type; + + public Block(TYPE _type, int _lhsFrom, int _rhsFrom) { + lhsFrom = lhsTo = _lhsFrom; + rhsFrom = rhsTo = _rhsFrom; + type = _type; + } + + public void extend(int _lhsTo, int _rhsTo) { + lhsTo = _lhsTo; + rhsTo = _rhsTo; + } + + public String toString(String[] _lhs, String[] _rhs) { + StringBuilder sb = new StringBuilder(); + sb.append(type).append("\n"); + + switch (type) { + case SAME: + for (int i = lhsFrom; i <= lhsTo; i++) { + sb.append(" ==" + _lhs[i]).append("\n"); + } + break; + case LEFT: + for (int i = lhsFrom; i <= lhsTo; i++) { + sb.append(" <" + _lhs[i]).append("\n"); + } + break; + case RIGHT: + for (int i = rhsFrom; i <= rhsTo; i++) { + sb.append(" >" + _rhs[i]).append("\n"); + } + break; + } + return (sb.toString()); + } + + } + + List<Block> blocks = new ArrayList<Block>(); + + private String[] rhs; + + private String[] lhs; + + public void add(TYPE _type, int lhs, int rhs) { + if (false) { + if (blocks.size() > 0) { + Block lastBlock = blocks.get(blocks.size() - 1); + if (lastBlock.type == _type) { + lastBlock.extend(lhs, rhs); + } else { + blocks.add(new Block(_type, lhs, rhs)); + } + } else { + blocks.add(new Block(_type, lhs, rhs)); + } + } + blocks.add(new Block(_type, lhs, rhs)); + } + + DiffResult(String[] _lhs, String[] _rhs) { + lhs = _lhs; + rhs = _rhs; + } + + public String[] getLhs() { + return lhs; + } + + public String[] getRhs() { + return rhs; + } + + public String toString() { + StringBuilder sb = new StringBuilder(); + for (Block block : blocks) { + sb.append(block.toString(lhs, rhs)).append("\n"); + } + return (sb.toString()); + } + } + + @SuppressWarnings("unchecked") public static DiffResult diff(String[] lhsString, String[] rhsString) { + DiffResult diffResult = new DiffResult(lhsString, rhsString); + int[] lhsHash = hash(lhsString); + int[] rhsHash = hash(rhsString); + int lhsLength = lhsHash.length; // number of lines of first file + int rhsLength = rhsHash.length; // number of lines of second file + + // opt[i][j] = length of LCS of x[i..M] and y[j..N] + int[][] opt = new int[lhsLength + 1][rhsLength + 1]; + List<Point>[][] flags = new ArrayList[lhsLength + 1][rhsLength + 1]; + + // compute length of LCS and all subproblems via dynamic programming + for (int i = 0; i < lhsLength; i++) { + for (int j = 0; j < rhsLength; j++) { + if (lhsHash[i] == rhsHash[j]) { + // We are the same so continue the diagonal is intact + if (i == 0 || j == 0) { + opt[i][j] = 0; + } else { + opt[i][j] = opt[i - 1][j - 1] + 1; + } + costDiag(flags, i, j); + } else { + cleanIslands(flags, i, j); + if (i == 0 || j == 0) { + opt[i][j] = 0; + } else { + opt[i][j] = Math.max(opt[i - 1][j], opt[i][j - 1]); + } + } + } + } + + // recover LCS itself and print out non-matching lines to standard output + int i = 0, j = 0; + while (i < lhsLength && j < rhsLength) { + // if the diagonal is in tact walk it + if (lhsHash[i] == rhsHash[j]) { + diffResult.add(DiffResult.TYPE.SAME, i, j); + i++; + j++; + } + // otherwise walk along the xx or y axis which is the longer + // this is not always the best approach. + // we need to find the shortest path between {i,j} and the {i+ii,j+jj} which + // connects us to the next diagonal run + else if (opt[i + 1][j] >= opt[i][j + 1]) { + diffResult.add(DiffResult.TYPE.LEFT, i, j); + System.out.println("lhs:" + i + "< " + lhsString[i++]); + } else { + diffResult.add(DiffResult.TYPE.RIGHT, i, j); + System.out.println("rhs:" + j + "> " + rhsString[j++]); + } + } + + // dump out one remainder of one string if the other is exhausted + while (i < lhsLength || j < rhsLength) { + if (i == lhsLength) { + diffResult.add(DiffResult.TYPE.RIGHT, i, j); + System.out.println("lhs:" + i + "> " + rhsString[j++]); + } else if (j == rhsLength) { + diffResult.add(DiffResult.TYPE.LEFT, i, j); + System.out.println("rhs:" + j + "< " + lhsString[i++]); + } + } + return (diffResult); + } + + public static boolean same(String left, String right) { + StringBuilder leftAll = new StringBuilder(); + + for (String s : left.replace("\n", "").split(" *")) { + leftAll.append(s); + } + + StringBuilder rightAll = new StringBuilder(); + for (String s : right.replace("\n", " ").split(" *")) { + rightAll.append(s); + } + boolean same = leftAll.toString().equals(rightAll.toString()); + if (!same) { + String[] lhs = left.split("\n"); + for (int i = 0; i < lhs.length; i++) { + lhs[i] = lhs[i].trim(); + } + String[] rhs = right.split("\n"); + for (int i = 0; i < rhs.length; i++) { + rhs[i] = rhs[i].trim(); + } + diff(lhs, rhs); + } + return (same); + } + +} diff --git a/src/test/java/com/aparapi/codegen/KernelHelper.java b/src/test/java/com/aparapi/codegen/KernelHelper.java new file mode 100644 index 0000000000000000000000000000000000000000..a50599a22a3b67cf2be776382e31d88f3b94ad98 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/KernelHelper.java @@ -0,0 +1,71 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* +Copyright (c) 2010-2011, Advanced Micro Devices, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following +disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +disclaimer in the documentation and/or other materials provided with the distribution. + +Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +If you use the software (in whole or in part), you shall adhere to all applicable U.S., European, and other export +laws, including but not limited to the U.S. Export Administration Regulations ("EAR"), (15 C.F.R. Sections 730 through +774), and E.U. Council Regulation (EC) No 1334/2000 of 22 June 2000. Further, pursuant to Section 740.6 of the EAR, +you hereby certify that, except pursuant to a license granted by the United States Department of Commerce Bureau of +Industry and Security or as otherwise permitted pursuant to a License Exception under the U.S. Export Administration +Regulations ("EAR"), you will not (1) export, re-export or release to a national of a country in Country Groups D:1, +E:1 or E:2 any restricted technology, software, or source code you receive hereunder, or (2) export to Country Groups +D:1, E:1 or E:2 the direct product of such technology or software, if such foreign produced direct product is subject +to national security controls as identified on the Commerce Control List (currently found in Supplement 1 to Part 774 +of EAR). For the most current Country Group listings, or for additional information about the EAR or your obligations +under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. + +*/ +package com.aparapi.codegen; + +// contains some things that only tests would use +// but in the com.codegen package for convenience + +public class KernelHelper{ + // public KernelHelper(Kernel kernel) { + // this.kernel = kernel; + // this.kernelRunner = kernel.getKernelRunner(); + // } + // + // public boolean hasFP64Support() { + // return kernelRunner.hasFP64Support(); + // } + // + // Kernel kernel; + // + // KernelRunner kernelRunner; +} diff --git a/src/test/java/com/aparapi/codegen/Source.java b/src/test/java/com/aparapi/codegen/Source.java new file mode 100644 index 0000000000000000000000000000000000000000..c5b44d1377ba527e3b331c6be6959e6a0098223c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/Source.java @@ -0,0 +1,201 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* +Copyright (c) 2010-2011, Advanced Micro Devices, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following +disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +disclaimer in the documentation and/or other materials provided with the distribution. + +Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +If you use the software (in whole or in part), you shall adhere to all applicable U.S., European, and other export +laws, including but not limited to the U.S. Export Administration Regulations ("EAR"), (15 C.F.R. Sections 730 through +774), and E.U. Council Regulation (EC) No 1334/2000 of 22 June 2000. Further, pursuant to Section 740.6 of the EAR, +you hereby certify that, except pursuant to a license granted by the United States Department of Commerce Bureau of +Industry and Security or as otherwise permitted pursuant to a License Exception under the U.S. Export Administration +Regulations ("EAR"), you will not (1) export, re-export or release to a national of a country in Country Groups D:1, +E:1 or E:2 any restricted technology, software, or source code you receive hereunder, or (2) export to Country Groups +D:1, E:1 or E:2 the direct product of such technology or software, if such foreign produced direct product is subject +to national security controls as identified on the Commerce Control List (currently found in Supplement 1 to Part 774 +of EAR). For the most current Country Group listings, or for additional information about the EAR or your obligations +under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. + +*/ +package com.aparapi.codegen; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; + +public class Source{ + enum STATE { + NONE, + JAVA, + OPENCL, + DOC + }; + + static final String OpenCLStart = "/**{OpenCL{"; + + static final String OpenCLEnd = "}OpenCL}**/"; + + static final String ThrowsStart = "/**{Throws{"; + + static final String ThrowsEnd = "}Throws}**/"; + + static final String DocStart = "/**"; + + static final String DocEnd = "*/"; + + Class<?> clazz; + + File file; + + Source.STATE state = STATE.NONE; + + List<String> all = new ArrayList<String>(); + + List<List<String>> opencl = new ArrayList<List<String>>(); + + List<String> doc = new ArrayList<String>(); + + List<String> java = new ArrayList<String>(); + + List<String> exceptions = new ArrayList<String>(); + + public Source(Class<?> _clazz, File _rootDir) { + clazz = _clazz; + String srcName = clazz.getPackage().getName().replace(".", "/") + "/" + clazz + ".java"; + file = new File(_rootDir, srcName); + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); + + state = STATE.JAVA; + List<String> openclSection = null; + for (String line = reader.readLine(); line != null; line = reader.readLine()) { + all.add(line); + String trimmedLine = line.trim(); + switch (state) { + case JAVA: + if (trimmedLine.equals(OpenCLStart)) { + state = STATE.OPENCL; + openclSection = new ArrayList<String>(); + opencl.add(openclSection); + + } else if (trimmedLine.startsWith(ThrowsStart) && trimmedLine.endsWith(ThrowsEnd)) { + exceptions.add(trimmedLine.substring(ThrowsStart.length(), trimmedLine.length() - ThrowsEnd.length())); + } else if (trimmedLine.equals(DocStart)) { + state = STATE.DOC; + } else { + java.add(line); + } + break; + case OPENCL: + if (trimmedLine.equals(OpenCLEnd)) { + state = STATE.JAVA; + } else { + openclSection.add(line); + } + break; + case DOC: + if (trimmedLine.equals(DocEnd)) { + state = STATE.JAVA; + } else { + doc.add(line); + } + break; + + } + } + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private String listToString(List<String> list) { + StringBuilder stringBuilder = new StringBuilder(); + for (String line : list) { + stringBuilder.append(line).append("\n"); + } + return (stringBuilder.toString().trim()); + } + + public String getOpenCLString(int _index) { + return (listToString(opencl.get(_index))); + } + + public List<List<String>> getOpenCL() { + return (opencl); + } + + public String getJavaString() { + return (listToString(java)); + } + + public List<String> getJava() { + return (java); + } + + public File getFile() { + return (file); + } + + public String getExceptionsString() { + return (listToString(exceptions)); + } + + public List<String> getExceptions() { + return (exceptions); + } + + public String getDocString() { + return (listToString(doc)); + } + + public List<String> getDoc() { + return (doc); + } + + public int getOpenCLSectionCount() { + return (opencl.size()); + } +} diff --git a/src/test/java/com/aparapi/codegen/SwingDiff.java b/src/test/java/com/aparapi/codegen/SwingDiff.java new file mode 100644 index 0000000000000000000000000000000000000000..0b43135944164eb25bbea7384177057f4e4634d2 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/SwingDiff.java @@ -0,0 +1,216 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* +Copyright (c) 2010-2011, Advanced Micro Devices, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the +following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following +disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following +disclaimer in the documentation and/or other materials provided with the distribution. + +Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products +derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +If you use the software (in whole or in part), you shall adhere to all applicable U.S., European, and other export +laws, including but not limited to the U.S. Export Administration Regulations ("EAR"), (15 C.F.R. Sections 730 through +774), and E.U. Council Regulation (EC) No 1334/2000 of 22 June 2000. Further, pursuant to Section 740.6 of the EAR, +you hereby certify that, except pursuant to a license granted by the United States Department of Commerce Bureau of +Industry and Security or as otherwise permitted pursuant to a License Exception under the U.S. Export Administration +Regulations ("EAR"), you will not (1) export, re-export or release to a national of a country in Country Groups D:1, +E:1 or E:2 any restricted technology, software, or source code you receive hereunder, or (2) export to Country Groups +D:1, E:1 or E:2 the direct product of such technology or software, if such foreign produced direct product is subject +to national security controls as identified on the Commerce Control List (currently found in Supplement 1 to Part 774 +of EAR). For the most current Country Group listings, or for additional information about the EAR or your obligations +under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. + +*/ +package com.aparapi.codegen; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextPane; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.text.BadLocationException; +import javax.swing.text.DefaultStyledDocument; +import javax.swing.text.Style; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyleContext; + +public class SwingDiff{ + JFrame frame; + + public SwingDiff(Diff.DiffResult result) { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + + frame = new JFrame("SwingDiff"); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JPanel panel = new JPanel(){ + @Override public void paint(Graphics g) { + super.paint(g); + g.drawRect(10, 10, 100, 100); + } + }; + panel.setLayout(new BorderLayout()); + + StyleContext sc = new StyleContext(); + + // Create and add the style + final Style rootStyle = sc.addStyle("Root", null); + rootStyle.addAttribute(StyleConstants.Foreground, Color.black); + rootStyle.addAttribute(StyleConstants.FontSize, new Integer(12)); + rootStyle.addAttribute(StyleConstants.FontFamily, "serif"); + rootStyle.addAttribute(StyleConstants.Bold, new Boolean(false)); + final Style heading1Style = sc.addStyle("Heading1", rootStyle); + heading1Style.addAttribute(StyleConstants.Foreground, Color.blue); + + final Style heading2Style = sc.addStyle("Heading2", rootStyle); + heading2Style.addAttribute(StyleConstants.Foreground, Color.red); + heading2Style.addAttribute(StyleConstants.Background, Color.green); + + final DefaultStyledDocument lhsdoc = new DefaultStyledDocument(sc); + JTextPane lhs = new JTextPane(lhsdoc); + + lhsdoc.insertString(0, arrayToString(result.getLhs()), null); + + // Finally, apply the style to the heading + + lhsdoc.setParagraphAttributes(4, 1, heading2Style, false); + lhsdoc.setParagraphAttributes(20, 5, heading1Style, false); + + lhs.setPreferredSize(new Dimension(800, 800)); + final DefaultStyledDocument rhsdoc = new DefaultStyledDocument(sc); + JTextPane rhs = new JTextPane(rhsdoc); + rhsdoc.insertString(0, arrayToString(result.getRhs()), null); + + rhsdoc.setParagraphAttributes(4, 1, heading2Style, false); + rhsdoc.setParagraphAttributes(20, 5, heading1Style, false); + rhs.setPreferredSize(new Dimension(800, 800)); + panel.add(new JScrollPane(lhs), BorderLayout.WEST); + panel.add(new JScrollPane(rhs), BorderLayout.EAST); + + // frame.setBackground(background); + frame.getContentPane().add(panel); + frame.pack(); + frame.setVisible(true); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (UnsupportedLookAndFeelException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (BadLocationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public static void main(String[] args) { + String[] lhs = getFileContents("expected.c"); + String[] rhs = getFileContents("actual.c"); + + Diff.DiffResult result = Diff.diff(lhs, rhs); + System.out.println(result); + + SwingDiff swingDiff = new SwingDiff(result); + } + + private static String arrayToString(String[] array) { + StringBuilder stringBuilder = new StringBuilder(); + for (String line : array) { + stringBuilder.append(line).append("\n"); + } + return (stringBuilder.toString().trim()); + } + + private static String[] getFileContents(String string) { + String[] content = null; + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(string))); + List<String> lines = new ArrayList<String>(); + for (String line = reader.readLine(); line != null; line = reader.readLine()) { + lines.add(line); + } + reader.close(); + content = lines.toArray(new String[0]); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return (content); + + } + + private static String getFileContent(String string) { + String content = null; + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(string))); + StringBuilder sb = new StringBuilder(); + for (String line = reader.readLine(); line != null; line = reader.readLine()) { + sb.append(line).append("\n"); + } + reader.close(); + content = sb.toString(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return (content); + + } + +} diff --git a/src/test/java/com/aparapi/codegen/test/Access2DIntArray.java b/src/test/java/com/aparapi/codegen/test/Access2DIntArray.java new file mode 100644 index 0000000000000000000000000000000000000000..130dcfc08c7f09182fdffdbc9f6d8f904aa37037 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/Access2DIntArray.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class Access2DIntArray { + int[][] ints = new int[1024][]; + + public void run() { + int value = ints[0][0]; + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/Access2DIntArrayTest.java b/src/test/java/com/aparapi/codegen/test/Access2DIntArrayTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4cc93f54660a047abbf97e0ac3056b3f24ad3095 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/Access2DIntArrayTest.java @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class Access2DIntArrayTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = {"typedef struct This_s{\n" + + " __global int *ints;\n" + + " int ints__javaArrayLength0;\n" + + " int ints__javaArrayDimension0;\n" + + " int ints__javaArrayLength1;\n" + + " int ints__javaArrayDimension1;\n" + + " int passid;\n" + + "}This;\n" + + "int get_pass_id(This *this){\n" + + " return this->passid;\n" + + "}\n" + + "__kernel void run(\n" + + " __global int *ints, \n" + + " int ints__javaArrayLength0, \n" + + " int ints__javaArrayDimension0, \n" + + " int ints__javaArrayLength1, \n" + + " int ints__javaArrayDimension1, \n" + + " int passid\n" + + "){\n" + + " This thisStruct;\n" + + " This* this=&thisStruct;\n" + + " this->ints = ints;\n" + + " this->ints__javaArrayLength0 = ints__javaArrayLength0;\n" + + " this->ints__javaArrayDimension0 = ints__javaArrayDimension0;\n" + + " this->ints__javaArrayLength1 = ints__javaArrayLength1;\n" + + " this->ints__javaArrayDimension1 = ints__javaArrayDimension1;\n" + + " this->passid = passid;\n" + + " {\n" + + " int value = (&this->ints[0 * this->ints__javaArrayDimension0])[0];\n" + + " return;\n" + + " }\n" + + "}\n" + + "\n"}; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @Test + public void Access2DIntArrayTest() { + test(com.aparapi.codegen.test.Access2DIntArray.class, expectedException, expectedOpenCL); + } + + @Test + public void Access2DIntArrayTestWorksWithCaching() { + test(com.aparapi.codegen.test.Access2DIntArray.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/AccessBooleanArray.java b/src/test/java/com/aparapi/codegen/test/AccessBooleanArray.java new file mode 100644 index 0000000000000000000000000000000000000000..c711d52e86606368b95149cc54f8628b5a0cf701 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AccessBooleanArray.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class AccessBooleanArray { + boolean[] ba = new boolean[1024]; + + public void run() { + for (int i = 0; i < 1024; i++) { + if (i % 2 == 0) { + ba[i] = true; + } else { + ba[i] = false; + } + } + } +} +/**{OpenCL{ + typedef struct This_s{ + __global char *ba; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global char *ba, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->ba = ba; + this->passid = passid; + { + for (int i = 0; i<1024; i++){ + if ((i % 2)==0){ + this->ba[i] = 1; + } else { + this->ba[i] = 0; + } + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/AccessBooleanArrayTest.java b/src/test/java/com/aparapi/codegen/test/AccessBooleanArrayTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3c385b0b1679415e6a613299ce505a5f9d98ee6e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AccessBooleanArrayTest.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class AccessBooleanArrayTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = {"typedef struct This_s{\n" + + " __global char *ba;\n" + + " int passid;\n" + + "}This;\n" + + "int get_pass_id(This *this){\n" + + " return this->passid;\n" + + "}\n" + + "__kernel void run(\n" + + " __global char *ba, \n" + + " int passid\n" + + "){\n" + + " This thisStruct;\n" + + " This* this=&thisStruct;\n" + + " this->ba = ba;\n" + + " this->passid = passid;\n" + + " {\n" + + " for (int i = 0; i<1024; i++){\n" + + " if ((i % 2)==0){\n" + + " this->ba[i] = 1;\n" + + " } else {\n" + + " this->ba[i] = 0;\n" + + " }\n" + + " }\n" + + " return;\n" + + " }\n" + + "}\n" + + "\n"}; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @Test + public void AccessBooleanArrayTest() { + test(com.aparapi.codegen.test.AccessBooleanArray.class, expectedException, expectedOpenCL); + } + + @Test + public void AccessBooleanArrayTestWorksWithCaching() { + test(com.aparapi.codegen.test.AccessBooleanArray.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/AccessByteArray.java b/src/test/java/com/aparapi/codegen/test/AccessByteArray.java new file mode 100644 index 0000000000000000000000000000000000000000..9596c0b95e5f1ab3a48b8aed664ddfc5d0e45f4f --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AccessByteArray.java @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +/** + * + * Test whether we can assign a byte array element. + * @author gfrost + * + */ +public class AccessByteArray { + byte[] bytes = new byte[1024]; + + public void run() { + + for (int i = 0; i < 1024; i++) { + + bytes[i] = (byte) 1; + + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + __global char *bytes; + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global char *bytes, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->bytes = bytes; + this->passid = passid; + { + for (int i = 0; i<1024; i++){ + this->bytes[i] = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/AccessByteArrayTest.java b/src/test/java/com/aparapi/codegen/test/AccessByteArrayTest.java new file mode 100644 index 0000000000000000000000000000000000000000..be92c00d23a0ac915dfd585dd551eeb11915c061 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AccessByteArrayTest.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class AccessByteArrayTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = {"typedef struct This_s{\n" + + " __global char *bytes;\n" + + " int passid;\n" + + "}This;\n" + + "int get_pass_id(This *this){\n" + + " return this->passid;\n" + + "}\n" + + "__kernel void run(\n" + + " __global char *bytes, \n" + + " int passid\n" + + "){\n" + + " This thisStruct;\n" + + " This* this=&thisStruct;\n" + + " this->bytes = bytes;\n" + + " this->passid = passid;\n" + + " {\n" + + " for (int i = 0; i<1024; i++){\n" + + " this->bytes[i] = 1;\n" + + " }\n" + + " return;\n" + + " }\n" + + "}\n" + + "\n"}; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @Test + public void AccessByteArrayTest() { + test(com.aparapi.codegen.test.AccessByteArray.class, expectedException, expectedOpenCL); + } + + @Test + public void AccessByteArrayTestWorksWithCaching() { + test(com.aparapi.codegen.test.AccessByteArray.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/AccessDoubleArray.java b/src/test/java/com/aparapi/codegen/test/AccessDoubleArray.java new file mode 100644 index 0000000000000000000000000000000000000000..d479cf68dcf29a7492e9ced5c1ca5450f3b7f372 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AccessDoubleArray.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class AccessDoubleArray { + double[] doubles = new double[1024]; + + public void run() { + + for (int i = 0; i < 1024; i++) { + doubles[i] = 1.0; + } + } +} +/**{OpenCL{ + #pragma OPENCL EXTENSION cl_khr_fp64 : enable + + typedef struct This_s{ + __global double *doubles; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global double *doubles, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->doubles = doubles; + this->passid = passid; + { + for (int i = 0; i<1024; i++){ + this->doubles[i] = 1.0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/AccessDoubleArrayTest.java b/src/test/java/com/aparapi/codegen/test/AccessDoubleArrayTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8c43a995f536195367601a905aa2b52c3e57411c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AccessDoubleArrayTest.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class AccessDoubleArrayTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = {"#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n" + + "\n" + + "typedef struct This_s{\n" + + " __global double *doubles;\n" + + " int passid;\n" + + "}This;\n" + + "int get_pass_id(This *this){\n" + + " return this->passid;\n" + + "}\n" + + "__kernel void run(\n" + + " __global double *doubles, \n" + + " int passid\n" + + "){\n" + + " This thisStruct;\n" + + " This* this=&thisStruct;\n" + + " this->doubles = doubles;\n" + + " this->passid = passid;\n" + + " {\n" + + " for (int i = 0; i<1024; i++){\n" + + " this->doubles[i] = 1.0;\n" + + " }\n" + + " return;\n" + + " }\n" + + "}\n" + + "\n"}; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @Test + public void AccessDoubleArrayTest() { + test(com.aparapi.codegen.test.AccessDoubleArray.class, expectedException, expectedOpenCL); + } + + @Test + public void AccessDoubleArrayTestWorksWithCaching() { + test(com.aparapi.codegen.test.AccessDoubleArray.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/AccessFloatArray.java b/src/test/java/com/aparapi/codegen/test/AccessFloatArray.java new file mode 100644 index 0000000000000000000000000000000000000000..8be51ceb24cea8609315500e57a580f48a731023 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AccessFloatArray.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class AccessFloatArray { + float[] floats = new float[1024]; + + public void run() { + for (int i = 0; i < 1024; i++) { + floats[i] = 1f; + } + } +} +/**{OpenCL{ + typedef struct This_s{ + __global float *floats; + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global float *floats, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->floats = floats; + this->passid = passid; + { + for (int i = 0; i<1024; i++){ + this->floats[i] = 1.0f; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/AccessFloatArrayTest.java b/src/test/java/com/aparapi/codegen/test/AccessFloatArrayTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c6cadebc7f60f2a7c9c13169be52241d844830c9 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AccessFloatArrayTest.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class AccessFloatArrayTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = {"typedef struct This_s{\n" + + " __global float *floats;\n" + + " int passid;\n" + + "}This;\n" + + "int get_pass_id(This *this){\n" + + " return this->passid;\n" + + "}\n" + + "__kernel void run(\n" + + " __global float *floats, \n" + + " int passid\n" + + "){\n" + + " This thisStruct;\n" + + " This* this=&thisStruct;\n" + + " this->floats = floats;\n" + + " this->passid = passid;\n" + + " {\n" + + " for (int i = 0; i<1024; i++){\n" + + " this->floats[i] = 1.0f;\n" + + " }\n" + + " return;\n" + + " }\n" + + "}\n" + + "\n"}; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @Test + public void AccessFloatArrayTest() { + test(com.aparapi.codegen.test.AccessFloatArray.class, expectedException, expectedOpenCL); + } + + @Test + public void AccessFloatArrayTestWorksWithCaching() { + test(com.aparapi.codegen.test.AccessFloatArray.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/AccessIntArray.java b/src/test/java/com/aparapi/codegen/test/AccessIntArray.java new file mode 100644 index 0000000000000000000000000000000000000000..52757e6ceb8d6491c21ee6698542eb84d4430313 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AccessIntArray.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class AccessIntArray { + int[] ints = new int[1024]; + + public void run() { + for (int i = 0; i < 1024; i++) { + ints[i] = 1; + } + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *ints; + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global int *ints, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->ints = ints; + this->passid = passid; + { + for (int i = 0; i<1024; i++){ + this->ints[i] = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/AccessIntArrayTest.java b/src/test/java/com/aparapi/codegen/test/AccessIntArrayTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5d405c1294bd4a469674b9bca075f18f0c9c43d8 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AccessIntArrayTest.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class AccessIntArrayTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = {"typedef struct This_s{\n" + + " __global int *ints;\n" + + " int passid;\n" + + "}This;\n" + + "int get_pass_id(This *this){\n" + + " return this->passid;\n" + + "}\n" + + "__kernel void run(\n" + + " __global int *ints, \n" + + " int passid\n" + + "){\n" + + " This thisStruct;\n" + + " This* this=&thisStruct;\n" + + " this->ints = ints;\n" + + " this->passid = passid;\n" + + " {\n" + + " for (int i = 0; i<1024; i++){\n" + + " this->ints[i] = 1;\n" + + " }\n" + + " return;\n" + + " }\n" + + "}\n" + + "\n"}; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @Test + public void AccessIntArrayTest() { + test(com.aparapi.codegen.test.AccessIntArray.class, expectedException, expectedOpenCL); + } + + @Test + public void AccessIntArrayTestWorksWithCaching() { + test(com.aparapi.codegen.test.AccessIntArray.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/AccessLongArray.java b/src/test/java/com/aparapi/codegen/test/AccessLongArray.java new file mode 100644 index 0000000000000000000000000000000000000000..ee38585c08f818052df79d3e6cdaca1679ac7f2a --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AccessLongArray.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class AccessLongArray { + long[] longs = new long[1024]; + + public void run() { + for (int i = 0; i < 1024; i++) { + longs[i] = 1; + } + } +} +/**{OpenCL{ + typedef struct This_s{ + __global long *longs; + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global long *longs, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->longs = longs; + this->passid = passid; + { + for (int i = 0; i<1024; i++){ + this->longs[i] = 1L; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/AccessLongArrayTest.java b/src/test/java/com/aparapi/codegen/test/AccessLongArrayTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c8846eda2c110acefdad703fbef1e7631cd0e76e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AccessLongArrayTest.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class AccessLongArrayTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = {"typedef struct This_s{\n" + + " __global long *longs;\n" + + " int passid;\n" + + "}This;\n" + + "int get_pass_id(This *this){\n" + + " return this->passid;\n" + + "}\n" + + "__kernel void run(\n" + + " __global long *longs, \n" + + " int passid\n" + + "){\n" + + " This thisStruct;\n" + + " This* this=&thisStruct;\n" + + " this->longs = longs;\n" + + " this->passid = passid;\n" + + " {\n" + + " for (int i = 0; i<1024; i++){\n" + + " this->longs[i] = 1L;\n" + + " }\n" + + " return;\n" + + " }\n" + + "}\n" + + "\n"}; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @Test + public void AccessLongArrayTest() { + test(com.aparapi.codegen.test.AccessLongArray.class, expectedException, expectedOpenCL); + } + + @Test + public void AccessLongArrayTestWorksWithCaching() { + test(com.aparapi.codegen.test.AccessLongArray.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/AccessNested2DIntArray.java b/src/test/java/com/aparapi/codegen/test/AccessNested2DIntArray.java new file mode 100644 index 0000000000000000000000000000000000000000..fe3574c74c94d0e89009e5f309cdd640b87647db --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AccessNested2DIntArray.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class AccessNested2DIntArray { + int[] indices = new int[1024]; + + int[][] ints = new int[1024][]; + + public void run() { + int value = ints[indices[0]][0]; + } + +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/AccessNested2DIntArrayTest.java b/src/test/java/com/aparapi/codegen/test/AccessNested2DIntArrayTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e3336f37421107f293152b6df8b21f5de354ac1e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AccessNested2DIntArrayTest.java @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class AccessNested2DIntArrayTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = {"typedef struct This_s{\n" + + " __global int *ints;\n" + + " int ints__javaArrayLength0;\n" + + " int ints__javaArrayDimension0;\n" + + " int ints__javaArrayLength1;\n" + + " int ints__javaArrayDimension1;\n" + + " __global int *indices;\n" + + " int passid;\n" + + "}This;\n" + + "int get_pass_id(This *this){\n" + + " return this->passid;\n" + + "}\n" + + "__kernel void run(\n" + + " __global int *ints, \n" + + " int ints__javaArrayLength0, \n" + + " int ints__javaArrayDimension0, \n" + + " int ints__javaArrayLength1, \n" + + " int ints__javaArrayDimension1, \n" + + " __global int *indices, \n" + + " int passid\n" + + "){\n" + + " This thisStruct;\n" + + " This* this=&thisStruct;\n" + + " this->ints = ints;\n" + + " this->ints__javaArrayLength0 = ints__javaArrayLength0;\n" + + " this->ints__javaArrayDimension0 = ints__javaArrayDimension0;\n" + + " this->ints__javaArrayLength1 = ints__javaArrayLength1;\n" + + " this->ints__javaArrayDimension1 = ints__javaArrayDimension1;\n" + + " this->indices = indices;\n" + + " this->passid = passid;\n" + + " {\n" + + " int value = (&this->ints[this->indices[0] * this->ints__javaArrayDimension0])[0];\n" + + " return;\n" + + " }\n" + + "}\n" + + "\n"}; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @Test + public void AccessNested2DIntArrayTest() { + test(com.aparapi.codegen.test.AccessNested2DIntArray.class, expectedException, expectedOpenCL); + } + + @Test + public void AccessNested2DIntArrayTestWorksWithCaching() { + test(com.aparapi.codegen.test.AccessNested2DIntArray.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/AccessShortArray.java b/src/test/java/com/aparapi/codegen/test/AccessShortArray.java new file mode 100644 index 0000000000000000000000000000000000000000..cfddfc8846751a6c22fe3c9e76ee3cc04f719f2d --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AccessShortArray.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class AccessShortArray { + short[] shorts = new short[1024]; + + public void run() { + for (int i = 0; i < 1024; i++) { + shorts[i] = 1; + } + } +} +/**{OpenCL{ + typedef struct This_s{ + __global short *shorts; + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global short *shorts, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->shorts = shorts; + this->passid = passid; + { + for (int i = 0; i<1024; i++){ + this->shorts[i] = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/AccessShortArrayTest.java b/src/test/java/com/aparapi/codegen/test/AccessShortArrayTest.java new file mode 100644 index 0000000000000000000000000000000000000000..323ed934cb185060d15f3bc4666f79779928e54c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AccessShortArrayTest.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class AccessShortArrayTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = {"typedef struct This_s{\n" + + " __global short *shorts;\n" + + " int passid;\n" + + "}This;\n" + + "int get_pass_id(This *this){\n" + + " return this->passid;\n" + + "}\n" + + "__kernel void run(\n" + + " __global short *shorts, \n" + + " int passid\n" + + "){\n" + + " This thisStruct;\n" + + " This* this=&thisStruct;\n" + + " this->shorts = shorts;\n" + + " this->passid = passid;\n" + + " {\n" + + " for (int i = 0; i<1024; i++){\n" + + " this->shorts[i] = 1;\n" + + " }\n" + + " return;\n" + + " }\n" + + "}\n" + + "\n"}; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @Test + public void AccessShortArrayTest() { + test(com.aparapi.codegen.test.AccessShortArray.class, expectedException, expectedOpenCL); + } + + @Test + public void AccessShortArrayTestWorksWithCaching() { + test(com.aparapi.codegen.test.AccessShortArray.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/AndOrAndPrecedence.java b/src/test/java/com/aparapi/codegen/test/AndOrAndPrecedence.java new file mode 100644 index 0000000000000000000000000000000000000000..a2c57582a9b1ff05a401facf97f0f6289baa83ee --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AndOrAndPrecedence.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class AndOrAndPrecedence { + public void run() { + boolean a = true; + boolean b = true; + boolean c = true; + boolean d = true; + @SuppressWarnings("unused") boolean pass = false; + + if (a && b || c && d) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char c = 1; + char d = 1; + char pass = 0; + if (a!=0 && b!=0 || c!=0 && d!=0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/AndOrAndPrecedenceTest.java b/src/test/java/com/aparapi/codegen/test/AndOrAndPrecedenceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e72927f76421eafbf9668baca65c458a7ea27d94 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AndOrAndPrecedenceTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class AndOrAndPrecedenceTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void AndOrAndPrecedenceTest() { + test(com.aparapi.codegen.test.AndOrAndPrecedence.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void AndOrAndPrecedenceTestWorksWithCaching() { + test(com.aparapi.codegen.test.AndOrAndPrecedence.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/AndOrPrecedence.java b/src/test/java/com/aparapi/codegen/test/AndOrPrecedence.java new file mode 100644 index 0000000000000000000000000000000000000000..7547bb30d5454d41f1b7dd93095621b71bd6a94a --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AndOrPrecedence.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class AndOrPrecedence { + public void run() { + boolean a = true; + boolean b = false; + boolean c = false; + @SuppressWarnings("unused") boolean pass = false; + + if (a || b && c) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 0; + char c = 0; + char pass = 0; + if (a!=0 || b!=0 && c!=0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/AndOrPrecedence2.java b/src/test/java/com/aparapi/codegen/test/AndOrPrecedence2.java new file mode 100644 index 0000000000000000000000000000000000000000..8a306ad4214900fcbd1fb5ebac5373a8736ad871 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AndOrPrecedence2.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class AndOrPrecedence2 { + public void run() { + boolean a = false; + boolean b = false; + boolean d = false; + @SuppressWarnings("unused") boolean pass = false; + + if (a && !(b && d)) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 0; + char b = 0; + char d = 0; + char pass = 0; + if (a!=0 && (b==0 || d==0)){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/AndOrPrecedence2Test.java b/src/test/java/com/aparapi/codegen/test/AndOrPrecedence2Test.java new file mode 100644 index 0000000000000000000000000000000000000000..b6d165a724a493db88603a4806aa8592e10a4880 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AndOrPrecedence2Test.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class AndOrPrecedence2Test extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void AndOrPrecedence2Test() { + test(com.aparapi.codegen.test.AndOrPrecedence2.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void AndOrPrecedence2TestWorksWithCaching() { + test(com.aparapi.codegen.test.AndOrPrecedence2.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/AndOrPrecedenceTest.java b/src/test/java/com/aparapi/codegen/test/AndOrPrecedenceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..551dc90cd323477299eaf9a5b58a83a4c10821c6 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AndOrPrecedenceTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class AndOrPrecedenceTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void AndOrPrecedenceTest() { + test(com.aparapi.codegen.test.AndOrPrecedence.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void AndOrPrecedenceTestWorksWithCaching() { + test(com.aparapi.codegen.test.AndOrPrecedence.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ArbitraryScope.java b/src/test/java/com/aparapi/codegen/test/ArbitraryScope.java new file mode 100644 index 0000000000000000000000000000000000000000..f17fa3cd8d16b3f8f236ae7e7171c0e232295e35 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ArbitraryScope.java @@ -0,0 +1,118 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ArbitraryScope { + int width = 1024; + + float scale = 1f; + + int maxIterations = 10; + + public void run() { + int tid = 0; + + int i = tid % width; + int j = tid / width; + + float x0 = ((i * scale) - ((scale / 2) * width)) / width; + float y0 = ((j * scale) - ((scale / 2) * width)) / width; + + float x = x0; + float y = y0; + + float x2 = x * x; + float y2 = y * y; + + { + + float scaleSquare = scale * scale; + + int count = 0; + + for (int iter = 0; iter < maxIterations; ++iter) { + if (x2 + y2 <= scaleSquare) { + y = 2 * x * y + y0; + x = x2 - y2 + x0; + + x2 = x * x; + y2 = y * y; + count++; + } else { + count--; + } + } + @SuppressWarnings("unused") int value = (256 * count) / maxIterations; + } + + @SuppressWarnings("unused") float scaleSquare = 1f; + } +} +/**{OpenCL{ + typedef struct This_s{ + int width; + float scale; + int maxIterations; + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int width, + float scale, + int maxIterations, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->width = width; + this->scale = scale; + this->maxIterations = maxIterations; + this->passid = passid; + { + int tid = 0; + int i = tid % this->width; + int j = tid / this->width; + float x0 = (((float)i * this->scale) - ((this->scale / 2.0f) * (float)this->width)) / (float)this->width; + float y0 = (((float)j * this->scale) - ((this->scale / 2.0f) * (float)this->width)) / (float)this->width; + float x = x0; + float y = y0; + float x2 = x * x; + float y2 = y * y; + { + float scaleSquare = this->scale * this->scale; + int count = 0; + for (int iter = 0; iter<this->maxIterations; iter++){ + if ((x2 + y2)<=scaleSquare){ + y = ((2.0f * x) * y) + y0; + x = (x2 - y2) + x0; + x2 = x * x; + y2 = y * y; + count++; + } else { + count--; + } + } + int value = (256 * count) / this->maxIterations; + } + float scaleSquare = 1.0f; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ArbitraryScope2.java b/src/test/java/com/aparapi/codegen/test/ArbitraryScope2.java new file mode 100644 index 0000000000000000000000000000000000000000..fd3ab8c8f2fa6ceb77b3399bb7402c946a57a265 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ArbitraryScope2.java @@ -0,0 +1,119 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ArbitraryScope2 { + int width = 1024; + + float scale = 1f; + + int maxIterations = 10; + + public void run() { + int tid = 0; + + int i = tid % width; + int j = tid / width; + + float x0 = ((i * scale) - ((scale / 2) * width)) / width; + float y0 = ((j * scale) - ((scale / 2) * width)) / width; + + float x = x0; + float y = y0; + + float x2 = x * x; + float y2 = y * y; + + { + int count = 0; + count++; + } + + float scaleSquare = scale * scale; + + int count = 0; + + for (int iter = 0; iter < maxIterations; ++iter) { + if (x2 + y2 <= scaleSquare) { + y = 2 * x * y + y0; + x = x2 - y2 + x0; + + x2 = x * x; + y2 = y * y; + count++; + } else { + count--; + } + } + @SuppressWarnings("unused") int value = (256 * count) / maxIterations; + + } +} +/**{OpenCL{ + typedef struct This_s{ + int width; + float scale; + int maxIterations; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int width, + float scale, + int maxIterations, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->width = width; + this->scale = scale; + this->maxIterations = maxIterations; + this->passid = passid; + { + int tid = 0; + int i = tid % this->width; + int j = tid / this->width; + float x0 = (((float)i * this->scale) - ((this->scale / 2.0f) * (float)this->width)) / (float)this->width; + float y0 = (((float)j * this->scale) - ((this->scale / 2.0f) * (float)this->width)) / (float)this->width; + float x = x0; + float y = y0; + float x2 = x * x; + float y2 = y * y; + { + int count = 0; + count++; + } + float scaleSquare = this->scale * this->scale; + int count = 0; + for (int iter = 0; iter<this->maxIterations; iter++){ + if ((x2 + y2)<=scaleSquare){ + y = ((2.0f * x) * y) + y0; + x = (x2 - y2) + x0; + x2 = x * x; + y2 = y * y; + count++; + } else { + count--; + } + } + int value = (256 * count) / this->maxIterations; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ArbitraryScope2Test.java b/src/test/java/com/aparapi/codegen/test/ArbitraryScope2Test.java new file mode 100644 index 0000000000000000000000000000000000000000..a4f42eecd0b720fbdbb396e019ed4f8e58b092c4 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ArbitraryScope2Test.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ArbitraryScope2Test extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ArbitraryScope2Test() { + test(com.aparapi.codegen.test.ArbitraryScope2.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ArbitraryScope2TestWorksWithCaching() { + test(com.aparapi.codegen.test.ArbitraryScope2.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ArbitraryScopeSimple.java b/src/test/java/com/aparapi/codegen/test/ArbitraryScopeSimple.java new file mode 100644 index 0000000000000000000000000000000000000000..0c2ac91dd32e1164f4c045625edadfe23aa0725e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ArbitraryScopeSimple.java @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ArbitraryScopeSimple { + + public void run() { + int value = 10; + { + int count = 10; + float f = 10f; + value = (int) (count * f); + } + @SuppressWarnings("unused") int result = 0; + int count = 0; + result = value + count; + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int value = 10; + { + int count = 10; + float f = 10.0f; + value = (int)((float)count * f); + } + int result = 0; + int count = 0; + result = value + count; + return; + } + } + + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ArbitraryScopeSimpleTest.java b/src/test/java/com/aparapi/codegen/test/ArbitraryScopeSimpleTest.java new file mode 100644 index 0000000000000000000000000000000000000000..230ff974708d347ac6a9685cf55b5411dfa0915f --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ArbitraryScopeSimpleTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ArbitraryScopeSimpleTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ArbitraryScopeSimpleTest() { + test(com.aparapi.codegen.test.ArbitraryScopeSimple.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ArbitraryScopeSimpleTestWorksWithCaching() { + test(com.aparapi.codegen.test.ArbitraryScopeSimple.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ArbitraryScopeTest.java b/src/test/java/com/aparapi/codegen/test/ArbitraryScopeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b18e9725cc6cf74d367c2d31de92b4ee90903995 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ArbitraryScopeTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ArbitraryScopeTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ArbitraryScopeTest() { + test(com.aparapi.codegen.test.ArbitraryScope.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ArbitraryScopeTestWorksWithCaching() { + test(com.aparapi.codegen.test.ArbitraryScope.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ArrayTortureIssue35.java b/src/test/java/com/aparapi/codegen/test/ArrayTortureIssue35.java new file mode 100644 index 0000000000000000000000000000000000000000..0755b5381f868588ae71945f90f6505fd76ce439 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ArrayTortureIssue35.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ArrayTortureIssue35 { + int[] a = new int[1]; + + int[] b = new int[1]; + + public void run() { + a[b[0]++] = 1; + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *a; + __global int *b; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global int *a, + __global int *b, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->a = a; + this->b = b; + this->passid = passid; + { + this->a[this->b[0]++] = 1; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ArrayTortureIssue35Test.java b/src/test/java/com/aparapi/codegen/test/ArrayTortureIssue35Test.java new file mode 100644 index 0000000000000000000000000000000000000000..c2c5168cec10a9b10cf58ea76519c7a21cb9bc73 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ArrayTortureIssue35Test.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ArrayTortureIssue35Test extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ArrayTortureIssue35Test() { + test(com.aparapi.codegen.test.ArrayTortureIssue35.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ArrayTortureIssue35TestWorksWithCaching() { + test(com.aparapi.codegen.test.ArrayTortureIssue35.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/Assign2DIntArray.java b/src/test/java/com/aparapi/codegen/test/Assign2DIntArray.java new file mode 100644 index 0000000000000000000000000000000000000000..e38d8b5b982ef58ff49559d901b0e03c19573859 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/Assign2DIntArray.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class Assign2DIntArray { + int[][] ints = new int[1024][]; + + public void run() { + ints[0][0] = 1; + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/Assign2DIntArrayTest.java b/src/test/java/com/aparapi/codegen/test/Assign2DIntArrayTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cbdc2c8b803297fd92f906eb17b0c38571a42ec5 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/Assign2DIntArrayTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class Assign2DIntArrayTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void Assign2DIntArrayTest() { + test(com.aparapi.codegen.test.Assign2DIntArray.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void Assign2DIntArrayTestWorksWithCaching() { + test(com.aparapi.codegen.test.Assign2DIntArray.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/AssignAndPassAsParameter.java b/src/test/java/com/aparapi/codegen/test/AssignAndPassAsParameter.java new file mode 100644 index 0000000000000000000000000000000000000000..f52a5a7ff9a794c2315a6cb0e47493ddc46502b1 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AssignAndPassAsParameter.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class AssignAndPassAsParameter { + + final static int START_SIZE = 128; + + public int[] values = new int[START_SIZE]; + + public int[] results = new int[START_SIZE]; + int y = 2; + + int actuallyDoIt(int a) { + return 1; + } + + public void run() { + actuallyDoIt(results[y] = actuallyDoIt(y)); + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *results; + int y; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + int com_amd_aparapi_test_AssignAndPassAsParameter__actuallyDoIt(This *this, int a){ + return(1); + } + __kernel void run( + __global int *results, + int y, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->results = results; + this->y = y; + this->passid = passid; + { + com_amd_aparapi_test_AssignAndPassAsParameter__actuallyDoIt(this, this->results[this->y] = com_amd_aparapi_test_AssignAndPassAsParameter__actuallyDoIt(this, this->y)); + return; + } + } + + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/AssignAndPassAsParameterSimple.java b/src/test/java/com/aparapi/codegen/test/AssignAndPassAsParameterSimple.java new file mode 100644 index 0000000000000000000000000000000000000000..eb0c1044e88e32b06316e3a4cfee1350d9c8e141 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AssignAndPassAsParameterSimple.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class AssignAndPassAsParameterSimple { + + void actuallyDoIt(int a) { + + } + + public void run() { + @SuppressWarnings("unused") int z; + actuallyDoIt(z = 1); + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/AssignAndPassAsParameterSimpleTest.java b/src/test/java/com/aparapi/codegen/test/AssignAndPassAsParameterSimpleTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c30743c14cdc1990d91db5a3ccf176e33b5bafda --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AssignAndPassAsParameterSimpleTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class AssignAndPassAsParameterSimpleTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void AssignAndPassAsParameterSimpleTest() { + test(com.aparapi.codegen.test.AssignAndPassAsParameterSimple.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void AssignAndPassAsParameterSimpleTestWorksWithCaching() { + test(com.aparapi.codegen.test.AssignAndPassAsParameterSimple.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/AssignAndPassAsParameterTest.java b/src/test/java/com/aparapi/codegen/test/AssignAndPassAsParameterTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8c15f7879e121f2d0857ef611bbc55812e1eb921 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AssignAndPassAsParameterTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class AssignAndPassAsParameterTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void AssignAndPassAsParameterTest() { + test(com.aparapi.codegen.test.AssignAndPassAsParameter.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void AssignAndPassAsParameterTestWorksWithCaching() { + test(com.aparapi.codegen.test.AssignAndPassAsParameter.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/AssignField.java b/src/test/java/com/aparapi/codegen/test/AssignField.java new file mode 100644 index 0000000000000000000000000000000000000000..32ea9432ed142a13697f55aacf135207822026e5 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AssignField.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class AssignField { + int field = 1024; + + public void run() { + field = 100; + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/AssignFieldTest.java b/src/test/java/com/aparapi/codegen/test/AssignFieldTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9376dbfbcf0a05073da22af14d83583cadfd81af --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/AssignFieldTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class AssignFieldTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void AssignFieldTest() { + test(com.aparapi.codegen.test.AssignField.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void AssignFieldTestWorksWithCaching() { + test(com.aparapi.codegen.test.AssignField.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/Atomic32Pragma.java b/src/test/java/com/aparapi/codegen/test/Atomic32Pragma.java new file mode 100644 index 0000000000000000000000000000000000000000..6067b2d9beab0ff9d427010d2e4252a7baecd6c2 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/Atomic32Pragma.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class Atomic32Pragma extends Kernel { + + final int[] values = new int[10]; + + @Override + public void run() { + atomicAdd(values, 1, 1); + } +} + +/**{OpenCL{ + #pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable + #pragma OPENCL EXTENSION cl_khr_global_int32_extended_atomics : enable + #pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics : enable + #pragma OPENCL EXTENSION cl_khr_local_int32_extended_atomics : enable + int atomicAdd(__global int *_arr, int _index, int _delta){ + return atomic_add(&_arr[_index], _delta); + } + typedef struct This_s{ + __global int *values; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global int *values, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->values = values; + this->passid = passid; + { + atomicAdd(this->values, 1, 1); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/Atomic32PragmaTest.java b/src/test/java/com/aparapi/codegen/test/Atomic32PragmaTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a5337c95966240c20a67f97442d3a4498e2d2288 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/Atomic32PragmaTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class Atomic32PragmaTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void Atomic32PragmaTest() { + test(com.aparapi.codegen.test.Atomic32Pragma.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void Atomic32PragmaTestWorksWithCaching() { + test(com.aparapi.codegen.test.Atomic32Pragma.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/BooleanToggle.java b/src/test/java/com/aparapi/codegen/test/BooleanToggle.java new file mode 100644 index 0000000000000000000000000000000000000000..19d9ecfc1a013123f01428b13a169fb8f4b3c999 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/BooleanToggle.java @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class BooleanToggle { + public void run() { + boolean pass = false; + + pass = !pass; + + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + pass = (pass==0)?1:0; + return; + } + } + }OpenCL}**/ +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + pass = (pass!=0)?0:1; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/BooleanToggleTest.java b/src/test/java/com/aparapi/codegen/test/BooleanToggleTest.java new file mode 100644 index 0000000000000000000000000000000000000000..22640e2923a82d48d35a00d6dde9ada6ebd66501 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/BooleanToggleTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class BooleanToggleTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void BooleanToggleTest() { + test(com.aparapi.codegen.test.BooleanToggle.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void BooleanToggleTestWorksWithCaching() { + test(com.aparapi.codegen.test.BooleanToggle.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/Break.java b/src/test/java/com/aparapi/codegen/test/Break.java new file mode 100644 index 0000000000000000000000000000000000000000..426e5f79609f01a0c9c6f58a5424754de6b07d4b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/Break.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class Break { + public void run() { + @SuppressWarnings("unused") boolean pass = false; + for (int i = 0; i < 10; i++) { + if (i == 5) { + break; + } + pass = true; + } + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/BreakTest.java b/src/test/java/com/aparapi/codegen/test/BreakTest.java new file mode 100644 index 0000000000000000000000000000000000000000..73daa3d51a7a195dadd51af93d93a06782fd86b7 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/BreakTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class BreakTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void BreakTest() { + test(com.aparapi.codegen.test.Break.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void BreakTestWorksWithCaching() { + test(com.aparapi.codegen.test.Break.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ByteParams.java b/src/test/java/com/aparapi/codegen/test/ByteParams.java new file mode 100644 index 0000000000000000000000000000000000000000..910cc8df2b46073539d433db02c96c50ccd203ec --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ByteParams.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ByteParams { + + // input for addEmUp2 + byte[] test = new byte[4]; + + byte addEmUp2(byte x, byte y) { + return (byte) ((byte) x + (byte) y); + } + + public void run() { + + @SuppressWarnings("unused") byte bb = 0; + byte cc = 7; + + addEmUp2((bb = cc), cc); + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + char com_amd_aparapi_test_ByteParams__addEmUp2(This *this, char x, char y){ + return((char )(x + y)); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char bb = 0; + char cc = 7; + com_amd_aparapi_test_ByteParams__addEmUp2(this, bb = cc, cc); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ByteParamsSimple.java b/src/test/java/com/aparapi/codegen/test/ByteParamsSimple.java new file mode 100644 index 0000000000000000000000000000000000000000..6040d125d00aec8ab19033498275489bc3d5ff4d --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ByteParamsSimple.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ByteParamsSimple { + + void addEmUp2(byte x, byte y) { + + } + + public void run() { + + byte bb = 0; + byte cc = 7; + + addEmUp2(bb, cc); + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + void com_amd_aparapi_test_ByteParamsSimple__addEmUp2(This *this, char x, char y){ + return; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char bb = 0; + char cc = 7; + com_amd_aparapi_test_ByteParamsSimple__addEmUp2(this, bb, cc); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ByteParamsSimpleTest.java b/src/test/java/com/aparapi/codegen/test/ByteParamsSimpleTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c3998f227f2000044f14e954071f160378cddc9c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ByteParamsSimpleTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ByteParamsSimpleTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ByteParamsSimpleTest() { + test(com.aparapi.codegen.test.ByteParamsSimple.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ByteParamsSimpleTestWorksWithCaching() { + test(com.aparapi.codegen.test.ByteParamsSimple.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ByteParamsTest.java b/src/test/java/com/aparapi/codegen/test/ByteParamsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4f8f6063581d61706a9f59272c3dddcdbe1968dc --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ByteParamsTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ByteParamsTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ByteParamsTest() { + test(com.aparapi.codegen.test.ByteParams.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ByteParamsTestWorksWithCaching() { + test(com.aparapi.codegen.test.ByteParams.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/CallGetPassId.java b/src/test/java/com/aparapi/codegen/test/CallGetPassId.java new file mode 100644 index 0000000000000000000000000000000000000000..4eababb95636d81a3f8aff024bfbe97179bde119 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CallGetPassId.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class CallGetPassId extends Kernel { + public void run() { + int thePassId = getPassId(); + } + +} +/**{OpenCL{ + + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int thePassId = get_pass_id(this); + return; + } + } + + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/CallGetPassIdTest.java b/src/test/java/com/aparapi/codegen/test/CallGetPassIdTest.java new file mode 100644 index 0000000000000000000000000000000000000000..408a2b2cc1acad58e9a85625a52f0b95f3c5c858 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CallGetPassIdTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class CallGetPassIdTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void CallGetPassIdTest() { + test(com.aparapi.codegen.test.CallGetPassId.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void CallGetPassIdTestWorksWithCaching() { + test(com.aparapi.codegen.test.CallGetPassId.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/CallObject.java b/src/test/java/com/aparapi/codegen/test/CallObject.java new file mode 100644 index 0000000000000000000000000000000000000000..13a5553fd4b945c32eec933b11b19a0a335ad179 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CallObject.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class CallObject extends Kernel { + Dummy dummy = new Dummy(); + + ; + int out[] = new int[2]; + + public void run() { + out[0] = dummy.foo(); + } + + static class Dummy { + public int foo() { + return 42; + } + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/CallObjectStatic.java b/src/test/java/com/aparapi/codegen/test/CallObjectStatic.java new file mode 100644 index 0000000000000000000000000000000000000000..2f135007887bf0cc3b02292da7b9acd1d4b21fa8 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CallObjectStatic.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class CallObjectStatic extends Kernel { + int out[] = new int[2]; + + ; + + public void run() { + out[0] = Dummy.foo(); + } + + static class Dummy { + static public int foo() { + return 42; + } + } +} + +/**{OpenCL{ + typedef struct This_s{ + __global int *out; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + int com_amd_aparapi_test_CallObjectStatic$Dummy__foo(){ + return(42); + } + __kernel void run( + __global int *out, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->out = out; + this->passid = passid; + { + this->out[0] = com_amd_aparapi_test_CallObjectStatic$Dummy__foo(); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/CallObjectStaticTest.java b/src/test/java/com/aparapi/codegen/test/CallObjectStaticTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2adfbbde5a68abad3be3f5f723eef9499266841a --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CallObjectStaticTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class CallObjectStaticTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void CallObjectStaticTest() { + test(com.aparapi.codegen.test.CallObjectStatic.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void CallObjectStaticTestWorksWithCaching() { + test(com.aparapi.codegen.test.CallObjectStatic.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/CallObjectTest.java b/src/test/java/com/aparapi/codegen/test/CallObjectTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c26d62f375d41b16e779fbec18b5d5ce1c387c22 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CallObjectTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class CallObjectTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void CallObjectTest() { + test(com.aparapi.codegen.test.CallObject.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void CallObjectTestWorksWithCaching() { + test(com.aparapi.codegen.test.CallObject.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/CallRunSuper.java b/src/test/java/com/aparapi/codegen/test/CallRunSuper.java new file mode 100644 index 0000000000000000000000000000000000000000..9ed326d0d8467912e393efc1aa1e5c65cdce4977 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CallRunSuper.java @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +class CallRunSuperBase extends Kernel { + int out[] = new int[2]; + + @Override + public void run() { + out[0] = 2; + } +} + +public class CallRunSuper extends CallRunSuperBase { + public void run() { + super.run(); + out[1] = 3; + } + +} +/**{OpenCL{ + typedef struct This_s{ + __global int *out; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + void com_amd_aparapi_test_CallRunSuperBase__run(This *this){ + this->out[0] = 2; + return; + } + __kernel void run( + __global int *out, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->out = out; + this->passid = passid; + { + com_amd_aparapi_test_CallRunSuperBase__run(this); + this->out[1] = 3; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/CallRunSuperTest.java b/src/test/java/com/aparapi/codegen/test/CallRunSuperTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e70e71a984c5a7a65649b00c83729552d47d7224 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CallRunSuperTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class CallRunSuperTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void CallRunSuperTest() { + test(com.aparapi.codegen.test.CallRunSuper.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void CallRunSuperTestWorksWithCaching() { + test(com.aparapi.codegen.test.CallRunSuper.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/CallStaticInAnotherClass.java b/src/test/java/com/aparapi/codegen/test/CallStaticInAnotherClass.java new file mode 100644 index 0000000000000000000000000000000000000000..d6666f056ce0bc0308f99b7f32d3a001e9389813 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CallStaticInAnotherClass.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +class AnotherClass { + static public int foo() { + return 42; + } +}; + +public class CallStaticInAnotherClass extends Kernel { + + int out[] = new int[2]; + + public int doodoo() { + return AnotherClass.foo(); + } + + public void run() { + out[0] = AnotherClass.foo() + doodoo(); + } +} + +/**{OpenCL{ + typedef struct This_s{ + __global int *out; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + int com_amd_aparapi_test_AnotherClass__foo(){ + return(42); + } + int com_amd_aparapi_test_CallStaticInAnotherClass__doodoo(This *this){ + return(com_amd_aparapi_test_AnotherClass__foo()); + } + __kernel void run( + __global int *out, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->out = out; + this->passid = passid; + { + this->out[0] = com_amd_aparapi_test_AnotherClass__foo() + com_amd_aparapi_test_CallStaticInAnotherClass__doodoo(this); + return; + } + } + + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/CallStaticInAnotherClassTest.java b/src/test/java/com/aparapi/codegen/test/CallStaticInAnotherClassTest.java new file mode 100644 index 0000000000000000000000000000000000000000..df8c09436758635d1fb0d88c86285b4f3162119d --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CallStaticInAnotherClassTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class CallStaticInAnotherClassTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void CallStaticInAnotherClassTest() { + test(com.aparapi.codegen.test.CallStaticInAnotherClass.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void CallStaticInAnotherClassTestWorksWithCaching() { + test(com.aparapi.codegen.test.CallStaticInAnotherClass.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/CallSuper.java b/src/test/java/com/aparapi/codegen/test/CallSuper.java new file mode 100644 index 0000000000000000000000000000000000000000..5e3913bfaef4d39283d9bfd541206d3b7c8323a5 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CallSuper.java @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +abstract class CallSuperBase extends Kernel { + int foo(int n) { + return n * 2; + } +} + +public class CallSuper extends CallSuperBase { + int out[] = new int[1]; + + public void run() { + out[0] = foo(2); + } + + int foo(int n) { + return 1 + super.foo(n); + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *out; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + int com_amd_aparapi_test_CallSuperBase__foo(This *this, int n){ + return((n * 2)); + } + int com_amd_aparapi_test_CallSuper__foo(This *this, int n){ + return((1 + com_amd_aparapi_test_CallSuperBase__foo(this, n))); + } + __kernel void run( + __global int *out, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->out = out; + this->passid = passid; + { + this->out[0] = com_amd_aparapi_test_CallSuper__foo(this, 2); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/CallSuperTest.java b/src/test/java/com/aparapi/codegen/test/CallSuperTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2270d9b3050c435964089c3ffd77a390d9f517cb --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CallSuperTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class CallSuperTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void CallSuperTest() { + test(com.aparapi.codegen.test.CallSuper.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void CallSuperTestWorksWithCaching() { + test(com.aparapi.codegen.test.CallSuper.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/CallTwice.java b/src/test/java/com/aparapi/codegen/test/CallTwice.java new file mode 100644 index 0000000000000000000000000000000000000000..fe331587df3a9b30520554f296f8b016dbf035f4 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CallTwice.java @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class CallTwice extends Kernel { + + int out[] = new int[1]; + + public int getOne() { + return (1); + } + + @Override + public void run() { + out[0] = getOne() + getOne(); + } +} + +/**{OpenCL{ + typedef struct This_s{ + __global int *out; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + int com_amd_aparapi_test_CallTwice__getOne(This *this){ + return(1); + } + __kernel void run( + __global int *out, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->out = out; + this->passid = passid; + { + this->out[0] = com_amd_aparapi_test_CallTwice__getOne(this) + com_amd_aparapi_test_CallTwice__getOne(this); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/CallTwiceTest.java b/src/test/java/com/aparapi/codegen/test/CallTwiceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8effb46908693887a71ca4d392dadb9745ae5b82 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CallTwiceTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class CallTwiceTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void CallTwiceTest() { + test(com.aparapi.codegen.test.CallTwice.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void CallTwiceTestWorksWithCaching() { + test(com.aparapi.codegen.test.CallTwice.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/CharArrayField.java b/src/test/java/com/aparapi/codegen/test/CharArrayField.java new file mode 100644 index 0000000000000000000000000000000000000000..0f398785d88e5422c01c3b6abc1345b7b760d970 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CharArrayField.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class CharArrayField { + char out[] = new char[1]; + + public void run() { + out[0] = 0; + } +} + +/**{OpenCL{ + typedef struct This_s{ + __global unsigned short *out; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + __global unsigned short *out, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->out = out; + this->passid = passid; + { + this->out[0] = 0; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/CharArrayFieldTest.java b/src/test/java/com/aparapi/codegen/test/CharArrayFieldTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5790c1d10a82b9d75f3332ef09703052be4950e5 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CharArrayFieldTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class CharArrayFieldTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void CharArrayFieldTest() { + test(com.aparapi.codegen.test.CharArrayField.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void CharArrayFieldTestWorksWithCaching() { + test(com.aparapi.codegen.test.CharArrayField.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/CharAsParameter.java b/src/test/java/com/aparapi/codegen/test/CharAsParameter.java new file mode 100644 index 0000000000000000000000000000000000000000..7433aad164f825d1de05b91a16322797ee921ffa --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CharAsParameter.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class CharAsParameter { + + public char doIt(char x) { + return x; + } + + public void run() { + byte b = 0x1; + + doIt('A'); + + doIt((char) b); + } +} + +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + unsigned short com_amd_aparapi_test_CharAsParameter__doIt(This *this, unsigned short x){ + return(x); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char b = 1; + com_amd_aparapi_test_CharAsParameter__doIt(this, 65); + com_amd_aparapi_test_CharAsParameter__doIt(this, (unsigned short )b); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/CharAsParameterTest.java b/src/test/java/com/aparapi/codegen/test/CharAsParameterTest.java new file mode 100644 index 0000000000000000000000000000000000000000..915f112ac876d81e6e7204badddfdd83b4f7f9e8 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CharAsParameterTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class CharAsParameterTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void CharAsParameterTest() { + test(com.aparapi.codegen.test.CharAsParameter.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void CharAsParameterTestWorksWithCaching() { + test(com.aparapi.codegen.test.CharAsParameter.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/CharType.java b/src/test/java/com/aparapi/codegen/test/CharType.java new file mode 100644 index 0000000000000000000000000000000000000000..fd997320de20429d332b3e249c5a4842256fca7e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CharType.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class CharType extends Kernel { + int out[] = new int[1]; + + @Override + public void run() { + final char c = Character.MAX_VALUE; + this.out[0] = c; + } +} + +/**{OpenCL{ + typedef struct This_s{ + __global int *out; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + __global int *out, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->out = out; + this->passid = passid; + { + unsigned short c = 65535; + this->out[0] = 65535; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/CharTypeTest.java b/src/test/java/com/aparapi/codegen/test/CharTypeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..eb5e98d8daa26cad1cb6ecadabed79205d26bc89 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CharTypeTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class CharTypeTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void CharTypeTest() { + test(com.aparapi.codegen.test.CharType.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void CharTypeTestWorksWithCaching() { + test(com.aparapi.codegen.test.CharType.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ClassHasStaticFieldAccess.java b/src/test/java/com/aparapi/codegen/test/ClassHasStaticFieldAccess.java new file mode 100644 index 0000000000000000000000000000000000000000..3b3d296e7bd70a36cb076f43b65f3f1c58a4d81e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ClassHasStaticFieldAccess.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ClassHasStaticFieldAccess { + static int foo = 6; + int[] ints = new int[1024]; + + public void run() { + for (int i = 0; i < 1024; i++) { + if (i % 2 == 0) { + ints[i] = foo; + } + } + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *ints; + int foo; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + __global int *ints, + int foo, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->ints = ints; + this->foo = foo; + this->passid = passid; + { + for (int i = 0; i<1024; i++){ + if ((i % 2)==0){ + this->ints[i] = foo; + } + } + return; + } + } + + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ClassHasStaticFieldAccessTest.java b/src/test/java/com/aparapi/codegen/test/ClassHasStaticFieldAccessTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6bd9a0ab3132fa3127a191ac61b0f1fe36575bdd --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ClassHasStaticFieldAccessTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ClassHasStaticFieldAccessTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ClassHasStaticFieldAccessTest() { + test(com.aparapi.codegen.test.ClassHasStaticFieldAccess.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ClassHasStaticFieldAccessTestWorksWithCaching() { + test(com.aparapi.codegen.test.ClassHasStaticFieldAccess.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ClassHasStaticMethod.java b/src/test/java/com/aparapi/codegen/test/ClassHasStaticMethod.java new file mode 100644 index 0000000000000000000000000000000000000000..8277d55f0de6b0cc4ff78e462d898fa224b9f4ac --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ClassHasStaticMethod.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ClassHasStaticMethod { + int[] ints = new int[1024]; + + static int getIntAndReturnIt(int a) { + return (int) (((int) 1) - a); + } + + public void run() { + int foo = 1; + for (int i = 0; i < 1024; i++) { + if (i % 2 == 0) { + ints[i] = foo; + } else { + ints[i] = getIntAndReturnIt(foo); + ; + } + } + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *ints; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + int com_amd_aparapi_test_ClassHasStaticMethod__getIntAndReturnIt(int a){ + return((1 - a)); + } + __kernel void run( + __global int *ints, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->ints = ints; + this->passid = passid; + { + int foo = 1; + for (int i = 0; i<1024; i++){ + if ((i % 2)==0){ + this->ints[i] = foo; + } else { + this->ints[i] = com_amd_aparapi_test_ClassHasStaticMethod__getIntAndReturnIt(foo); + } + } + return; + } + } + }OpenCL}**/ + diff --git a/src/test/java/com/aparapi/codegen/test/ClassHasStaticMethodSimple.java b/src/test/java/com/aparapi/codegen/test/ClassHasStaticMethodSimple.java new file mode 100644 index 0000000000000000000000000000000000000000..0e7ce96c25a23acd39e74ad9892142cd5bd46dff --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ClassHasStaticMethodSimple.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ClassHasStaticMethodSimple { + + static void staticMethod() { + + } + + public void run() { + staticMethod(); + + } +} + +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + void com_amd_aparapi_test_ClassHasStaticMethodSimple__staticMethod(){ + return; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + com_amd_aparapi_test_ClassHasStaticMethodSimple__staticMethod(); + return; + } + } + }OpenCL}**/ + diff --git a/src/test/java/com/aparapi/codegen/test/ClassHasStaticMethodSimpleTest.java b/src/test/java/com/aparapi/codegen/test/ClassHasStaticMethodSimpleTest.java new file mode 100644 index 0000000000000000000000000000000000000000..99f6dff20b8f4085b0c0e818e4c978edbcb6f884 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ClassHasStaticMethodSimpleTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ClassHasStaticMethodSimpleTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ClassHasStaticMethodSimpleTest() { + test(com.aparapi.codegen.test.ClassHasStaticMethodSimple.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ClassHasStaticMethodSimpleTestWorksWithCaching() { + test(com.aparapi.codegen.test.ClassHasStaticMethodSimple.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ClassHasStaticMethodTest.java b/src/test/java/com/aparapi/codegen/test/ClassHasStaticMethodTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ed001eaa43af6fe19278f39ab348073fb4e65b7f --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ClassHasStaticMethodTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ClassHasStaticMethodTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ClassHasStaticMethodTest() { + test(com.aparapi.codegen.test.ClassHasStaticMethod.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ClassHasStaticMethodTestWorksWithCaching() { + test(com.aparapi.codegen.test.ClassHasStaticMethod.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/CompositeArbitraryScope.java b/src/test/java/com/aparapi/codegen/test/CompositeArbitraryScope.java new file mode 100644 index 0000000000000000000000000000000000000000..540660557447c855b2a56bac8365232b0655b525 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CompositeArbitraryScope.java @@ -0,0 +1,199 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +// this example gave the following error: +/// com.codegen.classtools.writer.CodeGenException: composite COMPOSITE_ARBITRARY_SCOPE + +import com.aparapi.Kernel; + +public class CompositeArbitraryScope extends Kernel { + + void t5() { + int gid = getGlobalId(); + int numRemaining = 1; + int thisCount = 0; + while (numRemaining > 0 && gid > 0) { + numRemaining += 1; + thisCount = min(numRemaining, gid); + numRemaining -= thisCount; + numRemaining += 1; + } + gid -= thisCount; + } + + void t4() { + int gid = getGlobalId(); + int numRemaining = 1; + while (numRemaining > 0 && gid > 0) { + numRemaining += 1; + int thisCount = min(numRemaining, gid); + numRemaining -= thisCount; + numRemaining += 1; + gid--; + } + } + + void t3() { + int gid = getGlobalId(); + int numRemaining = 1; + while (numRemaining > 0) { + numRemaining += 1; + int thisCount = min(numRemaining, gid); + numRemaining -= thisCount; + numRemaining += 1; + } + } + + void t2() { + int gid = getGlobalId(); + int numRemaining = 1; + while (numRemaining > 0) { + { + int thisCount = min(numRemaining, gid); + numRemaining -= thisCount; + } + numRemaining += 0; + } + } + + void t1() { + int gid = getGlobalId(); + int numRemaining = 1; + while (numRemaining > 0) { + numRemaining += 1; + int thisCount = min(numRemaining, gid); + numRemaining -= thisCount; + } + } + + @Override + public void run() { + int gid = getGlobalId(); + int numRemaining = 1; + + t1(); + t2(); + t3(); + t4(); + t5(); + + while (numRemaining > 0) { + numRemaining += 1; + { + int thisCount = min(numRemaining, gid); + numRemaining -= thisCount; + } + } + } +} + +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + void com_amd_aparapi_test_CompositeArbitraryScope__t5(This *this){ + int gid = get_global_id(0); + int numRemaining = 1; + int thisCount = 0; + for (; numRemaining>0 && gid>0; numRemaining++){ + numRemaining++; + thisCount = min(numRemaining, gid); + numRemaining = numRemaining - thisCount; + } + gid = gid - thisCount; + return; + } + void com_amd_aparapi_test_CompositeArbitraryScope__t4(This *this){ + int gid = get_global_id(0); + int numRemaining = 1; + while (numRemaining>0 && gid>0){ + numRemaining++; + { + int thisCount = min(numRemaining, gid); + numRemaining = numRemaining - thisCount; + numRemaining++; + gid--; + } + } + return; + } + void com_amd_aparapi_test_CompositeArbitraryScope__t3(This *this){ + int gid = get_global_id(0); + int numRemaining = 1; + while (numRemaining>0){ + numRemaining++; + { + int thisCount = min(numRemaining, gid); + numRemaining = numRemaining - thisCount; + numRemaining++; + } + } + return; + } + void com_amd_aparapi_test_CompositeArbitraryScope__t2(This *this){ + int gid = get_global_id(0); + int numRemaining = 1; + for (; numRemaining>0; numRemaining){ + { + int thisCount = min(numRemaining, gid); + numRemaining = numRemaining - thisCount; + } + } + return; + } + void com_amd_aparapi_test_CompositeArbitraryScope__t1(This *this){ + int gid = get_global_id(0); + int numRemaining = 1; + while (numRemaining>0){ + numRemaining++; + { + int thisCount = min(numRemaining, gid); + numRemaining = numRemaining - thisCount; + } + } + return; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int gid = get_global_id(0); + int numRemaining = 1; + com_amd_aparapi_test_CompositeArbitraryScope__t1(this); + com_amd_aparapi_test_CompositeArbitraryScope__t2(this); + com_amd_aparapi_test_CompositeArbitraryScope__t3(this); + com_amd_aparapi_test_CompositeArbitraryScope__t4(this); + com_amd_aparapi_test_CompositeArbitraryScope__t5(this); + while (numRemaining>0){ + numRemaining++; + { + int thisCount = min(numRemaining, gid); + numRemaining = numRemaining - thisCount; + } + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/CompositeArbitraryScopeTest.java b/src/test/java/com/aparapi/codegen/test/CompositeArbitraryScopeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7e581aaed02be28ebd3304b9b38580037399a4dc --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/CompositeArbitraryScopeTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class CompositeArbitraryScopeTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void CompositeArbitraryScopeTest() { + test(com.aparapi.codegen.test.CompositeArbitraryScope.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void CompositeArbitraryScopeTestWorksWithCaching() { + test(com.aparapi.codegen.test.CompositeArbitraryScope.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ConstantAssignInExpression.java b/src/test/java/com/aparapi/codegen/test/ConstantAssignInExpression.java new file mode 100644 index 0000000000000000000000000000000000000000..03cacda626479debf9e671028c9065a82569ccd8 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ConstantAssignInExpression.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ConstantAssignInExpression { + + void func(int _arg) { + // nada + } + + public void run() { + @SuppressWarnings("unused") int result = 1; + func(result = 0); + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + void com_amd_aparapi_test_ConstantAssignInExpression__func(This *this, int _arg){ + return; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int result = 1; + com_amd_aparapi_test_ConstantAssignInExpression__func(this, result=0); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ConstantAssignInExpressionTest.java b/src/test/java/com/aparapi/codegen/test/ConstantAssignInExpressionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b6ef1cf2e98bc1077b2d42f1eb6a4c59f0655d9b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ConstantAssignInExpressionTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ConstantAssignInExpressionTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ConstantAssignInExpressionTest() { + test(com.aparapi.codegen.test.ConstantAssignInExpression.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ConstantAssignInExpressionTestWorksWithCaching() { + test(com.aparapi.codegen.test.ConstantAssignInExpression.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/Continue.java b/src/test/java/com/aparapi/codegen/test/Continue.java new file mode 100644 index 0000000000000000000000000000000000000000..67856f480c75555db791c363a390141753eac2b9 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/Continue.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class Continue { + public void run() { + @SuppressWarnings("unused") boolean pass = false; + for (int i = 0; i < 10; i++) { + if (i == 5) { + continue; + } + pass = true; + } + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + for (int i = 0; i<10; i++){ + if (i==5){ + } else { + pass = 1; + } + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ContinueTest.java b/src/test/java/com/aparapi/codegen/test/ContinueTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3e34924822350735754af145509d1a63826106d1 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ContinueTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ContinueTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ContinueTest() { + test(com.aparapi.codegen.test.Continue.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ContinueTestWorksWithCaching() { + test(com.aparapi.codegen.test.Continue.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ContinueTorture.java b/src/test/java/com/aparapi/codegen/test/ContinueTorture.java new file mode 100644 index 0000000000000000000000000000000000000000..5ab3f07ec7f2df03f9c00c55c8b0aba7ab90cb1b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ContinueTorture.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ContinueTorture { + + final static int START_SIZE = 128; + + public int[] values = new int[START_SIZE]; + + public int[] results = new int[START_SIZE]; + int myId = 34; + + int actuallyDoIt(int a) { + return 1; + } + + int actuallyDoIt2(int a) { + return -1; + } + + public void run() { + int idx = myId; + while (--idx > 0) { + + if (myId == 0) { + continue; + } + if (myId % 2 == 0) { + results[myId] = actuallyDoIt(idx); + continue; + } else { + results[myId] = actuallyDoIt2(idx); + continue; + } + } + } +} +//**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ContinueTortureTest.java b/src/test/java/com/aparapi/codegen/test/ContinueTortureTest.java new file mode 100644 index 0000000000000000000000000000000000000000..eef016f780c3ccbf8be7baed2bd62f27d4baf436 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ContinueTortureTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ContinueTortureTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ContinueTortureTest() { + test(com.aparapi.codegen.test.ContinueTorture.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ContinueTortureTestWorksWithCaching() { + test(com.aparapi.codegen.test.ContinueTorture.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/DirectRecursion.java b/src/test/java/com/aparapi/codegen/test/DirectRecursion.java new file mode 100644 index 0000000000000000000000000000000000000000..76153fabf5a843c81195d88a1d944f335d40df30 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/DirectRecursion.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class DirectRecursion extends Kernel { + + int intout[] = new int[1]; + + public void run() { + intout[0] = fact(10); + @SuppressWarnings("unused") boolean pass = false; + } + + int fact(int n) { + return (n <= 1 ? n : n * fact(n - 1)); + } + +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/DirectRecursionTest.java b/src/test/java/com/aparapi/codegen/test/DirectRecursionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e105289d25afb71bba300cfdb3dc6f4ce0770eee --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/DirectRecursionTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class DirectRecursionTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void DirectRecursionTest() { + test(com.aparapi.codegen.test.DirectRecursion.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void DirectRecursionTestWorksWithCaching() { + test(com.aparapi.codegen.test.DirectRecursion.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/DoWhile.java b/src/test/java/com/aparapi/codegen/test/DoWhile.java new file mode 100644 index 0000000000000000000000000000000000000000..22d2117294f28454a43c6b58477115280a7fc6e1 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/DoWhile.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class DoWhile { + public void run() { + @SuppressWarnings("unused") boolean pass = false; + int i = 0; + do { + pass = true; + i++; + } while (i < 10); + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + int i = 0; + do{ + pass = 1; + i++; + }while (i<10); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/DoWhileTest.java b/src/test/java/com/aparapi/codegen/test/DoWhileTest.java new file mode 100644 index 0000000000000000000000000000000000000000..863699b6d674089d6afa883268cf0cd21db2804c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/DoWhileTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class DoWhileTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void DoWhileTest() { + test(com.aparapi.codegen.test.DoWhile.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void DoWhileTestWorksWithCaching() { + test(com.aparapi.codegen.test.DoWhile.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/Drem.java b/src/test/java/com/aparapi/codegen/test/Drem.java new file mode 100644 index 0000000000000000000000000000000000000000..f1fa250ce64ef5216749ba8c0053cf78a33f0a15 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/Drem.java @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class Drem { + double out[] = new double[10]; + double m; + double n; + + public void run() { + out[0] = m % n; + } +} + +/**{OpenCL{ + #pragma OPENCL EXTENSION cl_khr_fp64 : enable + + typedef struct This_s{ + __global double *out; + double m; + double n; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + __global double *out, + double m, + double n, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->out = out; + this->m = m; + this->n = n; + this->passid = passid; + { + this->out[0] = this->m % this->n; + return; + } + } + + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/DremTest.java b/src/test/java/com/aparapi/codegen/test/DremTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e30bc87225e9fd36618b5aed1ac7863a4eee0e9b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/DremTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class DremTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void DremTest() { + test(com.aparapi.codegen.test.Drem.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void DremTestWorksWithCaching() { + test(com.aparapi.codegen.test.Drem.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/EarlyReturn.java b/src/test/java/com/aparapi/codegen/test/EarlyReturn.java new file mode 100644 index 0000000000000000000000000000000000000000..67283b36dec649f64b1824b8ff6386131d4092f7 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/EarlyReturn.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class EarlyReturn { + public void run() { + @SuppressWarnings("unused") boolean pass = false; + int i = 0; + if ((i % 2) == 0) { + return; + } + i++; + + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + int i=0; + if ((i%2)==0){ + return; + } + i++; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/EarlyReturnTest.java b/src/test/java/com/aparapi/codegen/test/EarlyReturnTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5024cdc8270d688bd7c1d300b01af3bdc12fdd98 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/EarlyReturnTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class EarlyReturnTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void EarlyReturnTest() { + test(com.aparapi.codegen.test.EarlyReturn.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void EarlyReturnTestWorksWithCaching() { + test(com.aparapi.codegen.test.EarlyReturn.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/EmptyWhileWithInc.java b/src/test/java/com/aparapi/codegen/test/EmptyWhileWithInc.java new file mode 100644 index 0000000000000000000000000000000000000000..b20024b31f7f74dc54f79c1f9c137c2f2f77cdf8 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/EmptyWhileWithInc.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class EmptyWhileWithInc { + public void run() { + int x = 0; + while (x++ < 10) { + } + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + for (int x = 0; x++<10;){} + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/EmptyWhileWithIncTest.java b/src/test/java/com/aparapi/codegen/test/EmptyWhileWithIncTest.java new file mode 100644 index 0000000000000000000000000000000000000000..388c88a4b61cb1659bc355cb4dbef23075a68a8c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/EmptyWhileWithIncTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class EmptyWhileWithIncTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void EmptyWhileWithIncTest() { + test(com.aparapi.codegen.test.EmptyWhileWithInc.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void EmptyWhileWithIncTestWorksWithCaching() { + test(com.aparapi.codegen.test.EmptyWhileWithInc.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/EntrypointRecursion.java b/src/test/java/com/aparapi/codegen/test/EntrypointRecursion.java new file mode 100644 index 0000000000000000000000000000000000000000..52c6e5481701bf952107269fa5195d053a0c1d72 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/EntrypointRecursion.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class EntrypointRecursion extends Kernel { + + int[] values = new int[128]; + + public void run() { + int id = getGlobalId(); + + values[id]++; + + if (values[id] < 20) { + run(); + } + } + +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/EntrypointRecursionTest.java b/src/test/java/com/aparapi/codegen/test/EntrypointRecursionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..67ef9931354f6f0d6e0b83c986631e0a715607b1 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/EntrypointRecursionTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class EntrypointRecursionTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void EntrypointRecursionTest() { + test(com.aparapi.codegen.test.EntrypointRecursion.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void EntrypointRecursionTestWorksWithCaching() { + test(com.aparapi.codegen.test.EntrypointRecursion.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/Ex.java b/src/test/java/com/aparapi/codegen/test/Ex.java new file mode 100644 index 0000000000000000000000000000000000000000..4baf8012dbbbf63355341113660179f42e362ff5 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/Ex.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class Ex { + public void run() { + int total = 0; + for (int i = 0; i < 100; i++) { + if (i % 10 == 0 && i % 4 == 0) { + total++; + } + } + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int total = 0; + for (int i = 0; i<100; i++){ + if ((i % 10)==0 && (i % 4)==0){ + total++; + } + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ExTest.java b/src/test/java/com/aparapi/codegen/test/ExTest.java new file mode 100644 index 0000000000000000000000000000000000000000..809dd3e102c920feaebe7e61dd25b3e3d21a8796 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ExTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ExTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ExTest() { + test(com.aparapi.codegen.test.Ex.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ExTestWorksWithCaching() { + test(com.aparapi.codegen.test.Ex.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/FirstAssignInExpression.java b/src/test/java/com/aparapi/codegen/test/FirstAssignInExpression.java new file mode 100644 index 0000000000000000000000000000000000000000..82225037c0ee83c6b45f7a7165bf9040b3cb1802 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/FirstAssignInExpression.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class FirstAssignInExpression { + + int y = 2; + + void func(int _arg) { + // nada + } + + public void run() { + int value = 1; + @SuppressWarnings("unused") int result; + func(result = value); + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + void func(This *this, int _arg){ + return; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int result; + func(this, result = 0); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/FirstAssignInExpression2.java b/src/test/java/com/aparapi/codegen/test/FirstAssignInExpression2.java new file mode 100644 index 0000000000000000000000000000000000000000..05272630dd242c1e2ef6be55d64f700550ba8bd8 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/FirstAssignInExpression2.java @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class FirstAssignInExpression2 { + + public void run() { + int value = 1; + int assignMe; + int result = 0; + if (value == value) { + result = assignMe = value; + } else { + assignMe = 1; + result = 2; + } + result++; + assignMe++; + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int value = 1; + int result=0; + int assignMe=0; + if (true){ + result = assignMe = value; + }else{ + assignMe =1; + result=2; + } + result++; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/FirstAssignInExpression2Test.java b/src/test/java/com/aparapi/codegen/test/FirstAssignInExpression2Test.java new file mode 100644 index 0000000000000000000000000000000000000000..49dfd7705b3a58e2e16edb9573f47900b4bbbcbc --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/FirstAssignInExpression2Test.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class FirstAssignInExpression2Test extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void FirstAssignInExpression2Test() { + test(com.aparapi.codegen.test.FirstAssignInExpression2.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void FirstAssignInExpression2TestWorksWithCaching() { + test(com.aparapi.codegen.test.FirstAssignInExpression2.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/FirstAssignInExpressionTest.java b/src/test/java/com/aparapi/codegen/test/FirstAssignInExpressionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2bf88c25430b42daa127bfafc75d65c651490c6e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/FirstAssignInExpressionTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class FirstAssignInExpressionTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void FirstAssignInExpressionTest() { + test(com.aparapi.codegen.test.FirstAssignInExpression.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void FirstAssignInExpressionTestWorksWithCaching() { + test(com.aparapi.codegen.test.FirstAssignInExpression.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/FloatParams.java b/src/test/java/com/aparapi/codegen/test/FloatParams.java new file mode 100644 index 0000000000000000000000000000000000000000..bad318158ac431e695b4a116d04899040afbb378 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/FloatParams.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class FloatParams { + + int addEmUp(float y, float z) { + return ((int) y + (int) z); + } + + public void run() { + + int y = 2; + + float x = 0f; + + addEmUp((x = (float) y), x); + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + int com_amd_aparapi_test_FloatParams__addEmUp(This *this, float y, float z){ + return(((int)y + (int)z)); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int y = 2; + float x = 0.0f; + com_amd_aparapi_test_FloatParams__addEmUp(this, x=(float)y, x); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/FloatParamsSimple.java b/src/test/java/com/aparapi/codegen/test/FloatParamsSimple.java new file mode 100644 index 0000000000000000000000000000000000000000..5b3ecf2378ed936845cbba94ef22fdb90e8742d2 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/FloatParamsSimple.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class FloatParamsSimple { + + void floatParams(float y) { + + } + + public void run() { + + floatParams(0f); + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + void com_amd_aparapi_test_FloatParamsSimple__floatParams(This *this, float y){ + return; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + com_amd_aparapi_test_FloatParamsSimple__floatParams(this, 0.0f); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/FloatParamsSimpleTest.java b/src/test/java/com/aparapi/codegen/test/FloatParamsSimpleTest.java new file mode 100644 index 0000000000000000000000000000000000000000..40595596ad6d464667322f3230ec467fab063435 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/FloatParamsSimpleTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class FloatParamsSimpleTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void FloatParamsSimpleTest() { + test(com.aparapi.codegen.test.FloatParamsSimple.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void FloatParamsSimpleTestWorksWithCaching() { + test(com.aparapi.codegen.test.FloatParamsSimple.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/FloatParamsTest.java b/src/test/java/com/aparapi/codegen/test/FloatParamsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..378829a1f12ee7c1cbc3703bd2d4d4d7d4041634 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/FloatParamsTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class FloatParamsTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void FloatParamsTest() { + test(com.aparapi.codegen.test.FloatParams.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void FloatParamsTestWorksWithCaching() { + test(com.aparapi.codegen.test.FloatParams.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/For.java b/src/test/java/com/aparapi/codegen/test/For.java new file mode 100644 index 0000000000000000000000000000000000000000..1976b2091341558135aae1d38ae3ab38f62f540a --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/For.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class For { + public void run() { + @SuppressWarnings("unused") boolean pass = false; + for (int i = 0; i < 10; i++) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + for (int i = 0; i<10; i++){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ForAnd.java b/src/test/java/com/aparapi/codegen/test/ForAnd.java new file mode 100644 index 0000000000000000000000000000000000000000..f5abc211909ad06159017da7dae0a55774a1cce1 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForAnd.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ForAnd { + public void run() { + @SuppressWarnings("unused") boolean pass = false; + for (int i = 0; i > 2 && i < 10; i++) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + for (int i = 0; i>2 && i<10; i++){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ForAndMandel.java b/src/test/java/com/aparapi/codegen/test/ForAndMandel.java new file mode 100644 index 0000000000000000000000000000000000000000..9646ed1c67dbba0dd730d88f9cdaacebca251cec --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForAndMandel.java @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ForAndMandel { + int width = 1024; + + float scale = 1f; + + int maxIterations = 10; + + public void run() { + int tid = 0; + + int i = tid % width; + int j = tid / width; + + float x0 = ((i * scale) - ((scale / 2) * width)) / width; + float y0 = ((j * scale) - ((scale / 2) * width)) / width; + + float x = x0; + float y = y0; + + float x2 = x * x; + float y2 = y * y; + + float scaleSquare = scale * scale; + + int count = 0; + + for (int iter = 0; x2 + y2 <= scaleSquare && (iter < maxIterations); ++iter) { + + y = 2 * x * y + y0; + x = x2 - y2 + x0; + + x2 = x * x; + y2 = y * y; + count++; + } + @SuppressWarnings("unused") int value = (256 * count) / maxIterations; + } +} +/**{OpenCL{ + typedef struct This_s{ + int width; + float scale; + int maxIterations; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int width, + float scale, + int maxIterations, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->width = width; + this->scale = scale; + this->maxIterations = maxIterations; + this->passid = passid; + { + int tid = 0; + int i = tid % this->width; + int j = tid / this->width; + float x0 = (((float)i * this->scale) - ((this->scale / 2.0f) * (float)this->width)) / (float)this->width; + float y0 = (((float)j * this->scale) - ((this->scale / 2.0f) * (float)this->width)) / (float)this->width; + float x = x0; + float y = y0; + float x2 = x * x; + float y2 = y * y; + float scaleSquare = this->scale * this->scale; + int count = 0; + for (int iter = 0; (x2 + y2)<=scaleSquare && iter<this->maxIterations; iter++){ + y = ((2.0f * x) * y) + y0; + x = (x2 - y2) + x0; + x2 = x * x; + y2 = y * y; + count++; + } + int value = (256 * count) / this->maxIterations; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ForAndMandelNoInitialize.java b/src/test/java/com/aparapi/codegen/test/ForAndMandelNoInitialize.java new file mode 100644 index 0000000000000000000000000000000000000000..a6b2d3352f08803fdd2203706016df01ebb784dd --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForAndMandelNoInitialize.java @@ -0,0 +1,103 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ForAndMandelNoInitialize { + int width = 1024; + + float scale = 1f; + + int maxIterations = 10; + + public void run() { + int tid = 0; + + int i = tid % width; + int j = tid / width; + + float x0 = ((i * scale) - ((scale / 2) * width)) / width; + float y0 = ((j * scale) - ((scale / 2) * width)) / width; + + float x = x0; + float y = y0; + + float x2 = x * x; + float y2 = y * y; + + float scaleSquare = scale * scale; + + int count = 0; + int iter = 0; + for (; (x2 + y2 <= scaleSquare) && (iter < maxIterations); ++iter) { + + y = 2 * x * y + y0; + x = x2 - y2 + x0; + + x2 = x * x; + y2 = y * y; + count++; + } + @SuppressWarnings("unused") int value = (256 * count) / maxIterations; + } +} +/**{OpenCL{ + typedef struct This_s{ + int width; + float scale; + int maxIterations; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int width, + float scale, + int maxIterations, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->width = width; + this->scale = scale; + this->maxIterations = maxIterations; + this->passid = passid; + { + int tid = 0; + int i = tid % this->width; + int j = tid / this->width; + float x0 = (((float)i * this->scale) - ((this->scale / 2.0f) * (float)this->width)) / (float)this->width; + float y0 = (((float)j * this->scale) - ((this->scale / 2.0f) * (float)this->width)) / (float)this->width; + float x = x0; + float y = y0; + float x2 = x * x; + float y2 = y * y; + float scaleSquare = this->scale * this->scale; + int count = 0; + int iter = 0; + for (; (x2 + y2)<=scaleSquare && iter<this->maxIterations; iter++){ + y = ((2.0f * x) * y) + y0; + x = (x2 - y2) + x0; + x2 = x * x; + y2 = y * y; + count++; + } + int value = (256 * count) / this->maxIterations; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ForAndMandelNoInitializeTest.java b/src/test/java/com/aparapi/codegen/test/ForAndMandelNoInitializeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..17cddbcc3de49278db5c7865d3c4dbc0bc24e0bd --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForAndMandelNoInitializeTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ForAndMandelNoInitializeTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ForAndMandelNoInitializeTest() { + test(com.aparapi.codegen.test.ForAndMandelNoInitialize.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ForAndMandelNoInitializeTestWorksWithCaching() { + test(com.aparapi.codegen.test.ForAndMandelNoInitialize.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ForAndMandelTest.java b/src/test/java/com/aparapi/codegen/test/ForAndMandelTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2c80c53f88779b68dc0cfb91e42c8ba5d6837483 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForAndMandelTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ForAndMandelTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ForAndMandelTest() { + test(com.aparapi.codegen.test.ForAndMandel.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ForAndMandelTestWorksWithCaching() { + test(com.aparapi.codegen.test.ForAndMandel.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ForAndTest.java b/src/test/java/com/aparapi/codegen/test/ForAndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7240866f1d68edafbf18599b8e5272e443905296 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForAndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ForAndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ForAndTest() { + test(com.aparapi.codegen.test.ForAnd.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ForAndTestWorksWithCaching() { + test(com.aparapi.codegen.test.ForAnd.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ForAsFirst.java b/src/test/java/com/aparapi/codegen/test/ForAsFirst.java new file mode 100644 index 0000000000000000000000000000000000000000..4f17e576e9ccc22ff93b094b8c1cd07265472038 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForAsFirst.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ForAsFirst { + + public void run() { + + for (int i = 0; i < 1; i++) { + + } + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + for (int i = 0; i<1; i++){ + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ForAsFirstTest.java b/src/test/java/com/aparapi/codegen/test/ForAsFirstTest.java new file mode 100644 index 0000000000000000000000000000000000000000..84dddaf2638bff7b4d48b1e8ee9fbfcff208282a --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForAsFirstTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ForAsFirstTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ForAsFirstTest() { + test(com.aparapi.codegen.test.ForAsFirst.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ForAsFirstTestWorksWithCaching() { + test(com.aparapi.codegen.test.ForAsFirst.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ForBooleanToggle.java b/src/test/java/com/aparapi/codegen/test/ForBooleanToggle.java new file mode 100644 index 0000000000000000000000000000000000000000..56518c61fcdc0e08398ab044aee8ee35a7ffdfb7 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForBooleanToggle.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ForBooleanToggle { + public void run() { + boolean pass = false; + for (int i = 0; i > 2 && i < 10; i++) { + pass = !pass; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + for (int i = 0; i>2 && i<10; i++){ + pass = (pass==0)?1:0; + } + return; + } + } + }OpenCL}**/ + +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + for (int i = 0; i>2 && i<10; i++){ + pass = (pass!=0)?0:1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ForBooleanToggleTest.java b/src/test/java/com/aparapi/codegen/test/ForBooleanToggleTest.java new file mode 100644 index 0000000000000000000000000000000000000000..afbe1bf3a99fcee188935b70f0291539f6a5124a --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForBooleanToggleTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ForBooleanToggleTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ForBooleanToggleTest() { + test(com.aparapi.codegen.test.ForBooleanToggle.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ForBooleanToggleTestWorksWithCaching() { + test(com.aparapi.codegen.test.ForBooleanToggle.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ForBreak.java b/src/test/java/com/aparapi/codegen/test/ForBreak.java new file mode 100644 index 0000000000000000000000000000000000000000..f6df9d809c8ee7fd59c0ce1f49eda830e4fc6960 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForBreak.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ForBreak { + public void run() { + @SuppressWarnings("unused") boolean pass = false; + for (int i = 0; i > 2 && i < 10; i++) { + pass = false; + if (i == 5 || i == 6) { + if (i == 5) { + pass = true; + break; + } + } + } + + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ForBreakTest.java b/src/test/java/com/aparapi/codegen/test/ForBreakTest.java new file mode 100644 index 0000000000000000000000000000000000000000..852ac1ad242589178acddc5a0ebea62da07d93db --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForBreakTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ForBreakTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ForBreakTest() { + test(com.aparapi.codegen.test.ForBreak.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ForBreakTestWorksWithCaching() { + test(com.aparapi.codegen.test.ForBreak.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ForEach.java b/src/test/java/com/aparapi/codegen/test/ForEach.java new file mode 100644 index 0000000000000000000000000000000000000000..6c06e275568c878a45f066a8e2da04d5525d08b9 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForEach.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ForEach { + + int out[] = new int[10]; + int in[] = new int[10]; + + public void run() { + int max = Integer.MIN_VALUE; + for (int i : in) { + if (i > max) + max = i; + } + out[0] = max; + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ForEachTest.java b/src/test/java/com/aparapi/codegen/test/ForEachTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ed751fadfff5eec997462f81cfc73a4495ea5f28 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForEachTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ForEachTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ForEachTest() { + test(com.aparapi.codegen.test.ForEach.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ForEachTestWorksWithCaching() { + test(com.aparapi.codegen.test.ForEach.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ForIf.java b/src/test/java/com/aparapi/codegen/test/ForIf.java new file mode 100644 index 0000000000000000000000000000000000000000..75888e1b37e5ef2794e43da02eb4d2168f3e9e1b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForIf.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ForIf { + public void run() { + @SuppressWarnings("unused") boolean pass = false; + for (int i = 0; i > 2; i++) { + if (i == 3) { + pass = true; + } + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + for (int i = 0; i>2; i++){ + if (i==3){ + pass = 1; + } + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ForIfMandel.java b/src/test/java/com/aparapi/codegen/test/ForIfMandel.java new file mode 100644 index 0000000000000000000000000000000000000000..b2ac5c77cf667f04d8833e3aa40ca20ce8beb911 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForIfMandel.java @@ -0,0 +1,109 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ForIfMandel { + int width = 1024; + + float scale = 1f; + + int maxIterations = 10; + + public void run() { + int tid = 0; + + int i = tid % width; + int j = tid / width; + + float x0 = ((i * scale) - ((scale / 2) * width)) / width; + float y0 = ((j * scale) - ((scale / 2) * width)) / width; + + float x = x0; + float y = y0; + + float x2 = x * x; + float y2 = y * y; + + float scaleSquare = scale * scale; + + int count = 0; + + for (int iter = 0; iter < maxIterations; ++iter) { + if (x2 + y2 <= scaleSquare) { + y = 2 * x * y + y0; + x = x2 - y2 + x0; + + x2 = x * x; + y2 = y * y; + count++; + } else { + count--; + } + } + @SuppressWarnings("unused") int value = (256 * count) / maxIterations; + } +} +/**{OpenCL{ + typedef struct This_s{ + int width; + float scale; + int maxIterations; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int width, + float scale, + int maxIterations, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->width = width; + this->scale = scale; + this->maxIterations = maxIterations; + this->passid = passid; + { + int tid = 0; + int i = tid % this->width; + int j = tid / this->width; + float x0 = (((float)i * this->scale) - ((this->scale / 2.0f) * (float)this->width)) / (float)this->width; + float y0 = (((float)j * this->scale) - ((this->scale / 2.0f) * (float)this->width)) / (float)this->width; + float x = x0; + float y = y0; + float x2 = x * x; + float y2 = y * y; + float scaleSquare = this->scale * this->scale; + int count = 0; + for (int iter = 0; iter<this->maxIterations; iter++){ + if ((x2 + y2)<=scaleSquare){ + y = ((2.0f * x) * y) + y0; + x = (x2 - y2) + x0; + x2 = x * x; + y2 = y * y; + count++; + } else { + count--; + } + } + int value = (256 * count) / this->maxIterations; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ForIfMandelTest.java b/src/test/java/com/aparapi/codegen/test/ForIfMandelTest.java new file mode 100644 index 0000000000000000000000000000000000000000..be67ca88703b6fc2cf09071a6a090cd6b881e266 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForIfMandelTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ForIfMandelTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ForIfMandelTest() { + test(com.aparapi.codegen.test.ForIfMandel.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ForIfMandelTestWorksWithCaching() { + test(com.aparapi.codegen.test.ForIfMandel.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ForIfTest.java b/src/test/java/com/aparapi/codegen/test/ForIfTest.java new file mode 100644 index 0000000000000000000000000000000000000000..95a1d3c857abd68f0a0aee7d7954c7e5a96e1ce4 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForIfTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ForIfTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ForIfTest() { + test(com.aparapi.codegen.test.ForIf.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ForIfTestWorksWithCaching() { + test(com.aparapi.codegen.test.ForIf.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ForTest.java b/src/test/java/com/aparapi/codegen/test/ForTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d91894fa87708de20a5b7af3c7aaac14b8d5c81e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ForTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ForTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ForTest() { + test(com.aparapi.codegen.test.For.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ForTestWorksWithCaching() { + test(com.aparapi.codegen.test.For.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/Frem.java b/src/test/java/com/aparapi/codegen/test/Frem.java new file mode 100644 index 0000000000000000000000000000000000000000..51bdccd04a9995e5867bc226745089dab965075e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/Frem.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class Frem { + float out[] = new float[10]; + float m; + float n; + + public void run() { + out[0] = m % n; + } +} + +/**{OpenCL{ + typedef struct This_s{ + __global float *out; + float m; + float n; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + __global float *out, + float m, + float n, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->out = out; + this->m = m; + this->n = n; + this->passid = passid; + { + this->out[0] = this->m % this->n; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/FremTest.java b/src/test/java/com/aparapi/codegen/test/FremTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e2cb8d0db09635461affd2522f2ea6b727a27eb8 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/FremTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class FremTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void FremTest() { + test(com.aparapi.codegen.test.Frem.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void FremTestWorksWithCaching() { + test(com.aparapi.codegen.test.Frem.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IEEERemainderDouble.java b/src/test/java/com/aparapi/codegen/test/IEEERemainderDouble.java new file mode 100644 index 0000000000000000000000000000000000000000..734c62fe1dcbe78f8abd3567b82d7079234e3dea --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IEEERemainderDouble.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class IEEERemainderDouble extends Kernel { + double out[] = new double[10]; + double m; + double n; + + public void run() { + out[0] = IEEEremainder(m, n); + } +} + +/**{OpenCL{ + #pragma OPENCL EXTENSION cl_khr_fp64 : enable + + typedef struct This_s{ + __global double *out; + double m; + double n; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + __global double *out, + double m, + double n, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->out = out; + this->m = m; + this->n = n; + this->passid = passid; + { + this->out[0] = remainder(this->m, this->n); + return; + } + } + + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IEEERemainderDoubleTest.java b/src/test/java/com/aparapi/codegen/test/IEEERemainderDoubleTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d6a56b82fd3a032718a9ecef0344232d7a82425c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IEEERemainderDoubleTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IEEERemainderDoubleTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IEEERemainderDoubleTest() { + test(com.aparapi.codegen.test.IEEERemainderDouble.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IEEERemainderDoubleTestWorksWithCaching() { + test(com.aparapi.codegen.test.IEEERemainderDouble.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IEEERemainderFloat.java b/src/test/java/com/aparapi/codegen/test/IEEERemainderFloat.java new file mode 100644 index 0000000000000000000000000000000000000000..ac1c6864f18304f51962a76f05a9d4e3be0459fc --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IEEERemainderFloat.java @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class IEEERemainderFloat extends Kernel { + float out[] = new float[10]; + float m; + float n; + + public void run() { + out[0] = IEEEremainder(m, n); + } +} + +/**{OpenCL{ + typedef struct This_s{ + __global float *out; + float m; + float n; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + __global float *out, + float m, + float n, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->out = out; + this->m = m; + this->n = n; + this->passid = passid; + { + this->out[0] = remainder(this->m, this->n); + return; + } + } + + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IEEERemainderFloatTest.java b/src/test/java/com/aparapi/codegen/test/IEEERemainderFloatTest.java new file mode 100644 index 0000000000000000000000000000000000000000..66511edc041bc10bd9f2db17eed41cc32aaa886a --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IEEERemainderFloatTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IEEERemainderFloatTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IEEERemainderFloatTest() { + test(com.aparapi.codegen.test.IEEERemainderFloat.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IEEERemainderFloatTestWorksWithCaching() { + test(com.aparapi.codegen.test.IEEERemainderFloat.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/If.java b/src/test/java/com/aparapi/codegen/test/If.java new file mode 100644 index 0000000000000000000000000000000000000000..0f486cbd5d941f4cb848fcb87ae783a50ac3c525 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class If { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if (testValue % 4 == 0) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if ( (testValue % 4) == 0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfAnd.java b/src/test/java/com/aparapi/codegen/test/IfAnd.java new file mode 100644 index 0000000000000000000000000000000000000000..402e0f5fb0e3440c5369c92b0b7b23d6e11dfe7c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfAnd.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfAnd { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if (testValue >= 0 && testValue < 100) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if (testValue>=0 && testValue<100){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfAndAnd.java b/src/test/java/com/aparapi/codegen/test/IfAndAnd.java new file mode 100644 index 0000000000000000000000000000000000000000..a53513419c2cf79cb056fdeb6d7cc819e64c350a --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfAndAnd.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfAndAnd { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if (testValue >= 0 && testValue < 100 && testValue == 20) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if (testValue>=0 && testValue<100 && testValue==20){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfAndAndAnd.java b/src/test/java/com/aparapi/codegen/test/IfAndAndAnd.java new file mode 100644 index 0000000000000000000000000000000000000000..af21b6447f78851ff24a886ed04f35a8eb9a4eb9 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfAndAndAnd.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfAndAndAnd { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if (testValue % 2 == 0 && testValue <= 10 && testValue >= 0 && testValue % 4 == 0) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if ((testValue % 2)==0 && testValue<=10 && testValue>=0 && (testValue % 4)==0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfAndAndAndTest.java b/src/test/java/com/aparapi/codegen/test/IfAndAndAndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..aef528e3c3f4d7742fc436b03d38826da420adf6 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfAndAndAndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfAndAndAndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfAndAndAndTest() { + test(com.aparapi.codegen.test.IfAndAndAnd.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfAndAndAndTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfAndAndAnd.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfAndAndTest.java b/src/test/java/com/aparapi/codegen/test/IfAndAndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cd15b208a688e165336b21dfd99803d248471b35 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfAndAndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfAndAndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfAndAndTest() { + test(com.aparapi.codegen.test.IfAndAnd.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfAndAndTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfAndAnd.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfAndOrAnd.java b/src/test/java/com/aparapi/codegen/test/IfAndOrAnd.java new file mode 100644 index 0000000000000000000000000000000000000000..fbe982875e0551d5ea50cf6d7db3808a061ba1b5 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfAndOrAnd.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfAndOrAnd { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if (testValue % 2 == 0 && testValue <= 10 || testValue >= 0 && testValue % 4 == 0) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if ((testValue % 2)==0 && testValue<=10 || testValue>=0 && (testValue % 4)==0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfAndOrAndTest.java b/src/test/java/com/aparapi/codegen/test/IfAndOrAndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..45c17836462da447b73ba42135569361913420af --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfAndOrAndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfAndOrAndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfAndOrAndTest() { + test(com.aparapi.codegen.test.IfAndOrAnd.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfAndOrAndTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfAndOrAnd.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfAndTest.java b/src/test/java/com/aparapi/codegen/test/IfAndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..bed08fc7bf16c5a2141af500f309bd07925ae121 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfAndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfAndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfAndTest() { + test(com.aparapi.codegen.test.IfAnd.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfAndTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfAnd.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfBooleanAndAndAnd.java b/src/test/java/com/aparapi/codegen/test/IfBooleanAndAndAnd.java new file mode 100644 index 0000000000000000000000000000000000000000..134d643a040998c6c6a6a1715480b7f1c3783022 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfBooleanAndAndAnd.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfBooleanAndAndAnd { + public void run() { + boolean a = true, b = true, c = true, d = true; + @SuppressWarnings("unused") boolean pass = false; + + if (a && b && c && d) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char c = 1; + char d = 1; + char pass = 0; + if (a!=0 && b!=0 && c!=0 && d!=0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfBooleanAndAndAndTest.java b/src/test/java/com/aparapi/codegen/test/IfBooleanAndAndAndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c6cc2b25dfacc7b7a9dde09cbce6bd0c229e7d00 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfBooleanAndAndAndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfBooleanAndAndAndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfBooleanAndAndAndTest() { + test(com.aparapi.codegen.test.IfBooleanAndAndAnd.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfBooleanAndAndAndTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfBooleanAndAndAnd.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfBooleanAndAndOr.java b/src/test/java/com/aparapi/codegen/test/IfBooleanAndAndOr.java new file mode 100644 index 0000000000000000000000000000000000000000..ca716135bdb5e0477b17335d2f4f11e64b21a443 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfBooleanAndAndOr.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfBooleanAndAndOr { + public void run() { + boolean a = true, b = true, c = true, d = true; + @SuppressWarnings("unused") boolean pass = false; + + if (a && b && c || d) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char c = 1; + char d = 1; + char pass = 0; + if (a!=0 && b!=0 && c!=0 || d!=0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfBooleanAndAndOrTest.java b/src/test/java/com/aparapi/codegen/test/IfBooleanAndAndOrTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b3d68a81bd7567ba4786cb6279ea4dfc5e4e4a0e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfBooleanAndAndOrTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfBooleanAndAndOrTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfBooleanAndAndOrTest() { + test(com.aparapi.codegen.test.IfBooleanAndAndOr.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfBooleanAndAndOrTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfBooleanAndAndOr.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfBooleanAndOrAnd.java b/src/test/java/com/aparapi/codegen/test/IfBooleanAndOrAnd.java new file mode 100644 index 0000000000000000000000000000000000000000..3abc231b38065f22c017017a833b3f4e2b716939 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfBooleanAndOrAnd.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfBooleanAndOrAnd { + public void run() { + boolean a = true, b = true, c = true, d = true; + @SuppressWarnings("unused") boolean pass = false; + + if (a && b || c && d) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char c = 1; + char d = 1; + char pass = 0; + if (a!=0 && b!=0 || c!=0 && d!=0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfBooleanAndOrAndTest.java b/src/test/java/com/aparapi/codegen/test/IfBooleanAndOrAndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..bcaf567b47f2f8ca334beced975dd937d0153aca --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfBooleanAndOrAndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfBooleanAndOrAndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfBooleanAndOrAndTest() { + test(com.aparapi.codegen.test.IfBooleanAndOrAnd.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfBooleanAndOrAndTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfBooleanAndOrAnd.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfBooleanAndOrOr.java b/src/test/java/com/aparapi/codegen/test/IfBooleanAndOrOr.java new file mode 100644 index 0000000000000000000000000000000000000000..1c1159339d739b1070dc5b087ff5ce966448ebb0 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfBooleanAndOrOr.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfBooleanAndOrOr { + public void run() { + boolean a = true, b = true, c = true, d = true; + @SuppressWarnings("unused") boolean pass = false; + + if (a && b && c || d) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char c = 1; + char d = 1; + char pass = 0; + if (a!=0 && b!=0 && c!=0 || d!=0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfBooleanAndOrOrTest.java b/src/test/java/com/aparapi/codegen/test/IfBooleanAndOrOrTest.java new file mode 100644 index 0000000000000000000000000000000000000000..13e3e63753406428bf8af44e24fb0e5a7b05412f --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfBooleanAndOrOrTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfBooleanAndOrOrTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfBooleanAndOrOrTest() { + test(com.aparapi.codegen.test.IfBooleanAndOrOr.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfBooleanAndOrOrTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfBooleanAndOrOr.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfBooleanOrAndAnd.java b/src/test/java/com/aparapi/codegen/test/IfBooleanOrAndAnd.java new file mode 100644 index 0000000000000000000000000000000000000000..397344a9c45ef5a9b7f1d94fc3ac2c6fad1a0f81 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfBooleanOrAndAnd.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfBooleanOrAndAnd { + public void run() { + boolean a = true, b = true, c = true, d = true; + @SuppressWarnings("unused") boolean pass = false; + + if (a || b && c && d) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char c = 1; + char d = 1; + char pass = 0; + if (a!=0 || b!=0 && c!=0 && d!=0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfBooleanOrAndAndTest.java b/src/test/java/com/aparapi/codegen/test/IfBooleanOrAndAndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f7e28ac3862ab2be3fa3414ac473176455c8ef1f --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfBooleanOrAndAndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfBooleanOrAndAndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfBooleanOrAndAndTest() { + test(com.aparapi.codegen.test.IfBooleanOrAndAnd.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfBooleanOrAndAndTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfBooleanOrAndAnd.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfBooleanOrAndOr.java b/src/test/java/com/aparapi/codegen/test/IfBooleanOrAndOr.java new file mode 100644 index 0000000000000000000000000000000000000000..09e8853cadb89d3e4641d928ccfd5a524d66e3a1 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfBooleanOrAndOr.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfBooleanOrAndOr { + public void run() { + boolean a = true; + boolean b = true; + boolean c = true; + boolean d = true; + @SuppressWarnings("unused") boolean pass = false; + + if (a || b && c || d) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char c = 1; + char d = 1; + char pass = 0; + if (a!=0 || b!=0 && c!=0 || d!=0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfBooleanOrAndOrTest.java b/src/test/java/com/aparapi/codegen/test/IfBooleanOrAndOrTest.java new file mode 100644 index 0000000000000000000000000000000000000000..71f4187f39058e0d9309dcfe51e606e56d61046c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfBooleanOrAndOrTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfBooleanOrAndOrTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfBooleanOrAndOrTest() { + test(com.aparapi.codegen.test.IfBooleanOrAndOr.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfBooleanOrAndOrTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfBooleanOrAndOr.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfBooleanOrOrAnd.java b/src/test/java/com/aparapi/codegen/test/IfBooleanOrOrAnd.java new file mode 100644 index 0000000000000000000000000000000000000000..a761885ba5b68da3dec3c104470798476b4936bd --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfBooleanOrOrAnd.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfBooleanOrOrAnd { + public void run() { + boolean a = true, b = true, c = true, d = true; + @SuppressWarnings("unused") boolean pass = false; + + if (a || b || c && d) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char c = 1; + char d = 1; + char pass = 0; + if (a!=0 || b!=0 || c!=0 && d!=0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfBooleanOrOrAndTest.java b/src/test/java/com/aparapi/codegen/test/IfBooleanOrOrAndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..32a1a77e409420a2ce83af27902891b861983ead --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfBooleanOrOrAndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfBooleanOrOrAndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfBooleanOrOrAndTest() { + test(com.aparapi.codegen.test.IfBooleanOrOrAnd.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfBooleanOrOrAndTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfBooleanOrOrAnd.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfBooleanOrOrOr.java b/src/test/java/com/aparapi/codegen/test/IfBooleanOrOrOr.java new file mode 100644 index 0000000000000000000000000000000000000000..0f8e0aec1900ba5f017939a17f1bed0aa2a38941 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfBooleanOrOrOr.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfBooleanOrOrOr { + public void run() { + boolean a = true, b = true, c = true, d = true; + @SuppressWarnings("unused") boolean pass = false; + + if (a || b || c || d) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char c = 1; + char d = 1; + char pass = 0; + if (a!=0 || b!=0 || c!=0 || d!=0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfBooleanOrOrOrTest.java b/src/test/java/com/aparapi/codegen/test/IfBooleanOrOrOrTest.java new file mode 100644 index 0000000000000000000000000000000000000000..32f28ba5818e5a093cfcb4ec5856488cfbe490b0 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfBooleanOrOrOrTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfBooleanOrOrOrTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfBooleanOrOrOrTest() { + test(com.aparapi.codegen.test.IfBooleanOrOrOr.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfBooleanOrOrOrTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfBooleanOrOrOr.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfElse.java b/src/test/java/com/aparapi/codegen/test/IfElse.java new file mode 100644 index 0000000000000000000000000000000000000000..c249e01caec51c0652e2ca930038093f61e87a62 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElse.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfElse { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if (testValue % 4 == 0) { + pass = true; + } else { + pass = false; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if ( (testValue % 4) == 0){ + pass = 1; + } else { + pass = 0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfElseAnd.java b/src/test/java/com/aparapi/codegen/test/IfElseAnd.java new file mode 100644 index 0000000000000000000000000000000000000000..73243580bd9fe6801829efb231cbf1dbb2131c59 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElseAnd.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfElseAnd { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if (testValue >= 0 && testValue < 100) { + pass = true; + } else { + pass = false; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if (testValue>=0 && testValue<100){ + pass = 1; + } else { + pass = 0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfElseAndAndAnd.java b/src/test/java/com/aparapi/codegen/test/IfElseAndAndAnd.java new file mode 100644 index 0000000000000000000000000000000000000000..277ce435d1aae8391c11cc27a833369f7803822c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElseAndAndAnd.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfElseAndAndAnd { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if (testValue % 2 == 0 && testValue <= 10 && testValue >= 0 && testValue % 4 == 0) { + pass = true; + } else { + pass = false; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if ((testValue % 2)==0 && testValue<=10 && testValue>=0 && (testValue % 4)==0){ + pass = 1; + } else { + pass = 0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfElseAndAndAndTest.java b/src/test/java/com/aparapi/codegen/test/IfElseAndAndAndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..967ff06a139a25930408b5232def032df727ebd1 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElseAndAndAndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfElseAndAndAndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfElseAndAndAndTest() { + test(com.aparapi.codegen.test.IfElseAndAndAnd.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfElseAndAndAndTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfElseAndAndAnd.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfElseAndTest.java b/src/test/java/com/aparapi/codegen/test/IfElseAndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..94a43b40d29ecffff86df27e888d1a48b2b03555 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElseAndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfElseAndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfElseAndTest() { + test(com.aparapi.codegen.test.IfElseAnd.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfElseAndTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfElseAnd.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfElseIfElseIfElse.java b/src/test/java/com/aparapi/codegen/test/IfElseIfElseIfElse.java new file mode 100644 index 0000000000000000000000000000000000000000..9a76f2a564d87a2f35c43b5c45fcc53d964486fc --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElseIfElseIfElse.java @@ -0,0 +1,120 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfElseIfElseIfElse { + /* + 1: istore_1 (0:iconst_1) + 3: istore_2 (2:iconst_1) + 5: istore_3 (4:iconst_1) + 7: istore 4 (6:iconst_0) + 10: ifeq 16 (9:iload_1) ? + 13: goto 39 | + + 17: ifeq 26 (16: iload_2) v | ? + 21: istore 4 (20: iconst_1) | | + 23: goto 39 | | + + 27: ifeq 36 (26: iload_3) | v | ? + 31: istore 4 (30: iconst_1) | | | + 33: goto 39 | | | + + 37: istore 4 (36: iconst_1) | | v | + 39: return v v v + */ + public void run() { + boolean a = true; + boolean b = true; + boolean c = true; + @SuppressWarnings("unused") boolean result = false; + + if (a) { + } else if (b) { + result = true; + } else if (c) { + result = true; + } else { + result = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char c = 1; + char result = 0; + if (a!=0){ + } else { + if (b!=0){ + result = 1; + } else { + if (c!=0){ + result = 1; + } else { + result = 1; + } + } + } + return; + } + } + }OpenCL}**/ +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char c = 1; + char result = 0; + if (a==0){ + if (b!=0){ + result = 1; + } else { + if (c!=0){ + result = 1; + } else { + result = 1; + } + } + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfElseIfElseIfElseTest.java b/src/test/java/com/aparapi/codegen/test/IfElseIfElseIfElseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..65f3ff3babf039fe261a79a523a685d616ffe698 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElseIfElseIfElseTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfElseIfElseIfElseTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfElseIfElseIfElseTest() { + test(com.aparapi.codegen.test.IfElseIfElseIfElse.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfElseIfElseIfElseTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfElseIfElseIfElse.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfElseNot__OrOr_And_.java b/src/test/java/com/aparapi/codegen/test/IfElseNot__OrOr_And_.java new file mode 100644 index 0000000000000000000000000000000000000000..69a0884c8f0fc9d18e0fbf8233a9150a9d291d5e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElseNot__OrOr_And_.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfElseNot__OrOr_And_ { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if (!((testValue % 2 == 0 || testValue <= 0 || testValue >= 100) && testValue % 4 == 0)) { + pass = true; + } else { + pass = false; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if ((testValue % 2)!=0 && testValue>0 && testValue<100 || (testValue % 4)!=0){ + pass = 1; + } else { + pass = 0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfElseNot__OrOr_And_Test.java b/src/test/java/com/aparapi/codegen/test/IfElseNot__OrOr_And_Test.java new file mode 100644 index 0000000000000000000000000000000000000000..e39d43ec05a2047d1fa4993165b9b15190664511 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElseNot__OrOr_And_Test.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfElseNot__OrOr_And_Test extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfElseNot__OrOr_And_Test() { + test(com.aparapi.codegen.test.IfElseNot__OrOr_And_.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfElseNot__OrOr_And_TestWorksWithCaching() { + test(com.aparapi.codegen.test.IfElseNot__OrOr_And_.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfElseOrOrAnd.java b/src/test/java/com/aparapi/codegen/test/IfElseOrOrAnd.java new file mode 100644 index 0000000000000000000000000000000000000000..b6245263aed2832a58315c5a3aeaf99a67080f5e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElseOrOrAnd.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfElseOrOrAnd { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if (testValue % 2 == 0 || testValue <= 0 || testValue >= 100 && testValue % 4 == 0) { + pass = true; + } else { + pass = false; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if ((testValue % 2)==0 || testValue<=0 || testValue>=100 && (testValue % 4)==0){ + pass = 1; + } else { + pass = 0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfElseOrOrAndTest.java b/src/test/java/com/aparapi/codegen/test/IfElseOrOrAndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..14010141a9901fc4ff76e048e5a1ad41625ebb8e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElseOrOrAndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfElseOrOrAndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfElseOrOrAndTest() { + test(com.aparapi.codegen.test.IfElseOrOrAnd.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfElseOrOrAndTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfElseOrOrAnd.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfElseOrOrOr.java b/src/test/java/com/aparapi/codegen/test/IfElseOrOrOr.java new file mode 100644 index 0000000000000000000000000000000000000000..a309754a191f81986f2d0950b392eb6c63c48bd2 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElseOrOrOr.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfElseOrOrOr { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if (testValue % 2 == 0 || testValue <= 0 || testValue >= 100 || testValue == 10) { + pass = true; + } else { + pass = false; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if ((testValue % 2)==0 || testValue<=0 || testValue>=100 || testValue==10){ + pass = 1; + } else { + pass = 0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfElseOrOrOrTest.java b/src/test/java/com/aparapi/codegen/test/IfElseOrOrOrTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a5d648e6d88c6f3ac39e3394f91cc552597db865 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElseOrOrOrTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfElseOrOrOrTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfElseOrOrOrTest() { + test(com.aparapi.codegen.test.IfElseOrOrOr.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfElseOrOrOrTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfElseOrOrOr.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfElseTest.java b/src/test/java/com/aparapi/codegen/test/IfElseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8285d7282221aab235aa3ddb763bcec1e644f7c2 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElseTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfElseTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfElseTest() { + test(com.aparapi.codegen.test.IfElse.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfElseTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfElse.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfElse_And_Or_And.java b/src/test/java/com/aparapi/codegen/test/IfElse_And_Or_And.java new file mode 100644 index 0000000000000000000000000000000000000000..8f9ef5694eb4c114413138e74d723d8c9171a0ae --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElse_And_Or_And.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfElse_And_Or_And { + public void run() { + int x = 5; + int y = 5; + + @SuppressWarnings("unused") boolean pass = false; + + if ((x >= 0 && x < 10) || (y >= 0 && y < 10)) { + pass = true; + } else { + pass = false; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int x = 5; + int y = 5; + char pass = 0; + if (x>=0 && x<10 || y>=0 && y<10){ + pass = 1; + } else { + pass = 0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfElse_And_Or_AndTest.java b/src/test/java/com/aparapi/codegen/test/IfElse_And_Or_AndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2365020ee538faafe67d8f819eb71c3d8ac23f3f --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElse_And_Or_AndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfElse_And_Or_AndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfElse_And_Or_AndTest() { + test(com.aparapi.codegen.test.IfElse_And_Or_And.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfElse_And_Or_AndTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfElse_And_Or_And.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfElse_OrOr_And.java b/src/test/java/com/aparapi/codegen/test/IfElse_OrOr_And.java new file mode 100644 index 0000000000000000000000000000000000000000..5b1d66741379411b64bdcc91d6764d1c93e0faa0 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElse_OrOr_And.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfElse_OrOr_And { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if ((testValue % 2 == 0 || testValue <= 0 || testValue >= 100) && testValue % 4 == 0) { + pass = true; + } else { + pass = false; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if (((testValue % 2)==0 || testValue<=0 || testValue>=100) && (testValue % 4)==0){ + pass = 1; + } else { + pass = 0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfElse_OrOr_AndTest.java b/src/test/java/com/aparapi/codegen/test/IfElse_OrOr_AndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0f4d72c9c4bf8c76d6b0a8bf9388d1c8d8a5ae98 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElse_OrOr_AndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfElse_OrOr_AndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfElse_OrOr_AndTest() { + test(com.aparapi.codegen.test.IfElse_OrOr_And.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfElse_OrOr_AndTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfElse_OrOr_And.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfElse_Or_And_Or.java b/src/test/java/com/aparapi/codegen/test/IfElse_Or_And_Or.java new file mode 100644 index 0000000000000000000000000000000000000000..34e8442e6d5eadddaef86be1caa3daebd184f6a2 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElse_Or_And_Or.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfElse_Or_And_Or { + public void run() { + int x = 5; + int y = 5; + + @SuppressWarnings("unused") boolean pass = false; + + if ((x < 0 || x >= 10) && (y < 0 || y >= 10)) { + pass = true; + } else { + pass = false; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int x = 5; + int y = 5; + char pass = 0; + if ((x<0 || x>=10) && (y<0 || y>=10)){ + pass = 1; + } else { + pass = 0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfElse_Or_And_OrTest.java b/src/test/java/com/aparapi/codegen/test/IfElse_Or_And_OrTest.java new file mode 100644 index 0000000000000000000000000000000000000000..da08956befa728b6d64c5265885c3e794524e05b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfElse_Or_And_OrTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfElse_Or_And_OrTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfElse_Or_And_OrTest() { + test(com.aparapi.codegen.test.IfElse_Or_And_Or.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfElse_Or_And_OrTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfElse_Or_And_Or.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfOr.java b/src/test/java/com/aparapi/codegen/test/IfOr.java new file mode 100644 index 0000000000000000000000000000000000000000..66839f15fa15ecee33aaabd97f76fee06220601c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfOr.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfOr { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if (testValue >= 0 || testValue < 100) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if (testValue>=0 || testValue<100){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfOrAndOr.java b/src/test/java/com/aparapi/codegen/test/IfOrAndOr.java new file mode 100644 index 0000000000000000000000000000000000000000..e30db4dc62ffc5fbc5a4652000ef7476a22e3098 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfOrAndOr.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfOrAndOr { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if (testValue % 2 == 0 || testValue <= 0 && testValue >= 100 || testValue % 4 == 0) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if ((testValue % 2)==0 || testValue<=0 && testValue>=100 || (testValue % 4)==0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfOrAndOrTest.java b/src/test/java/com/aparapi/codegen/test/IfOrAndOrTest.java new file mode 100644 index 0000000000000000000000000000000000000000..715a9ab26e18a7a99824cdd6a94c891722d84aa7 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfOrAndOrTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfOrAndOrTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfOrAndOrTest() { + test(com.aparapi.codegen.test.IfOrAndOr.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfOrAndOrTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfOrAndOr.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfOrOr.java b/src/test/java/com/aparapi/codegen/test/IfOrOr.java new file mode 100644 index 0000000000000000000000000000000000000000..14f8a706822872f59ff1b621f162becf5985a9ab --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfOrOr.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfOrOr { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if (testValue >= 0 || testValue < 100 || testValue == 20) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if (testValue>=0 || testValue<100 || testValue==20){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfOrOrAnd.java b/src/test/java/com/aparapi/codegen/test/IfOrOrAnd.java new file mode 100644 index 0000000000000000000000000000000000000000..dc3091ec206d9c93f30441d98f7883d5030d1f10 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfOrOrAnd.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfOrOrAnd { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if (testValue % 2 == 0 || testValue <= 0 || testValue >= 100 && testValue % 4 == 0) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if ((testValue % 2)==0 || testValue<=0 || testValue>=100 && (testValue % 4)==0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfOrOrAndTest.java b/src/test/java/com/aparapi/codegen/test/IfOrOrAndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a8618ca816afdeb2f7162a13e2a1960d36c13ec4 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfOrOrAndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfOrOrAndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfOrOrAndTest() { + test(com.aparapi.codegen.test.IfOrOrAnd.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfOrOrAndTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfOrOrAnd.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfOrOrOr.java b/src/test/java/com/aparapi/codegen/test/IfOrOrOr.java new file mode 100644 index 0000000000000000000000000000000000000000..3d16d86b20176fda154fb9a9e55e311d3a6ba831 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfOrOrOr.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IfOrOrOr { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if (testValue % 2 == 0 || testValue <= 0 || testValue >= 100 || testValue == 10) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if ((testValue % 2)==0 || testValue<=0 || testValue>=100 || testValue==10){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IfOrOrOrTest.java b/src/test/java/com/aparapi/codegen/test/IfOrOrOrTest.java new file mode 100644 index 0000000000000000000000000000000000000000..33b20c04c05a8d40e4f5110deddb8a494af6d730 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfOrOrOrTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfOrOrOrTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfOrOrOrTest() { + test(com.aparapi.codegen.test.IfOrOrOr.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfOrOrOrTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfOrOrOr.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfOrOrTest.java b/src/test/java/com/aparapi/codegen/test/IfOrOrTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a03755d0b6f4f6cae5e4bce8cd4494614bcbc062 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfOrOrTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfOrOrTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfOrOrTest() { + test(com.aparapi.codegen.test.IfOrOr.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfOrOrTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfOrOr.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfOrTest.java b/src/test/java/com/aparapi/codegen/test/IfOrTest.java new file mode 100644 index 0000000000000000000000000000000000000000..477c9406388aee2ec3da6f2b9d3cfaba2ea0332b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfOrTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfOrTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfOrTest() { + test(com.aparapi.codegen.test.IfOr.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfOrTestWorksWithCaching() { + test(com.aparapi.codegen.test.IfOr.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IfTest.java b/src/test/java/com/aparapi/codegen/test/IfTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c3163de098953eb4cccdfd6bd4dedd292d971ef5 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IfTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IfTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IfTest() { + test(com.aparapi.codegen.test.If.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IfTestWorksWithCaching() { + test(com.aparapi.codegen.test.If.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/If_IfElseIfElseElse_Else.java b/src/test/java/com/aparapi/codegen/test/If_IfElseIfElseElse_Else.java new file mode 100644 index 0000000000000000000000000000000000000000..bb546f8f9dd955caec11b0d04d88373da30870b5 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_IfElseIfElseElse_Else.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class If_IfElseIfElseElse_Else { + public void run() { + boolean a = true; + boolean b = true; + boolean c = true; + @SuppressWarnings("unused") boolean result = false; + + if (a) { + if (b) { + result = true; + } else if (c) { + result = true; + } else { + result = true; + } + } else { + result = false; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char c = 1; + char result = 0; + if (a!=0){ + if (b!=0){ + result = 1; + } else { + if (c!=0){ + result = 1; + } else { + result = 1; + } + } + } else { + result = 0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/If_IfElseIfElseElse_ElseTest.java b/src/test/java/com/aparapi/codegen/test/If_IfElseIfElseElse_ElseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..1bd8ff6ce206c5adc8eec667e330fec6b5474fae --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_IfElseIfElseElse_ElseTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class If_IfElseIfElseElse_ElseTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void If_IfElseIfElseElse_ElseTest() { + test(com.aparapi.codegen.test.If_IfElseIfElseElse_Else.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void If_IfElseIfElseElse_ElseTestWorksWithCaching() { + test(com.aparapi.codegen.test.If_IfElseIfElseElse_Else.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/If_IfElse_Else.java b/src/test/java/com/aparapi/codegen/test/If_IfElse_Else.java new file mode 100644 index 0000000000000000000000000000000000000000..db8a042592d424b998b348d7ce37e64001fb0d0b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_IfElse_Else.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class If_IfElse_Else { + public void run() { + boolean a = true; + boolean b = true; + @SuppressWarnings("unused") boolean result = false; + + if (a) { + if (b) { + result = true; + } else { + result = true; + } + } else { + result = false; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char result = 0; + if (a!=0){ + if (b!=0){ + result = 1; + } else { + result = 1; + } + } else { + result = 0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/If_IfElse_ElseTest.java b/src/test/java/com/aparapi/codegen/test/If_IfElse_ElseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..570d4ac61e44ef474688ffed0f20cbbb979ebffc --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_IfElse_ElseTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class If_IfElse_ElseTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void If_IfElse_ElseTest() { + test(com.aparapi.codegen.test.If_IfElse_Else.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void If_IfElse_ElseTestWorksWithCaching() { + test(com.aparapi.codegen.test.If_IfElse_Else.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/If_IfElse_Else_IfElse_.java b/src/test/java/com/aparapi/codegen/test/If_IfElse_Else_IfElse_.java new file mode 100644 index 0000000000000000000000000000000000000000..57e6235c7fc3507ae2711dd550ec8432b2c8eda3 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_IfElse_Else_IfElse_.java @@ -0,0 +1,141 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class If_IfElse_Else_IfElse_ { + /* + 1: istore_1 ( 0: iconst_1) + 3: istore_2 ( 2: iconst_1) + 5: istore_3 ( 4: iconst_1) + 7: istore 4 ( 6: iconst_1) + 10: istore 5 ( 9: iconst_0) + 13: ifeq 50 (12: iload_1) ? + 17: ifeq 36 (16: iload_2) | ? + 21: ifeq 30 (20: iload_3) | | ? + 25: istore 5 (24: iconst_1) | | | + 27: goto 50 | | | + + 31: istore 5 (30: iconst_2) | | v | + 33: goto 50 | | | + + 38: ifeq 47 (36: iload 4) | v | | ? !!!!!!! + 42: istore 5 (41: iconst_3) | | | | + 44: goto 50 | | | | + + 48: istore 5 (47: iconst_4) | | | v | + 50: return v v v v + + + + 1: istore_1 ( 0: iconst_1) + 3: istore_2 ( 2: iconst_1) + 5: istore_3 ( 4: iconst_1) + 7: istore 4 ( 6: iconst_1) + 10: istore 5 ( 9: iconst_0) + 13: ifeq 50 (12: iload_1) ? + 17: ifeq 36 (16: iload_2) | ? + 21: IFELSE | | + 33: goto 50 | | | + + 38: ifeq 47 (36: iload 4) | v | | ? !!!!!!!! + 42: istore 5 (41: iconst_3) | | | | + 44: goto 50 | | | | + + 48: istore 5 (47: iconst_4) | | | v | + 50: return v v v v + + 1: istore_1 ( 0: iconst_1) + 3: istore_2 ( 2: iconst_1) + 5: istore_3 ( 4: iconst_1) + 7: istore 4 ( 6: iconst_1) + 10: istore 5 ( 9: iconst_0) + 13: ifeq 50 (12: iload_1) ? + 17: ifeq 36 (16: iload_2) | ? <---- ignore this + 21: IFELSE | | + 33: goto 50 | | + + 38: IFELSE | v | + 50: return v v + + 1: istore_1 ( 0: iconst_1) + 3: istore_2 ( 2: iconst_1) + 5: istore_3 ( 4: iconst_1) + 7: istore 4 ( 6: iconst_1) + 10: istore 5 ( 9: iconst_0) + 13: ifeq 50 (12: iload_1) ? + 21: IFELSE | + 33: goto 50 | + + 38: IFELSE | | + 50: return v v + */ + public void run() { + boolean a = true; + boolean b = true; + boolean c = true; + boolean d = true; + @SuppressWarnings("unused") int count = 0; + if (a) { + if (b) { + if (c) { + count = 1; + } else { + count = 2; + } + } else { + if (d) { + count = 3; + } else { + count = 4; + } + } + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char c = 1; + char d = 1; + int count = 0; + if (a!=0){ + if (b!=0){ + if (c!=0){ + count = 1; + } else { + count = 2; + } + } else { + if (d!=0){ + count = 3; + } else { + count = 4; + } + } + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/If_IfElse_Else_IfElse_Test.java b/src/test/java/com/aparapi/codegen/test/If_IfElse_Else_IfElse_Test.java new file mode 100644 index 0000000000000000000000000000000000000000..413015b550b551d78f6757c0ee568040c27629ae --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_IfElse_Else_IfElse_Test.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class If_IfElse_Else_IfElse_Test extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void If_IfElse_Else_IfElse_Test() { + test(com.aparapi.codegen.test.If_IfElse_Else_IfElse_.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void If_IfElse_Else_IfElse_TestWorksWithCaching() { + test(com.aparapi.codegen.test.If_IfElse_Else_IfElse_.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/If_If_Else.java b/src/test/java/com/aparapi/codegen/test/If_If_Else.java new file mode 100644 index 0000000000000000000000000000000000000000..5e13ad06c97b3c0481055a96a022a5a56b239eb4 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_If_Else.java @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class If_If_Else { + /* + 1: istore_1 (0: iconst_1) + 3: istore_2 (2: iconst_1) + 5: istore_3 (4: iconst_0) + 7: ifeq 19 (6: iload_1) ? + 11: ifeq 21 (10: iload_2) | ? + 15: istore_3 (14: iconst_1) | | + 16: goto 21 | | + + 20: istore_3 (19: iconst_0) v | | + 21: return v v + */ + public void run() { + boolean a = true; + boolean b = true; + @SuppressWarnings("unused") boolean result = false; + + if (a) { + if (b) { + result = true; + } + } else { + result = false; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char result = 0; + if (a!=0){ + if (b!=0){ + result = 1; + } + } else { + result = 0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/If_If_Else2.java b/src/test/java/com/aparapi/codegen/test/If_If_Else2.java new file mode 100644 index 0000000000000000000000000000000000000000..01a6fc7d609fdba9c858f2481ab6edb70ce344bd --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_If_Else2.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class If_If_Else2 { + public void run() { + boolean a = true; + boolean b = true; + @SuppressWarnings("unused") boolean result = false; + + if (a && b) { + result = true; + } else { + result = false; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char result = 0; + if (a!=0 && b!=0){ + result = 1; + } else { + result = 0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/If_If_Else2Test.java b/src/test/java/com/aparapi/codegen/test/If_If_Else2Test.java new file mode 100644 index 0000000000000000000000000000000000000000..3e9e70c88940ed4a372080f96863af435c1a5892 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_If_Else2Test.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class If_If_Else2Test extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void If_If_Else2Test() { + test(com.aparapi.codegen.test.If_If_Else2.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void If_If_Else2TestWorksWithCaching() { + test(com.aparapi.codegen.test.If_If_Else2.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/If_If_ElseTest.java b/src/test/java/com/aparapi/codegen/test/If_If_ElseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..91106ccbadb3c54c65e3bda2e07a78ac7e26138d --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_If_ElseTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class If_If_ElseTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void If_If_ElseTest() { + test(com.aparapi.codegen.test.If_If_Else.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void If_If_ElseTestWorksWithCaching() { + test(com.aparapi.codegen.test.If_If_Else.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/If_If_Else_If_.java b/src/test/java/com/aparapi/codegen/test/If_If_Else_If_.java new file mode 100644 index 0000000000000000000000000000000000000000..057f149d8923798fde6cb50042caff11090c5309 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_If_Else_If_.java @@ -0,0 +1,79 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class If_If_Else_If_ { + /* + 1: istore_1 (0:iconst_1) + 3: istore_2 (2:iconst_1) + 5: istore_3 (4:iconst_0) + 7: ifeq 19 (6:iload_1) ? + 11: ifeq 25 (10:iload_2) | ? + 15: istore_3 (14:iconst_1) | | + 16: goto 25 | | + + 20: ifeq 25 (19:iload_2) v | | ? + 24: istore_3 (23:iconst_1) | | | + 25: return v v v + */ + public void run() { + boolean a = true; + boolean b = true; + @SuppressWarnings("unused") boolean result = false; + + if (a) { + if (b) { + result = true; + } + } else { + if (b) { + result = true; + } + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char result = 0; + if (a!=0){ + if (b!=0){ + result = 1; + } + } else { + if (b!=0){ + result = 1; + } + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/If_If_Else_If_Test.java b/src/test/java/com/aparapi/codegen/test/If_If_Else_If_Test.java new file mode 100644 index 0000000000000000000000000000000000000000..6729086b459eb367ccf338d6af33e0edfe9bdf53 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_If_Else_If_Test.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class If_If_Else_If_Test extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void If_If_Else_If_Test() { + test(com.aparapi.codegen.test.If_If_Else_If_.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void If_If_Else_If_TestWorksWithCaching() { + test(com.aparapi.codegen.test.If_If_Else_If_.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/If_OrOr_And.java b/src/test/java/com/aparapi/codegen/test/If_OrOr_And.java new file mode 100644 index 0000000000000000000000000000000000000000..c3849292d8788b289e1735c7e115d72a20833102 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_OrOr_And.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class If_OrOr_And { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if ((testValue % 2 == 0 || testValue <= 0 || testValue >= 100) && testValue % 4 == 0) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if (((testValue % 2)==0 || testValue<=0 || testValue>=100) && (testValue % 4)==0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/If_OrOr_AndTest.java b/src/test/java/com/aparapi/codegen/test/If_OrOr_AndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a5bd5e35a0c81e2fe04c45763ef9e7cbb45eefca --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_OrOr_AndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class If_OrOr_AndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void If_OrOr_AndTest() { + test(com.aparapi.codegen.test.If_OrOr_And.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void If_OrOr_AndTestWorksWithCaching() { + test(com.aparapi.codegen.test.If_OrOr_And.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/If_While_Else.java b/src/test/java/com/aparapi/codegen/test/If_While_Else.java new file mode 100644 index 0000000000000000000000000000000000000000..2f37f2081ea72add8514d2f096f45aa66b1b26b2 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_While_Else.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class If_While_Else { + public void run() { + boolean a = true; + + if (a) { + while (a) { + a = false; + } + } else { + a = true; + + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + if (a!=0){ + for (; a!=0; a = 0){ + } + } else { + a = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/If_While_ElseTest.java b/src/test/java/com/aparapi/codegen/test/If_While_ElseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..34f4211ce4a9a2be5fc9cae071f9ebb0a7c1252c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_While_ElseTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class If_While_ElseTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void If_While_ElseTest() { + test(com.aparapi.codegen.test.If_While_Else.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void If_While_ElseTestWorksWithCaching() { + test(com.aparapi.codegen.test.If_While_Else.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/If_While_Else_While.java b/src/test/java/com/aparapi/codegen/test/If_While_Else_While.java new file mode 100644 index 0000000000000000000000000000000000000000..a5cf9e9626d9473a57d49d9f0a2667b4bc9fe1b5 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_While_Else_While.java @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class If_While_Else_While { + public void run() { + boolean a = true; + + if (a) { + while (a) { + a = false; + } + } else { + while (!a) { + a = true; + } + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + if (a!=0){ + for (; a!=0; a = 0){ + } + } else { + for (; a==0; a = 1){ + } + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/If_While_Else_WhileTest.java b/src/test/java/com/aparapi/codegen/test/If_While_Else_WhileTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6ecc568816091fecf78bba577aa2b61cb178f52b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/If_While_Else_WhileTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class If_While_Else_WhileTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void If_While_Else_WhileTest() { + test(com.aparapi.codegen.test.If_While_Else_While.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void If_While_Else_WhileTestWorksWithCaching() { + test(com.aparapi.codegen.test.If_While_Else_While.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ImplementsInterface.java b/src/test/java/com/aparapi/codegen/test/ImplementsInterface.java new file mode 100644 index 0000000000000000000000000000000000000000..4041970c61a58d1059b56980db7a16bf11f40586 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ImplementsInterface.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +interface IFoo { + public int bar(int n); +} + +public class ImplementsInterface extends Kernel implements IFoo { + int out[] = new int[1]; + + int ival = 3; + + public int bar(int n) { + return n + ival; + } + + public void run() { + out[0] = bar(1); + @SuppressWarnings("unused") boolean pass = false; + } +} +/**{OpenCL{ + typedef struct This_s{ + int ival; + __global int *out; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + int com_amd_aparapi_test_ImplementsInterface__bar(This *this, int n){ + return((n + this->ival)); + } + __kernel void run( + int ival, + __global int *out, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->ival = ival; + this->out = out; + this->passid = passid; + { + this->out[0] = com_amd_aparapi_test_ImplementsInterface__bar(this, 1); + char pass = 0; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ImplementsInterfaceTest.java b/src/test/java/com/aparapi/codegen/test/ImplementsInterfaceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..212115dc2eeb7ae9544c91d87c5b46f9ab0adac1 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ImplementsInterfaceTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ImplementsInterfaceTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ImplementsInterfaceTest() { + test(com.aparapi.codegen.test.ImplementsInterface.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ImplementsInterfaceTestWorksWithCaching() { + test(com.aparapi.codegen.test.ImplementsInterface.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IncArrayArgContent.java b/src/test/java/com/aparapi/codegen/test/IncArrayArgContent.java new file mode 100644 index 0000000000000000000000000000000000000000..fdc80ecc03da8d32b6272a66773c19039c9daf85 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IncArrayArgContent.java @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IncArrayArgContent { + + int arr[] = new int[10]; + + public void run() { + + incit(arr); + } + + public void incit(int[] arr) { + arr[0]++; + + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *arr; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + void com_amd_aparapi_test_IncArrayArgContent__incit(This *this, __global int* arr){ + arr[0] = arr[0] + 1; + return; + } + __kernel void run( + __global int *arr, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->arr = arr; + this->passid = passid; + { + com_amd_aparapi_test_IncArrayArgContent__incit(this, this->arr); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IncArrayArgContentTest.java b/src/test/java/com/aparapi/codegen/test/IncArrayArgContentTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cdf452b7f2769e464c9ea29cf19da1c6db6d14ee --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IncArrayArgContentTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IncArrayArgContentTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IncArrayArgContentTest() { + test(com.aparapi.codegen.test.IncArrayArgContent.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IncArrayArgContentTestWorksWithCaching() { + test(com.aparapi.codegen.test.IncArrayArgContent.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IncField.java b/src/test/java/com/aparapi/codegen/test/IncField.java new file mode 100644 index 0000000000000000000000000000000000000000..66b4754cb577bf4d2ef651c451394538ca6bfc07 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IncField.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class IncField { + int field = 1024; + + public void run() { + field++; + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IncFieldTest.java b/src/test/java/com/aparapi/codegen/test/IncFieldTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b55a7881df21ea5c55ff914d5cc3504b7f9558b7 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IncFieldTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IncFieldTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IncFieldTest() { + test(com.aparapi.codegen.test.IncField.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IncFieldTestWorksWithCaching() { + test(com.aparapi.codegen.test.IncField.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/IndirectRecursion.java b/src/test/java/com/aparapi/codegen/test/IndirectRecursion.java new file mode 100644 index 0000000000000000000000000000000000000000..4e5ef7a432999cb9a7df76a0b81bbdec740c32de --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IndirectRecursion.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class IndirectRecursion extends Kernel { + + int intout[] = new int[1]; + + public void run() { + intout[0] = foo(10); + @SuppressWarnings("unused") boolean pass = false; + } + + int foo(int n) { + if (n > 0) { + return bar(n); + } + return -1; + } + + int bar(int n) { + return foo(--n); + } + +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/IndirectRecursionTest.java b/src/test/java/com/aparapi/codegen/test/IndirectRecursionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..dc00394cbd0176e5fc15816222961e1b93342be3 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/IndirectRecursionTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class IndirectRecursionTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void IndirectRecursionTest() { + test(com.aparapi.codegen.test.IndirectRecursion.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void IndirectRecursionTestWorksWithCaching() { + test(com.aparapi.codegen.test.IndirectRecursion.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/Interface.java b/src/test/java/com/aparapi/codegen/test/Interface.java new file mode 100644 index 0000000000000000000000000000000000000000..ca1da4319f346584633b1e6e5a3f685d90dfc91d --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/Interface.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class Interface { + + double out[] = new double[1]; + Operator sa = new SimpleAdder(); + + public void run() { + out[0] = sa.operate(0.0); + } + + public interface Operator { + public double operate(double d); + } + + public class SimpleAdder implements Operator { + public double operate(double d) { + return d + 1.0; + } + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/InterfaceTest.java b/src/test/java/com/aparapi/codegen/test/InterfaceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..06f642b29775ff3edb34a95903907c3d76b668d8 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/InterfaceTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class InterfaceTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void InterfaceTest() { + test(com.aparapi.codegen.test.Interface.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void InterfaceTestWorksWithCaching() { + test(com.aparapi.codegen.test.Interface.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/LongCompare.java b/src/test/java/com/aparapi/codegen/test/LongCompare.java new file mode 100644 index 0000000000000000000000000000000000000000..68bb343d2d67bc3151fe60b2cf5ea36752910ff1 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/LongCompare.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class LongCompare extends Kernel { + public void run() { + long n1 = 1; + long n2 = 2; + @SuppressWarnings("unused") boolean pass = false; + if (n2 > n1) + pass = true; + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + long n1 = 1L; + long n2 = 2L; + char pass = 0; + if ((n2 - n1)>0){ + pass = 1; + } + return; + } + } + + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/LongCompareTest.java b/src/test/java/com/aparapi/codegen/test/LongCompareTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3ed04f077dbbf3aca33b76dbbdf94d41505468d0 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/LongCompareTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class LongCompareTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void LongCompareTest() { + test(com.aparapi.codegen.test.LongCompare.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void LongCompareTestWorksWithCaching() { + test(com.aparapi.codegen.test.LongCompare.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/LongCompares.java b/src/test/java/com/aparapi/codegen/test/LongCompares.java new file mode 100644 index 0000000000000000000000000000000000000000..60590804b77e7c2b86894d5ad14fd7dee7667407 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/LongCompares.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class LongCompares { + public void run() { + + @SuppressWarnings("unused") boolean pass = false; + long l1 = 1L; + long l2 = 1L; + if (l1 > l2) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + long l1 = 1L; + long l2 = 1L; + if ((l1 - l2)>0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/LongComparesTest.java b/src/test/java/com/aparapi/codegen/test/LongComparesTest.java new file mode 100644 index 0000000000000000000000000000000000000000..18a2436e1d22342b0a262542eedd2a953febfaa7 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/LongComparesTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class LongComparesTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void LongComparesTest() { + test(com.aparapi.codegen.test.LongCompares.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void LongComparesTestWorksWithCaching() { + test(com.aparapi.codegen.test.LongCompares.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/Loops.java b/src/test/java/com/aparapi/codegen/test/Loops.java new file mode 100644 index 0000000000000000000000000000000000000000..9f555540e80ddcb3cdcd74dbffdf98eaed534608 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/Loops.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class Loops { + public void run() { + int sum = 0; + + for (int i = 0; i < 100; i++) { + sum = sum + ++i; + } + + for (int i = 0; i < 100; i++) { + sum = sum + i++; + } + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int sum = 0; + for (int i = 0; i<100; i++){ + sum = sum + ++i; + } + for (int i = 0; i<100; i++){ + sum = sum + i++; + } + return; + } + } + }OpenCL}**/ + diff --git a/src/test/java/com/aparapi/codegen/test/LoopsTest.java b/src/test/java/com/aparapi/codegen/test/LoopsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a9c440880ef8e63290989c35709f8ce85684ccdd --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/LoopsTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class LoopsTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void LoopsTest() { + test(com.aparapi.codegen.test.Loops.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void LoopsTestWorksWithCaching() { + test(com.aparapi.codegen.test.Loops.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/MathAbs.java b/src/test/java/com/aparapi/codegen/test/MathAbs.java new file mode 100644 index 0000000000000000000000000000000000000000..ca11d573a93557b712e01eb032ac367c6a77a1ff --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MathAbs.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class MathAbs extends Kernel { + public void run() { + double d = -1.0; + float f = -1.0f; + int i = -1; + long n = -1; + @SuppressWarnings("unused") boolean pass = true; + if ((abs(d) != 1) || (abs(f) != 1) || (abs(i) != 1) || (abs(n) != 1)) + pass = false; + } +} +/**{OpenCL{ + #pragma OPENCL EXTENSION cl_khr_fp64 : enable + + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + double d = -1.0; + float f = -1.0f; + int i = -1; + long n = -1L; + char pass = 1; + if (fabs(d)!=1.0 || fabs(f)!=1.0f || abs(i)!=1 || (abs(n) - 1L)!=0){ + pass = 0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/MathAbsTest.java b/src/test/java/com/aparapi/codegen/test/MathAbsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3d0f9415beff496da6c875548a57b316c9db54e0 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MathAbsTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class MathAbsTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void MathAbsTest() { + test(com.aparapi.codegen.test.MathAbs.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void MathAbsTestWorksWithCaching() { + test(com.aparapi.codegen.test.MathAbs.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/MathDegRad.java b/src/test/java/com/aparapi/codegen/test/MathDegRad.java new file mode 100644 index 0000000000000000000000000000000000000000..676c8753a3478490225bf1a19d7a2d4d8582a76c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MathDegRad.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class MathDegRad extends Kernel { + public void run() { + double d = -1.0; + float f = -1.0f; + @SuppressWarnings("unused") boolean pass = true; + if ((toRadians(toDegrees(d)) != d) || (toRadians(toDegrees(f)) != f)) + pass = false; + } +} +/**{OpenCL{ + #pragma OPENCL EXTENSION cl_khr_fp64 : enable + + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + double d = -1.0; + float f = -1.0f; + char pass = 1; + if (radians(degrees(d))!=d || radians(degrees(f))!=f){ + pass = 0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/MathDegRadTest.java b/src/test/java/com/aparapi/codegen/test/MathDegRadTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8dc8a72f5760d1ae73a1d7ae39f8033bcb957f18 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MathDegRadTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class MathDegRadTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void MathDegRadTest() { + test(com.aparapi.codegen.test.MathDegRad.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void MathDegRadTestWorksWithCaching() { + test(com.aparapi.codegen.test.MathDegRad.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/MathFallThru.java b/src/test/java/com/aparapi/codegen/test/MathFallThru.java new file mode 100644 index 0000000000000000000000000000000000000000..d6b6875d92e3b5e806b58951020e624294c05ae0 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MathFallThru.java @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class MathFallThru extends Kernel { + + long longout[] = new long[1]; + int intout[] = new int[1]; + + public void run() { + float f1 = 1.0f; + double d1 = 1.0; + longout[0] = round(ceil(cos(exp(floor(log(pow(d1, d1)))))) + tan(sqrt(sin(rint(acos(asin(atan(atan2(d1, d1))))))))); + intout[0] = round(ceil(cos(exp(floor(log(pow(f1, f1)))))) + tan(sqrt(sin(rint(acos(asin(atan(atan2(f1, f1))))))))); + @SuppressWarnings("unused") boolean pass = false; + } +} +/**{OpenCL{ + #pragma OPENCL EXTENSION cl_khr_fp64 : enable + + typedef struct This_s{ + __global long *longout; + __global int *intout; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global long *longout, + __global int *intout, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->longout = longout; + this->intout = intout; + this->passid = passid; + { + float f1 = 1.0f; + double d1 = 1.0; + this->longout[0] = round((ceil(cos(exp(floor(log(pow(d1, d1)))))) + tan(sqrt(sin(rint(acos(asin(atan(atan2(d1, d1)))))))))); + this->intout[0] = round((ceil(cos(exp(floor(log(pow(f1, f1)))))) + tan(sqrt(sin(rint(acos(asin(atan(atan2(f1, f1)))))))))); + char pass = 0; + return; + } + } + + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/MathFallThruTest.java b/src/test/java/com/aparapi/codegen/test/MathFallThruTest.java new file mode 100644 index 0000000000000000000000000000000000000000..fb538a1dc59f3dbb27f09c1bd3a3ce989dfa7097 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MathFallThruTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class MathFallThruTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void MathFallThruTest() { + test(com.aparapi.codegen.test.MathFallThru.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void MathFallThruTestWorksWithCaching() { + test(com.aparapi.codegen.test.MathFallThru.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/MathMax.java b/src/test/java/com/aparapi/codegen/test/MathMax.java new file mode 100644 index 0000000000000000000000000000000000000000..9faf762cc1385eaf8f513526fe61e07fdc8c7588 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MathMax.java @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class MathMax extends Kernel { + public void run() { + double d1 = -1.0, d2 = 1.0; + float f1 = -1.0f, f2 = 1.0f; + int i1 = -1, i2 = 1; + long n1 = -1, n2 = 1; + @SuppressWarnings("unused") boolean pass = true; + if ((max(d1, d2) != 1) || (max(f1, f2) != 1) || (max(i1, i2) != 1) || (max(n1, n2) != 1)) + pass = false; + } +} +/**{OpenCL{ + #pragma OPENCL EXTENSION cl_khr_fp64 : enable + + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + double d1 = -1.0; + double d2 = 1.0; + float f1 = -1.0f; + float f2 = 1.0f; + int i1 = -1; + int i2 = 1; + long n1 = -1L; + long n2 = 1L; + char pass = 1; + if (fmax(d1, d2)!=1.0 || fmax(f1, f2)!=1.0f || max(i1, i2)!=1 || (max(n1, n2) - 1L)!=0){ + pass = 0; + } + return; + } + } + + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/MathMaxTest.java b/src/test/java/com/aparapi/codegen/test/MathMaxTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2add0856e49ccce5f14b019446107ac548ca9355 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MathMaxTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class MathMaxTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void MathMaxTest() { + test(com.aparapi.codegen.test.MathMax.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void MathMaxTestWorksWithCaching() { + test(com.aparapi.codegen.test.MathMax.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/MathMin.java b/src/test/java/com/aparapi/codegen/test/MathMin.java new file mode 100644 index 0000000000000000000000000000000000000000..fc16404f2e55059ca1dc09491106b0c1b5a2609d --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MathMin.java @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class MathMin extends Kernel { + public void run() { + double d1 = -1.0, d2 = 1.0; + float f1 = -1.0f, f2 = 1.0f; + int i1 = -1, i2 = 1; + long n1 = -1, n2 = 1; + @SuppressWarnings("unused") boolean pass = true; + if ((min(d1, d2) != 1) || (min(f1, f2) != 1) || (min(i1, i2) != 1) || (min(n1, n2) != 1)) + pass = false; + } +} +/**{OpenCL{ + #pragma OPENCL EXTENSION cl_khr_fp64 : enable + + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + double d1 = -1.0; + double d2 = 1.0; + float f1 = -1.0f; + float f2 = 1.0f; + int i1 = -1; + int i2 = 1; + long n1 = -1L; + long n2 = 1L; + char pass = 1; + if (fmin(d1, d2)!=1.0 || fmin(f1, f2)!=1.0f || min(i1, i2)!=1 || (min(n1, n2) - 1L)!=0){ + pass = 0; + } + return; + } + } + + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/MathMinTest.java b/src/test/java/com/aparapi/codegen/test/MathMinTest.java new file mode 100644 index 0000000000000000000000000000000000000000..caa22adbe6013ac956204c8ca77fc1f3c42dfee8 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MathMinTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class MathMinTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void MathMinTest() { + test(com.aparapi.codegen.test.MathMin.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void MathMinTestWorksWithCaching() { + test(com.aparapi.codegen.test.MathMin.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/MathRemainder.java b/src/test/java/com/aparapi/codegen/test/MathRemainder.java new file mode 100644 index 0000000000000000000000000000000000000000..eb377bdb0ab326e8c29ef6f324a052c6f35ac176 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MathRemainder.java @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class MathRemainder extends Kernel { + public void run() { + double d1 = 7.0, d2 = 2.0; + float f1 = 7.0f, f2 = 2.0f; + @SuppressWarnings("unused") boolean pass = true; + if ((IEEEremainder(d1, d2) != 1) || (IEEEremainder(f1, f2) != 1)) + pass = false; + } +} +/**{OpenCL{ + #pragma OPENCL EXTENSION cl_khr_fp64 : enable + + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + double d1 = 7.0; + double d2 = 2.0; + float f1 = 7.0f; + float f2 = 2.0f; + char pass = 1; + if (remainder(d1, d2)!=1.0 || remainder(f1, f2)!=1.0f){ + pass = 0; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/MathRemainderTest.java b/src/test/java/com/aparapi/codegen/test/MathRemainderTest.java new file mode 100644 index 0000000000000000000000000000000000000000..56bd0c8ce44288f3e61443cbc5442410b37b8ad8 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MathRemainderTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class MathRemainderTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void MathRemainderTest() { + test(com.aparapi.codegen.test.MathRemainder.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void MathRemainderTestWorksWithCaching() { + test(com.aparapi.codegen.test.MathRemainder.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/MultiContinue.java b/src/test/java/com/aparapi/codegen/test/MultiContinue.java new file mode 100644 index 0000000000000000000000000000000000000000..8ae68a2f6c4da821031b5ab09167b103aa8b03de --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MultiContinue.java @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class MultiContinue { + public void run() { + @SuppressWarnings("unused") boolean pass = false; + for (int i = 0; i < 10; i++) { + if (i == 5) { + continue; + } else { + if (i == 2) { + continue; + } + if (i == 1) { + continue; + } + } + if (i == 10) { + continue; + } + pass = true; + } + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + for (int i = 0; i<10; i++){ + if (i==5){ + } else { + if (i==2){ + } else { + if (i==1){ + } else { + if (i==10){ + } else { + pass = 1; + } + } + } + } + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/MultiContinueTest.java b/src/test/java/com/aparapi/codegen/test/MultiContinueTest.java new file mode 100644 index 0000000000000000000000000000000000000000..54f8a66cb8a60066979c66c98c1e51c01c62224b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MultiContinueTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class MultiContinueTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void MultiContinueTest() { + test(com.aparapi.codegen.test.MultiContinue.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void MultiContinueTestWorksWithCaching() { + test(com.aparapi.codegen.test.MultiContinue.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/MultipleAssign.java b/src/test/java/com/aparapi/codegen/test/MultipleAssign.java new file mode 100644 index 0000000000000000000000000000000000000000..fdcceaa7a56e374af66f3d6959b6c9ddfd1f6727 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MultipleAssign.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class MultipleAssign { + + public void run() { + @SuppressWarnings("unused") int a = 0; + @SuppressWarnings("unused") int b = 0; + @SuppressWarnings("unused") int c = 0; + a = b = c = 4; + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int a = 0; + int b = 0; + int c = 0; + a = b = c = 4; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/MultipleAssignExpr.java b/src/test/java/com/aparapi/codegen/test/MultipleAssignExpr.java new file mode 100644 index 0000000000000000000000000000000000000000..db75c1d67316f88616f12ad7ae7ac054b6d3ece4 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MultipleAssignExpr.java @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class MultipleAssignExpr { + + int sum(int lhs, int rhs) { + return (lhs + rhs); + } + + public void run() { + @SuppressWarnings("unused") int a = 0; + @SuppressWarnings("unused") int b = 0; + @SuppressWarnings("unused") int c = 0; + a = b = c = sum(1, 2); + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + int com_amd_aparapi_test_MultipleAssignExpr__sum(This *this, int lhs, int rhs){ + return((lhs + rhs)); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int a = 0; + int b = 0; + int c = 0; + a = b = c = com_amd_aparapi_test_MultipleAssignExpr__sum(this, 1, 2); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/MultipleAssignExprTest.java b/src/test/java/com/aparapi/codegen/test/MultipleAssignExprTest.java new file mode 100644 index 0000000000000000000000000000000000000000..615304a39af2a652ebada1e63101da7df4a9eadc --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MultipleAssignExprTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class MultipleAssignExprTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void MultipleAssignExprTest() { + test(com.aparapi.codegen.test.MultipleAssignExpr.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void MultipleAssignExprTestWorksWithCaching() { + test(com.aparapi.codegen.test.MultipleAssignExpr.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/MultipleAssignTest.java b/src/test/java/com/aparapi/codegen/test/MultipleAssignTest.java new file mode 100644 index 0000000000000000000000000000000000000000..85bcd8e15f8ab405015deb86831a3c49cdde9724 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/MultipleAssignTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class MultipleAssignTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void MultipleAssignTest() { + test(com.aparapi.codegen.test.MultipleAssign.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void MultipleAssignTestWorksWithCaching() { + test(com.aparapi.codegen.test.MultipleAssign.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/NaN.java b/src/test/java/com/aparapi/codegen/test/NaN.java new file mode 100644 index 0000000000000000000000000000000000000000..9146e638346e1890aa0909f216bd98e418158638 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/NaN.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class NaN extends Kernel { + @Override + public void run() { + double d = 1.0E-10; + } +} +/**{OpenCL{ + #pragma OPENCL EXTENSION cl_khr_fp64 : enable + + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + double d = 1.0E-10; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/NaNTest.java b/src/test/java/com/aparapi/codegen/test/NaNTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0ed91ff9ae0baaed35643f6f638527bdf3234f41 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/NaNTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class NaNTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void NaNTest() { + test(com.aparapi.codegen.test.NaN.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void NaNTestWorksWithCaching() { + test(com.aparapi.codegen.test.NaN.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/NewLocalArray.java b/src/test/java/com/aparapi/codegen/test/NewLocalArray.java new file mode 100644 index 0000000000000000000000000000000000000000..d45a4f577201c6b41bb982d5b0e51241e0c695f0 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/NewLocalArray.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class NewLocalArray { + + int array[] = new int[4]; + + public void run() { + @SuppressWarnings("unused") boolean pass = false; + int i = 0; + if (i++ == 0) + pass = true; + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + int i = 0; + if (i++==0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/NewLocalArrayTest.java b/src/test/java/com/aparapi/codegen/test/NewLocalArrayTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4fb9aaa2a903c1b6cc2146345ad592b7f79c60f7 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/NewLocalArrayTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class NewLocalArrayTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void NewLocalArrayTest() { + test(com.aparapi.codegen.test.NewLocalArray.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void NewLocalArrayTestWorksWithCaching() { + test(com.aparapi.codegen.test.NewLocalArray.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/NonNullCheck.java b/src/test/java/com/aparapi/codegen/test/NonNullCheck.java new file mode 100644 index 0000000000000000000000000000000000000000..5e0fda903a171e38bdde223d498e5c29445b6a40 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/NonNullCheck.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class NonNullCheck { + int[] ints = new int[1024]; + + public void run() { + if (ints != null) { + int value = ints[0]; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *ints; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global int *ints, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->ints = ints; + this->passid = passid; + { + if (this->ints != NULL){ + int value = this->ints[0]; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/NonNullCheckTest.java b/src/test/java/com/aparapi/codegen/test/NonNullCheckTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8c69e7e09c98698e0f4b7fb600a9c873fc394029 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/NonNullCheckTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class NonNullCheckTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void NonNullCheckTest() { + test(com.aparapi.codegen.test.NonNullCheck.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void NonNullCheckTestWorksWithCaching() { + test(com.aparapi.codegen.test.NonNullCheck.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/NullCheck.java b/src/test/java/com/aparapi/codegen/test/NullCheck.java new file mode 100644 index 0000000000000000000000000000000000000000..7a1abf0969360595c22f9c1c719cd20497ae3f2d --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/NullCheck.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class NullCheck { + int[] ints = new int[1024]; + + public void run() { + if (ints == null) { + return; + } + int value = ints[0]; + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *ints; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global int *ints, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->ints = ints; + this->passid = passid; + { + if (this->ints == NULL){ + return; + } + int value = this->ints[0]; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/NullCheckTest.java b/src/test/java/com/aparapi/codegen/test/NullCheckTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c6c0d882f5d0e28c5caa5f441dff1c1b45c7856d --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/NullCheckTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class NullCheckTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void NullCheckTest() { + test(com.aparapi.codegen.test.NullCheck.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void NullCheckTestWorksWithCaching() { + test(com.aparapi.codegen.test.NullCheck.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayCallHierarchy.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayCallHierarchy.java new file mode 100644 index 0000000000000000000000000000000000000000..5de756a1c27600c8bc0e0f2b1436df8306aa4264 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayCallHierarchy.java @@ -0,0 +1,85 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class ObjectArrayCallHierarchy extends Kernel { + + final static int size = 16; + int something; + + ; + DummyOOA dummy[] = null; + + ; + + public ObjectArrayCallHierarchy() { + something = -1; + dummy = new DummyOOA[size]; + dummy[0] = new DummyOOA(); + } + + public int bar(int x) { + return -x; + } + + public void run() { + int myId = getGlobalId(); + dummy[myId].intField = bar(2) + dummy[myId].funnyGet(); + } + + static class DummyParent { + int intField; + + int field2; + + public DummyParent() { + intField = -3; + field2 = -4; + } + + public int getIntField() { + return intField; + } + + public void setIntField(int x) { + intField = x; + } + + public void call2() { + setIntField(intField + field2); + } + + } + + final static class DummyOOA extends DummyParent { + int intField; + + public void funnyCall() { + setIntField(intField + getIntField()); + call2(); + } + + public int funnyGet() { + funnyCall(); + setIntField(intField + getIntField()); + return intField + getIntField(); + } + } +} + +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayCallHierarchyTest.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayCallHierarchyTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4084dd852096fabc11db81bf18efca8a1ce3bddd --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayCallHierarchyTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ObjectArrayCallHierarchyTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ObjectArrayCallHierarchyTest() { + test(com.aparapi.codegen.test.ObjectArrayCallHierarchy.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ObjectArrayCallHierarchyTestWorksWithCaching() { + test(com.aparapi.codegen.test.ObjectArrayCallHierarchy.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayCommonSuper.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayCommonSuper.java new file mode 100644 index 0000000000000000000000000000000000000000..9871090f8c736ae04a44f3dbf1d009819f107755 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayCommonSuper.java @@ -0,0 +1,72 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class ObjectArrayCommonSuper extends Kernel { + + final static int size = 16; + DummyBrother db[] = new DummyBrother[size]; + + ; + DummySister ds[] = new DummySister[size]; + + ; + + public ObjectArrayCommonSuper() { + db[0] = new DummyBrother(); + ds[0] = new DummySister(); + } + + ; + + public void run() { + int myId = getGlobalId(); + db[myId].intField = db[myId].getIntField() + db[myId].getBrosInt(); + ds[myId].intField = ds[myId].getIntField() + ds[myId].getSisInt(); + } + + static class DummyParent { + int intField; + + public DummyParent() { + intField = -3; + } + + public int getIntField() { + return intField; + } + } + + final static class DummyBrother extends DummyParent { + int brosInt; + + public int getBrosInt() { + return brosInt; + } + } + + final static class DummySister extends DummyParent { + int sisInt; + + public int getSisInt() { + return sisInt; + } + } +} + +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayCommonSuperTest.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayCommonSuperTest.java new file mode 100644 index 0000000000000000000000000000000000000000..81fa2518cd42892111dcfe9373ce0f1175391b06 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayCommonSuperTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ObjectArrayCommonSuperTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ObjectArrayCommonSuperTest() { + test(com.aparapi.codegen.test.ObjectArrayCommonSuper.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ObjectArrayCommonSuperTestWorksWithCaching() { + test(com.aparapi.codegen.test.ObjectArrayCommonSuper.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberAccess.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberAccess.java new file mode 100644 index 0000000000000000000000000000000000000000..75765b76181155358854d93569961bfaf6f932f8 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberAccess.java @@ -0,0 +1,111 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class ObjectArrayMemberAccess extends Kernel { + + final int size = 64; + + ; + int out[] = new int[2]; + + int something; + + DummyOOA dummy[] = null; + + public ObjectArrayMemberAccess() { + something = -1; + dummy = new DummyOOA[size]; + + dummy[0] = new DummyOOA(); + } + + public int getSomething() { + return something; + } + + public int bar(int x) { + return -x; + } + + public void run() { + int myId = getGlobalId(); + dummy[myId].mem = dummy[myId].mem + 2; + dummy[myId].floatField = dummy[myId].floatField + (float) 2.0; + } + + final static class DummyOOA { + int mem; + + float floatField; + + public DummyOOA() { + mem = -3; + floatField = -3; + } + + public int getMem() { + return mem; + } + + public void setMem(int x) { + mem = x; + } + + public float getFloatField() { + return floatField; + } + + public void setFloatField(float x) { + floatField = x; + } + + } +} + +/**{OpenCL{ + typedef struct com_amd_aparapi_test_ObjectArrayMemberAccess$DummyOOA_s{ + int mem; + float floatField; + + } com_amd_aparapi_test_ObjectArrayMemberAccess$DummyOOA; + + typedef struct This_s{ + __global com_amd_aparapi_test_ObjectArrayMemberAccess$DummyOOA *dummy; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global com_amd_aparapi_test_ObjectArrayMemberAccess$DummyOOA *dummy, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->dummy = dummy; + this->passid = passid; + { + int myId = get_global_id(0); + this->dummy[myId].mem=this->dummy[myId].mem + 2; + this->dummy[myId].floatField=this->dummy[myId].floatField + 2.0f; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberAccessTest.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberAccessTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a0668bd7a7c29d5deb00161f27f755e69098f407 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberAccessTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ObjectArrayMemberAccessTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = {""}; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ObjectArrayMemberAccessTest() { + test(com.aparapi.codegen.test.ObjectArrayMemberAccess.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ObjectArrayMemberAccessTestWorksWithCaching() { + test(com.aparapi.codegen.test.ObjectArrayMemberAccess.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberBadGetter.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberBadGetter.java new file mode 100644 index 0000000000000000000000000000000000000000..6eccfed5824366e2156dca1dee58c4906ff3ed76 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberBadGetter.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class ObjectArrayMemberBadGetter extends Kernel { + + final int size = 64; + + ; + DummyOOA dummy[] = null; + + public ObjectArrayMemberBadGetter() { + dummy = new DummyOOA[size]; + + dummy[0] = new DummyOOA(); + } + + public void run() { + int myId = getGlobalId(); + dummy[myId].setFloatField(dummy[myId].getFloatField() + (float) 2.0); + } + + final class DummyOOA { + int mem; + + float floatField; + + float theOtherFloatField; + + public float getFloatField() { + //return floatField; + return theOtherFloatField; + } + + public void setFloatField(float x) { + floatField = x; + } + } +} + +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberBadGetterTest.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberBadGetterTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a13c8cad92363da4247a6e0b73bad560e08a9e58 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberBadGetterTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ObjectArrayMemberBadGetterTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ObjectArrayMemberBadGetterTest() { + test(com.aparapi.codegen.test.ObjectArrayMemberBadGetter.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ObjectArrayMemberBadGetterTestWorksWithCaching() { + test(com.aparapi.codegen.test.ObjectArrayMemberBadGetter.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberBadSetter.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberBadSetter.java new file mode 100644 index 0000000000000000000000000000000000000000..8893df3294314d18d337729ab8927e1c76a0ea8a --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberBadSetter.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class ObjectArrayMemberBadSetter extends Kernel { + + final int size = 64; + + ; + DummyOOA dummy[] = null; + + public ObjectArrayMemberBadSetter() { + dummy = new DummyOOA[size]; + + dummy[0] = new DummyOOA(); + } + + public void run() { + int myId = getGlobalId(); + dummy[myId].setFloatField(dummy[myId].getFloatField() + (float) 2.0); + } + + final class DummyOOA { + int mem; + + float floatField; + + float theOtherFloatField; + + public float getFloatField() { + return floatField; + } + + public void setFloatField(float x) { + theOtherFloatField = x; + } + } +} + +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberBadSetterTest.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberBadSetterTest.java new file mode 100644 index 0000000000000000000000000000000000000000..498bb833191a46120aeb4b1df1357119758fb3e2 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberBadSetterTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ObjectArrayMemberBadSetterTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ObjectArrayMemberBadSetterTest() { + test(com.aparapi.codegen.test.ObjectArrayMemberBadSetter.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ObjectArrayMemberBadSetterTestWorksWithCaching() { + test(com.aparapi.codegen.test.ObjectArrayMemberBadSetter.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberCall.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberCall.java new file mode 100644 index 0000000000000000000000000000000000000000..28eb3709a5ebad20c8645a7c0aa596f43cf24467 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberCall.java @@ -0,0 +1,124 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class ObjectArrayMemberCall extends Kernel { + + final int size = 64; + + ; + int out[] = new int[2]; + + int something; + + DummyOOA dummy[] = null; + + public ObjectArrayMemberCall() { + something = -1; + dummy = new DummyOOA[size]; + + dummy[0] = new DummyOOA(); + } + + public int getSomething() { + return something; + } + + public int bar(int x) { + return -x; + } + + public void run() { + int myId = getGlobalId(); + dummy[myId].mem = dummy[myId].addEmUp(dummy[myId].mem, 2); + int tmp = dummy[myId].addToMem(2); + int tmp2 = dummy[myId].addEmUpPlusOne(2, tmp); + } + + final static class DummyOOA { + int mem; + + public DummyOOA() { + mem = -3; + } + + public int getMem() { + return mem; + } + + public void setMem(int x) { + mem = x; + } + + public int addEmUp(int x, int y) { + return x + y; + } + + public int addToMem(int x) { + return x + mem; + } + + public int addEmUpPlusOne(int x, int y) { + return addEmUp(x, y) + 1 + getMem(); + } + } +} + +/**{OpenCL{ + typedef struct com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA_s{ + int mem; + + } com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA; + + typedef struct This_s{ + __global com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA *dummy; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + int com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA__getMem( __global com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA *this){ + return(this->mem); + } + int com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA__addEmUp( __global com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA *this, int x, int y){ + return((x + y)); + } + int com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA__addEmUpPlusOne( __global com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA *this, int x, int y){ + return(((com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA__addEmUp(this, x, y) + 1) + com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA__getMem(this))); + } + int com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA__addToMem( __global com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA *this, int x){ + return((x + this->mem)); + } + __kernel void run( + __global com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA *dummy, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->dummy = dummy; + this->passid = passid; + { + int myId = get_global_id(0); + this->dummy[myId].mem=com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA__addEmUp( &(this->dummy[myId]), this->dummy[myId].mem, 2); + int tmp = com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA__addToMem( &(this->dummy[myId]), 2); + int tmp2 = com_amd_aparapi_test_ObjectArrayMemberCall$DummyOOA__addEmUpPlusOne( &(this->dummy[myId]), 2, tmp); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberCallTest.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberCallTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ca92e44b73b3f63f2bebad0751ee71368f624427 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberCallTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ObjectArrayMemberCallTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ObjectArrayMemberCallTest() { + test(com.aparapi.codegen.test.ObjectArrayMemberCall.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ObjectArrayMemberCallTestWorksWithCaching() { + test(com.aparapi.codegen.test.ObjectArrayMemberCall.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberGetterSetter.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberGetterSetter.java new file mode 100644 index 0000000000000000000000000000000000000000..f0f6d76b2ff99280a603770a85bcf96cdd3b08c6 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberGetterSetter.java @@ -0,0 +1,234 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +final class DummyOOA { + int mem; + + float floatField; + + long longField; + + boolean boolField; + + byte byteField; + + public DummyOOA() { + mem = 8; + } + + public boolean isBoolField() { + return boolField; + } + + public boolean getBoolField() { + return boolField; + } + + public void setBoolField(boolean x) { + //boolField = x & true; + boolField = x; + } + + public int getMem() { + return mem; + } + + public void setMem(int x) { + mem = x; + } + + public float getFloatField() { + return floatField; + } + + public void setFloatField(float x) { + floatField = x; + } + + public long getLongField() { + return longField; + } + + public void setLongField(long x) { + longField = x; + } +}; + +final class TheOtherOne { + int mem; + + public TheOtherOne() { + mem = 8; + } + + public int getMem() { + return mem; + } + + public void setMem(int x) { + mem = x; + } +}; + +public class ObjectArrayMemberGetterSetter extends Kernel { + + final int size = 64; + int out[] = new int[2]; + int something; + DummyOOA dummy[] = null; + TheOtherOne other[] = null; + + public ObjectArrayMemberGetterSetter() { + something = -1; + dummy = new DummyOOA[size]; + other = new TheOtherOne[size]; + + dummy[0] = new DummyOOA(); + other[0] = new TheOtherOne(); + } + + public int getSomething() { + return something; + } + + public int bar(int x) { + return -x; + } + + public void run() { + int myId = getGlobalId(); + + int tmp = dummy[myId].getMem(); + + dummy[myId].setMem(dummy[myId].getMem() + 2); + + dummy[myId].setMem(other[myId].getMem() + getSomething()); + + other[myId].setMem(other[myId].getMem() + getSomething()); + + dummy[myId].setLongField(dummy[myId].getLongField() + 2); + + dummy[myId].setFloatField(dummy[myId].getFloatField() + (float) 2.0); + + dummy[myId].setBoolField(dummy[myId].getBoolField() | dummy[myId].isBoolField()); + + out[myId] = getSomething(); + } +} +/**{OpenCL{ + typedef struct com_amd_aparapi_test_TheOtherOne_s{ + int mem; + + } com_amd_aparapi_test_TheOtherOne; + + typedef struct com_amd_aparapi_test_DummyOOA_s{ + long longField; + float floatField; + int mem; + char boolField; + char _pad_17; + char _pad_18; + char _pad_19; + char _pad_20; + char _pad_21; + char _pad_22; + char _pad_23; + + } com_amd_aparapi_test_DummyOOA; + + typedef struct This_s{ + int something; + __global com_amd_aparapi_test_DummyOOA *dummy; + __global com_amd_aparapi_test_TheOtherOne *other; + __global int *out; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + void com_amd_aparapi_test_DummyOOA__setBoolField( __global com_amd_aparapi_test_DummyOOA *this, char x){ + this->boolField=x; + return; + } + char com_amd_aparapi_test_DummyOOA__isBoolField( __global com_amd_aparapi_test_DummyOOA *this){ + return(this->boolField); + } + char com_amd_aparapi_test_DummyOOA__getBoolField( __global com_amd_aparapi_test_DummyOOA *this){ + return(this->boolField); + } + void com_amd_aparapi_test_DummyOOA__setFloatField( __global com_amd_aparapi_test_DummyOOA *this, float x){ + this->floatField=x; + return; + } + float com_amd_aparapi_test_DummyOOA__getFloatField( __global com_amd_aparapi_test_DummyOOA *this){ + return(this->floatField); + } + void com_amd_aparapi_test_DummyOOA__setLongField( __global com_amd_aparapi_test_DummyOOA *this, long x){ + this->longField=x; + return; + } + long com_amd_aparapi_test_DummyOOA__getLongField( __global com_amd_aparapi_test_DummyOOA *this){ + return(this->longField); + } + void com_amd_aparapi_test_TheOtherOne__setMem( __global com_amd_aparapi_test_TheOtherOne *this, int x){ + this->mem=x; + return; + } + int com_amd_aparapi_test_ObjectArrayMemberGetterSetter__getSomething(This *this){ + return(this->something); + } + int com_amd_aparapi_test_TheOtherOne__getMem( __global com_amd_aparapi_test_TheOtherOne *this){ + return(this->mem); + } + void com_amd_aparapi_test_DummyOOA__setMem( __global com_amd_aparapi_test_DummyOOA *this, int x){ + this->mem=x; + return; + } + int com_amd_aparapi_test_DummyOOA__getMem( __global com_amd_aparapi_test_DummyOOA *this){ + return(this->mem); + } + __kernel void run( + int something, + __global com_amd_aparapi_test_DummyOOA *dummy, + __global com_amd_aparapi_test_TheOtherOne *other, + __global int *out, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->something = something; + this->dummy = dummy; + this->other = other; + this->out = out; + this->passid = passid; + { + int myId = get_global_id(0); + int tmp = com_amd_aparapi_test_DummyOOA__getMem( &(this->dummy[myId])); + com_amd_aparapi_test_DummyOOA__setMem( &(this->dummy[myId]), (com_amd_aparapi_test_DummyOOA__getMem( &(this->dummy[myId])) + 2)); + com_amd_aparapi_test_DummyOOA__setMem( &(this->dummy[myId]), (com_amd_aparapi_test_TheOtherOne__getMem( &(this->other[myId])) + com_amd_aparapi_test_ObjectArrayMemberGetterSetter__getSomething(this))); + com_amd_aparapi_test_TheOtherOne__setMem( &(this->other[myId]), (com_amd_aparapi_test_TheOtherOne__getMem( &(this->other[myId])) + com_amd_aparapi_test_ObjectArrayMemberGetterSetter__getSomething(this))); + com_amd_aparapi_test_DummyOOA__setLongField( &(this->dummy[myId]), (com_amd_aparapi_test_DummyOOA__getLongField( &(this->dummy[myId])) + 2L)); + com_amd_aparapi_test_DummyOOA__setFloatField( &(this->dummy[myId]), (com_amd_aparapi_test_DummyOOA__getFloatField( &(this->dummy[myId])) + 2.0f)); + com_amd_aparapi_test_DummyOOA__setBoolField( &(this->dummy[myId]), (com_amd_aparapi_test_DummyOOA__getBoolField( &(this->dummy[myId])) | com_amd_aparapi_test_DummyOOA__isBoolField( &(this->dummy[myId])))); + this->out[myId] = com_amd_aparapi_test_ObjectArrayMemberGetterSetter__getSomething(this); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberGetterSetterTest.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberGetterSetterTest.java new file mode 100644 index 0000000000000000000000000000000000000000..24bfc5cf8ae60845ddf373cd515685c1379dcab2 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberGetterSetterTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ObjectArrayMemberGetterSetterTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ObjectArrayMemberGetterSetterTest() { + test(com.aparapi.codegen.test.ObjectArrayMemberGetterSetter.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ObjectArrayMemberGetterSetterTestWorksWithCaching() { + test(com.aparapi.codegen.test.ObjectArrayMemberGetterSetter.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberHierarchy.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberHierarchy.java new file mode 100644 index 0000000000000000000000000000000000000000..a7a5354ca1d7eae7c2286ac3f0d2a8f81aa8db77 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberHierarchy.java @@ -0,0 +1,128 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class ObjectArrayMemberHierarchy extends Kernel { + + final static int size = 16; + int something; + + ; + DummyOOA dummy[] = null; + + ; + + public ObjectArrayMemberHierarchy() { + something = -1; + dummy = new DummyOOA[size]; + + dummy[0] = new DummyOOA(); + } + + public int getSomething() { + return something; + } + + public int bar(int x) { + return -x; + } + + public void run() { + int myId = getGlobalId(); + dummy[myId].intField = dummy[myId].getIntField() + 2 + getSomething(); + dummy[myId].setFloatField(dummy[myId].floatField + (float) 2.0); + } + + static class DummyParent { + int intField; + + public DummyParent() { + intField = -3; + } + + public int getIntField() { + return intField; + } + + public void setIntField(int x) { + intField = x; + } + + public int foo() { + return 42 + getIntField(); + } + + } + + final static class DummyOOA extends DummyParent { + float floatField; + + public float getFloatField() { + return floatField; + } + + public void setFloatField(float x) { + floatField = x; + } + } +} + +/**{OpenCL{ + typedef struct com_amd_aparapi_test_ObjectArrayMemberHierarchy$DummyOOA_s{ + float floatField; + int intField; + + } com_amd_aparapi_test_ObjectArrayMemberHierarchy$DummyOOA; + + typedef struct This_s{ + int something; + __global com_amd_aparapi_test_ObjectArrayMemberHierarchy$DummyOOA *dummy; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + void com_amd_aparapi_test_ObjectArrayMemberHierarchy$DummyOOA__setFloatField( __global com_amd_aparapi_test_ObjectArrayMemberHierarchy$DummyOOA *this, float x){ + this->floatField=x; + return; + } + int com_amd_aparapi_test_ObjectArrayMemberHierarchy__getSomething(This *this){ + return(this->something); + } + int com_amd_aparapi_test_ObjectArrayMemberHierarchy$DummyParent__getIntField( __global com_amd_aparapi_test_ObjectArrayMemberHierarchy$DummyOOA *this){ + return(this->intField); + } + __kernel void run( + int something, + __global com_amd_aparapi_test_ObjectArrayMemberHierarchy$DummyOOA *dummy, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->something = something; + this->dummy = dummy; + this->passid = passid; + { + int myId = get_global_id(0); + this->dummy[myId].intField=(com_amd_aparapi_test_ObjectArrayMemberHierarchy$DummyParent__getIntField( &(this->dummy[myId])) + 2) + com_amd_aparapi_test_ObjectArrayMemberHierarchy__getSomething(this); + com_amd_aparapi_test_ObjectArrayMemberHierarchy$DummyOOA__setFloatField( &(this->dummy[myId]), (this->dummy[myId].floatField + 2.0f)); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberHierarchyTest.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberHierarchyTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c68776349f5d7b616ed0ec0eefcee40b1d17f88d --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberHierarchyTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ObjectArrayMemberHierarchyTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ObjectArrayMemberHierarchyTest() { + test(com.aparapi.codegen.test.ObjectArrayMemberHierarchy.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ObjectArrayMemberHierarchyTestWorksWithCaching() { + test(com.aparapi.codegen.test.ObjectArrayMemberHierarchy.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberNotFinal.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberNotFinal.java new file mode 100644 index 0000000000000000000000000000000000000000..4fa0f8748ff9f3f77d7b724e3c90c3dad7dc0c95 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberNotFinal.java @@ -0,0 +1,103 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +class DummyOOANF { + int mem; + + float floatField; + + long longField; + + boolean boolField; + + byte byteField; + + public DummyOOANF() { + mem = 8; + } + + public boolean isBoolField() { + return boolField; + } + + public boolean getBoolField() { + return boolField; + } + + public void setBoolField(boolean x) { + //boolField = x & true; + boolField = x; + } + + public int getMem() { + return mem; + } + + public void setMem(int x) { + mem = x; + } + + public float getFloatField() { + return floatField; + } + + public void setFloatField(float x) { + floatField = x; + } + + public long getLongField() { + return longField; + } + + public void setLongField(long x) { + longField = x; + } +}; + +public class ObjectArrayMemberNotFinal extends Kernel { + + final int size = 64; + int out[] = new int[2]; + int something; + DummyOOANF dummy[] = null; + + public ObjectArrayMemberNotFinal() { + something = -1; + dummy = new DummyOOANF[size]; + + dummy[0] = new DummyOOANF(); + } + + public int getSomething() { + return something; + } + + public int bar(int x) { + return -x; + } + + public void run() { + int myId = getGlobalId(); + + int tmp = dummy[myId].getMem(); + + dummy[myId].setMem(dummy[myId].getMem() + 2); + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberNotFinalTest.java b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberNotFinalTest.java new file mode 100644 index 0000000000000000000000000000000000000000..670bc8f53f32130bb4585f3187911a6fa7b1ab55 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectArrayMemberNotFinalTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ObjectArrayMemberNotFinalTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ObjectArrayMemberNotFinalTest() { + test(com.aparapi.codegen.test.ObjectArrayMemberNotFinal.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ObjectArrayMemberNotFinalTestWorksWithCaching() { + test(com.aparapi.codegen.test.ObjectArrayMemberNotFinal.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ObjectRefCopy.java b/src/test/java/com/aparapi/codegen/test/ObjectRefCopy.java new file mode 100644 index 0000000000000000000000000000000000000000..34353bf661ff1014f7f636aaeb89b2c9f91f734d --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectRefCopy.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class ObjectRefCopy extends Kernel { + + final int size = 8; + + ; + DummyOOA dummy[] = new DummyOOA[size]; + + public void run() { + int myId = getGlobalId(); + dummy[myId] = dummy[myId + 1]; + } + + final static class DummyOOA { + int mem; + + float floatField; + } +} + +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ObjectRefCopyTest.java b/src/test/java/com/aparapi/codegen/test/ObjectRefCopyTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ed57657a52339d3b1bda09a805e6de8224a90405 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectRefCopyTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ObjectRefCopyTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ObjectRefCopyTest() { + test(com.aparapi.codegen.test.ObjectRefCopy.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ObjectRefCopyTestWorksWithCaching() { + test(com.aparapi.codegen.test.ObjectRefCopy.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ObjectWithinObject.java b/src/test/java/com/aparapi/codegen/test/ObjectWithinObject.java new file mode 100644 index 0000000000000000000000000000000000000000..c288456b029762bbf42cdf8dc7671d8c4ae02174 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectWithinObject.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class ObjectWithinObject extends Kernel { + + final int size = 8; + + ; + DummyOOA dummy[] = new DummyOOA[size]; + + public void run() { + int myId = getGlobalId(); + dummy[myId].mem = dummy[myId].next.mem + 4; + } + + final static class DummyOOA { + int mem; + + float floatField; + + DummyOOA next; + + } +} + +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ObjectWithinObjectTest.java b/src/test/java/com/aparapi/codegen/test/ObjectWithinObjectTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8ca7c5a1d743aa47996ee9d6f88488cd944a5121 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ObjectWithinObjectTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ObjectWithinObjectTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ObjectWithinObjectTest() { + test(com.aparapi.codegen.test.ObjectWithinObject.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ObjectWithinObjectTestWorksWithCaching() { + test(com.aparapi.codegen.test.ObjectWithinObject.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/OrAndOrPrecedence.java b/src/test/java/com/aparapi/codegen/test/OrAndOrPrecedence.java new file mode 100644 index 0000000000000000000000000000000000000000..6022c859967fd806f77892415a25663db55c6f11 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/OrAndOrPrecedence.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class OrAndOrPrecedence { + public void run() { + boolean a = true; + boolean b = true; + boolean c = true; + boolean d = true; + @SuppressWarnings("unused") boolean pass = false; + + if ((a || b) && (c || d)) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 1; + char c = 1; + char d = 1; + char pass = 0; + if ((a!=0 || b!=0) && (c!=0 || d!=0)){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/OrAndOrPrecedenceTest.java b/src/test/java/com/aparapi/codegen/test/OrAndOrPrecedenceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..13ccf8468125907fc945857035c276a20e9ed5a0 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/OrAndOrPrecedenceTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class OrAndOrPrecedenceTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void OrAndOrPrecedenceTest() { + test(com.aparapi.codegen.test.OrAndOrPrecedence.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void OrAndOrPrecedenceTestWorksWithCaching() { + test(com.aparapi.codegen.test.OrAndOrPrecedence.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/OverloadMethod.java b/src/test/java/com/aparapi/codegen/test/OverloadMethod.java new file mode 100644 index 0000000000000000000000000000000000000000..c54ca0f13a5f455c8f9cd95b98fb5038ac0ce50e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/OverloadMethod.java @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class OverloadMethod extends Kernel { + int out[] = new int[1]; + + public void run() { + out[0] = foo(2) + foo(2, 3); + } + + int foo(int n) { + return n + 1; + } + + int foo(int a, int b) { + return min(a, b); + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *out; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + int com_amd_aparapi_test_OverloadMethod__foo(This *this, int a, int b){ + return(min(a, b)); + } + int com_amd_aparapi_test_OverloadMethod__foo(This *this, int n){ + return((n + 1)); + } + __kernel void run( + __global int *out, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->out = out; + this->passid = passid; + { + this->out[0] = com_amd_aparapi_test_OverloadMethod__foo(this, 2) + com_amd_aparapi_test_OverloadMethod__foo(this, 2, 3); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/OverloadMethodTest.java b/src/test/java/com/aparapi/codegen/test/OverloadMethodTest.java new file mode 100644 index 0000000000000000000000000000000000000000..904f8856dc2a0b136fda084fb5338903c90f19e4 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/OverloadMethodTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class OverloadMethodTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void OverloadMethodTest() { + test(com.aparapi.codegen.test.OverloadMethod.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void OverloadMethodTestWorksWithCaching() { + test(com.aparapi.codegen.test.OverloadMethod.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/OverriddenKernelField.java b/src/test/java/com/aparapi/codegen/test/OverriddenKernelField.java new file mode 100644 index 0000000000000000000000000000000000000000..f43a3453934861a4ee39e118665276fbdd9ca456 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/OverriddenKernelField.java @@ -0,0 +1,72 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +class OverriddenKernelFieldParent extends Kernel { + int out[] = new int[1]; + + int foo(int n) { + out[0] = n + 1; + return out[0]; + } + + public void run() { + out[0] = foo(3); + } +} + +public class OverriddenKernelField extends OverriddenKernelFieldParent { + int out[] = new int[1]; + + public void run() { + out[0] = foo(2); + } + + int foo(int n) { + return super.foo(n + 1); + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *out; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + int com_amd_aparapi_test_OverriddenKernelFieldParent__foo(This *this, int n){ + this->out[0] = n + 1; + return(this->out[0]); + } + int com_amd_aparapi_test_OverriddenKernelField__foo(This *this, int n){ + return(com_amd_aparapi_test_OverriddenKernelFieldParent__foo(this, (n + 1))); + } + __kernel void run( + __global int *out, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->out = out; + this->passid = passid; + { + this->out[0] = com_amd_aparapi_test_OverriddenKernelField__foo(this, 2); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/OverriddenKernelFieldTest.java b/src/test/java/com/aparapi/codegen/test/OverriddenKernelFieldTest.java new file mode 100644 index 0000000000000000000000000000000000000000..aec126be47a3cc5a04d1f5ab296704b4110421d9 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/OverriddenKernelFieldTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class OverriddenKernelFieldTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void OverriddenKernelFieldTest() { + test(com.aparapi.codegen.test.OverriddenKernelField.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void OverriddenKernelFieldTestWorksWithCaching() { + test(com.aparapi.codegen.test.OverriddenKernelField.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PlayPen.java b/src/test/java/com/aparapi/codegen/test/PlayPen.java new file mode 100644 index 0000000000000000000000000000000000000000..d494b46dcfc527128bf8b25bc0c272dd23d6ab37 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PlayPen.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PlayPen { + public void run() { + int testValue = 10; + @SuppressWarnings("unused") boolean pass = false; + + if ((testValue % 2 == 0 || testValue <= 0 && (testValue >= 100) && testValue % 4 == 0)) { + pass = true; + } + + if ((testValue < 3 || testValue > 5) && (testValue < 2 || testValue > 2) || testValue > 5) { + pass = true; + } + boolean a = false, b = false, c = false, d = false, e = false, f = false; + if ((a || b && c && d) && e || f) { + pass = true; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int testValue = 10; + char pass = 0; + if ((testValue % 2)==0 || testValue<=0 && testValue>=100 && (testValue % 4)==0){ + pass = 1; + } + if ((testValue<3 || testValue>5) && (testValue<2 || testValue>2) || testValue>5){ + pass = 1; + } + char a = 0; + char b = 0; + char c = 0; + char d = 0; + char e = 0; + char f = 0; + if ((a!=0 || b!=0 && c!=0 && d!=0) && e!=0 || f!=0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PlayPenTest.java b/src/test/java/com/aparapi/codegen/test/PlayPenTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6e921b08b01c2c44cd255c43ab51332a0dd61980 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PlayPenTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PlayPenTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PlayPenTest() { + test(com.aparapi.codegen.test.PlayPen.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PlayPenTestWorksWithCaching() { + test(com.aparapi.codegen.test.PlayPen.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PostDecArrayItem.java b/src/test/java/com/aparapi/codegen/test/PostDecArrayItem.java new file mode 100644 index 0000000000000000000000000000000000000000..22adf098c8fccbd46b4dc9516bbe7437239aae66 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostDecArrayItem.java @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PostDecArrayItem { + + final static int START_SIZE = 128; + + public int[] values = new int[START_SIZE]; + + public int[] results = new int[START_SIZE]; + + void actuallyDoIt(int a) { + + } + + public void run() { + int a = 10; + values[a] = results[a]--; + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *values; + __global int *results; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global int *values, + __global int *results, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->values = values; + this->results = results; + this->passid = passid; + { + int a = 10; + this->values[a] = this->results[a]--; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PostDecArrayItemTest.java b/src/test/java/com/aparapi/codegen/test/PostDecArrayItemTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a08cb92f757941851def365ec690fc7e445c14ad --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostDecArrayItemTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PostDecArrayItemTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PostDecArrayItemTest() { + test(com.aparapi.codegen.test.PostDecArrayItem.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PostDecArrayItemTestWorksWithCaching() { + test(com.aparapi.codegen.test.PostDecArrayItem.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PostDecByte.java b/src/test/java/com/aparapi/codegen/test/PostDecByte.java new file mode 100644 index 0000000000000000000000000000000000000000..60f999410237464c973eb7c968538ee8a6a5e4e1 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostDecByte.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PostDecByte { + + /** + * This is a nonsense test, but it should be emitted correctly to return the + * original value of a + */ + byte incByte(byte a) { + return a++; + } + + public void run() { + byte startValue = (byte) 3; + @SuppressWarnings("unused") byte result = incByte(startValue--); + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + char com_amd_aparapi_test_PostDecByte__incByte(This *this, char a){ + return(a++); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char startValue = 3; + char result = com_amd_aparapi_test_PostDecByte__incByte(this, startValue--); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PostDecByteTest.java b/src/test/java/com/aparapi/codegen/test/PostDecByteTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8299068896c0c7f2a2d1302358b3e2ae9a96ae99 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostDecByteTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PostDecByteTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PostDecByteTest() { + test(com.aparapi.codegen.test.PostDecByte.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PostDecByteTestWorksWithCaching() { + test(com.aparapi.codegen.test.PostDecByte.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PostDecLocal.java b/src/test/java/com/aparapi/codegen/test/PostDecLocal.java new file mode 100644 index 0000000000000000000000000000000000000000..b7a301f26d028da45d16667e648068b6598c171b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostDecLocal.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PostDecLocal { + + public void run() { + @SuppressWarnings("unused") boolean pass = false; + int i = 0; + if (i-- == 0) + pass = true; + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + int i = 0; + if (i--==0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PostDecLocalTest.java b/src/test/java/com/aparapi/codegen/test/PostDecLocalTest.java new file mode 100644 index 0000000000000000000000000000000000000000..1cf61e6ec46c5b6e022056815f88e72250686650 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostDecLocalTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PostDecLocalTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PostDecLocalTest() { + test(com.aparapi.codegen.test.PostDecLocal.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PostDecLocalTestWorksWithCaching() { + test(com.aparapi.codegen.test.PostDecLocal.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PostDecPostInc.java b/src/test/java/com/aparapi/codegen/test/PostDecPostInc.java new file mode 100644 index 0000000000000000000000000000000000000000..d9208c36e6e6f80a4de2398aafb1fcbbc4607eb3 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostDecPostInc.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PostDecPostInc { + + public void run() { + int i = 0; + @SuppressWarnings("unused") int result = 0; + result = i-- + i++; + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int i = 0; + int result = 0; + result = i-- + i++; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PostDecPostIncTest.java b/src/test/java/com/aparapi/codegen/test/PostDecPostIncTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5760f04b71cd6b979d4e6107714a3d4b6f3e8ed0 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostDecPostIncTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PostDecPostIncTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PostDecPostIncTest() { + test(com.aparapi.codegen.test.PostDecPostInc.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PostDecPostIncTestWorksWithCaching() { + test(com.aparapi.codegen.test.PostDecPostInc.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PostIncArrayIndexAndElement.java b/src/test/java/com/aparapi/codegen/test/PostIncArrayIndexAndElement.java new file mode 100644 index 0000000000000000000000000000000000000000..fc9d545e35bbeb70adbd2327686726ad5db2be29 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncArrayIndexAndElement.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PostIncArrayIndexAndElement { + + int array[] = new int[4]; + + public void run() { + int i = 0; + array[i++]++; + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *array; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global int *array, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->array = array; + this->passid = passid; + { + int i = 0; + this->array[i++] = this->array[i] + 1; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PostIncArrayIndexAndElementTest.java b/src/test/java/com/aparapi/codegen/test/PostIncArrayIndexAndElementTest.java new file mode 100644 index 0000000000000000000000000000000000000000..1d98bc01f81d148bc1b4313cf5b4a312c32d7772 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncArrayIndexAndElementTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PostIncArrayIndexAndElementTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PostIncArrayIndexAndElementTest() { + test(com.aparapi.codegen.test.PostIncArrayIndexAndElement.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PostIncArrayIndexAndElementTestWorksWithCaching() { + test(com.aparapi.codegen.test.PostIncArrayIndexAndElement.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PostIncArrayItem.java b/src/test/java/com/aparapi/codegen/test/PostIncArrayItem.java new file mode 100644 index 0000000000000000000000000000000000000000..4d2a74ab0d7c1cb88a2fa21d9f4a342648019bc9 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncArrayItem.java @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PostIncArrayItem { + + final static int START_SIZE = 128; + + public int[] values = new int[START_SIZE]; + + public int[] results = new int[START_SIZE]; + + void actuallyDoIt(int a) { + + } + + public void run() { + int a = 10; + values[a] = results[a]++; + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *values; + __global int *results; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global int *values, + __global int *results, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->values = values; + this->results = results; + this->passid = passid; + { + int a = 10; + this->values[a] = this->results[a]++; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PostIncArrayItemAsParameter.java b/src/test/java/com/aparapi/codegen/test/PostIncArrayItemAsParameter.java new file mode 100644 index 0000000000000000000000000000000000000000..6f56a7b297e79523155a32eaaa66c76299dd1eaa --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncArrayItemAsParameter.java @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PostIncArrayItemAsParameter { + + final static int START_SIZE = 128; + + public int[] values = new int[START_SIZE]; + + public int[] results = new int[START_SIZE]; + int y = 2; + + int actuallyDoIt(int a) { + return 1; + } + + public void run() { + actuallyDoIt(results[y]++); + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *results; + int y; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + int com_amd_aparapi_test_PostIncArrayItemAsParameter__actuallyDoIt(This *this, int a){ + return(1); + } + __kernel void run( + __global int *results, + int y, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->results = results; + this->y = y; + this->passid = passid; + { + com_amd_aparapi_test_PostIncArrayItemAsParameter__actuallyDoIt(this, this->results[this->y]++); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PostIncArrayItemAsParameterTest.java b/src/test/java/com/aparapi/codegen/test/PostIncArrayItemAsParameterTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cf7707ff6bdec588dbfae1062dd384945c1a5bbe --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncArrayItemAsParameterTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PostIncArrayItemAsParameterTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PostIncArrayItemAsParameterTest() { + test(com.aparapi.codegen.test.PostIncArrayItemAsParameter.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PostIncArrayItemAsParameterTestWorksWithCaching() { + test(com.aparapi.codegen.test.PostIncArrayItemAsParameter.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PostIncArrayItemFieldIndex.java b/src/test/java/com/aparapi/codegen/test/PostIncArrayItemFieldIndex.java new file mode 100644 index 0000000000000000000000000000000000000000..e6846dce6218c70385d38f877904b67a25215ec1 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncArrayItemFieldIndex.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PostIncArrayItemFieldIndex { + + final static int START_SIZE = 128; + + public int[] values = new int[START_SIZE]; + + public int[] results = new int[START_SIZE]; + + public int a = 10; + + public void run() { + values[a] = results[a]++; + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *values; + int a; + __global int *results; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global int *values, + int a, + __global int *results, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->values = values; + this->a = a; + this->results = results; + this->passid = passid; + { + this->values[this->a] = this->results[this->a]++; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PostIncArrayItemFieldIndexTest.java b/src/test/java/com/aparapi/codegen/test/PostIncArrayItemFieldIndexTest.java new file mode 100644 index 0000000000000000000000000000000000000000..01e149c176eea1d0ed92be74d91266659a841967 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncArrayItemFieldIndexTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PostIncArrayItemFieldIndexTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PostIncArrayItemFieldIndexTest() { + test(com.aparapi.codegen.test.PostIncArrayItemFieldIndex.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PostIncArrayItemFieldIndexTestWorksWithCaching() { + test(com.aparapi.codegen.test.PostIncArrayItemFieldIndex.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PostIncArrayItemTest.java b/src/test/java/com/aparapi/codegen/test/PostIncArrayItemTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2e93a03140c084044e424258ef842274dabbd05c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncArrayItemTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PostIncArrayItemTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PostIncArrayItemTest() { + test(com.aparapi.codegen.test.PostIncArrayItem.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PostIncArrayItemTestWorksWithCaching() { + test(com.aparapi.codegen.test.PostIncArrayItem.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PostIncByte.java b/src/test/java/com/aparapi/codegen/test/PostIncByte.java new file mode 100644 index 0000000000000000000000000000000000000000..9ff6078315e44a0c912883e86ae81945e1010a17 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncByte.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PostIncByte { + + /** + * This is a nonsense test, but it should be emitted correctly to return the + * original value of a + */ + byte incByte(byte a) { + return a++; + } + + public void run() { + byte startValue = (byte) 3; + @SuppressWarnings("unused") byte result = incByte(startValue++); + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + char com_amd_aparapi_test_PostIncByte__incByte(This *this, char a){ + return(a++); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char startValue = 3; + char result = com_amd_aparapi_test_PostIncByte__incByte(this, startValue++); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PostIncByteField.java b/src/test/java/com/aparapi/codegen/test/PostIncByteField.java new file mode 100644 index 0000000000000000000000000000000000000000..3a1625a81978144867f0c934ab0b224920e678b8 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncByteField.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PostIncByteField { + + byte z = (byte) 3; + + byte incByte(byte _a) { + return _a++; + } + + public void run() { + + z = incByte(z++); + + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PostIncByteFieldTest.java b/src/test/java/com/aparapi/codegen/test/PostIncByteFieldTest.java new file mode 100644 index 0000000000000000000000000000000000000000..797fa05bce97bb82d4547d07bf41cbad11ae8a57 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncByteFieldTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PostIncByteFieldTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PostIncByteFieldTest() { + test(com.aparapi.codegen.test.PostIncByteField.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PostIncByteFieldTestWorksWithCaching() { + test(com.aparapi.codegen.test.PostIncByteField.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PostIncByteTest.java b/src/test/java/com/aparapi/codegen/test/PostIncByteTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8bda1cdc518b5ce3bb6de356702852869b6075f5 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncByteTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PostIncByteTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PostIncByteTest() { + test(com.aparapi.codegen.test.PostIncByte.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PostIncByteTestWorksWithCaching() { + test(com.aparapi.codegen.test.PostIncByte.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PostIncInt.java b/src/test/java/com/aparapi/codegen/test/PostIncInt.java new file mode 100644 index 0000000000000000000000000000000000000000..923f728000c293a08204cd364d2e743aa3d87978 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncInt.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PostIncInt { + + int foo(int a) { + return a; + } + + public void run() { + int y = 2; + foo(y++); + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + int com_amd_aparapi_test_PostIncInt__foo(This *this, int a){ + return(a); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int y = 2; + com_amd_aparapi_test_PostIncInt__foo(this,y++); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PostIncIntField.java b/src/test/java/com/aparapi/codegen/test/PostIncIntField.java new file mode 100644 index 0000000000000000000000000000000000000000..716dfae0c06fd27ec4d5e2cfd31dbe73eb965460 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncIntField.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PostIncIntField { + + int _y = 2; + + int incInt(int a) { + return a++; + } + + public void run() { + + incInt(_y++); + + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PostIncIntFieldTest.java b/src/test/java/com/aparapi/codegen/test/PostIncIntFieldTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e30c8d63432e30219be84af8b415d03512eb49c5 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncIntFieldTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PostIncIntFieldTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PostIncIntFieldTest() { + test(com.aparapi.codegen.test.PostIncIntField.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PostIncIntFieldTestWorksWithCaching() { + test(com.aparapi.codegen.test.PostIncIntField.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PostIncIntTest.java b/src/test/java/com/aparapi/codegen/test/PostIncIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2bb23ad63f06cfcd30689274dddc853f07a9f86c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncIntTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PostIncIntTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PostIncIntTest() { + test(com.aparapi.codegen.test.PostIncInt.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PostIncIntTestWorksWithCaching() { + test(com.aparapi.codegen.test.PostIncInt.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PostIncLocal.java b/src/test/java/com/aparapi/codegen/test/PostIncLocal.java new file mode 100644 index 0000000000000000000000000000000000000000..fd4fb028ea80f37804191f003fbe5d1d37415cef --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncLocal.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PostIncLocal { + + public void run() { + @SuppressWarnings("unused") boolean pass = false; + int i = 0; + if (i++ == 0) + pass = true; + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + int i = 0; + if (i++==0){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PostIncLocalStandalone.java b/src/test/java/com/aparapi/codegen/test/PostIncLocalStandalone.java new file mode 100644 index 0000000000000000000000000000000000000000..90736f953a5c6b3344e7f356c528fab8ebd0ce1a --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncLocalStandalone.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PostIncLocalStandalone { + + public void run() { + + int i = 0; + i++; + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int i = 0; + i++; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PostIncLocalStandaloneTest.java b/src/test/java/com/aparapi/codegen/test/PostIncLocalStandaloneTest.java new file mode 100644 index 0000000000000000000000000000000000000000..66206406926360059a9c6a2d91b81b3139e87d99 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncLocalStandaloneTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PostIncLocalStandaloneTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PostIncLocalStandaloneTest() { + test(com.aparapi.codegen.test.PostIncLocalStandalone.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PostIncLocalStandaloneTestWorksWithCaching() { + test(com.aparapi.codegen.test.PostIncLocalStandalone.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PostIncLocalTest.java b/src/test/java/com/aparapi/codegen/test/PostIncLocalTest.java new file mode 100644 index 0000000000000000000000000000000000000000..56c0ad287546e49ede701369ee1cd7d02d323f85 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncLocalTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PostIncLocalTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PostIncLocalTest() { + test(com.aparapi.codegen.test.PostIncLocal.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PostIncLocalTestWorksWithCaching() { + test(com.aparapi.codegen.test.PostIncLocal.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PostIncLocalTwice.java b/src/test/java/com/aparapi/codegen/test/PostIncLocalTwice.java new file mode 100644 index 0000000000000000000000000000000000000000..bbd7c2296ed3f7eb1f2124404cf7ac75044453ab --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncLocalTwice.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PostIncLocalTwice { + + public void run() { + @SuppressWarnings("unused") boolean pass = false; + int i = 0; + if (i++ + i++ == 1) + pass = true; + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + int i = 0; + if ((i++ + i++)==1){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PostIncLocalTwiceTest.java b/src/test/java/com/aparapi/codegen/test/PostIncLocalTwiceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b7f09509ff5228ac590a522fde0ffe1b83a9ecaa --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PostIncLocalTwiceTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PostIncLocalTwiceTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PostIncLocalTwiceTest() { + test(com.aparapi.codegen.test.PostIncLocalTwice.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PostIncLocalTwiceTestWorksWithCaching() { + test(com.aparapi.codegen.test.PostIncLocalTwice.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PreDecArrayIndexAndElement.java b/src/test/java/com/aparapi/codegen/test/PreDecArrayIndexAndElement.java new file mode 100644 index 0000000000000000000000000000000000000000..70b16d695069f4028621a2ea3ea77fc1335b4053 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreDecArrayIndexAndElement.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PreDecArrayIndexAndElement { + + int array[] = new int[4]; + + public void run() { + int i = 0; + --array[--i]; + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *array; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global int *array, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->array = array; + this->passid = passid; + { + int i = 0; + this->array[--i] = this->array[i] - 1; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PreDecArrayIndexAndElementTest.java b/src/test/java/com/aparapi/codegen/test/PreDecArrayIndexAndElementTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c8735552bbac98985a58add592c363dcfdb955c0 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreDecArrayIndexAndElementTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PreDecArrayIndexAndElementTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PreDecArrayIndexAndElementTest() { + test(com.aparapi.codegen.test.PreDecArrayIndexAndElement.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PreDecArrayIndexAndElementTestWorksWithCaching() { + test(com.aparapi.codegen.test.PreDecArrayIndexAndElement.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PreDecArrayItem.java b/src/test/java/com/aparapi/codegen/test/PreDecArrayItem.java new file mode 100644 index 0000000000000000000000000000000000000000..8429c9a64150debdc88471bfa38f62c165d79166 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreDecArrayItem.java @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PreDecArrayItem { + + final static int START_SIZE = 128; + + public int[] values = new int[START_SIZE]; + + public int[] results = new int[START_SIZE]; + + public void run() { + int y = 2; + values[y] = --results[y]; + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *values; + __global int *results; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global int *values, + __global int *results, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->values = values; + this->results = results; + this->passid = passid; + { + int y = 2; + this->values[y] = --this->results[y]; + return; + } + } + + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PreDecArrayItemTest.java b/src/test/java/com/aparapi/codegen/test/PreDecArrayItemTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7e47fb3a92924a0d265add1194c7751a5e110b76 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreDecArrayItemTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PreDecArrayItemTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PreDecArrayItemTest() { + test(com.aparapi.codegen.test.PreDecArrayItem.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PreDecArrayItemTestWorksWithCaching() { + test(com.aparapi.codegen.test.PreDecArrayItem.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PreDecPostInc.java b/src/test/java/com/aparapi/codegen/test/PreDecPostInc.java new file mode 100644 index 0000000000000000000000000000000000000000..b5f489cc6e40ff38cd8d05589fe989404215a545 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreDecPostInc.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PreDecPostInc { + + public void run() { + int i = 0; + @SuppressWarnings("unused") int result = 0; + result = --i + i++; + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int i = 0; + int result = 0; + i--; + result = i + i++; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PreDecPostIncTest.java b/src/test/java/com/aparapi/codegen/test/PreDecPostIncTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d9db00d800fa45af358948b128c3aeccf7031e7e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreDecPostIncTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PreDecPostIncTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PreDecPostIncTest() { + test(com.aparapi.codegen.test.PreDecPostInc.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PreDecPostIncTestWorksWithCaching() { + test(com.aparapi.codegen.test.PreDecPostInc.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PreIncArrayIndexAndElement.java b/src/test/java/com/aparapi/codegen/test/PreIncArrayIndexAndElement.java new file mode 100644 index 0000000000000000000000000000000000000000..f626adf65631c6d019355a91e56fb1a7eecd59ba --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncArrayIndexAndElement.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PreIncArrayIndexAndElement { + + int array[] = new int[4]; + + public void run() { + int i = 0; + ++array[++i]; + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *array; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global int *array, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->array = array; + this->passid = passid; + { + int i = 0; + this->array[++i] = this->array[i] + 1; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PreIncArrayIndexAndElementTest.java b/src/test/java/com/aparapi/codegen/test/PreIncArrayIndexAndElementTest.java new file mode 100644 index 0000000000000000000000000000000000000000..fb080c0bf760bc36c3c0f174183d978b338fa42c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncArrayIndexAndElementTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PreIncArrayIndexAndElementTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PreIncArrayIndexAndElementTest() { + test(com.aparapi.codegen.test.PreIncArrayIndexAndElement.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PreIncArrayIndexAndElementTestWorksWithCaching() { + test(com.aparapi.codegen.test.PreIncArrayIndexAndElement.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PreIncArrayItem.java b/src/test/java/com/aparapi/codegen/test/PreIncArrayItem.java new file mode 100644 index 0000000000000000000000000000000000000000..7a73f5dec91b0e298a508d1e27d5a7c1e9cfc73d --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncArrayItem.java @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PreIncArrayItem { + + final static int START_SIZE = 128; + + public int[] values = new int[START_SIZE]; + + public int[] results = new int[START_SIZE]; + + public void run() { + int y = 2; + values[y] = ++results[y]; + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *values; + __global int *results; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global int *values, + __global int *results, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->values = values; + this->results = results; + this->passid = passid; + { + int y = 2; + this->values[y] = ++this->results[y]; + return; + } + } + + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PreIncArrayItemTest.java b/src/test/java/com/aparapi/codegen/test/PreIncArrayItemTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7b8430bbfddc9468f8b933cdc62166634f3ac653 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncArrayItemTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PreIncArrayItemTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PreIncArrayItemTest() { + test(com.aparapi.codegen.test.PreIncArrayItem.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PreIncArrayItemTestWorksWithCaching() { + test(com.aparapi.codegen.test.PreIncArrayItem.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PreIncByte.java b/src/test/java/com/aparapi/codegen/test/PreIncByte.java new file mode 100644 index 0000000000000000000000000000000000000000..2b6baf58d654b58fb823bb152b535a09ec2c9574 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncByte.java @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PreIncByte { + + byte preIncByte(byte a) { + return ++a; + } + + public void run() { + byte initValue = 0; + @SuppressWarnings("unused") byte result = preIncByte(++initValue); + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + char com_amd_aparapi_test_PreIncByte__preIncByte(This *this, char a){ + a = (char )(a + 1); + return(a); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char initValue = 0; + char result = com_amd_aparapi_test_PreIncByte__preIncByte(this, ++initValue); + return; + } + } + }OpenCL}**/ + +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + char com_amd_aparapi_test_PreIncByte__preIncByte(This *this, char a){ + return(a=(char )(a + 1)); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char initValue = 0; + char result = com_amd_aparapi_test_PreIncByte__preIncByte(this, initValue=(char )(initValue + 1)); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PreIncByteField.java b/src/test/java/com/aparapi/codegen/test/PreIncByteField.java new file mode 100644 index 0000000000000000000000000000000000000000..2a7724f08ee2e34674a6aaaf2f2b51a0cd0c811c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncByteField.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PreIncByteField { + + byte z = (byte) 3; + + byte incByte(byte _a) { + return ++_a; + } + + public void run() { + + z = incByte(++z); + + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PreIncByteFieldTest.java b/src/test/java/com/aparapi/codegen/test/PreIncByteFieldTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a583a3f8f8515ca57e2ab04778c52c31adee414b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncByteFieldTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PreIncByteFieldTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PreIncByteFieldTest() { + test(com.aparapi.codegen.test.PreIncByteField.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PreIncByteFieldTestWorksWithCaching() { + test(com.aparapi.codegen.test.PreIncByteField.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PreIncByteTest.java b/src/test/java/com/aparapi/codegen/test/PreIncByteTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8e5d4a57c5134cf5dff122385dafed7292ac7e57 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncByteTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PreIncByteTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PreIncByteTest() { + test(com.aparapi.codegen.test.PreIncByte.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PreIncByteTestWorksWithCaching() { + test(com.aparapi.codegen.test.PreIncByte.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PreIncInt.java b/src/test/java/com/aparapi/codegen/test/PreIncInt.java new file mode 100644 index 0000000000000000000000000000000000000000..8e0180786bdc84f9ef4f0f3851101931b626b9b4 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncInt.java @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PreIncInt { + + int preIncInt(int a) { + return a; + } + + public void run() { + + int y = 2; + + preIncInt(++y); + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + int com_amd_aparapi_test_PreIncInt__preIncInt(This *this, int a){ + return(a); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int y = 2; + com_amd_aparapi_test_PreIncInt__preIncInt(this,++y); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PreIncIntField.java b/src/test/java/com/aparapi/codegen/test/PreIncIntField.java new file mode 100644 index 0000000000000000000000000000000000000000..2e5a73b7eec016b70e90c58b402760171f09451b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncIntField.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PreIncIntField { + + int y = 2; + + int preIncInt(int _a) { + return ++_a; + } + + public void run() { + + preIncInt(++y); + + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PreIncIntFieldTest.java b/src/test/java/com/aparapi/codegen/test/PreIncIntFieldTest.java new file mode 100644 index 0000000000000000000000000000000000000000..bc30e352656bc48e239598d2bc0fdc4c0d633ec7 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncIntFieldTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PreIncIntFieldTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PreIncIntFieldTest() { + test(com.aparapi.codegen.test.PreIncIntField.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PreIncIntFieldTestWorksWithCaching() { + test(com.aparapi.codegen.test.PreIncIntField.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PreIncIntTest.java b/src/test/java/com/aparapi/codegen/test/PreIncIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..fb08ef48b92abaf7bb52b3f7f1eb48a2d2987d0b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncIntTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PreIncIntTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PreIncIntTest() { + test(com.aparapi.codegen.test.PreIncInt.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PreIncIntTestWorksWithCaching() { + test(com.aparapi.codegen.test.PreIncInt.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PreIncLocal.java b/src/test/java/com/aparapi/codegen/test/PreIncLocal.java new file mode 100644 index 0000000000000000000000000000000000000000..a595373ade028b6e37d5db66a4eacc2369318982 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncLocal.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PreIncLocal { + + public void run() { + @SuppressWarnings("unused") boolean pass = false; + int i = 0; + if (++i == 1) + pass = true; + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + int i = 0; + i++; + if (i==1){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PreIncLocalStandalone.java b/src/test/java/com/aparapi/codegen/test/PreIncLocalStandalone.java new file mode 100644 index 0000000000000000000000000000000000000000..70886ab89148c09a207defef6e8aacd0a5d1a634 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncLocalStandalone.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PreIncLocalStandalone { + + public void run() { + + int i = 0; + ++i; + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int i = 0; + i++; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PreIncLocalStandaloneTest.java b/src/test/java/com/aparapi/codegen/test/PreIncLocalStandaloneTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5a5eb987d780611ea7dce7c745c6325a5a00fe36 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncLocalStandaloneTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PreIncLocalStandaloneTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PreIncLocalStandaloneTest() { + test(com.aparapi.codegen.test.PreIncLocalStandalone.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PreIncLocalStandaloneTestWorksWithCaching() { + test(com.aparapi.codegen.test.PreIncLocalStandalone.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PreIncLocalTest.java b/src/test/java/com/aparapi/codegen/test/PreIncLocalTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cc2a25ca1e161088b22f39ccff44d6ec8cfff06f --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncLocalTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PreIncLocalTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PreIncLocalTest() { + test(com.aparapi.codegen.test.PreIncLocal.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PreIncLocalTestWorksWithCaching() { + test(com.aparapi.codegen.test.PreIncLocal.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/PreIncLocalTwice.java b/src/test/java/com/aparapi/codegen/test/PreIncLocalTwice.java new file mode 100644 index 0000000000000000000000000000000000000000..9b8e1ebecbdc5dd6503064902e11c8bc1363d0ec --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncLocalTwice.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class PreIncLocalTwice { + + public void run() { + @SuppressWarnings("unused") boolean pass = false; + int i = 0; + if (++i + ++i == 3) + pass = true; + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + int i = 0; + i++; + if ((i++ + i)==3){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/PreIncLocalTwiceTest.java b/src/test/java/com/aparapi/codegen/test/PreIncLocalTwiceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7bbbefaac9ac8722160c0719406908cffb63a7c5 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/PreIncLocalTwiceTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class PreIncLocalTwiceTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void PreIncLocalTwiceTest() { + test(com.aparapi.codegen.test.PreIncLocalTwice.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void PreIncLocalTwiceTestWorksWithCaching() { + test(com.aparapi.codegen.test.PreIncLocalTwice.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ReturnBooleanNewArray.java b/src/test/java/com/aparapi/codegen/test/ReturnBooleanNewArray.java new file mode 100644 index 0000000000000000000000000000000000000000..6271a5960cd0b8308c7fe4b0e28c0fc819e8544c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnBooleanNewArray.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ReturnBooleanNewArray { + + boolean[] returnBooleanNewArray() { + + return new boolean[1024]; + } + + public void run() { + returnBooleanNewArray(); + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ReturnBooleanNewArrayTest.java b/src/test/java/com/aparapi/codegen/test/ReturnBooleanNewArrayTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6c2bf359b9e392cdf425a92eb5bf078c506ceb85 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnBooleanNewArrayTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ReturnBooleanNewArrayTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ReturnBooleanNewArrayTest() { + test(com.aparapi.codegen.test.ReturnBooleanNewArray.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ReturnBooleanNewArrayTestWorksWithCaching() { + test(com.aparapi.codegen.test.ReturnBooleanNewArray.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ReturnBooleanVarArray.java b/src/test/java/com/aparapi/codegen/test/ReturnBooleanVarArray.java new file mode 100644 index 0000000000000000000000000000000000000000..757a8aa7a6517c348961e15c2b81f17d9037ea35 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnBooleanVarArray.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ReturnBooleanVarArray { + + boolean[] returnBooleanVarArray() { + + boolean[] ba = new boolean[1024]; + + return ba; + } + + public void run() { + returnBooleanVarArray(); + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ReturnBooleanVarArrayTest.java b/src/test/java/com/aparapi/codegen/test/ReturnBooleanVarArrayTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4568c206d0a8ffe099415282b60a26b95bda947f --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnBooleanVarArrayTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ReturnBooleanVarArrayTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ReturnBooleanVarArrayTest() { + test(com.aparapi.codegen.test.ReturnBooleanVarArray.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ReturnBooleanVarArrayTestWorksWithCaching() { + test(com.aparapi.codegen.test.ReturnBooleanVarArray.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ReturnByteArrayNew.java b/src/test/java/com/aparapi/codegen/test/ReturnByteArrayNew.java new file mode 100644 index 0000000000000000000000000000000000000000..fe08bdc9a242f46743fd480b72e122f0f955c302 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnByteArrayNew.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ReturnByteArrayNew { + + byte[] returnByteArrayNew() { + return new byte[1024]; + } + + public void run() { + returnByteArrayNew(); + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ReturnByteArrayNewTest.java b/src/test/java/com/aparapi/codegen/test/ReturnByteArrayNewTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8fab6de2779ce46058d601f07b5343a336b0a2b8 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnByteArrayNewTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ReturnByteArrayNewTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ReturnByteArrayNewTest() { + test(com.aparapi.codegen.test.ReturnByteArrayNew.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ReturnByteArrayNewTestWorksWithCaching() { + test(com.aparapi.codegen.test.ReturnByteArrayNew.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ReturnByteArrayVar.java b/src/test/java/com/aparapi/codegen/test/ReturnByteArrayVar.java new file mode 100644 index 0000000000000000000000000000000000000000..8751bfb61535679ee21adf254c51f4a75d2cb8d2 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnByteArrayVar.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ReturnByteArrayVar { + + byte[] returnByteArrayVar() { + byte[] bytes = new byte[1024]; + return bytes; + } + + public void run() { + + returnByteArrayVar(); + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ReturnByteArrayVarTest.java b/src/test/java/com/aparapi/codegen/test/ReturnByteArrayVarTest.java new file mode 100644 index 0000000000000000000000000000000000000000..75841058266799ab2830cafdcc4adf32670dbe26 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnByteArrayVarTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ReturnByteArrayVarTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ReturnByteArrayVarTest() { + test(com.aparapi.codegen.test.ReturnByteArrayVar.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ReturnByteArrayVarTestWorksWithCaching() { + test(com.aparapi.codegen.test.ReturnByteArrayVar.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ReturnDoubleArrayNew.java b/src/test/java/com/aparapi/codegen/test/ReturnDoubleArrayNew.java new file mode 100644 index 0000000000000000000000000000000000000000..64e3d29ad1d4fb1e70c2144a542f8b780b8c1d20 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnDoubleArrayNew.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ReturnDoubleArrayNew { + + double[] returnDoubleArrayNew() { + return new double[1024]; + } + + public void run() { + returnDoubleArrayNew(); + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ReturnDoubleArrayNewTest.java b/src/test/java/com/aparapi/codegen/test/ReturnDoubleArrayNewTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5ced42b86e5f3856fe7d23b2ee2d070368c80a30 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnDoubleArrayNewTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ReturnDoubleArrayNewTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ReturnDoubleArrayNewTest() { + test(com.aparapi.codegen.test.ReturnDoubleArrayNew.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ReturnDoubleArrayNewTestWorksWithCaching() { + test(com.aparapi.codegen.test.ReturnDoubleArrayNew.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ReturnDoubleArrayVar.java b/src/test/java/com/aparapi/codegen/test/ReturnDoubleArrayVar.java new file mode 100644 index 0000000000000000000000000000000000000000..4be6a58e097b9fd77120e3092fa3edf4f6aba020 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnDoubleArrayVar.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ReturnDoubleArrayVar { + + double[] returnDoubleArrayVar() { + double[] doubles = new double[1024]; + return doubles; + } + + public void run() { + + returnDoubleArrayVar(); + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ReturnDoubleArrayVarTest.java b/src/test/java/com/aparapi/codegen/test/ReturnDoubleArrayVarTest.java new file mode 100644 index 0000000000000000000000000000000000000000..83738972b2b2ca20183e08581d2fe2c7c1b4e6fc --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnDoubleArrayVarTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ReturnDoubleArrayVarTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ReturnDoubleArrayVarTest() { + test(com.aparapi.codegen.test.ReturnDoubleArrayVar.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ReturnDoubleArrayVarTestWorksWithCaching() { + test(com.aparapi.codegen.test.ReturnDoubleArrayVar.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ReturnFloatArrayNew.java b/src/test/java/com/aparapi/codegen/test/ReturnFloatArrayNew.java new file mode 100644 index 0000000000000000000000000000000000000000..9dd36a7c17de560cf1e769b7440fbdb14cdcbc77 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnFloatArrayNew.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ReturnFloatArrayNew { + + float[] returnFloatArrayNew() { + return new float[1024]; + } + + public void run() { + returnFloatArrayNew(); + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ReturnFloatArrayNewTest.java b/src/test/java/com/aparapi/codegen/test/ReturnFloatArrayNewTest.java new file mode 100644 index 0000000000000000000000000000000000000000..52667c043f21f2efbbef76a1437a923513304431 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnFloatArrayNewTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ReturnFloatArrayNewTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ReturnFloatArrayNewTest() { + test(com.aparapi.codegen.test.ReturnFloatArrayNew.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ReturnFloatArrayNewTestWorksWithCaching() { + test(com.aparapi.codegen.test.ReturnFloatArrayNew.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ReturnFloatArrayVar.java b/src/test/java/com/aparapi/codegen/test/ReturnFloatArrayVar.java new file mode 100644 index 0000000000000000000000000000000000000000..f843d65bc828b54fd64d8f290385cf1884862fd7 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnFloatArrayVar.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ReturnFloatArrayVar { + + float[] returnFloatArrayVar() { + float[] floats = new float[1024]; + return floats; + } + + public void run() { + + returnFloatArrayVar(); + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ReturnFloatArrayVarTest.java b/src/test/java/com/aparapi/codegen/test/ReturnFloatArrayVarTest.java new file mode 100644 index 0000000000000000000000000000000000000000..944908e1f6602ad0ce4993520104472d1d76ccd2 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnFloatArrayVarTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ReturnFloatArrayVarTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ReturnFloatArrayVarTest() { + test(com.aparapi.codegen.test.ReturnFloatArrayVar.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ReturnFloatArrayVarTestWorksWithCaching() { + test(com.aparapi.codegen.test.ReturnFloatArrayVar.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ReturnIntArrayNew.java b/src/test/java/com/aparapi/codegen/test/ReturnIntArrayNew.java new file mode 100644 index 0000000000000000000000000000000000000000..c8b8b1f0bac071996722160ba56649e720729038 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnIntArrayNew.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ReturnIntArrayNew { + + int[] returnIntArrayNew() { + return new int[1024]; + } + + public void run() { + returnIntArrayNew(); + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ReturnIntArrayNewTest.java b/src/test/java/com/aparapi/codegen/test/ReturnIntArrayNewTest.java new file mode 100644 index 0000000000000000000000000000000000000000..67d61f2778273bf5a8aaa3eb79ee9a40d1564000 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnIntArrayNewTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ReturnIntArrayNewTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ReturnIntArrayNewTest() { + test(com.aparapi.codegen.test.ReturnIntArrayNew.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ReturnIntArrayNewTestWorksWithCaching() { + test(com.aparapi.codegen.test.ReturnIntArrayNew.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ReturnIntArrayVar.java b/src/test/java/com/aparapi/codegen/test/ReturnIntArrayVar.java new file mode 100644 index 0000000000000000000000000000000000000000..172757e2de6ddbef740d19de2054ef79bebb8e88 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnIntArrayVar.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ReturnIntArrayVar { + + int[] returnIntArrayVar() { + int[] ints = new int[1024]; + return ints; + } + + public void run() { + + returnIntArrayVar(); + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ReturnIntArrayVarTest.java b/src/test/java/com/aparapi/codegen/test/ReturnIntArrayVarTest.java new file mode 100644 index 0000000000000000000000000000000000000000..22f46dce49abe65ff755de98c4930f2d2136b2de --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnIntArrayVarTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ReturnIntArrayVarTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ReturnIntArrayVarTest() { + test(com.aparapi.codegen.test.ReturnIntArrayVar.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ReturnIntArrayVarTestWorksWithCaching() { + test(com.aparapi.codegen.test.ReturnIntArrayVar.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ReturnLongArrayNew.java b/src/test/java/com/aparapi/codegen/test/ReturnLongArrayNew.java new file mode 100644 index 0000000000000000000000000000000000000000..e9143097afadcf6323b248c0259e5173453673ac --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnLongArrayNew.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ReturnLongArrayNew { + + long[] returnLongArrayNew() { + return new long[1024]; + } + + public void run() { + returnLongArrayNew(); + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ReturnLongArrayNewTest.java b/src/test/java/com/aparapi/codegen/test/ReturnLongArrayNewTest.java new file mode 100644 index 0000000000000000000000000000000000000000..1494821d38af402084a1bebfc326c86afe4ce516 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnLongArrayNewTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ReturnLongArrayNewTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ReturnLongArrayNewTest() { + test(com.aparapi.codegen.test.ReturnLongArrayNew.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ReturnLongArrayNewTestWorksWithCaching() { + test(com.aparapi.codegen.test.ReturnLongArrayNew.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ReturnLongArrayVar.java b/src/test/java/com/aparapi/codegen/test/ReturnLongArrayVar.java new file mode 100644 index 0000000000000000000000000000000000000000..31edd9467ee83bf4f0db96df068d387355c5df3a --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnLongArrayVar.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ReturnLongArrayVar { + + long[] returnLongArrayVar() { + long[] longs = new long[1024]; + return longs; + } + + public void run() { + + returnLongArrayVar(); + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ReturnLongArrayVarTest.java b/src/test/java/com/aparapi/codegen/test/ReturnLongArrayVarTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9b358a7d95b8ec1fd772aba4efd678af5a8abc1a --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnLongArrayVarTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ReturnLongArrayVarTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ReturnLongArrayVarTest() { + test(com.aparapi.codegen.test.ReturnLongArrayVar.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ReturnLongArrayVarTestWorksWithCaching() { + test(com.aparapi.codegen.test.ReturnLongArrayVar.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ReturnPostIncInt.java b/src/test/java/com/aparapi/codegen/test/ReturnPostIncInt.java new file mode 100644 index 0000000000000000000000000000000000000000..905f145eeecd3f0c476b2063774683c72218eabe --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnPostIncInt.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ReturnPostIncInt { + + int returnPostIncInt(int value) { + + return value++; + } + + public void run() { + returnPostIncInt(3); + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + int com_amd_aparapi_test_ReturnPostIncInt__returnPostIncInt(This *this, int value){ + return(value++); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + com_amd_aparapi_test_ReturnPostIncInt__returnPostIncInt(this, 3); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ReturnPostIncIntTest.java b/src/test/java/com/aparapi/codegen/test/ReturnPostIncIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..34f549ed28d6b908a07d42bdb3b86dc45bc5eda5 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnPostIncIntTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ReturnPostIncIntTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ReturnPostIncIntTest() { + test(com.aparapi.codegen.test.ReturnPostIncInt.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ReturnPostIncIntTestWorksWithCaching() { + test(com.aparapi.codegen.test.ReturnPostIncInt.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ReturnPreIncInt.java b/src/test/java/com/aparapi/codegen/test/ReturnPreIncInt.java new file mode 100644 index 0000000000000000000000000000000000000000..d807512ac5d7488e50e59ecddde948e97202f8ed --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnPreIncInt.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ReturnPreIncInt { + + int returnPreIncInt(int value) { + + return ++value; + } + + public void run() { + returnPreIncInt(3); + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + int com_amd_aparapi_test_ReturnPreIncInt__returnPreIncInt(This *this, int value){ + value++; + return(value); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + com_amd_aparapi_test_ReturnPreIncInt__returnPreIncInt(this, 3); + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ReturnPreIncIntTest.java b/src/test/java/com/aparapi/codegen/test/ReturnPreIncIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ea509daf65ff7cfe5ac6a1ca874794d68807c777 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnPreIncIntTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ReturnPreIncIntTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ReturnPreIncIntTest() { + test(com.aparapi.codegen.test.ReturnPreIncInt.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ReturnPreIncIntTestWorksWithCaching() { + test(com.aparapi.codegen.test.ReturnPreIncInt.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ReturnShortArrayNew.java b/src/test/java/com/aparapi/codegen/test/ReturnShortArrayNew.java new file mode 100644 index 0000000000000000000000000000000000000000..c3abc0394121647a55a7772d766d1d23c046aa27 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnShortArrayNew.java @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ReturnShortArrayNew { + + short[] returnShortArrayNew() { + return new short[1024]; + } + + public void run() { + returnShortArrayNew(); + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ReturnShortArrayNewTest.java b/src/test/java/com/aparapi/codegen/test/ReturnShortArrayNewTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7415307be5eeb1c6fcce8f817ef9ac608b0b6e4f --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnShortArrayNewTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ReturnShortArrayNewTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ReturnShortArrayNewTest() { + test(com.aparapi.codegen.test.ReturnShortArrayNew.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ReturnShortArrayNewTestWorksWithCaching() { + test(com.aparapi.codegen.test.ReturnShortArrayNew.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/ReturnShortArrayVar.java b/src/test/java/com/aparapi/codegen/test/ReturnShortArrayVar.java new file mode 100644 index 0000000000000000000000000000000000000000..07d590bdc880a2b94438718a17051bfd9123f53e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnShortArrayVar.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class ReturnShortArrayVar { + + short[] returnShortArrayVar() { + short[] shorts = new short[1024]; + return shorts; + } + + public void run() { + + returnShortArrayVar(); + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/ReturnShortArrayVarTest.java b/src/test/java/com/aparapi/codegen/test/ReturnShortArrayVarTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e02e8dc3bdc84d2c7a3dea6e1d06d906f6702d2f --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/ReturnShortArrayVarTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class ReturnShortArrayVarTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void ReturnShortArrayVarTest() { + test(com.aparapi.codegen.test.ReturnShortArrayVar.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void ReturnShortArrayVarTestWorksWithCaching() { + test(com.aparapi.codegen.test.ReturnShortArrayVar.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/RightShifts.java b/src/test/java/com/aparapi/codegen/test/RightShifts.java new file mode 100644 index 0000000000000000000000000000000000000000..2a5c1558691398808e9c614af6a2e16069a001dc --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/RightShifts.java @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class RightShifts extends Kernel { + + int iout[] = new int[10]; + + int i1, i2; + + public void run() { + iout[1] = i1 >> i2; + iout[2] = i1 >>> i2; + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *iout; + int i1; + int i2; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global int *iout, + int i1, + int i2, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->iout = iout; + this->i1 = i1; + this->i2 = i2; + this->passid = passid; + { + this->iout[1] = this->i1 >> this->i2; + this->iout[2] = ((unsigned int)this->i1) >> this->i2; + return; + } + } + + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/RightShiftsTest.java b/src/test/java/com/aparapi/codegen/test/RightShiftsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3f168385d7994fb7be2a509484d6f1ad8eb49441 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/RightShiftsTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class RightShiftsTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void RightShiftsTest() { + test(com.aparapi.codegen.test.RightShifts.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void RightShiftsTestWorksWithCaching() { + test(com.aparapi.codegen.test.RightShifts.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/Sequence.java b/src/test/java/com/aparapi/codegen/test/Sequence.java new file mode 100644 index 0000000000000000000000000000000000000000..d2afaeb775e23c21d7ad9e3c56c17113afbb0500 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/Sequence.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class Sequence { + public void run() { + @SuppressWarnings("unused") boolean pass = false; + + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/SequenceTest.java b/src/test/java/com/aparapi/codegen/test/SequenceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3437d5a5b542e068c3a996aa4396d522944bfb6a --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/SequenceTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class SequenceTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void SequenceTest() { + test(com.aparapi.codegen.test.Sequence.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void SequenceTestWorksWithCaching() { + test(com.aparapi.codegen.test.Sequence.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/StaticFieldStore.java b/src/test/java/com/aparapi/codegen/test/StaticFieldStore.java new file mode 100644 index 0000000000000000000000000000000000000000..b6f881cc6f118a4b660b315b36f261058b4af25d --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/StaticFieldStore.java @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class StaticFieldStore { + static int foo = 6; + int[] ints = new int[1024]; + + public void run() { + foo = ints[0]; + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/StaticFieldStoreTest.java b/src/test/java/com/aparapi/codegen/test/StaticFieldStoreTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5e12e0b10a8dac521fdbbac5845af41e34f4215b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/StaticFieldStoreTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class StaticFieldStoreTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void StaticFieldStoreTest() { + test(com.aparapi.codegen.test.StaticFieldStore.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void StaticFieldStoreTestWorksWithCaching() { + test(com.aparapi.codegen.test.StaticFieldStore.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/StaticMethodCall.java b/src/test/java/com/aparapi/codegen/test/StaticMethodCall.java new file mode 100644 index 0000000000000000000000000000000000000000..2b069e196623c467e04cd57a216633a97de82511 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/StaticMethodCall.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class StaticMethodCall extends Kernel { + int out[] = new int[1]; + + public static int add(int i, int j) { + return i + j; + } + + public void run() { + out[0] = add(1, 2); + } +} + +/**{OpenCL{ + typedef struct This_s{ + __global int *out; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + int com_amd_aparapi_test_StaticMethodCall__add(int i, int j){ + return((i + j)); + } + __kernel void run( + __global int *out, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->out = out; + this->passid = passid; + { + this->out[0] = com_amd_aparapi_test_StaticMethodCall__add(1, 2); + return; + } + } + + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/StaticMethodCallTest.java b/src/test/java/com/aparapi/codegen/test/StaticMethodCallTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5540106faabded73857907fdb2f7b6a7121eb737 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/StaticMethodCallTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class StaticMethodCallTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void StaticMethodCallTest() { + test(com.aparapi.codegen.test.StaticMethodCall.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void StaticMethodCallTestWorksWithCaching() { + test(com.aparapi.codegen.test.StaticMethodCall.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/SynchronizedMethods.java b/src/test/java/com/aparapi/codegen/test/SynchronizedMethods.java new file mode 100644 index 0000000000000000000000000000000000000000..5150000d06424516b965ebd0eee613c548f5280a --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/SynchronizedMethods.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class SynchronizedMethods { + int[] ints = new int[1024]; + + synchronized int doIt(int a) { + return (int) (((int) 1) - a); + } + + int doIt2(int a) { + return (int) (((int) 1) - a); + } + + public void run() { + int foo = 1; + for (int i = 0; i < 1024; i++) { + if (i % 2 == 0) { + ints[i] = doIt(i); + } else { + synchronized (this) { + ints[i] = doIt2(foo); + } + } + } + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/SynchronizedMethodsTest.java b/src/test/java/com/aparapi/codegen/test/SynchronizedMethodsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..694d80171e7868d2a566dccc2310e3c493bb00c6 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/SynchronizedMethodsTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class SynchronizedMethodsTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void SynchronizedMethodsTest() { + test(com.aparapi.codegen.test.SynchronizedMethods.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void SynchronizedMethodsTestWorksWithCaching() { + test(com.aparapi.codegen.test.SynchronizedMethods.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/Ternary.java b/src/test/java/com/aparapi/codegen/test/Ternary.java new file mode 100644 index 0000000000000000000000000000000000000000..fe58ebc09154509347bb9c67881d1e6b83704345 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/Ternary.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class Ternary { + + float random() { + return (.1f); + } + + public void run() { + @SuppressWarnings("unused") int count = (random() > .5f) ? +1 : -1; + @SuppressWarnings("unused") int foo = 3; + } + +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + float com_amd_aparapi_test_Ternary__random(This *this){ + return(0.1f); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int count = (com_amd_aparapi_test_Ternary__random(this)>0.5f)?1:-1; + int foo = 3; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/TernaryAnd.java b/src/test/java/com/aparapi/codegen/test/TernaryAnd.java new file mode 100644 index 0000000000000000000000000000000000000000..20866296e3013a903ac70e3366f868ca199575db --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/TernaryAnd.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class TernaryAnd { + float random() { + return (.1f); + } + + public void run() { + + @SuppressWarnings("unused") int count = ((random()) > .8f) && ((random()) < .2f) ? +1 : -1; + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + float com_amd_aparapi_test_TernaryAnd__random(This *this){ + return(0.1f); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int count = (com_amd_aparapi_test_TernaryAnd__random(this)>0.8f && com_amd_aparapi_test_TernaryAnd__random(this)<0.2f)?1:-1; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/TernaryAndOr.java b/src/test/java/com/aparapi/codegen/test/TernaryAndOr.java new file mode 100644 index 0000000000000000000000000000000000000000..c5c9b7a4b088ae5088edaf80dc41b16f7136e823 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/TernaryAndOr.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class TernaryAndOr { + float random() { + return (.1f); + } + + public void run() { + + @SuppressWarnings("unused") int count = random() == 0.f && (random() > .8f) || (random() < .2f) ? +1 : -1; + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + float com_amd_aparapi_test_TernaryAndOr__random(This *this){ + return(0.1f); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int count = (com_amd_aparapi_test_TernaryAndOr__random(this)==0.0f && com_amd_aparapi_test_TernaryAndOr__random(this)>0.8f || com_amd_aparapi_test_TernaryAndOr__random(this)<0.2f)?1:-1; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/TernaryAndOrTest.java b/src/test/java/com/aparapi/codegen/test/TernaryAndOrTest.java new file mode 100644 index 0000000000000000000000000000000000000000..366eeb8101b77c8806d20beae0df1febd7dfba37 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/TernaryAndOrTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class TernaryAndOrTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void TernaryAndOrTest() { + test(com.aparapi.codegen.test.TernaryAndOr.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void TernaryAndOrTestWorksWithCaching() { + test(com.aparapi.codegen.test.TernaryAndOr.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/TernaryAndTest.java b/src/test/java/com/aparapi/codegen/test/TernaryAndTest.java new file mode 100644 index 0000000000000000000000000000000000000000..40523f635b185061da948a076c14f6a0e423e12d --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/TernaryAndTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class TernaryAndTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void TernaryAndTest() { + test(com.aparapi.codegen.test.TernaryAnd.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void TernaryAndTestWorksWithCaching() { + test(com.aparapi.codegen.test.TernaryAnd.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/TernaryNested.java b/src/test/java/com/aparapi/codegen/test/TernaryNested.java new file mode 100644 index 0000000000000000000000000000000000000000..2196f9006aa94b309e1e52fe2a3d5bfa540e253c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/TernaryNested.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class TernaryNested { + public void run() { + boolean a = false, b = false, c = false; + @SuppressWarnings("unused") int count = a ? b ? 1 : 2 : c ? 3 : 4; + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 0; + char b = 0; + char c = 0; + int count = (a!=0)?(b!=0)?1:2:(c!=0)?3:4; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/TernaryNestedTest.java b/src/test/java/com/aparapi/codegen/test/TernaryNestedTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4f770a67b40279dcfca3d85a210bc9650465c2a7 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/TernaryNestedTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class TernaryNestedTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void TernaryNestedTest() { + test(com.aparapi.codegen.test.TernaryNested.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void TernaryNestedTestWorksWithCaching() { + test(com.aparapi.codegen.test.TernaryNested.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/TernaryOr.java b/src/test/java/com/aparapi/codegen/test/TernaryOr.java new file mode 100644 index 0000000000000000000000000000000000000000..96abda1bd8f14783aebad8d2665301b490f7ad88 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/TernaryOr.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class TernaryOr { + float random() { + return (.1f); + } + + public void run() { + + @SuppressWarnings("unused") int count = (random() > .8f || random() < .2f) ? +1 : -1; + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + float com_amd_aparapi_test_TernaryOr__random(This *this){ + return(0.1f); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int count = (com_amd_aparapi_test_TernaryOr__random(this)>0.8f || com_amd_aparapi_test_TernaryOr__random(this)<0.2f)?1:-1; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/TernaryOrTest.java b/src/test/java/com/aparapi/codegen/test/TernaryOrTest.java new file mode 100644 index 0000000000000000000000000000000000000000..03b90438ee80bf79e00188c4416d8805abbe859a --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/TernaryOrTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class TernaryOrTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void TernaryOrTest() { + test(com.aparapi.codegen.test.TernaryOr.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void TernaryOrTestWorksWithCaching() { + test(com.aparapi.codegen.test.TernaryOr.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/TernaryTest.java b/src/test/java/com/aparapi/codegen/test/TernaryTest.java new file mode 100644 index 0000000000000000000000000000000000000000..303965c4dc1a19bd1e27a739650f0651abe0f5f8 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/TernaryTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class TernaryTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void TernaryTest() { + test(com.aparapi.codegen.test.Ternary.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void TernaryTestWorksWithCaching() { + test(com.aparapi.codegen.test.Ternary.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/TwoForLoops.java b/src/test/java/com/aparapi/codegen/test/TwoForLoops.java new file mode 100644 index 0000000000000000000000000000000000000000..10977d55ed699cdded6f18d6e39b4c4c4490aaaa --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/TwoForLoops.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class TwoForLoops extends Kernel { + final int size = 100; + int a[] = new int[size]; + + public void run() { + for (int i = 0; i < size; i++) { + a[i] = i; + } + + int sum = 0; + for (int i = 0; i < size; i++) { + sum += a[i]; + } + } + +} +/**{OpenCL{ + typedef struct This_s{ + __global int *a; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global int *a, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->a = a; + this->passid = passid; + { + for (int i = 0; i<100; i++){ + this->a[i] = i; + } + int sum = 0; + for (int i = 0; i<100; i++){ + sum = sum + this->a[i]; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/TwoForLoopsTest.java b/src/test/java/com/aparapi/codegen/test/TwoForLoopsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..124a3c4df486b43ddb34c627911d616d34bf8111 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/TwoForLoopsTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class TwoForLoopsTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void TwoForLoopsTest() { + test(com.aparapi.codegen.test.TwoForLoops.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void TwoForLoopsTestWorksWithCaching() { + test(com.aparapi.codegen.test.TwoForLoops.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/UnrelatedIfElsesWithCommonEndByte.java b/src/test/java/com/aparapi/codegen/test/UnrelatedIfElsesWithCommonEndByte.java new file mode 100644 index 0000000000000000000000000000000000000000..e004359af7b1ab9e15e4ba6bb8125ea851f203eb --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/UnrelatedIfElsesWithCommonEndByte.java @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class UnrelatedIfElsesWithCommonEndByte { + /* + 1: istore_1 (0:iconst_1) + 3: istore_2 (2:iconst_0) + 5: istore_3 (4:iconst_1) + 7: istore 4 (6:iconst_0) + 10: ifeq 39 (9:iload_1) ? + 14: ifeq 23 (13:iload_2) | ? + 18: istore 4 (17:iconst_1) | | + 20: goto 26 | | + + 24: istore 4 (23: iconst_0) | v | + 27: ifeq 36 (26: iload_3) | v ? + 31: istore 4 (30: iconst_1) | | + 33: goto 39 | | + + 37: istore 4 (36: iconst_0) | v | + 39: return v v + */ + int width = 1024; + + float scale = 1f; + + int maxIterations = 10; + + public void run() { + boolean a = true; + boolean b = false; + boolean c = true; + @SuppressWarnings("unused") boolean result = false; + + if (a) { + if (b) { + result = true; + } else { + result = false; + } + + if (c) { + result = true; + } else { + result = false; + } + } + + } + +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 0; + char c = 1; + char result = 0; + if (a!=0){ + if (b!=0){ + result = 1; + } else { + result = 0; + } + if (c!=0){ + result = 1; + } else { + result = 0; + } + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/UnrelatedIfElsesWithCommonEndByteTest.java b/src/test/java/com/aparapi/codegen/test/UnrelatedIfElsesWithCommonEndByteTest.java new file mode 100644 index 0000000000000000000000000000000000000000..26b92dce653d3fb5147d6598751269f85e8ac8b9 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/UnrelatedIfElsesWithCommonEndByteTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class UnrelatedIfElsesWithCommonEndByteTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void UnrelatedIfElsesWithCommonEndByteTest() { + test(com.aparapi.codegen.test.UnrelatedIfElsesWithCommonEndByte.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void UnrelatedIfElsesWithCommonEndByteTestWorksWithCaching() { + test(com.aparapi.codegen.test.UnrelatedIfElsesWithCommonEndByte.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/UnrelatedIfsWithCommonEndByte.java b/src/test/java/com/aparapi/codegen/test/UnrelatedIfsWithCommonEndByte.java new file mode 100644 index 0000000000000000000000000000000000000000..5ff8f7711ca02e76a678b097ad2e9e755d430540 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/UnrelatedIfsWithCommonEndByte.java @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class UnrelatedIfsWithCommonEndByte { + int width = 1024; + + float scale = 1f; + + int maxIterations = 10; + + public void run() { + boolean a1 = true; + boolean a2 = true; + boolean b = false; + boolean c = true; + boolean outer = true; + @SuppressWarnings("unused") boolean result = false; + if (outer) { + if (a1 && !a2) { + // result = true; + if (b) { + result = true; + } + //result = false; + if (c) { + result = true; + } + // result = false; + } + } + + } + +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a1 = 1; + char a2 = 1; + char b = 0; + char c = 1; + char outer = 1; + char result = 0; + if (outer!=0 && a1!=0 && a2==0){ + if (b!=0){ + result = 1; + } + if (c!=0){ + result = 1; + } + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/UnrelatedIfsWithCommonEndByteTest.java b/src/test/java/com/aparapi/codegen/test/UnrelatedIfsWithCommonEndByteTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e45e26321bf049c08b12fae940c80f7997bae8c6 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/UnrelatedIfsWithCommonEndByteTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class UnrelatedIfsWithCommonEndByteTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void UnrelatedIfsWithCommonEndByteTest() { + test(com.aparapi.codegen.test.UnrelatedIfsWithCommonEndByte.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void UnrelatedIfsWithCommonEndByteTestWorksWithCaching() { + test(com.aparapi.codegen.test.UnrelatedIfsWithCommonEndByte.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/UnrelatedNestedIfElses.java b/src/test/java/com/aparapi/codegen/test/UnrelatedNestedIfElses.java new file mode 100644 index 0000000000000000000000000000000000000000..b072bc705ad58a866bec22dc33f3fdc4d4cecdeb --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/UnrelatedNestedIfElses.java @@ -0,0 +1,85 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class UnrelatedNestedIfElses { + + int width = 1024; + + float scale = 1f; + + int maxIterations = 10; + + public void run() { + boolean a = true; + boolean b = false; + boolean c = true; + @SuppressWarnings("unused") boolean result = false; + + if (a) { + if (b) { + result = true; + } else { + result = false; + } + } else { + if (c) { + result = true; + } else { + result = false; + } + } + + } + +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char a = 1; + char b = 0; + char c = 1; + char result = 0; + if (a!=0){ + if (b!=0){ + result = 1; + } else { + result = 0; + } + }else{ + if (c!=0){ + result = 1; + } else { + result = 0; + } + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/UnrelatedNestedIfElsesTest.java b/src/test/java/com/aparapi/codegen/test/UnrelatedNestedIfElsesTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4e83b392d81334432eb8a47441c240b879db628e --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/UnrelatedNestedIfElsesTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class UnrelatedNestedIfElsesTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void UnrelatedNestedIfElsesTest() { + test(com.aparapi.codegen.test.UnrelatedNestedIfElses.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void UnrelatedNestedIfElsesTestWorksWithCaching() { + test(com.aparapi.codegen.test.UnrelatedNestedIfElses.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/UseObject.java b/src/test/java/com/aparapi/codegen/test/UseObject.java new file mode 100644 index 0000000000000000000000000000000000000000..8979c148bef6576221ab5bd394133285eb2f2ffe --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/UseObject.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class UseObject extends Kernel { + Dummy dummy = new Dummy(); + + ; + int out[] = new int[2]; + int plainInt = -1; + + public void run() { + out[0] = dummy.n; + out[1] = plainInt; + } + + class Dummy { + public int n; + } + +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/UseObjectArrayLength.java b/src/test/java/com/aparapi/codegen/test/UseObjectArrayLength.java new file mode 100644 index 0000000000000000000000000000000000000000..84d0faf9fc210be3e7b5747c3ef6f7381d847d91 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/UseObjectArrayLength.java @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class UseObjectArrayLength extends Kernel { + int out[] = new int[2]; + + ; + Dummy dummy[] = new Dummy[10]; + + public void run() { + out[0] = dummy.length; + } + + final class Dummy { + public int n; + } +} +/**{OpenCL{ + typedef struct This_s{ + __global int *out; + __global com_amd_aparapi_test_UseObjectArrayLength$Dummy *dummy; + int dummy__javaArrayLength; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + __global int *out, + __global com_amd_aparapi_test_UseObjectArrayLength$Dummy *dummy, + int dummy__javaArrayLength, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->out = out; + this->dummy = dummy; + this->dummy__javaArrayLength = dummy__javaArrayLength; + this->passid = passid; + { + this->out[0] = this->dummy__javaArrayLength; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/UseObjectArrayLengthTest.java b/src/test/java/com/aparapi/codegen/test/UseObjectArrayLengthTest.java new file mode 100644 index 0000000000000000000000000000000000000000..807ffbbd02f84421d5d666e399239e4bc8d96582 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/UseObjectArrayLengthTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class UseObjectArrayLengthTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void UseObjectArrayLengthTest() { + test(com.aparapi.codegen.test.UseObjectArrayLength.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void UseObjectArrayLengthTestWorksWithCaching() { + test(com.aparapi.codegen.test.UseObjectArrayLength.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/UseObjectTest.java b/src/test/java/com/aparapi/codegen/test/UseObjectTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5f2d7445387252c3134ab8fafa97b993b8f17cc1 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/UseObjectTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class UseObjectTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void UseObjectTest() { + test(com.aparapi.codegen.test.UseObject.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void UseObjectTestWorksWithCaching() { + test(com.aparapi.codegen.test.UseObject.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/UsesArrayLength.java b/src/test/java/com/aparapi/codegen/test/UsesArrayLength.java new file mode 100644 index 0000000000000000000000000000000000000000..255581eb9b6536d6ed30186873199209b7b0a87f --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/UsesArrayLength.java @@ -0,0 +1,145 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import com.aparapi.Kernel; + +public class UsesArrayLength extends Kernel { + + boolean[] values; + + boolean[] results; + + boolean[] results2; + + boolean actuallyDoIt(int index) { + int x = 0; + + // in array index + @SuppressWarnings("unused") boolean y = values[values.length - index]; + + // in addition + x = index + results.length; + + // in subtraction + return (results.length - x > 0); + } + + public void run() { + int myId = 0; + + // in comparison + boolean x = (values.length > 0); + + // in bit AND and as argument + results[myId] = x & actuallyDoIt(values.length); + + // Note results2.length is not used so there should not + // be a results2__javaArrayLength in the emitted source + results2[myId] = !results[myId]; + } +} +/**{OpenCL{ + typedef struct This_s{ + __global char *values; + int values__javaArrayLength; + __global char *results; + int results__javaArrayLength; + __global char *results2; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + char com_amd_aparapi_test_UsesArrayLength__actuallyDoIt(This *this, int index){ + int x = 0; + char y = this->values[(this->values__javaArrayLength - index)]; + x = index + this->results__javaArrayLength; + return(((this->results__javaArrayLength - x)>0)?1:0); + } + __kernel void run( + __global char *values, + int values__javaArrayLength, + __global char *results, + int results__javaArrayLength, + __global char *results2, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->values = values; + this->values__javaArrayLength = values__javaArrayLength; + this->results = results; + this->results__javaArrayLength = results__javaArrayLength; + this->results2 = results2; + this->passid = passid; + { + int myId = 0; + char x = (this->values__javaArrayLength>0)?1:0; + this->results[myId] = x & com_amd_aparapi_test_UsesArrayLength__actuallyDoIt(this, this->values__javaArrayLength); + this->results2[myId] = (this->results[myId]==0)?1:0; + return; + } + } + }OpenCL}**/ + +/**{OpenCL{ + typedef struct This_s{ + __global char *values; + int values__javaArrayLength; + __global char *results; + int results__javaArrayLength; + __global char *results2; + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + char com_amd_aparapi_test_UsesArrayLength__actuallyDoIt(This *this, int index){ + int x = 0; + char y = this->values[(this->values__javaArrayLength - index)]; + x = index + this->results__javaArrayLength; + if ((this->results__javaArrayLength - x)>0){ + return(1); + } + return(0); + } + __kernel void run( + __global char *values, + int values__javaArrayLength, + __global char *results, + int results__javaArrayLength, + __global char *results2, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->values = values; + this->values__javaArrayLength = values__javaArrayLength; + this->results = results; + this->results__javaArrayLength = results__javaArrayLength; + this->results2 = results2; + this->passid = passid; + { + int myId = 0; + char x = (this->values__javaArrayLength>0)?1:0; + this->results[myId] = x & com_amd_aparapi_test_UsesArrayLength__actuallyDoIt(this, this->values__javaArrayLength); + this->results2[myId] = (this->results[myId]!=0)?0:1; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/UsesArrayLengthTest.java b/src/test/java/com/aparapi/codegen/test/UsesArrayLengthTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3de63e8d341d14addf0c82adae7b124f3ac0f827 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/UsesArrayLengthTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class UsesArrayLengthTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void UsesArrayLengthTest() { + test(com.aparapi.codegen.test.UsesArrayLength.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void UsesArrayLengthTestWorksWithCaching() { + test(com.aparapi.codegen.test.UsesArrayLength.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/UsesNew.java b/src/test/java/com/aparapi/codegen/test/UsesNew.java new file mode 100644 index 0000000000000000000000000000000000000000..57f3252bdbbd731f4e27ddc1f8b7c9ee35064e2d --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/UsesNew.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class UsesNew { + int[] ints = new int[1024]; + + public void run() { + @SuppressWarnings("unused") int foo = 1; + + ints = new int[128]; + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/UsesNewTest.java b/src/test/java/com/aparapi/codegen/test/UsesNewTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3f5e73652384ab5c7e3adbe3bb6e5459fab2b363 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/UsesNewTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class UsesNewTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void UsesNewTest() { + test(com.aparapi.codegen.test.UsesNew.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void UsesNewTestWorksWithCaching() { + test(com.aparapi.codegen.test.UsesNew.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/UsesThrow.java b/src/test/java/com/aparapi/codegen/test/UsesThrow.java new file mode 100644 index 0000000000000000000000000000000000000000..d6bcb9b4ab73308350cc910181931fec709e39a8 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/UsesThrow.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class UsesThrow { + int[] ints = new int[1024]; + + int doIt(int a) throws Exception { + if (a < 0) { + throw new Exception("Zoinks!"); + } + return (int) (((int) 1) - a); + } + + public void run() { + @SuppressWarnings("unused") int foo = 1; + try { + for (int i = 0; i < 1024; i++) { + if (i % 2 == 0) { + ints[i] = doIt(i); + } + } + } catch (Exception e) { + // nothing + } + } +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/UsesThrowTest.java b/src/test/java/com/aparapi/codegen/test/UsesThrowTest.java new file mode 100644 index 0000000000000000000000000000000000000000..282364c4b13c01d34ee16fb37796baf0acb71021 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/UsesThrowTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class UsesThrowTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void UsesThrowTest() { + test(com.aparapi.codegen.test.UsesThrow.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void UsesThrowTestWorksWithCaching() { + test(com.aparapi.codegen.test.UsesThrow.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/VarargsForEach.java b/src/test/java/com/aparapi/codegen/test/VarargsForEach.java new file mode 100644 index 0000000000000000000000000000000000000000..d53d41a1ce9cf3f83ea9bc438a11be2aa85de280 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/VarargsForEach.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class VarargsForEach { + int out[] = new int[1]; + + public static int max(int... values) { + if (values.length == 0) { + return 0; + } + + int max = Integer.MIN_VALUE; + for (int i : values) { + if (i > max) + max = i; + } + return max; + } + + public void run() { + out[0] = max(1, 4, 5, 9, 3); + } + +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/VarargsForEachTest.java b/src/test/java/com/aparapi/codegen/test/VarargsForEachTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9fe2e76376a9c87725ed921cd34446596e242970 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/VarargsForEachTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class VarargsForEachTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void VarargsForEachTest() { + test(com.aparapi.codegen.test.VarargsForEach.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void VarargsForEachTestWorksWithCaching() { + test(com.aparapi.codegen.test.VarargsForEach.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/VarargsSimple.java b/src/test/java/com/aparapi/codegen/test/VarargsSimple.java new file mode 100644 index 0000000000000000000000000000000000000000..76a63091d4db48e6f466b1af9305fdf890a4bf72 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/VarargsSimple.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class VarargsSimple { + int out[] = new int[1]; + + public static int max(int... values) { + if (values.length == 0) { + return 0; + } + + int max = Integer.MIN_VALUE; + for (int i = 0; i < values.length; i++) { + if (values[i] > max) + max = i; + } + return max; + } + + public void run() { + out[0] = max(1, 4, 5, 9, 3); + } + +} +/**{Throws{ClassParseException}Throws}**/ diff --git a/src/test/java/com/aparapi/codegen/test/VarargsSimpleTest.java b/src/test/java/com/aparapi/codegen/test/VarargsSimpleTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b47f8026e8980ccca21ca56ca8244743154d1067 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/VarargsSimpleTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class VarargsSimpleTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void VarargsSimpleTest() { + test(com.aparapi.codegen.test.VarargsSimple.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void VarargsSimpleTestWorksWithCaching() { + test(com.aparapi.codegen.test.VarargsSimple.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/While.java b/src/test/java/com/aparapi/codegen/test/While.java new file mode 100644 index 0000000000000000000000000000000000000000..af1c299d551724cd0c767bfb7075336cb6234af4 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/While.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class While { + public void run() { + @SuppressWarnings("unused") boolean pass = false; + int i = 0; + while (i < 10) { + pass = true; + i++; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + char pass = 0; + int i = 0; + for (; i<10; i++){ + pass = 1; + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/WhileAndMandel.java b/src/test/java/com/aparapi/codegen/test/WhileAndMandel.java new file mode 100644 index 0000000000000000000000000000000000000000..373bf0360488f40935ee7425098947832f018883 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WhileAndMandel.java @@ -0,0 +1,105 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class WhileAndMandel { + int width = 1024; + + float scale = 1f; + + int maxIterations = 10; + + public void run() { + int tid = 0; + + int i = tid % width; + int j = tid / width; + + float x0 = ((i * scale) - ((scale / 2) * width)) / width; + float y0 = ((j * scale) - ((scale / 2) * width)) / width; + + float x = x0; + float y = y0; + + float x2 = x * x; + float y2 = y * y; + + float scaleSquare = scale * scale; + + int count = 0; + int iter = 0; + while ((x2 + y2 <= scaleSquare) && (iter < maxIterations)) { + + y = 2 * x * y + y0; + x = x2 - y2 + x0; + + x2 = x * x; + y2 = y * y; + count++; + ++iter; + } + @SuppressWarnings("unused") int value = (256 * count) / maxIterations; + } +} +/**{OpenCL{ + typedef struct This_s{ + int width; + float scale; + int maxIterations; + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int width, + float scale, + int maxIterations, + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->width = width; + this->scale = scale; + this->maxIterations = maxIterations; + this->passid = passid; + { + int tid = 0; + int i = tid % this->width; + int j = tid / this->width; + float x0 = (((float)i * this->scale) - ((this->scale / 2.0f) * (float)this->width)) / (float)this->width; + float y0 = (((float)j * this->scale) - ((this->scale / 2.0f) * (float)this->width)) / (float)this->width; + float x = x0; + float y = y0; + float x2 = x * x; + float y2 = y * y; + float scaleSquare = this->scale * this->scale; + int count = 0; + int iter = 0; + for (; (x2 + y2)<=scaleSquare && iter<this->maxIterations; iter++){ + y = ((2.0f * x) * y) + y0; + x = (x2 - y2) + x0; + x2 = x * x; + y2 = y * y; + count++; + } + int value = (256 * count) / this->maxIterations; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/WhileAndMandelTest.java b/src/test/java/com/aparapi/codegen/test/WhileAndMandelTest.java new file mode 100644 index 0000000000000000000000000000000000000000..08798b52cdaf65b1b298a365449c7dc3750ce259 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WhileAndMandelTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class WhileAndMandelTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void WhileAndMandelTest() { + test(com.aparapi.codegen.test.WhileAndMandel.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void WhileAndMandelTestWorksWithCaching() { + test(com.aparapi.codegen.test.WhileAndMandel.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/WhileEmptyLoop.java b/src/test/java/com/aparapi/codegen/test/WhileEmptyLoop.java new file mode 100644 index 0000000000000000000000000000000000000000..c39aefcb02c47ecc5b61985547fcf5c2021f5979 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WhileEmptyLoop.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class WhileEmptyLoop { + public void run() { + int x = 10; + while (x-- != 0) { + } + } +} +/**{OpenCL{ + typedef struct This_s{ + + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + for (int x = 10; x--!=0;){} + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/WhileEmptyLoopTest.java b/src/test/java/com/aparapi/codegen/test/WhileEmptyLoopTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0c843f110d5291982f4845894c795a0ed00379b7 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WhileEmptyLoopTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class WhileEmptyLoopTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void WhileEmptyLoopTest() { + test(com.aparapi.codegen.test.WhileEmptyLoop.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void WhileEmptyLoopTestWorksWithCaching() { + test(com.aparapi.codegen.test.WhileEmptyLoop.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/WhileFloatCompound.java b/src/test/java/com/aparapi/codegen/test/WhileFloatCompound.java new file mode 100644 index 0000000000000000000000000000000000000000..9681ad8946b285060c7b39d45d79fdda64c4acd5 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WhileFloatCompound.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class WhileFloatCompound { + + public float randomFunc() { + + return (1.0f); + } + + public void run() { + float v1 = 1f, v2 = 0f, s = 1f; + + while (s < 1 && s > 0) { + v1 = randomFunc(); + v2 = randomFunc(); + s = v1 * v1 + v2 * v2; + } + + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + float com_amd_aparapi_test_WhileFloatCompound__randomFunc(This *this){ + return(1.0f); + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + float v1 = 1.0f; + float v2 = 0.0f; + float s = 1.0f; + for (; s<1.0f && s>0.0f; s = (v1 * v1) + (v2 * v2)){ + v1 = com_amd_aparapi_test_WhileFloatCompound__randomFunc(this); + v2 = com_amd_aparapi_test_WhileFloatCompound__randomFunc(this); + } + return; + } + } + }OpenCL}**/ + diff --git a/src/test/java/com/aparapi/codegen/test/WhileFloatCompoundTest.java b/src/test/java/com/aparapi/codegen/test/WhileFloatCompoundTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ae34cec8c4bdfbb80b3dac67aca76d865aafa6be --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WhileFloatCompoundTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class WhileFloatCompoundTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void WhileFloatCompoundTest() { + test(com.aparapi.codegen.test.WhileFloatCompound.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void WhileFloatCompoundTestWorksWithCaching() { + test(com.aparapi.codegen.test.WhileFloatCompound.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/WhileIf.java b/src/test/java/com/aparapi/codegen/test/WhileIf.java new file mode 100644 index 0000000000000000000000000000000000000000..6c3a175aa3fa1009a315b05541aa7fb2508786d7 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WhileIf.java @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class WhileIf { + public void run() { + + int a = 0; + int b = 0; + int c = 0; + int d = 0; + + while (a == a) { + if (b == b) { + c = c; + } + //d = d; // remove this will work + } + } + +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int a = 0; + int b = 0; + int c = 0; + int d = 0; + for (; a==a; ){ + if (b==b){ + c = c; + } + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/WhileIfElse.java b/src/test/java/com/aparapi/codegen/test/WhileIfElse.java new file mode 100644 index 0000000000000000000000000000000000000000..806a855f31bcc09575f640fb5db599c3677b3baf --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WhileIfElse.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class WhileIfElse { + public void run() { + + int a = 0; + int b = 0; + int c = 0; + int d = 0; + + while (a == a) { + if (b == b) { + c = c; + } else { + d = d; + } + } + } + +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int a = 0; + int b = 0; + int c = 0; + int d = 0; + for (; a==a; ){ + if (b==b){ + c = c; + } else { + d = d; + } + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/WhileIfElseTest.java b/src/test/java/com/aparapi/codegen/test/WhileIfElseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d22bc72ce9f8afbebd98cb3876edc004feddad54 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WhileIfElseTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class WhileIfElseTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void WhileIfElseTest() { + test(com.aparapi.codegen.test.WhileIfElse.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void WhileIfElseTestWorksWithCaching() { + test(com.aparapi.codegen.test.WhileIfElse.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/WhileIfTest.java b/src/test/java/com/aparapi/codegen/test/WhileIfTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e1d175b9aeb1fae75a371a2a3e71fb4929ad325b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WhileIfTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class WhileIfTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void WhileIfTest() { + test(com.aparapi.codegen.test.WhileIf.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void WhileIfTestWorksWithCaching() { + test(com.aparapi.codegen.test.WhileIf.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/WhileTest.java b/src/test/java/com/aparapi/codegen/test/WhileTest.java new file mode 100644 index 0000000000000000000000000000000000000000..71b253191d57cc305952990bd04fd912c3a9041a --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WhileTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class WhileTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void WhileTest() { + test(com.aparapi.codegen.test.While.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void WhileTestWorksWithCaching() { + test(com.aparapi.codegen.test.While.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/WhileWithoutMutator.java b/src/test/java/com/aparapi/codegen/test/WhileWithoutMutator.java new file mode 100644 index 0000000000000000000000000000000000000000..ecabbdfd608eab012900c3159c5ac940f8b6e651 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WhileWithoutMutator.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class WhileWithoutMutator { + public void run() { + int x = 0; + while (x != 0) { + } + } +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int x = 0; + for (; x!=0;){} + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/WhileWithoutMutatorTest.java b/src/test/java/com/aparapi/codegen/test/WhileWithoutMutatorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..440435f2f2c3d6598a98da8d6be28699c470a07b --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WhileWithoutMutatorTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class WhileWithoutMutatorTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void WhileWithoutMutatorTest() { + test(com.aparapi.codegen.test.WhileWithoutMutator.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void WhileWithoutMutatorTestWorksWithCaching() { + test(com.aparapi.codegen.test.WhileWithoutMutator.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/While_If_IfElseElse.java b/src/test/java/com/aparapi/codegen/test/While_If_IfElseElse.java new file mode 100644 index 0000000000000000000000000000000000000000..2b7f1eeb0f275bb9deed541068030b97c5d80cd8 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/While_If_IfElseElse.java @@ -0,0 +1,131 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class While_If_IfElseElse { + public void run() { + + int a = 0; + int b = 0; + int c = 0; + int d = 0; + int e = 0; + int f = 0; + int g = 0; + int h = 0; + int i = 0; + int j = 0; + int k = 0; + int l = 0; + int m = 0; + int n = 0; + int o = 0; + int p = 0; + int q = 0; + int r = 0; + + while (a == a) { + b = b; + if (c == c) { + d = d; + if (e == e && f == f) { + g = g; + } + } + if (h == h && i == i) { + if (j == j) { + k = k; + + } + if (l == l) { + if (m == m) { + n = n; + } else if (o == o) { + p = p; + } else { + q = q; + } + r = r; + } + } + } + + } + +} +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int a = 0; + int b = 0; + int c = 0; + int d = 0; + int e = 0; + int f = 0; + int g = 0; + int h = 0; + int i = 0; + int j = 0; + int k = 0; + int l = 0; + int m = 0; + int n = 0; + int o = 0; + int p = 0; + int q = 0; + int r = 0; + for (; a==a; ){ + b = b; + if (c==c){ + d = d; + if (e==e && f==f){ + g = g; + } + } + + if (h==h && i==i){ + if (j==j){ + k = k; + } + if (l==l){ + if (m==m){ + n = n; + } else { + if (o==o){ + p = p; + } else { + q = q; + } + } + r = r; + } + } + } + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/While_If_IfElseElseTest.java b/src/test/java/com/aparapi/codegen/test/While_If_IfElseElseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..120cceea05b1c69d6378adf9b273507a2f8de70c --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/While_If_IfElseElseTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class While_If_IfElseElseTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void While_If_IfElseElseTest() { + test(com.aparapi.codegen.test.While_If_IfElseElse.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void While_If_IfElseElseTestWorksWithCaching() { + test(com.aparapi.codegen.test.While_If_IfElseElse.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/WideInc.java b/src/test/java/com/aparapi/codegen/test/WideInc.java new file mode 100644 index 0000000000000000000000000000000000000000..e515d03f99640e5c96e101ed2dccba6724dfa6be --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WideInc.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class WideInc { + + public void run() { + int value = 0; + value += 128; + } +} + +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int value = 0; + value+=128; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/WideIncTest.java b/src/test/java/com/aparapi/codegen/test/WideIncTest.java new file mode 100644 index 0000000000000000000000000000000000000000..1bf3accb63689bf7d9224e1bc7b3842261fdf06d --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WideIncTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class WideIncTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void WideIncTest() { + test(com.aparapi.codegen.test.WideInc.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void WideIncTestWorksWithCaching() { + test(com.aparapi.codegen.test.WideInc.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/codegen/test/WideLoad.java b/src/test/java/com/aparapi/codegen/test/WideLoad.java new file mode 100644 index 0000000000000000000000000000000000000000..2c59483d82dd2b27de1aec0bbac132248a2f8e03 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WideLoad.java @@ -0,0 +1,558 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +public class WideLoad { + + public void run() { + // we need 256 local variables to force the use of wide local variable indices + int value00 = 0; + int value01 = 0; + int value02 = 0; + int value03 = 0; + int value04 = 0; + int value05 = 0; + int value06 = 0; + int value07 = 0; + int value08 = 0; + int value09 = 0; + int value0A = 0; + int value0B = 0; + int value0C = 0; + int value0D = 0; + int value0E = 0; + int value0F = 0; + int value10 = 0; + int value11 = 0; + int value12 = 0; + int value13 = 0; + int value14 = 0; + int value15 = 0; + int value16 = 0; + int value17 = 0; + int value18 = 0; + int value19 = 0; + int value1A = 0; + int value1B = 0; + int value1C = 0; + int value1D = 0; + int value1E = 0; + int value1F = 0; + int value20 = 0; + int value21 = 0; + int value22 = 0; + int value23 = 0; + int value24 = 0; + int value25 = 0; + int value26 = 0; + int value27 = 0; + int value28 = 0; + int value29 = 0; + int value2A = 0; + int value2B = 0; + int value2C = 0; + int value2D = 0; + int value2E = 0; + int value2F = 0; + int value30 = 0; + int value31 = 0; + int value32 = 0; + int value33 = 0; + int value34 = 0; + int value35 = 0; + int value36 = 0; + int value37 = 0; + int value38 = 0; + int value39 = 0; + int value3A = 0; + int value3B = 0; + int value3C = 0; + int value3D = 0; + int value3E = 0; + int value3F = 0; + int value40 = 0; + int value41 = 0; + int value42 = 0; + int value43 = 0; + int value44 = 0; + int value45 = 0; + int value46 = 0; + int value47 = 0; + int value48 = 0; + int value49 = 0; + int value4A = 0; + int value4B = 0; + int value4C = 0; + int value4D = 0; + int value4E = 0; + int value4F = 0; + int value50 = 0; + int value51 = 0; + int value52 = 0; + int value53 = 0; + int value54 = 0; + int value55 = 0; + int value56 = 0; + int value57 = 0; + int value58 = 0; + int value59 = 0; + int value5A = 0; + int value5B = 0; + int value5C = 0; + int value5D = 0; + int value5E = 0; + int value5F = 0; + int value60 = 0; + int value61 = 0; + int value62 = 0; + int value63 = 0; + int value64 = 0; + int value65 = 0; + int value66 = 0; + int value67 = 0; + int value68 = 0; + int value69 = 0; + int value6A = 0; + int value6B = 0; + int value6C = 0; + int value6D = 0; + int value6E = 0; + int value6F = 0; + int value70 = 0; + int value71 = 0; + int value72 = 0; + int value73 = 0; + int value74 = 0; + int value75 = 0; + int value76 = 0; + int value77 = 0; + int value78 = 0; + int value79 = 0; + int value7A = 0; + int value7B = 0; + int value7C = 0; + int value7D = 0; + int value7E = 0; + int value7F = 0; + int value80 = 0; + int value81 = 0; + int value82 = 0; + int value83 = 0; + int value84 = 0; + int value85 = 0; + int value86 = 0; + int value87 = 0; + int value88 = 0; + int value89 = 0; + int value8A = 0; + int value8B = 0; + int value8C = 0; + int value8D = 0; + int value8E = 0; + int value8F = 0; + int value90 = 0; + int value91 = 0; + int value92 = 0; + int value93 = 0; + int value94 = 0; + int value95 = 0; + int value96 = 0; + int value97 = 0; + int value98 = 0; + int value99 = 0; + int value9A = 0; + int value9B = 0; + int value9C = 0; + int value9D = 0; + int value9E = 0; + int value9F = 0; + int valueA0 = 0; + int valueA1 = 0; + int valueA2 = 0; + int valueA3 = 0; + int valueA4 = 0; + int valueA5 = 0; + int valueA6 = 0; + int valueA7 = 0; + int valueA8 = 0; + int valueA9 = 0; + int valueAA = 0; + int valueAB = 0; + int valueAC = 0; + int valueAD = 0; + int valueAE = 0; + int valueAF = 0; + int valueB0 = 0; + int valueB1 = 0; + int valueB2 = 0; + int valueB3 = 0; + int valueB4 = 0; + int valueB5 = 0; + int valueB6 = 0; + int valueB7 = 0; + int valueB8 = 0; + int valueB9 = 0; + int valueBA = 0; + int valueBB = 0; + int valueBC = 0; + int valueBD = 0; + int valueBE = 0; + int valueBF = 0; + int valueC0 = 0; + int valueC1 = 0; + int valueC2 = 0; + int valueC3 = 0; + int valueC4 = 0; + int valueC5 = 0; + int valueC6 = 0; + int valueC7 = 0; + int valueC8 = 0; + int valueC9 = 0; + int valueCA = 0; + int valueCB = 0; + int valueCC = 0; + int valueCD = 0; + int valueCE = 0; + int valueCF = 0; + int valueD0 = 0; + int valueD1 = 0; + int valueD2 = 0; + int valueD3 = 0; + int valueD4 = 0; + int valueD5 = 0; + int valueD6 = 0; + int valueD7 = 0; + int valueD8 = 0; + int valueD9 = 0; + int valueDA = 0; + int valueDB = 0; + int valueDC = 0; + int valueDD = 0; + int valueDE = 0; + int valueDF = 0; + int valueE0 = 0; + int valueE1 = 0; + int valueE2 = 0; + int valueE3 = 0; + int valueE4 = 0; + int valueE5 = 0; + int valueE6 = 0; + int valueE7 = 0; + int valueE8 = 0; + int valueE9 = 0; + int valueEA = 0; + int valueEB = 0; + int valueEC = 0; + int valueED = 0; + int valueEE = 0; + int valueEF = 0; + int valueF0 = 0; + int valueF1 = 0; + int valueF2 = 0; + int valueF3 = 0; + int valueF4 = 0; + int valueF5 = 0; + int valueF6 = 0; + int valueF7 = 0; + int valueF8 = 0; + int valueF9 = 0; + int valueFA = 0; + int valueFB = 0; + int valueFC = 0; + int valueFD = 0; + int valueFE = 0; + int valueFF = 0; + int valueWide = 0; // wide + valueWide++; // wide + } +} + +/**{OpenCL{ + typedef struct This_s{ + int passid; + }This; + int get_pass_id(This *this){ + return this->passid; + } + __kernel void run( + int passid + ){ + This thisStruct; + This* this=&thisStruct; + this->passid = passid; + { + int value00 = 0; + int value01 = 0; + int value02 = 0; + int value03 = 0; + int value04 = 0; + int value05 = 0; + int value06 = 0; + int value07 = 0; + int value08 = 0; + int value09 = 0; + int value0A = 0; + int value0B = 0; + int value0C = 0; + int value0D = 0; + int value0E = 0; + int value0F = 0; + int value10 = 0; + int value11 = 0; + int value12 = 0; + int value13 = 0; + int value14 = 0; + int value15 = 0; + int value16 = 0; + int value17 = 0; + int value18 = 0; + int value19 = 0; + int value1A = 0; + int value1B = 0; + int value1C = 0; + int value1D = 0; + int value1E = 0; + int value1F = 0; + int value20 = 0; + int value21 = 0; + int value22 = 0; + int value23 = 0; + int value24 = 0; + int value25 = 0; + int value26 = 0; + int value27 = 0; + int value28 = 0; + int value29 = 0; + int value2A = 0; + int value2B = 0; + int value2C = 0; + int value2D = 0; + int value2E = 0; + int value2F = 0; + int value30 = 0; + int value31 = 0; + int value32 = 0; + int value33 = 0; + int value34 = 0; + int value35 = 0; + int value36 = 0; + int value37 = 0; + int value38 = 0; + int value39 = 0; + int value3A = 0; + int value3B = 0; + int value3C = 0; + int value3D = 0; + int value3E = 0; + int value3F = 0; + int value40 = 0; + int value41 = 0; + int value42 = 0; + int value43 = 0; + int value44 = 0; + int value45 = 0; + int value46 = 0; + int value47 = 0; + int value48 = 0; + int value49 = 0; + int value4A = 0; + int value4B = 0; + int value4C = 0; + int value4D = 0; + int value4E = 0; + int value4F = 0; + int value50 = 0; + int value51 = 0; + int value52 = 0; + int value53 = 0; + int value54 = 0; + int value55 = 0; + int value56 = 0; + int value57 = 0; + int value58 = 0; + int value59 = 0; + int value5A = 0; + int value5B = 0; + int value5C = 0; + int value5D = 0; + int value5E = 0; + int value5F = 0; + int value60 = 0; + int value61 = 0; + int value62 = 0; + int value63 = 0; + int value64 = 0; + int value65 = 0; + int value66 = 0; + int value67 = 0; + int value68 = 0; + int value69 = 0; + int value6A = 0; + int value6B = 0; + int value6C = 0; + int value6D = 0; + int value6E = 0; + int value6F = 0; + int value70 = 0; + int value71 = 0; + int value72 = 0; + int value73 = 0; + int value74 = 0; + int value75 = 0; + int value76 = 0; + int value77 = 0; + int value78 = 0; + int value79 = 0; + int value7A = 0; + int value7B = 0; + int value7C = 0; + int value7D = 0; + int value7E = 0; + int value7F = 0; + int value80 = 0; + int value81 = 0; + int value82 = 0; + int value83 = 0; + int value84 = 0; + int value85 = 0; + int value86 = 0; + int value87 = 0; + int value88 = 0; + int value89 = 0; + int value8A = 0; + int value8B = 0; + int value8C = 0; + int value8D = 0; + int value8E = 0; + int value8F = 0; + int value90 = 0; + int value91 = 0; + int value92 = 0; + int value93 = 0; + int value94 = 0; + int value95 = 0; + int value96 = 0; + int value97 = 0; + int value98 = 0; + int value99 = 0; + int value9A = 0; + int value9B = 0; + int value9C = 0; + int value9D = 0; + int value9E = 0; + int value9F = 0; + int valueA0 = 0; + int valueA1 = 0; + int valueA2 = 0; + int valueA3 = 0; + int valueA4 = 0; + int valueA5 = 0; + int valueA6 = 0; + int valueA7 = 0; + int valueA8 = 0; + int valueA9 = 0; + int valueAA = 0; + int valueAB = 0; + int valueAC = 0; + int valueAD = 0; + int valueAE = 0; + int valueAF = 0; + int valueB0 = 0; + int valueB1 = 0; + int valueB2 = 0; + int valueB3 = 0; + int valueB4 = 0; + int valueB5 = 0; + int valueB6 = 0; + int valueB7 = 0; + int valueB8 = 0; + int valueB9 = 0; + int valueBA = 0; + int valueBB = 0; + int valueBC = 0; + int valueBD = 0; + int valueBE = 0; + int valueBF = 0; + int valueC0 = 0; + int valueC1 = 0; + int valueC2 = 0; + int valueC3 = 0; + int valueC4 = 0; + int valueC5 = 0; + int valueC6 = 0; + int valueC7 = 0; + int valueC8 = 0; + int valueC9 = 0; + int valueCA = 0; + int valueCB = 0; + int valueCC = 0; + int valueCD = 0; + int valueCE = 0; + int valueCF = 0; + int valueD0 = 0; + int valueD1 = 0; + int valueD2 = 0; + int valueD3 = 0; + int valueD4 = 0; + int valueD5 = 0; + int valueD6 = 0; + int valueD7 = 0; + int valueD8 = 0; + int valueD9 = 0; + int valueDA = 0; + int valueDB = 0; + int valueDC = 0; + int valueDD = 0; + int valueDE = 0; + int valueDF = 0; + int valueE0 = 0; + int valueE1 = 0; + int valueE2 = 0; + int valueE3 = 0; + int valueE4 = 0; + int valueE5 = 0; + int valueE6 = 0; + int valueE7 = 0; + int valueE8 = 0; + int valueE9 = 0; + int valueEA = 0; + int valueEB = 0; + int valueEC = 0; + int valueED = 0; + int valueEE = 0; + int valueEF = 0; + int valueF0 = 0; + int valueF1 = 0; + int valueF2 = 0; + int valueF3 = 0; + int valueF4 = 0; + int valueF5 = 0; + int valueF6 = 0; + int valueF7 = 0; + int valueF8 = 0; + int valueF9 = 0; + int valueFA = 0; + int valueFB = 0; + int valueFC = 0; + int valueFD = 0; + int valueFE = 0; + int valueFF = 0; + int valueWide = 0; + valueWide++; + return; + } + } + }OpenCL}**/ diff --git a/src/test/java/com/aparapi/codegen/test/WideLoadTest.java b/src/test/java/com/aparapi/codegen/test/WideLoadTest.java new file mode 100644 index 0000000000000000000000000000000000000000..40f801b981d05d0499555a86cfa628223c06d735 --- /dev/null +++ b/src/test/java/com/aparapi/codegen/test/WideLoadTest.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.codegen.test; + +import org.junit.Test; + +public class WideLoadTest extends com.aparapi.codegen.CodeGenJUnitBase { + private static final String[] expectedOpenCL = null; + private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null; + + @org.junit.Ignore + @Test + public void WideLoadTest() { + test(com.aparapi.codegen.test.WideLoad.class, expectedException, expectedOpenCL); + } + + @org.junit.Ignore + @Test + public void WideLoadTestWorksWithCaching() { + test(com.aparapi.codegen.test.WideLoad.class, expectedException, expectedOpenCL); + } +} diff --git a/src/test/java/com/aparapi/runtime/LoadClTest.java b/src/test/java/com/aparapi/runtime/LoadClTest.java index 60adc75579ba8b4395171da4dc6992cb7d3e83ee..5df9c66826d916822fe33e3d1c197552010f01ff 100644 --- a/src/test/java/com/aparapi/runtime/LoadClTest.java +++ b/src/test/java/com/aparapi/runtime/LoadClTest.java @@ -62,7 +62,7 @@ public class LoadClTest { } } - @Resource("com/aparapi/test/runtime/squarer.cl") + @Resource("com/aparapi/codegen/test/runtime/squarer.cl") interface Squarer extends OpenCL<Squarer> { public Squarer square(// Range _range,//