diff --git a/build.xml b/build.xml index 77d91cf9..6f041439 100644 --- a/build.xml +++ b/build.xml @@ -29,11 +29,6 @@ - - - - - @@ -44,19 +39,11 @@ - - - - - - - - - - + + @@ -82,13 +69,7 @@ - - - - - - diff --git a/capture-stream.diff b/capture-stream.diff new file mode 100644 index 00000000..f713e26b --- /dev/null +++ b/capture-stream.diff @@ -0,0 +1,54 @@ +diff -r 8d6fc90e7bbf src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java +--- a/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java Mon Dec 03 16:57:46 2012 +0100 ++++ b/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java Wed Dec 19 11:04:00 2012 -0500 +@@ -29,6 +29,7 @@ + import java.lang.reflect.Method; + import java.security.ProtectionDomain; + import java.util.concurrent.atomic.AtomicInteger; ++import java.util.concurrent.ConcurrentHashMap; + import jdk.internal.org.objectweb.asm.*; + import static jdk.internal.org.objectweb.asm.Opcodes.*; + import sun.misc.Unsafe; +@@ -38,7 +39,7 @@ + /** + * InnerClassLambdaMetafactory + */ +-/*non-public*/ final class InnerClassLambdaMetafactory extends AbstractValidatingLambdaMetafactory { ++public final class InnerClassLambdaMetafactory extends AbstractValidatingLambdaMetafactory { + private static final int CLASSFILE_VERSION = 51; + private static final Type TYPE_VOID = Type.getType(void.class); + private static final String METHOD_DESCRIPTOR_VOID = Type.getMethodDescriptor(Type.VOID_TYPE); +@@ -156,6 +157,17 @@ + } + } + ++ ++ ++ private static final ConcurrentHashMap classByteArrayTable = new ConcurrentHashMap(); ++ ++ public static byte[] getBytesForClassName(String className) { ++ return classByteArrayTable.get(className); ++ } ++ public static void setBytesForClassName( String className, byte[] classBytes) { ++ classByteArrayTable.put(className,classBytes); ++ } ++ + /** + * Generate a class file which implements the functional + * interface, define and return the class. +@@ -227,7 +239,15 @@ + } + } + ); ++ + ++ // ecaspole 121211 ++ System.out.println("spinInnerClass: lambdaClassName = " + lambdaClassName + ++ ", classBytes = " + classBytes + ++ ", loader = " + loader ); ++ ++ setBytesForClassName(lambdaClassName, classBytes); ++ + return (Class) Unsafe.getUnsafe().defineClass(lambdaClassName, classBytes, 0, classBytes.length, loader, pd); + } + diff --git a/com.amd.aparapi.jni/src/cpp/aparapi.cpp b/com.amd.aparapi.jni/src/cpp/aparapi.cpp index c56cb589..afcf6f2d 100644 --- a/com.amd.aparapi.jni/src/cpp/aparapi.cpp +++ b/com.amd.aparapi.jni/src/cpp/aparapi.cpp @@ -139,11 +139,13 @@ class KernelArg{ static jfieldID typeFieldID; static jfieldID sizeInBytesFieldID; static jfieldID numElementsFieldID; + static jfieldID fieldHolderFieldID; public: static jfieldID javaArrayFieldID; public: JNIContext *jniContext; jobject argObj; // the Java KernelRunner.KernelArg object that we are mirroring. + jobject fieldHolder; // The java Object to pull this field from (for lambda it could be block, KernelRunner or lambda's this) jobject javaArg; // global reference to the corresponding java KernelArg object we grabbed our own global reference so that the object won't be collected until we dispose! char *name; // used for debugging printfs jint type; // a bit mask determining the type of this arg @@ -273,6 +275,7 @@ jfieldID KernelArg::typeFieldID=0; jfieldID KernelArg::javaArrayFieldID=0; jfieldID KernelArg::sizeInBytesFieldID=0; jfieldID KernelArg::numElementsFieldID=0; +jfieldID KernelArg::fieldHolderFieldID=0; class JNIContext{ private: @@ -454,6 +457,7 @@ KernelArg::KernelArg(JNIEnv *jenv, JNIContext *jniContext, jobject argObj): if (argClazz == 0){ jclass c = jenv->GetObjectClass(argObj); nameFieldID = jenv->GetFieldID(c, "name", "Ljava/lang/String;"); ASSERT_FIELD(name); + fieldHolderFieldID = jenv->GetFieldID(c, "fieldHolder", "Ljava/lang/Object;"); ASSERT_FIELD(name); typeFieldID = jenv->GetFieldID(c, "type", "I"); ASSERT_FIELD(type); javaArrayFieldID = jenv->GetFieldID(c, "javaArray", "Ljava/lang/Object;"); ASSERT_FIELD(javaArray); sizeInBytesFieldID = jenv->GetFieldID(c, "sizeInBytes", "I"); ASSERT_FIELD(sizeInBytes); @@ -461,6 +465,9 @@ KernelArg::KernelArg(JNIEnv *jenv, JNIContext *jniContext, jobject argObj): argClazz = c; } type = jenv->GetIntField(argObj, typeFieldID); + + // Need to delete this + fieldHolder = jenv->NewGlobalRef( jenv->GetObjectField(argObj, fieldHolderFieldID) ); jstring nameString = (jstring)jenv->GetObjectField(argObj, nameFieldID); const char *nameChars = jenv->GetStringUTFChars(nameString, NULL); #ifdef _WIN32 @@ -482,18 +489,22 @@ cl_int KernelArg::setLocalBufferArg(JNIEnv *jenv, int argIdx, int argPos){ } cl_int KernelArg::setPrimitiveArg(JNIEnv *jenv, int argIdx, int argPos){ cl_int status = CL_SUCCESS; + + // Get the class of the object holding this field + jclass fieldHolderClass = jenv->GetObjectClass(fieldHolder); + if (isFloat()){ if (isStatic()){ - jfieldID fieldID = jenv->GetStaticFieldID(jniContext->kernelClass, name, "F"); - jfloat f = jenv->GetStaticFloatField(jniContext->kernelClass, fieldID); + jfieldID fieldID = jenv->GetStaticFieldID(fieldHolderClass, name, "F"); + jfloat f = jenv->GetStaticFloatField(fieldHolderClass, fieldID); if (config->isVerbose()){ fprintf(stderr, "clSetKernelArg static primitive float '%s' index=%d pos=%d value=%f\n", name, argIdx, argPos, f); } status = clSetKernelArg(jniContext->kernel, argPos, sizeof(jfloat), &f); }else{ - jfieldID fieldID = jenv->GetFieldID(jniContext->kernelClass, name, "F"); - jfloat f = jenv->GetFloatField(jniContext->kernelObject, fieldID); + jfieldID fieldID = jenv->GetFieldID(fieldHolderClass, name, "F"); + jfloat f = jenv->GetFloatField(fieldHolder, fieldID); if (config->isVerbose()){ fprintf(stderr, "clSetKernelArg primitive float '%s' index=%d pos=%d value=%f\n", name, argIdx, argPos, f); @@ -502,16 +513,16 @@ cl_int KernelArg::setPrimitiveArg(JNIEnv *jenv, int argIdx, int argPos){ } }else if (isInt()){ if (isStatic()){ - jfieldID fieldID = jenv->GetStaticFieldID(jniContext->kernelClass, name, "I"); - jint i = jenv->GetStaticIntField(jniContext->kernelClass, fieldID); + jfieldID fieldID = jenv->GetStaticFieldID(fieldHolderClass, name, "I"); + jint i = jenv->GetStaticIntField(fieldHolderClass, fieldID); if (config->isVerbose()){ fprintf(stderr, "clSetKernelArg static primitive int '%s' index=%d pos=%d value=%d\n", name, argIdx, argPos, i); } status = clSetKernelArg(jniContext->kernel, argPos, sizeof(jint), &i); }else{ - jfieldID fieldID = jenv->GetFieldID(jniContext->kernelClass, name, "I"); - jint i = jenv->GetIntField(jniContext->kernelObject, fieldID); + jfieldID fieldID = jenv->GetFieldID(fieldHolderClass, name, "I"); + jint i = jenv->GetIntField(fieldHolder, fieldID); if (config->isVerbose()){ fprintf(stderr, "clSetKernelArg primitive int '%s' index=%d pos=%d value=%d\n", name, argIdx, argPos, i); @@ -520,16 +531,16 @@ cl_int KernelArg::setPrimitiveArg(JNIEnv *jenv, int argIdx, int argPos){ } }else if (isBoolean()){ if (isStatic()){ - jfieldID fieldID = jenv->GetStaticFieldID(jniContext->kernelClass, name, "Z"); - jboolean z = jenv->GetStaticBooleanField(jniContext->kernelClass, fieldID); + jfieldID fieldID = jenv->GetStaticFieldID(fieldHolderClass, name, "Z"); + jboolean z = jenv->GetStaticBooleanField(fieldHolderClass, fieldID); if (config->isVerbose()){ fprintf(stderr, "clSetKernelArg static primitive boolean '%s' index=%d pos=%d value=%d\n", name, argIdx, argPos, z); } status = clSetKernelArg(jniContext->kernel, argPos, sizeof(jboolean), &z); }else{ - jfieldID fieldID = jenv->GetFieldID(jniContext->kernelClass, name, "Z"); - jboolean z = jenv->GetBooleanField(jniContext->kernelObject, fieldID); + jfieldID fieldID = jenv->GetFieldID(fieldHolderClass, name, "Z"); + jboolean z = jenv->GetBooleanField(fieldHolder, fieldID); if (config->isVerbose()){ fprintf(stderr, "clSetKernelArg primitive boolean '%s' index=%d pos=%d value=%d\n", name, argIdx, argPos, z); @@ -538,16 +549,16 @@ cl_int KernelArg::setPrimitiveArg(JNIEnv *jenv, int argIdx, int argPos){ } }else if (isByte()){ if (isStatic()){ - jfieldID fieldID = jenv->GetStaticFieldID(jniContext->kernelClass, name, "B"); - jbyte b = jenv->GetStaticByteField(jniContext->kernelClass, fieldID); + jfieldID fieldID = jenv->GetStaticFieldID(fieldHolderClass, name, "B"); + jbyte b = jenv->GetStaticByteField(fieldHolderClass, fieldID); if (config->isVerbose()){ fprintf(stderr, "clSetKernelArg static primitive byte '%s' index=%d pos=%d value=%d\n", name, argIdx, argPos, b); } status = clSetKernelArg(jniContext->kernel, argPos, sizeof(jbyte), &b); }else{ - jfieldID fieldID = jenv->GetFieldID(jniContext->kernelClass, name, "B"); - jbyte b = jenv->GetByteField(jniContext->kernelObject, fieldID); + jfieldID fieldID = jenv->GetFieldID(fieldHolderClass, name, "B"); + jbyte b = jenv->GetByteField(fieldHolder, fieldID); if (config->isVerbose()){ fprintf(stderr, "clSetKernelArg primitive byte '%s' index=%d pos=%d value=%d\n", name, argIdx, argPos, b); @@ -556,16 +567,16 @@ cl_int KernelArg::setPrimitiveArg(JNIEnv *jenv, int argIdx, int argPos){ } }else if (isLong()){ if (isStatic()){ - jfieldID fieldID = jenv->GetStaticFieldID(jniContext->kernelClass, name, "J"); - jlong j = jenv->GetStaticLongField(jniContext->kernelClass, fieldID); + jfieldID fieldID = jenv->GetStaticFieldID(fieldHolderClass, name, "J"); + jlong j = jenv->GetStaticLongField(fieldHolderClass, fieldID); if (config->isVerbose()){ fprintf(stderr, "clSetKernelArg static primitive long '%s' index=%d pos=%d value=%ld\n", name, argIdx, argPos, j); } status = clSetKernelArg(jniContext->kernel, argPos, sizeof(jlong), &j); }else{ - jfieldID fieldID = jenv->GetFieldID(jniContext->kernelClass, name, "J"); - jlong j = jenv->GetLongField(jniContext->kernelObject, fieldID); + jfieldID fieldID = jenv->GetFieldID(fieldHolderClass, name, "J"); + jlong j = jenv->GetLongField(fieldHolder, fieldID); if (config->isVerbose()){ fprintf(stderr, "clSetKernelArg primitive long '%s' index=%d pos=%d value=%ld\n", name, argIdx, argPos, j); @@ -574,16 +585,16 @@ cl_int KernelArg::setPrimitiveArg(JNIEnv *jenv, int argIdx, int argPos){ } }else if (isDouble()){ if (isStatic()){ - jfieldID fieldID = jenv->GetStaticFieldID(jniContext->kernelClass, name, "D"); - jdouble d = jenv->GetStaticDoubleField(jniContext->kernelClass, fieldID); + jfieldID fieldID = jenv->GetStaticFieldID(fieldHolderClass, name, "D"); + jdouble d = jenv->GetStaticDoubleField(fieldHolderClass, fieldID); if (config->isVerbose()){ fprintf(stderr, "clSetKernelArg static primitive long '%s' index=%d pos=%d value=%lf\n", name, argIdx, argPos, d); } status = clSetKernelArg(jniContext->kernel, argPos, sizeof(jdouble), &d); }else{ - jfieldID fieldID = jenv->GetFieldID(jniContext->kernelClass, name, "D"); - jdouble d = jenv->GetDoubleField(jniContext->kernelObject, fieldID); + jfieldID fieldID = jenv->GetFieldID(fieldHolderClass, name, "D"); + jdouble d = jenv->GetDoubleField(fieldHolder, fieldID); if (config->isVerbose()){ fprintf(stderr, "clSetKernelArg primitive long '%s' index=%d pos=%d value=%lf\n", name, argIdx, argPos, d); @@ -791,6 +802,21 @@ jint updateNonPrimitiveReferences(JNIEnv *jenv, jobject jobj, JNIContext* jniCon +JNI_JAVA(jint, KernelRunner, updateLambdaBlockJNI) + (JNIEnv *jenv, jobject jobj, jlong jniContextHandle, jobject newHolder, jint argc) { + + JNIContext* jniContext = JNIContext::getJNIContext(jniContextHandle); + + for(int argIdx=0; argIdxDeleteGlobalRef(jniContext->args[argIdx]->fieldHolder); + // in with the new! + jniContext->args[argIdx]->fieldHolder = jenv->NewGlobalRef(newHolder); + } + + return 0; +} + JNI_JAVA(jint, KernelRunner, runKernelJNI) (JNIEnv *jenv, jobject jobj, jlong jniContextHandle, jobject _range, jboolean needSync, jint passes) { if (config== NULL){ diff --git a/com.amd.aparapi.jni/src/cpp/jniHelper.cpp b/com.amd.aparapi.jni/src/cpp/jniHelper.cpp index 3997bd5b..8437e3c4 100644 --- a/com.amd.aparapi.jni/src/cpp/jniHelper.cpp +++ b/com.amd.aparapi.jni/src/cpp/jniHelper.cpp @@ -234,7 +234,7 @@ jobject JNIHelper::getStaticFieldObject(JNIEnv *jenv, char *className, char *fie return(NULL); } - jobject value = jenv->GetStaticObjectField(NULL, fieldId); + jobject value = jenv->GetStaticObjectField(theClass, fieldId); if (value == NULL || jenv->ExceptionCheck()) { jenv->ExceptionDescribe(); jenv->ExceptionClear(); diff --git a/com.amd.aparapi/build.xml b/com.amd.aparapi/build.xml index d3017f52..85384ab1 100644 --- a/com.amd.aparapi/build.xml +++ b/com.amd.aparapi/build.xml @@ -18,9 +18,8 @@ OS Version: ${os.version} OS Arch: ${os.arch} - - - + + @@ -76,6 +75,11 @@ + + + + + diff --git a/com.amd.aparapi/src/java/com/amd/aparapi/Annotations.java b/com.amd.aparapi/src/java/com/amd/aparapi/Annotations.java deleted file mode 100644 index 39368a17..00000000 --- a/com.amd.aparapi/src/java/com/amd/aparapi/Annotations.java +++ /dev/null @@ -1,86 +0,0 @@ -/* -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.amd.aparapi; - -/** - * A collection of annotations used at dev time to tag intent. - * - * We should be able to remove all of these before OpenSource release. - * - * @author gfrost - */ -class Annotations{ - - /** - * Use this annotation to tag stuff that needs Java Doc added. - * - * @author gfrost - */ - @interface DocMe { - } - - /** - * Use this annotation to tag fields that we think need to be removed (method/field/var). - * - * @author gfrost - */ - @interface RemoveMe { - } - - /** - * Used to tag experimental features (methods/fields). - * - * Do not rely on anything tagged as experimental, it will probably be retracted/refactored. - * - * @author gfrost - * - */ - @interface Experimental { - } - - /** - * Used to tag unused features (methods/fields). - * - * Do not rely on anything tagged as unused, it will probably be retracted/refactored. - * - * @author gfrost - * - */ - @interface Unused { - } -} diff --git a/com.amd.aparapi/src/java/com/amd/aparapi/Aparapi.java b/com.amd.aparapi/src/java/com/amd/aparapi/Aparapi.java new file mode 100644 index 00000000..ad564815 --- /dev/null +++ b/com.amd.aparapi/src/java/com/amd/aparapi/Aparapi.java @@ -0,0 +1,182 @@ +package com.amd.aparapi; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +//import java.lang.invoke.InnerClassLambdaMetafactory; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.BrokenBarrierException; +import java.util.function.IntBlock; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.HashMap; +import java.util.List; + +import com.amd.aparapi.ClassModel.ConstantPool.MethodEntry; +import com.amd.aparapi.InstructionSet.AccessField; +import com.amd.aparapi.InstructionSet.MethodCall; +import com.amd.aparapi.InstructionSet.VirtualMethodCall; + +public class Aparapi{ + + private static Logger logger = Logger.getLogger(Config.getLoggerName()); + + public interface KernelI { + void run(int x); + } + public interface KernelII { + void run(int x, int y); + } + public interface KernelIII { + void run(int x, int y, int id); + } + + public interface KernelSAM { + void run(); + } + + static void wait(CyclicBarrier barrier){ + try { + barrier.await(); + } catch (InterruptedException ex) { + } catch (BrokenBarrierException ex) { + } + } + +/* + static public void forEach(int width, int height, KernelII kernel){ + final int threads = Runtime.getRuntime().availableProcessors(); + final CyclicBarrier barrier = new CyclicBarrier(threads+1); + for (int t=0; t{ + for (int x=finalt*(width/threads); x<(finalt+1)*(width/threads); x++){ + for (int y=0; y{ + for (int x=finalt*(width/threads); x<(finalt+1)*(width/threads); x++){ + kernel.run(x); + } + wait(barrier); + }).start(); + } + wait(barrier); + } +*/ + + + static public void forEachJava(int jobSize, IntBlock block) { + + // Single threaded solution + //for (int i=0; i{ + for (int x=finalt*(width/threads); x<(finalt+1)*(width/threads); x++){ + block.accept(x); + } + wait(barrier); + }).start(); + } + wait(barrier); + + } + + + static final ConcurrentHashMap kernels = new ConcurrentHashMap(); + static final ConcurrentHashMap haveGoodKernel = new ConcurrentHashMap(); + + + static public void forEach(int jobSize, IntBlock block) { + + // Note it is a new Block object each time + + KernelRunner kernelRunner = kernels.get(block.getClass()); + Boolean haveKernel = haveGoodKernel.get(block.getClass()); + + try { + + if ((kernelRunner == null) && (haveKernel == null)) { + kernelRunner = new KernelRunner(block); + } + + if ((kernelRunner != null) && (kernelRunner.getRunnable() == true)) { + boolean success = kernelRunner.execute(block, Range.create(jobSize), 1); + if (success == true) { + kernels.put(block.getClass(), kernelRunner); + haveGoodKernel.put(block.getClass(), true); + } + kernelRunner.setRunnable(success); + + } else { + forEachJava(jobSize, block); + } + + return; + + } catch (AparapiException e) { + System.err.println(e); + e.printStackTrace(); + + if (logger.isLoggable(Level.FINE)) { + logger.fine("Kernel failed, try to revert to java."); + } + + haveGoodKernel.put(block.getClass(), false); + + if (kernelRunner != null) { + kernelRunner.setRunnable(false); + } + } + + if (logger.isLoggable(Level.FINE)) { + logger.fine("Running java."); + } + + forEachJava(jobSize, block); + } +/* + static public void forEach(int[][] intArray, KernelIII kernel){ + final int width = intArray.length; + final int threads = Runtime.getRuntime().availableProcessors(); + final CyclicBarrier barrier = new CyclicBarrier(threads+1); + for (int t=0; t{ + for (int x=finalt*(width/threads); x<(finalt+1)*(width/threads); x++){ + int[] arr = intArray[x]; + int arrLen = arr.length; + for (int y=0; y map = new HashMap(); + + static class Transformer implements ClassFileTransformer{ + @Override public byte[] transform(ClassLoader loader, String name, Class clazz, ProtectionDomain domain, byte[] bytes){ + if (name != null && name.contains("$$")){ + map.put(name.replace('/','.'), bytes); + System.out.println("+"+name+" length="+bytes.length); + } + return(bytes); + } + } + static void premain(String agentArgs, Instrumentation inst){ + System.out.println("inside premain!"); + inst.addTransformer(new Transformer()); + } + + static public byte[] getBytes(Class clazz){ + byte[] bytes = map.get(clazz.getName()); + if (bytes == null){ + System.out.println("can't get bytes for ="+clazz); + }else{ + System.out.println("getting bytes for ="+clazz+" size="+bytes.length); + } + return(bytes); + } + +} diff --git a/com.amd.aparapi/src/java/com/amd/aparapi/BlockWriter.java b/com.amd.aparapi/src/java/com/amd/aparapi/BlockWriter.java index e2336381..05913f53 100644 --- a/com.amd.aparapi/src/java/com/amd/aparapi/BlockWriter.java +++ b/com.amd.aparapi/src/java/com/amd/aparapi/BlockWriter.java @@ -120,6 +120,8 @@ protected void newLine() { write(" "); } } + + String getLambdaIterationIntArgName() { return null; } protected void writeConditionalBranch16(ConditionalBranch16 _branch16, boolean _invert) throws CodeGenException { @@ -372,7 +374,22 @@ protected String convertCast(String _cast) { return ("(" + raw + ")"); } - void writeInstruction(Instruction _instruction) throws CodeGenException { + + String filterLambdaIterationVariable(Instruction _instruction) { + assert _instruction instanceof AccessLocalVariable : "Must be AccessLocalVariable"; + AccessLocalVariable localVariableLoadInstruction = (AccessLocalVariable) _instruction; + LocalVariableInfo localVariable = localVariableLoadInstruction.getLocalVariableInfo(); + String local = localVariable.getVariableName(); + if (local.equals(this.getLambdaIterationIntArgName())) { + //System.out.println("## Inserting get_global_id for lambdaIterationIntArgName = " + this.getLambdaIterationIntArgName()); + // this is the lambda iteration variable, so substitute get_global_id + return "get_global_id(0)"; + } + return local; + } + + + void writeInstruction(Instruction _instruction) throws CodeGenException { if (_instruction instanceof CompositeIfElseInstruction) { write("("); Instruction lhs = writeConditional(((CompositeInstruction) _instruction).getBranchSet()); @@ -495,9 +512,9 @@ void writeInstruction(Instruction _instruction) throws CodeGenException { } } else if (_instruction instanceof AccessLocalVariable) { - AccessLocalVariable localVariableLoadInstruction = (AccessLocalVariable) _instruction; - LocalVariableInfo localVariable = localVariableLoadInstruction.getLocalVariableInfo(); - write(localVariable.getVariableName()); + + write(filterLambdaIterationVariable(_instruction)); + } else if (_instruction instanceof I_IINC) { I_IINC location = (I_IINC) _instruction; LocalVariableInfo localVariable = location.getLocalVariableInfo(); diff --git a/com.amd.aparapi/src/java/com/amd/aparapi/ClassModel.java b/com.amd.aparapi/src/java/com/amd/aparapi/ClassModel.java index e75266b6..3db0e5d0 100644 --- a/com.amd.aparapi/src/java/com/amd/aparapi/ClassModel.java +++ b/com.amd.aparapi/src/java/com/amd/aparapi/ClassModel.java @@ -140,7 +140,7 @@ interface LocalVariableTableEntry extends Iterable< // Find better way to do this check // The java.lang.Object test is for unit test framework to succeed - should // not occur in normal use - if ((mySuper != null) && (!mySuper.getName().equals(Kernel.class.getName())) + if ((mySuper != null) /* && (!mySuper.getName().equals(Kernel.class.getName())) */ && (!mySuper.getName().equals("java.lang.Object"))) { superClazz = new ClassModel(mySuper); } @@ -194,7 +194,7 @@ ClassModel getSuperClazz() { return superClazz; } - @Annotations.DocMe void replaceSuperClazz(ClassModel c) { + void replaceSuperClazz(ClassModel c) { if (this.superClazz != null) { assert c.isSuperClass(this.getClassWeAreModelling()) == true : "not my super"; if (this.superClazz.getClassWeAreModelling().getName().equals(c.getClassWeAreModelling().getName())) { @@ -2405,8 +2405,19 @@ ClassModel getClassModel() { } public String toString() { - return getClassModel().getClassWeAreModelling().getName() + "." + - getName() + " " + getDescriptor(); + ClassModel cm = getClassModel(); + assert cm != null : "ClassModel should not be null"; + + // ecaspole 121211 - I think this is an actual bug where clazz is not set when creating + // ClassModel from the stream + //Class theClass = cm.getClassWeAreModelling(); + //assert theClass != null : "ClassModel should not be null"; + + //System.out.println(" Hi Eric: " + ClassModel.this.getClassEntry().getNameUTF8Entry().getUTF8()); + + //return getClassModel().getClassWeAreModelling().getName() + "." + + // getName() + " " + getDescriptor(); + return getName() + " " + getDescriptor(); } } @@ -2453,6 +2464,10 @@ void parse(Class _class) throws ClassParseException { * @throws ClassParseException */ private void parse(ClassLoader _classLoader, String _className) throws ClassParseException { + String asDotClass = _className.replace('.', '/') + ".class"; + InputStream is = _classLoader.getResourceAsStream(asDotClass); + System.out.println("stream is: " + is); + parse(_classLoader.getResourceAsStream(_className.replace('.', '/') + ".class")); } @@ -2545,6 +2560,9 @@ ClassModelField getField(String _name) { } ClassModelMethod getMethod(String _name, String _descriptor) { + + //System.out.println("methods = " + methods); + for (ClassModelMethod entry : methods) { if (entry.getName().equals(_name) && entry.getDescriptor().equals(_descriptor)) { return (entry); @@ -2602,6 +2620,10 @@ ClassModelMethod getMethod(MethodEntry _methodEntry, boolean _isSpecial) { MethodModel getMethodModel(String _name, String _signature) throws AparapiException { ClassModelMethod method = getMethod(_name, _signature); + + + + assert method != null : "ClassModelMethod should not be null"; return new MethodModel(method); } diff --git a/com.amd.aparapi/src/java/com/amd/aparapi/ClassParseException.java b/com.amd.aparapi/src/java/com/amd/aparapi/ClassParseException.java index c375baff..b4a07c75 100644 --- a/com.amd.aparapi/src/java/com/amd/aparapi/ClassParseException.java +++ b/com.amd.aparapi/src/java/com/amd/aparapi/ClassParseException.java @@ -80,7 +80,8 @@ public static enum TYPE { ACCESSEDOBJECTSETTERARRAY("Passing array arguments to Intrinsics in expression form is not supported"), // MULTIDIMENSIONARRAYASSIGN("Can't assign to two dimension array"), // MULTIDIMENSIONARRAYACCESS("Can't access through a two dimensional array"), // - MISSINGLOCALVARIABLETABLE("Method does not contain a local variable table (recompile with -g?)"); + MISSINGLOCALVARIABLETABLE("Method does not contain a local variable table (recompile with -g?)"), + UNHANDLEDMAPPEDMETHOD("Unhandled JDK mapped method "); private String description; diff --git a/com.amd.aparapi/src/java/com/amd/aparapi/Entrypoint.java b/com.amd.aparapi/src/java/com/amd/aparapi/Entrypoint.java index 34868697..e7ec473e 100644 --- a/com.amd.aparapi/src/java/com/amd/aparapi/Entrypoint.java +++ b/com.amd.aparapi/src/java/com/amd/aparapi/Entrypoint.java @@ -152,6 +152,17 @@ Object getKernelInstance() { void setKernelInstance(Object _k) { kernelInstance = _k; } + + int lambdaActualParamsCount = 0; + + // This could be done by parsing the signature + void setLambdaActualParamsCount(int count) { + lambdaActualParamsCount = count; + } + + int getLambdaActualParamsCount() { + return lambdaActualParamsCount; + } Map getObjectArrayFieldsClasses() { return objectArrayFieldsClasses; @@ -199,8 +210,11 @@ static Field getFieldFromClassHierarchy(Class _clazz, String _name) throws Ap logger.fine("looking for " + _name + " in " + mySuper.getName()); } - // Find better way to do this check - while (!mySuper.getName().equals(Kernel.class.getName())) { + assert _clazz != null && mySuper != null : "Classes should not be null"; + + // For the jambi demo, we are not operating on Kernel subclass, keep looking + while ((!mySuper.getName().equals(Object.class.getName())) /* && + (!mySuper.getName().equals(Kernel.class.getName())) */ ) { try { field = mySuper.getDeclaredField(_name); int modifiers = field.getModifiers(); @@ -214,8 +228,6 @@ static Field getFieldFromClassHierarchy(Class _clazz, String _name) throws Ap } throw new ClassParseException(ClassParseException.TYPE.OBJECTFIELDREFERENCE); } else { - // This should be looger fine... - //System.out.println("field " + _name + " not suitable: " + java.lang.reflect.Modifier.toString(modifiers)); return null; } } catch (NoSuchFieldException nsfe) { @@ -235,6 +247,8 @@ static Field getFieldFromClassHierarchy(Class _clazz, String _name) throws Ap * * It is important to have only one ClassModel for each class used in the kernel * and only one MethodModel per method, so comparison operations work properly. + * + * The className param is in dot form, not slashes */ ClassModel getOrUpdateAllClassAccesses(String className) throws AparapiException { ClassModel memberClassModel = allFieldsClasses.get(className); @@ -242,6 +256,11 @@ ClassModel getOrUpdateAllClassAccesses(String className) throws AparapiException try { Class memberClass = Class.forName(className); + // Quick and dirty way to bail out from unhandled Math methods etc + if (className.startsWith("java.lang")) { + throw new ClassParseException(ClassParseException.TYPE.UNHANDLEDMAPPEDMETHOD); + } + // Immediately add this class and all its supers if necessary memberClassModel = new ClassModel(memberClass); if (logger.isLoggable(Level.FINEST)) { @@ -403,7 +422,7 @@ void updateObjectMemberFieldAccesses(String className, FieldEntry field) throws ClassModelMethod resolveCalledMethod(MethodCall methodCall, ClassModel classModel) throws AparapiException { MethodEntry methodEntry = methodCall.getConstantPoolMethodEntry(); int thisClassIndex = classModel.getThisClassConstantPoolIndex();//arf - boolean isMapped = (thisClassIndex != methodEntry.getClassIndex()) && Kernel.isMappedMethod(methodEntry); + boolean isMapped = (thisClassIndex != methodEntry.getClassIndex()) && KernelRunner.isMappedMethod(methodEntry); if (logger.isLoggable(Level.FINE)) { if (methodCall instanceof I_INVOKESPECIAL) { logger.fine("Method call to super: " + methodEntry); @@ -664,11 +683,12 @@ && getFieldFromClassHierarchy(getClassModel().getClassWeAreModelling(), assigned } else if (instruction instanceof I_INVOKEVIRTUAL) { I_INVOKEVIRTUAL invokeInstruction = (I_INVOKEVIRTUAL) instruction; MethodEntry methodEntry = invokeInstruction.getConstantPoolMethodEntry(); - if (Kernel.isMappedMethod(methodEntry)) { //only do this for intrinsics + if (KernelRunner.isMappedMethod(methodEntry)) { //only do this for intrinsics - if (Kernel.usesAtomic32(methodEntry)) { - setRequiresAtomics32Pragma(true); - } + // I forgot what atomics are for, check with Gary +// if (Kernel.usesAtomic32(methodEntry)) { +// setRequiresAtomics32Pragma(true); +// } Arg methodArgs[] = methodEntry.getArgs(); if (methodArgs.length > 0 && methodArgs[0].isArray()) { //currently array arg can only take slot 0 @@ -844,7 +864,7 @@ ClassModel getClassModel() { */ MethodModel getCallTarget(MethodEntry _methodEntry, boolean _isSpecial) { ClassModelMethod target = getClassModel().getMethod(_methodEntry, _isSpecial); - boolean isMapped = Kernel.isMappedMethod(_methodEntry); + boolean isMapped = KernelRunner.isMappedMethod(_methodEntry); if (logger.isLoggable(Level.FINE) && target == null) { logger.fine("Did not find call target: " + _methodEntry + " in " + diff --git a/com.amd.aparapi/src/java/com/amd/aparapi/InstructionSet.java b/com.amd.aparapi/src/java/com/amd/aparapi/InstructionSet.java index 755a45db..202a6583 100644 --- a/com.amd.aparapi/src/java/com/amd/aparapi/InstructionSet.java +++ b/com.amd.aparapi/src/java/com/amd/aparapi/InstructionSet.java @@ -2233,6 +2233,9 @@ static class I_GETFIELD extends Index16 implements AccessInstanceField{ return (1); } + @Override public String toString() { + return super.toString() + " " + getConstantPoolFieldEntry().getNameAndTypeEntry().getNameUTF8Entry().getUTF8(); + } } static class I_GETSTATIC extends Index16 implements AccessField{ @@ -3024,6 +3027,10 @@ static class I_INVOKEVIRTUAL extends Index16 implements VirtualMethodCall{ } return (child); } + + @Override public String toString() { + return super.toString() + " " + method.getConstantPool().getMethodEntry(getConstantPoolMethodIndex()); + } @Override public Instruction getInstanceReference() { return (getFirstChild()); diff --git a/com.amd.aparapi/src/java/com/amd/aparapi/Kernel.java b/com.amd.aparapi/src/java/com/amd/aparapi/Kernel.java deleted file mode 100644 index 26721605..00000000 --- a/com.amd.aparapi/src/java/com/amd/aparapi/Kernel.java +++ /dev/null @@ -1,2217 +0,0 @@ -/* -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.amd.aparapi; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.concurrent.BrokenBarrierException; -import java.util.concurrent.CyclicBarrier; -import java.util.logging.Logger; - -import com.amd.aparapi.ClassModel.ConstantPool.MethodReferenceEntry; - -/** - * A kernel encapsulates a data parallel algorithm that will execute either on a GPU - * (through conversion to OpenCL) or on a CPU via a Java Thread Pool. - *

- * To write a new kernel, a developer extends the Kernel class and overrides the Kernel.run() method. - * To execute this kernel, the developer creates a new instance of it and calls Kernel.execute(int globalSize) with a suitable 'global size'. At runtime - * Aparapi will attempt to convert the Kernel.run() method (and any method called directly or indirectly - * by Kernel.run()) into OpenCL for execution on GPU devices made available via the OpenCL platform. - *

- * Note that Kernel.run() is not called directly. Instead, - * the Kernel.execute(int globalSize) method will cause the overridden Kernel.run() - * method to be invoked once for each value in the range 0...globalSize. - *

- * On the first call to Kernel.execute(int _globalSize), Aparapi will determine the EXECUTION_MODE of the kernel. - * This decision is made dynamically based on two factors: - *

    - *
  1. Whether OpenCL is available (appropriate drivers are installed and the OpenCL and Aparapi dynamic libraries are included on the system path).
  2. - *
  3. Whether the bytecode of the run() method (and every method that can be called directly or indirectly from the run() method) - * can be converted into OpenCL.
  4. - *
- *

- * Below is an example Kernel that calculates the square of a set of input values. - *

- *

- *     class SquareKernel extends Kernel{
- *         private int values[];
- *         private int squares[];
- *         public SquareKernel(int values[]){
- *            this.values = values;
- *            squares = new int[values.length];
- *         }
- *         public void run() {
- *             int gid = getGlobalID();
- *             squares[gid] = values[gid]*values[gid];
- *         }
- *         public int[] getSquares(){
- *             return(squares);
- *         }
- *     }
- * 
- *

- * To execute this kernel, first create a new instance of it and then call execute(Range _range). - *

- *

- *     int[] values = new int[1024];
- *     // fill values array
- *     Range range = Range.create(values.length); // create a range 0..1024
- *     SquareKernel kernel = new SquareKernel(values);
- *     kernel.execute(range);
- * 
- *

- * When execute(Range) returns, all the executions of Kernel.run() have completed and the results are available in the squares array. - *

- *

- *     int[] squares = kernel.getSquares();
- *     for (int i=0; i< values.length; i++){
- *        System.out.printf("%4d %4d %8d\n", i, values[i], squares[i]);
- *     }
- * 
- *

- * A different approach to creating kernels that avoids extending Kernel is to write an anonymous inner class: - *

- *

- *   
- *     final int[] values = new int[1024];
- *     // fill the values array 
- *     final int[] squares = new int[values.length];
- *     final Range range = Range.create(values.length);
- *   
- *     Kernel kernel = new Kernel(){
- *         public void run() {
- *             int gid = getGlobalID();
- *             squares[gid] = values[gid]*values[gid];
- *         }
- *     };
- *     kernel.execute(range);
- *     for (int i=0; i< values.length; i++){
- *        System.out.printf("%4d %4d %8d\n", i, values[i], squares[i]);
- *     }
- *     
- * 
- *

- * - * @author gfrost AMD Javalabs - * @version Alpha, 21/09/2010 - */ - -public abstract class Kernel implements Cloneable{ - @Retention(RetentionPolicy.RUNTIME) @interface OpenCLMapping { - String mapTo() default ""; - - boolean atomic32() default false; - - boolean atomic64() default false; - } - - @Retention(RetentionPolicy.RUNTIME) @interface OpenCLDelegate { - - } - - /** - * We can use this Annotation to 'tag' intended local buffers. - * - * So we can either annotate the buffer - *


-    *  @Local int[] buffer = new int[1024];
-    *  
- * Or use a special suffix - *

-    *  int[] buffer_$local$ = new int[1024];
-    *  
- * - * @see LOCAL_SUFFIX - * - * - */ - public @Retention(RetentionPolicy.RUNTIME) @interface Local { - - } - - /** - * We can use this Annotation to 'tag' intended constant buffers. - * - * So we can either annotate the buffer - *

-    *  @Constant int[] buffer = new int[1024];
-    *  
- * Or use a special suffix - *

-    *  int[] buffer_$constant$ = new int[1024];
-    *  
- * - * @see LOCAL_SUFFIX - * - * - */ - public @Retention(RetentionPolicy.RUNTIME) @interface Constant { - - } - - /** - * We can use this suffix to 'tag' intended local buffers. - * - * - * So either name the buffer - *

-    *  int[] buffer_$local$ = new int[1024];
-    *  
- * Or use the Annotation form - *

-    *  @Local int[] buffer = new int[1024];
-    *  
- */ - - final static String LOCAL_SUFFIX = "_$local$"; - - /** - * We can use this suffix to 'tag' intended constant buffers. - * - * - * So either name the buffer - *

-    *  int[] buffer_$constant$ = new int[1024];
-    *  
- * Or use the Annotation form - *

-    *  @Constant int[] buffer = new int[1024];
-    *  
- */ - - final static String CONSTANT_SUFFIX = "_$constant$"; - - private static Logger logger = Logger.getLogger(Config.getLoggerName()); - - public abstract class Entry{ - public abstract void run(); - - public Kernel execute(Range _range) { - return (Kernel.this.execute("foo", _range, 1)); - } - } - - /** - * The execution mode ENUM enumerates the possible modes of executing a kernel. - * One can request a mode of execution using the values below, and query a kernel after it first executes to - * determine how it executed. - * - *

- * Aparapi supports 4 execution modes. - *

    - * - * - * - * - * - * - *
    Enum valueExecution
    GPUExecute using OpenCL on first available GPU device
    CPUExecute using OpenCL on first available CPU device
    JTPExecute using a Java Thread Pool (one thread spawned per available core)
    SEQExecute using a single loop. This is useful for debugging but will be less - * performant than the other modes
    - *
- *

- * To request that a kernel is executed in a specific mode, call Kernel.setExecutionMode(EXECUTION_MODE) before the - * kernel first executes. - *

- *

-    *     int[] values = new int[1024];
-    *     // fill values array
-    *     SquareKernel kernel = new SquareKernel(values);
-    *     kernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP);
-    *     kernel.execute(values.length);
-    * 
- *

- * Alternatively, the property com.amd.aparapi.executionMode can be set to one of JTP,GPU,CPU,SEQ - * when an application is launched. - *

-    *    java -classpath ....;aparapi.jar -Dcom.amd.aparapi.executionMode=GPU MyApplication  
-    * 

- * 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. - * - * @author gfrost AMD Javalabs - * @version Alpha, 21/09/2010 - */ - - public static enum EXECUTION_MODE { - /** - * A dummy value to indicate an unknown state. - */ - NONE, - /** - * The value representing execution on a GPU device via OpenCL. - */ - GPU, - /** - * The value representing execution on a CPU device via OpenCL. - *

- * Note not all OpenCL implementations support OpenCL compute on the CPU. - */ - CPU, - /** - * The value representing execution on a Java Thread Pool. - *

- * By default one Java thread is started for each available core and each core will execute globalSize/cores work items. - * This creates a total of globalSize%cores threads to complete the work. - * Choose suitable values for globalSize to minimize the number of threads that are spawned. - */ - JTP, - /** - * The value representing execution sequentially in a single loop. - *

- * This is meant to be used for debugging a kernel. - */ - SEQ; - /* static boolean openCLAvailable; - - static { - String arch = System.getProperty("os.arch"); - logger.fine("arch = " + arch); - - String libName = null; - try { - - if (arch.equals("amd64") || arch.equals("x86_64")) { - - libName = "aparapi_x86_64"; - logger.fine("attempting to load shared lib " + libName); - System.loadLibrary(libName); - openCLAvailable = true; - } else if (arch.equals("x86") || arch.equals("i386")) { - libName = "aparapi_x86"; - logger.fine("attempting to load shared lib " + libName); - System.loadLibrary(libName); - openCLAvailable = true; - } else { - logger.warning("Expected property os.arch to contain amd64 or x86 but found " + arch - + " don't know which library to load."); - - } - } catch (UnsatisfiedLinkError e) { - logger.warning("Check your environment. Failed to load aparapi native library " - + libName - + " or possibly failed to locate opencl native library (opencl.dll/opencl.so). Ensure that both are in your PATH (windows) or in LD_LIBRARY_PATH (linux)."); - - openCLAvailable = false; - } - } - */ - - static EXECUTION_MODE getDefaultExecutionMode() { - EXECUTION_MODE defaultExecutionMode = OpenCLJNI.getJNI().isOpenCLAvailable() ? GPU : JTP; - String executionMode = Config.executionMode; - if (executionMode != null) { - try { - EXECUTION_MODE requestedExecutionMode; - requestedExecutionMode = getExecutionModeFromString(executionMode).iterator().next(); - logger.fine("requested execution mode ="); - if ((OpenCLJNI.getJNI().isOpenCLAvailable() && requestedExecutionMode.isOpenCL()) - || !requestedExecutionMode.isOpenCL()) { - defaultExecutionMode = requestedExecutionMode; - } - } catch (Throwable t) { - // we will take the default - } - } - - logger.fine("default execution modes = " + defaultExecutionMode); - - return (defaultExecutionMode); - } - - static LinkedHashSet getDefaultExecutionModes() { - LinkedHashSet defaultExecutionModes = new LinkedHashSet(); - if (OpenCLJNI.getJNI().isOpenCLAvailable()) { - defaultExecutionModes.add(GPU); - defaultExecutionModes.add(JTP); - } else { - defaultExecutionModes.add(JTP); - } - String executionMode = Config.executionMode; - if (executionMode != null) { - try { - LinkedHashSet requestedExecutionModes; - requestedExecutionModes = EXECUTION_MODE.getExecutionModeFromString(executionMode); - logger.fine("requested execution mode ="); - for (EXECUTION_MODE mode : requestedExecutionModes) { - logger.fine(" " + mode); - } - if ((OpenCLJNI.getJNI().isOpenCLAvailable() && EXECUTION_MODE.anyOpenCL(requestedExecutionModes)) - || !EXECUTION_MODE.anyOpenCL(requestedExecutionModes)) { - defaultExecutionModes = requestedExecutionModes; - } - } catch (Throwable t) { - // we will take the default - } - } - - logger.info("default execution modes = " + defaultExecutionModes); - - for (EXECUTION_MODE e : defaultExecutionModes) { - logger.info("SETTING DEFAULT MODE: " + e.toString()); - } - - return (defaultExecutionModes); - } - - static LinkedHashSet getExecutionModeFromString(String executionMode) { - LinkedHashSet executionModes = new LinkedHashSet(); - for (String mode : executionMode.split(",")) { - executionModes.add(valueOf(mode.toUpperCase())); - } - return executionModes; - } - - static EXECUTION_MODE getFallbackExecutionMode() { - EXECUTION_MODE defaultFallbackExecutionMode = JTP; - logger.info("fallback execution mode = " + defaultFallbackExecutionMode); - return (defaultFallbackExecutionMode); - } - - static boolean anyOpenCL(LinkedHashSet _executionModes) { - for (EXECUTION_MODE mode : _executionModes) { - if (mode == GPU || mode == CPU) { - return true; - } - } - return false; - } - - boolean isOpenCL() { - return this == GPU || this == CPU; - } - - }; - - int[] globalId = new int[] { - 0, - 0, - 0 - }; - - int[] localId = new int[] { - 0, - 0, - 0 - }; - - int[] groupId = new int[] { - 0, - 0, - 0 - }; - - Range range; - - int passId; - - volatile CyclicBarrier localBarrier; - - /** - * Determine the globalId of an executing kernel. - *

- * The kernel implementation uses the globalId to determine which of the executing kernels (in the global domain space) this invocation is expected to deal with. - *

- * For example in a SquareKernel implementation: - *

- *

-    *     class SquareKernel extends Kernel{
-    *         private int values[];
-    *         private int squares[];
-    *         public SquareKernel(int values[]){
-    *            this.values = values;
-    *            squares = new int[values.length];
-    *         }
-    *         public void run() {
-    *             int gid = getGlobalID();
-    *             squares[gid] = values[gid]*values[gid];
-    *         }
-    *         public int[] getSquares(){
-    *             return(squares);
-    *         }
-    *     }
-    * 
- *

- * Each invocation of SquareKernel.run() retrieves it's globalId by calling getGlobalId(), and then computes the value of square[gid] for a given value of value[gid]. - *

- * @return The globalId for the Kernel being executed - * - * @see #getLocalId() - * @see #getGroupId() - * @see #getGlobalSize() - * @see #getNumGroups() - * @see #getLocalSize() - */ - - @OpenCLDelegate protected final int getGlobalId() { - return (getGlobalId(0)); - } - - @OpenCLDelegate protected final int getGlobalId(int _dim) { - return (globalId[_dim]); - } - - /* - @OpenCLDelegate protected final int getGlobalX() { - return (getGlobalId(0)); - } - - @OpenCLDelegate protected final int getGlobalY() { - return (getGlobalId(1)); - } - - @OpenCLDelegate protected final int getGlobalZ() { - return (getGlobalId(2)); - } - */ - /** - * Determine the groupId of an executing kernel. - *

- * When a Kernel.execute(int globalSize) is invoked for a particular kernel, the runtime will break the work into various 'groups'. - *

- * A kernel can use getGroupId() to determine which group a kernel is currently - * dispatched to - *

- * The following code would capture the groupId for each kernel and map it against globalId. - *

-    *     final int[] groupIds = new int[1024];
-    *     Kernel kernel = new Kernel(){
-    *         public void run() {
-    *             int gid = getGlobalId();
-    *             groupIds[gid] = getGroupId();
-    *         }
-    *     };
-    *     kernel.execute(groupIds.length);
-    *     for (int i=0; i< values.length; i++){
-    *        System.out.printf("%4d %4d\n", i, groupIds[i]);
-    *     } 
-    * 
- * - * @see #getLocalId() - * @see #getGlobalId() - * @see #getGlobalSize() - * @see #getNumGroups() - * @see #getLocalSize() - * - * @return The groupId for this Kernel being executed - */ - @OpenCLDelegate protected final int getGroupId() { - return (getGroupId(0)); - } - - @OpenCLDelegate protected final int getGroupId(int _dim) { - return (groupId[_dim]); - } - - /* - @OpenCLDelegate protected final int getGroupX() { - return (getGroupId(0)); - } - - @OpenCLDelegate protected final int getGroupY() { - return (getGroupId(1)); - } - - @OpenCLDelegate protected final int getGroupZ() { - return (getGroupId(2)); - } - */ - /** - * Determine the passId of an executing kernel. - *

- * When a Kernel.execute(int globalSize, int passes) is invoked for a particular kernel, the runtime will break the work into various 'groups'. - *

- * A kernel can use getPassId() to determine which pass we are in. This is ideal for 'reduce' type phases - * - * @see #getLocalId() - * @see #getGlobalId() - * @see #getGlobalSize() - * @see #getNumGroups() - * @see #getLocalSize() - * - * @return The groupId for this Kernel being executed - */ - @OpenCLDelegate protected final int getPassId() { - return (passId); - } - - /** - * Determine the local id of an executing kernel. - *

- * When a Kernel.execute(int globalSize) is invoked for a particular kernel, the runtime will break the work into - * various 'groups'. - * getLocalId() can be used to determine the relative id of the current kernel within a specific group. - *

- * The following code would capture the groupId for each kernel and map it against globalId. - *

-    *     final int[] localIds = new int[1024];
-    *     Kernel kernel = new Kernel(){
-    *         public void run() {
-    *             int gid = getGlobalId();
-    *             localIds[gid] = getLocalId();
-    *         }
-    *     };
-    *     kernel.execute(localIds.length);
-    *     for (int i=0; i< values.length; i++){
-    *        System.out.printf("%4d %4d\n", i, localIds[i]);
-    *     } 
-    * 
- * - * @see #getGroupId() - * @see #getGlobalId() - * @see #getGlobalSize() - * @see #getNumGroups() - * @see #getLocalSize() - * - * @return The local id for this Kernel being executed - */ - @OpenCLDelegate protected final int getLocalId() { - return (getLocalId(0)); - } - - @OpenCLDelegate protected final int getLocalId(int _dim) { - return (localId[_dim]); - } - - /* - @OpenCLDelegate protected final int getLocalX() { - return (getLocalId(0)); - } - - @OpenCLDelegate protected final int getLocalY() { - return (getLocalId(1)); - } - - @OpenCLDelegate protected final int getLocalZ() { - return (getLocalId(2)); - } - */ - /** - * Determine the size of the group that an executing kernel is a member of. - *

- * When a Kernel.execute(int globalSize) is invoked for a particular kernel, the runtime will break the work into - * various 'groups'. getLocalSize() allows a kernel to determine the size of the current group. - *

- * Note groups may not all be the same size. In particular, if (global size)%(# of compute devices)!=0, the runtime can choose to dispatch kernels to - * groups with differing sizes. - * - * @see #getGroupId() - * @see #getGlobalId() - * @see #getGlobalSize() - * @see #getNumGroups() - * @see #getLocalSize() - * - * @return The size of the currently executing group. - */ - @OpenCLDelegate protected final int getLocalSize() { - return (range.getLocalSize(0)); - } - - @OpenCLDelegate protected final int getLocalSize(int _dim) { - return (range.getLocalSize(_dim)); - } - - /* - @OpenCLDelegate protected final int getLocalWidth() { - return (range.getLocalSize(0)); - } - - @OpenCLDelegate protected final int getLocalHeight() { - return (range.getLocalSize(1)); - } - - @OpenCLDelegate protected final int getLocalDepth() { - return (range.getLocalSize(2)); - } - */ - /** - * Determine the value that was passed to Kernel.execute(int globalSize) method. - * - * @see #getGroupId() - * @see #getGlobalId() - * @see #getNumGroups() - * @see #getLocalSize() - * - * @return The value passed to Kernel.execute(int globalSize) causing the current execution. - */ - @OpenCLDelegate protected final int getGlobalSize() { - return (range.getGlobalSize(0)); - } - - @OpenCLDelegate protected final int getGlobalSize(int _dim) { - return (range.getGlobalSize(_dim)); - } - - /* - @OpenCLDelegate protected final int getGlobalWidth() { - return (range.getGlobalSize(0)); - } - - @OpenCLDelegate protected final int getGlobalHeight() { - return (range.getGlobalSize(1)); - } - - @OpenCLDelegate protected final int getGlobalDepth() { - return (range.getGlobalSize(2)); - } - */ - /** - * Determine the number of groups that will be used to execute a kernel - *

- * When Kernel.execute(int globalSize) is invoked, the runtime will split the work into - * multiple 'groups'. getNumGroups() returns the total number of groups that will be used. - * - * @see #getGroupId() - * @see #getGlobalId() - * @see #getGlobalSize() - * @see #getNumGroups() - * @see #getLocalSize() - * - * @return The number of groups that kernels will be dispatched into. - */ - @OpenCLDelegate protected final int getNumGroups() { - return (range.getNumGroups(0)); - } - - @OpenCLDelegate protected final int getNumGroups(int _dim) { - return (range.getNumGroups(_dim)); - } - - /* - @OpenCLDelegate protected final int getNumGroupsWidth() { - return (range.getGroups(0)); - } - - @OpenCLDelegate protected final int getNumGroupsHeight() { - return (range.getGroups(1)); - } - - @OpenCLDelegate protected final int getNumGroupsDepth() { - return (range.getGroups(2)); - } - */ - /** - * The entry point of a kernel. - * - *

- * Every kernel must override this method. - */ - public abstract void run(); - - /** - * When using a Java Thread Pool Aparapi uses clone to copy the initial instance to each thread. - * - *

- * If you choose to override clone() you are responsible for delegating to super.clone(); - */ - @Override protected Object clone() { - try { - Kernel worker = (Kernel) super.clone(); - worker.groupId = new int[] { - 0, - 0, - 0 - }; - worker.localId = new int[] { - 0, - 0, - 0 - }; - worker.globalId = new int[] { - 0, - 0, - 0 - }; - return worker; - } catch (CloneNotSupportedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return (null); - } - } - - /** - * Delegates to either {@link java.lang.Math#acos(double)} (Java) or acos(float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param a value to delegate to {@link java.lang.Math#acos(double)}/acos(float) - * @return {@link java.lang.Math#acos(double)} casted to float/acos(float) - * - * @see java.lang.Math#acos(double) - * @see acos(float) - */ - @OpenCLMapping(mapTo = "acos") protected float acos(float a) { - return (float) Math.acos(a); - } - - /** - * Delegates to either {@link java.lang.Math#acos(double)} (Java) or acos(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param a value to delegate to {@link java.lang.Math#acos(double)}/acos(double) - * @return {@link java.lang.Math#acos(double)}/acos(double) - * - * @see java.lang.Math#acos(double) - * @see acos(double) - */ - @OpenCLMapping(mapTo = "acos") protected double acos(double a) { - return Math.acos(a); - } - - /** - * Delegates to either {@link java.lang.Math#asin(double)} (Java) or asin(float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f value to delegate to {@link java.lang.Math#asin(double)}/asin(float) - * @return {@link java.lang.Math#asin(double)} casted to float/asin(float) - * - * @see java.lang.Math#asin(double) - * @see asin(float) - */ - @OpenCLMapping(mapTo = "asin") protected float asin(float _f) { - return (float) Math.asin(_f); - } - - /** - * Delegates to either {@link java.lang.Math#asin(double)} (Java) or asin(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d value to delegate to {@link java.lang.Math#asin(double)}/asin(double) - * @return {@link java.lang.Math#asin(double)}/asin(double) - * - * @see java.lang.Math#asin(double) - * @see asin(double) - */ - @OpenCLMapping(mapTo = "asin") protected double asin(double _d) { - return Math.asin(_d); - } - - /** - * Delegates to either {@link java.lang.Math#atan(double)} (Java) or atan(float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f value to delegate to {@link java.lang.Math#atan(double)}/atan(float) - * @return {@link java.lang.Math#atan(double)} casted to float/atan(float) - * - * @see java.lang.Math#atan(double) - * @see atan(float) - */ - @OpenCLMapping(mapTo = "atan") protected float atan(float _f) { - return (float) Math.atan(_f); - } - - /** - * Delegates to either {@link java.lang.Math#atan(double)} (Java) or atan(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d value to delegate to {@link java.lang.Math#atan(double)}/atan(double) - * @return {@link java.lang.Math#atan(double)}/atan(double) - * - * @see java.lang.Math#atan(double) - * @see atan(double) - */ - @OpenCLMapping(mapTo = "atan") protected double atan(double _d) { - return Math.atan(_d); - } - - /** - * Delegates to either {@link java.lang.Math#atan2(double, double)} (Java) or atan2(float, float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f1 value to delegate to first argument of {@link java.lang.Math#atan2(double, double)}/atan2(float, float) - * @param _f2 value to delegate to second argument of {@link java.lang.Math#atan2(double, double)}/atan2(float, float) - * @return {@link java.lang.Math#atan2(double, double)} casted to float/atan2(float, float) - * - * @see java.lang.Math#atan2(double, double) - * @see atan2(float, float) - */ - @OpenCLMapping(mapTo = "atan2") protected float atan2(float _f1, float _f2) { - return (float) Math.atan2(_f1, _f2); - } - - /** - * Delegates to either {@link java.lang.Math#atan2(double, double)} (Java) or atan2(double, double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d1 value to delegate to first argument of {@link java.lang.Math#atan2(double, double)}/atan2(double, double) - * @param _d2 value to delegate to second argument of {@link java.lang.Math#atan2(double, double)}/atan2(double, double) - * @return {@link java.lang.Math#atan2(double, double)}/atan2(double, double) - * - * @see java.lang.Math#atan2(double, double) - * @see atan2(double, double) - */ - @OpenCLMapping(mapTo = "atan2") protected double atan2(double _d1, double _d2) { - return Math.atan2(_d1, _d2); - } - - /** - * Delegates to either {@link java.lang.Math#ceil(double)} (Java) or ceil(float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f value to delegate to {@link java.lang.Math#ceil(double)}/ceil(float) - * @return {@link java.lang.Math#ceil(double)} casted to float/ceil(float) - * - * @see java.lang.Math#ceil(double) - * @see ceil(float) - */ - @OpenCLMapping(mapTo = "ceil") protected float ceil(float _f) { - return (float) Math.ceil(_f); - } - - /** - * Delegates to either {@link java.lang.Math#ceil(double)} (Java) or ceil(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d value to delegate to {@link java.lang.Math#ceil(double)}/ceil(double) - * @return {@link java.lang.Math#ceil(double)}/ceil(double) - * - * @see java.lang.Math#ceil(double) - * @see ceil(double) - */ - @OpenCLMapping(mapTo = "ceil") protected double ceil(double _d) { - return Math.ceil(_d); - } - - /** - * Delegates to either {@link java.lang.Math#cos(double)} (Java) or cos(float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f value to delegate to {@link java.lang.Math#cos(double)}/cos(float) - * @return {@link java.lang.Math#cos(double)} casted to float/cos(float) - * - * @see java.lang.Math#cos(double) - * @see cos(float) - */ - @OpenCLMapping(mapTo = "cos") protected float cos(float _f) { - return (float) Math.cos(_f); - } - - /** - * Delegates to either {@link java.lang.Math#cos(double)} (Java) or cos(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d value to delegate to {@link java.lang.Math#cos(double)}/cos(double) - * @return {@link java.lang.Math#cos(double)}/cos(double) - * - * @see java.lang.Math#cos(double) - * @see cos(double) - */ - @OpenCLMapping(mapTo = "cos") protected double cos(double _d) { - return Math.cos(_d); - } - - /** - * Delegates to either {@link java.lang.Math#exp(double)} (Java) or exp(float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f value to delegate to {@link java.lang.Math#exp(double)}/exp(float) - * @return {@link java.lang.Math#exp(double)} casted to float/exp(float) - * - * @see java.lang.Math#exp(double) - * @see exp(float) - */ - @OpenCLMapping(mapTo = "exp") protected float exp(float _f) { - return (float) Math.exp(_f); - } - - /** - * Delegates to either {@link java.lang.Math#exp(double)} (Java) or exp(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d value to delegate to {@link java.lang.Math#exp(double)}/exp(double) - * @return {@link java.lang.Math#exp(double)}/exp(double) - * - * @see java.lang.Math#exp(double) - * @see exp(double) - */ - @OpenCLMapping(mapTo = "exp") protected double exp(double _d) { - return Math.exp(_d); - } - - /** - * Delegates to either {@link java.lang.Math#abs(float)} (Java) or fabs(float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f value to delegate to {@link java.lang.Math#abs(float)}/fabs(float) - * @return {@link java.lang.Math#abs(float)}/fabs(float) - * - * @see java.lang.Math#abs(float) - * @see fabs(float) - */ - @OpenCLMapping(mapTo = "fabs") protected float abs(float _f) { - return Math.abs(_f); - } - - /** - * Delegates to either {@link java.lang.Math#abs(double)} (Java) or fabs(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d value to delegate to {@link java.lang.Math#abs(double)}/fabs(double) - * @return {@link java.lang.Math#abs(double)}/fabs(double) - * - * @see java.lang.Math#abs(double) - * @see fabs(double) - */ - @OpenCLMapping(mapTo = "fabs") protected double abs(double _d) { - return Math.abs(_d); - } - - /** - * Delegates to either {@link java.lang.Math#abs(int)} (Java) or abs(int) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param n value to delegate to {@link java.lang.Math#abs(int)}/abs(int) - * @return {@link java.lang.Math#abs(int)}/abs(int) - * - * @see java.lang.Math#abs(int) - * @see abs(int) - */ - @OpenCLMapping(mapTo = "abs") protected int abs(int n) { - return Math.abs(n); - } - - /** - * Delegates to either {@link java.lang.Math#abs(long)} (Java) or abs(long) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param n value to delegate to {@link java.lang.Math#abs(long)}/abs(long) - * @return {@link java.lang.Math#abs(long)}/abs(long) - * - * @see java.lang.Math#abs(long) - * @see abs(long) - */ - @OpenCLMapping(mapTo = "abs") protected long abs(long n) { - return Math.abs(n); - } - - /** - * Delegates to either {@link java.lang.Math#floor(double)} (Java) or floor(float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f value to delegate to {@link java.lang.Math#floor(double)}/floor(float) - * @return {@link java.lang.Math#floor(double)} casted to float/floor(float) - * - * @see java.lang.Math#floor(double) - * @see floor(float) - */ - @OpenCLMapping(mapTo = "floor") protected float floor(float _f) { - return (float) Math.floor(_f); - } - - /** - * Delegates to either {@link java.lang.Math#floor(double)} (Java) or floor(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d value to delegate to {@link java.lang.Math#floor(double)}/floor(double) - * @return {@link java.lang.Math#floor(double)}/floor(double) - * - * @see java.lang.Math#floor(double) - * @see floor(double) - */ - @OpenCLMapping(mapTo = "floor") protected double floor(double _d) { - return Math.floor(_d); - } - - /** - * Delegates to either {@link java.lang.Math#max(float, float)} (Java) or fmax(float, float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f1 value to delegate to first argument of {@link java.lang.Math#max(float, float)}/fmax(float, float) - * @param _f2 value to delegate to second argument of {@link java.lang.Math#max(float, float)}/fmax(float, float) - * @return {@link java.lang.Math#max(float, float)}/fmax(float, float) - * - * @see java.lang.Math#max(float, float) - * @see fmax(float, float) - */ - @OpenCLMapping(mapTo = "fmax") protected float max(float _f1, float _f2) { - return Math.max(_f1, _f2); - } - - /** - * Delegates to either {@link java.lang.Math#max(double, double)} (Java) or fmax(double, double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d1 value to delegate to first argument of {@link java.lang.Math#max(double, double)}/fmax(double, double) - * @param _d2 value to delegate to second argument of {@link java.lang.Math#max(double, double)}/fmax(double, double) - * @return {@link java.lang.Math#max(double, double)}/fmax(double, double) - * - * @see java.lang.Math#max(double, double) - * @see fmax(double, double) - */ - @OpenCLMapping(mapTo = "fmax") protected double max(double _d1, double _d2) { - return Math.max(_d1, _d2); - } - - /** - * Delegates to either {@link java.lang.Math#max(int, int)} (Java) or max(int, int) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param n1 value to delegate to {@link java.lang.Math#max(int, int)}/max(int, int) - * @param n2 value to delegate to {@link java.lang.Math#max(int, int)}/max(int, int) - * @return {@link java.lang.Math#max(int, int)}/max(int, int) - * - * @see java.lang.Math#max(int, int) - * @see max(int, int) - */ - @OpenCLMapping(mapTo = "max") protected int max(int n1, int n2) { - return Math.max(n1, n2); - } - - /** - * Delegates to either {@link java.lang.Math#max(long, long)} (Java) or max(long, long) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param n1 value to delegate to first argument of {@link java.lang.Math#max(long, long)}/max(long, long) - * @param n2 value to delegate to second argument of {@link java.lang.Math#max(long, long)}/max(long, long) - * @return {@link java.lang.Math#max(long, long)}/max(long, long) - * - * @see java.lang.Math#max(long, long) - * @see max(long, long) - */ - @OpenCLMapping(mapTo = "max") protected long max(long n1, long n2) { - return Math.max(n1, n2); - } - - /** - * Delegates to either {@link java.lang.Math#min(float, float)} (Java) or fmin(float, float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f1 value to delegate to first argument of {@link java.lang.Math#min(float, float)}/fmin(float, float) - * @param _f2 value to delegate to second argument of {@link java.lang.Math#min(float, float)}/fmin(float, float) - * @return {@link java.lang.Math#min(float, float)}/fmin(float, float) - * - * @see java.lang.Math#min(float, float) - * @see fmin(float, float) - */ - @OpenCLMapping(mapTo = "fmin") protected float min(float _f1, float _f2) { - return Math.min(_f1, _f2); - } - - /** - * Delegates to either {@link java.lang.Math#min(double, double)} (Java) or fmin(double, double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d1 value to delegate to first argument of {@link java.lang.Math#min(double, double)}/fmin(double, double) - * @param _d2 value to delegate to second argument of {@link java.lang.Math#min(double, double)}/fmin(double, double) - * @return {@link java.lang.Math#min(double, double)}/fmin(double, double) - * - * @see java.lang.Math#min(double, double) - * @see fmin(double, double) - */ - @OpenCLMapping(mapTo = "fmin") protected double min(double _d1, double _d2) { - return Math.min(_d1, _d2); - } - - /** - * Delegates to either {@link java.lang.Math#min(int, int)} (Java) or min(int, int) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param n1 value to delegate to first argument of {@link java.lang.Math#min(int, int)}/min(int, int) - * @param n2 value to delegate to second argument of {@link java.lang.Math#min(int, int)}/min(int, int) - * @return {@link java.lang.Math#min(int, int)}/min(int, int) - * - * @see java.lang.Math#min(int, int) - * @see min(int, int) - */ - @OpenCLMapping(mapTo = "min") protected int min(int n1, int n2) { - return Math.min(n1, n2); - } - - /** - * Delegates to either {@link java.lang.Math#min(long, long)} (Java) or min(long, long) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param n1 value to delegate to first argument of {@link java.lang.Math#min(long, long)}/min(long, long) - * @param n2 value to delegate to second argument of {@link java.lang.Math#min(long, long)}/min(long, long) - * @return {@link java.lang.Math#min(long, long)}/min(long, long) - * - * @see java.lang.Math#min(long, long) - * @see min(long, long) - */ - @OpenCLMapping(mapTo = "min") protected long min(long n1, long n2) { - return Math.min(n1, n2); - } - - /** - * Delegates to either {@link java.lang.Math#log(double)} (Java) or log(float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f value to delegate to {@link java.lang.Math#log(double)}/log(float) - * @return {@link java.lang.Math#log(double)} casted to float/log(float) - * - * @see java.lang.Math#log(double) - * @see log(float) - */ - @OpenCLMapping(mapTo = "log") protected float log(float _f) { - return (float) Math.log(_f); - } - - /** - * Delegates to either {@link java.lang.Math#log(double)} (Java) or log(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d value to delegate to {@link java.lang.Math#log(double)}/log(double) - * @return {@link java.lang.Math#log(double)}/log(double) - * - * @see java.lang.Math#log(double) - * @see log(double) - */ - @OpenCLMapping(mapTo = "log") protected double log(double _d) { - return Math.log(_d); - } - - /** - * Delegates to either {@link java.lang.Math#pow(double, double)} (Java) or pow(float, float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f1 value to delegate to first argument of {@link java.lang.Math#pow(double, double)}/pow(float, float) - * @param _f2 value to delegate to second argument of {@link java.lang.Math#pow(double, double)}/pow(float, float) - * @return {@link java.lang.Math#pow(double, double)} casted to float/pow(float, float) - * - * @see java.lang.Math#pow(double, double) - * @see pow(float, float) - */ - @OpenCLMapping(mapTo = "pow") protected float pow(float _f1, float _f2) { - return (float) Math.pow(_f1, _f2); - } - - /** - * Delegates to either {@link java.lang.Math#pow(double, double)} (Java) or pow(double, double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d1 value to delegate to first argument of {@link java.lang.Math#pow(double, double)}/pow(double, double) - * @param _d2 value to delegate to second argument of {@link java.lang.Math#pow(double, double)}/pow(double, double) - * @return {@link java.lang.Math#pow(double, double)}/pow(double, double) - * - * @see java.lang.Math#pow(double, double) - * @see pow(double, double) - */ - @OpenCLMapping(mapTo = "pow") protected double pow(double _d1, double _d2) { - return Math.pow(_d1, _d2); - } - - /** - * Delegates to either {@link java.lang.Math#IEEEremainder(double, double)} (Java) or remainder(float, float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f1 value to delegate to first argument of {@link java.lang.Math#IEEEremainder(double, double)}/remainder(float, float) - * @param _f2 value to delegate to second argument of {@link java.lang.Math#IEEEremainder(double, double)}/remainder(float, float) - * @return {@link java.lang.Math#IEEEremainder(double, double)} casted to float/remainder(float, float) - * - * @see java.lang.Math#IEEEremainder(double, double) - * @see remainder(float, float) - */ - @OpenCLMapping(mapTo = "remainder") protected float IEEEremainder(float _f1, float _f2) { - return (float) Math.IEEEremainder(_f1, _f2); - } - - /** - * Delegates to either {@link java.lang.Math#IEEEremainder(double, double)} (Java) or remainder(double, double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d1 value to delegate to first argument of {@link java.lang.Math#IEEEremainder(double, double)}/remainder(double, double) - * @param _d2 value to delegate to second argument of {@link java.lang.Math#IEEEremainder(double, double)}/remainder(double, double) - * @return {@link java.lang.Math#IEEEremainder(double, double)}/remainder(double, double) - * - * @see java.lang.Math#IEEEremainder(double, double) - * @see remainder(double, double) - */ - @OpenCLMapping(mapTo = "remainder") protected double IEEEremainder(double _d1, double _d2) { - return Math.IEEEremainder(_d1, _d2); - } - - /** - * Delegates to either {@link java.lang.Math#toRadians(double)} (Java) or radians(float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f value to delegate to {@link java.lang.Math#toRadians(double)}/radians(float) - * @return {@link java.lang.Math#toRadians(double)} casted to float/radians(float) - * - * @see java.lang.Math#toRadians(double) - * @see radians(float) - */ - @OpenCLMapping(mapTo = "radians") protected float toRadians(float _f) { - return (float) Math.toRadians(_f); - } - - /** - * Delegates to either {@link java.lang.Math#toRadians(double)} (Java) or radians(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d value to delegate to {@link java.lang.Math#toRadians(double)}/radians(double) - * @return {@link java.lang.Math#toRadians(double)}/radians(double) - * - * @see java.lang.Math#toRadians(double) - * @see radians(double) - */ - @OpenCLMapping(mapTo = "radians") protected double toRadians(double _d) { - return Math.toRadians(_d); - } - - /** - * Delegates to either {@link java.lang.Math#toDegrees(double)} (Java) or degrees(float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f value to delegate to {@link java.lang.Math#toDegrees(double)}/degrees(float) - * @return {@link java.lang.Math#toDegrees(double)} casted to float/degrees(float) - * - * @see java.lang.Math#toDegrees(double) - * @see degrees(float) - */ - @OpenCLMapping(mapTo = "degrees") protected float toDegrees(float _f) { - return (float) Math.toDegrees(_f); - } - - /** - * Delegates to either {@link java.lang.Math#toDegrees(double)} (Java) or degrees(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d value to delegate to {@link java.lang.Math#toDegrees(double)}/degrees(double) - * @return {@link java.lang.Math#toDegrees(double)}/degrees(double) - * - * @see java.lang.Math#toDegrees(double) - * @see degrees(double) - */ - @OpenCLMapping(mapTo = "degrees") protected double toDegrees(double _d) { - return Math.toDegrees(_d); - } - - /** - * Delegates to either {@link java.lang.Math#rint(double)} (Java) or rint(float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f value to delegate to {@link java.lang.Math#rint(double)}/rint(float) - * @return {@link java.lang.Math#rint(double)} casted to float/rint(float) - * - * @see java.lang.Math#rint(double) - * @see rint(float) - */ - @OpenCLMapping(mapTo = "rint") protected float rint(float _f) { - return (float) Math.rint(_f); - } - - /** - * Delegates to either {@link java.lang.Math#rint(double)} (Java) or rint(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d value to delegate to {@link java.lang.Math#rint(double)}/rint(double) - * @return {@link java.lang.Math#rint(double)}/rint(double) - * - * @see java.lang.Math#rint(double) - * @see rint(double) - */ - @OpenCLMapping(mapTo = "rint") protected double rint(double _d) { - return Math.rint(_d); - } - - /** - * Delegates to either {@link java.lang.Math#round(float)} (Java) or round(float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f value to delegate to {@link java.lang.Math#round(float)}/round(float) - * @return {@link java.lang.Math#round(float)}/round(float) - * - * @see java.lang.Math#round(float) - * @see round(float) - */ - @OpenCLMapping(mapTo = "round") protected int round(float _f) { - return Math.round(_f); - } - - /** - * Delegates to either {@link java.lang.Math#round(double)} (Java) or round(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d value to delegate to {@link java.lang.Math#round(double)}/round(double) - * @return {@link java.lang.Math#round(double)}/round(double) - * - * @see java.lang.Math#round(double) - * @see round(double) - */ - @OpenCLMapping(mapTo = "round") protected long round(double _d) { - return Math.round(_d); - } - - /** - * Delegates to either {@link java.lang.Math#sin(double)} (Java) or sin(float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f value to delegate to {@link java.lang.Math#sin(double)}/sin(float) - * @return {@link java.lang.Math#sin(double)} casted to float/sin(float) - * - * @see java.lang.Math#sin(double) - * @see sin(float) - */ - @OpenCLMapping(mapTo = "sin") protected float sin(float _f) { - return (float) Math.sin(_f); - } - - /** - * Delegates to either {@link java.lang.Math#sin(double)} (Java) or sin(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d value to delegate to {@link java.lang.Math#sin(double)}/sin(double) - * @return {@link java.lang.Math#sin(double)}/sin(double) - * - * @see java.lang.Math#sin(double) - * @see sin(double) - */ - @OpenCLMapping(mapTo = "sin") protected double sin(double _d) { - return Math.sin(_d); - } - - /** - * Delegates to either {@link java.lang.Math#sqrt(double)} (Java) or sqrt(float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f value to delegate to {@link java.lang.Math#sqrt(double)}/sqrt(float) - * @return {@link java.lang.Math#sqrt(double)} casted to float/sqrt(float) - * - * @see java.lang.Math#sqrt(double) - * @see sqrt(float) - */ - @OpenCLMapping(mapTo = "sqrt") protected float sqrt(float _f) { - return (float) Math.sqrt(_f); - } - - /** - * Delegates to either {@link java.lang.Math#sqrt(double)} (Java) or sqrt(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d value to delegate to {@link java.lang.Math#sqrt(double)}/sqrt(double) - * @return {@link java.lang.Math#sqrt(double)}/sqrt(double) - * - * @see java.lang.Math#sqrt(double) - * @see sqrt(double) - */ - @OpenCLMapping(mapTo = "sqrt") protected double sqrt(double _d) { - return Math.sqrt(_d); - } - - /** - * Delegates to either {@link java.lang.Math#tan(double)} (Java) or tan(float) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f value to delegate to {@link java.lang.Math#tan(double)}/tan(float) - * @return {@link java.lang.Math#tan(double)} casted to float/tan(float) - * - * @see java.lang.Math#tan(double) - * @see tan(float) - */ - @OpenCLMapping(mapTo = "tan") protected float tan(float _f) { - return (float) Math.tan(_f); - } - - /** - * Delegates to either {@link java.lang.Math#tan(double)} (Java) or tan(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d value to delegate to {@link java.lang.Math#tan(double)}/tan(double) - * @return {@link java.lang.Math#tan(double)}/tan(double) - * - * @see java.lang.Math#tan(double) - * @see tan(double) - */ - @OpenCLMapping(mapTo = "tan") protected double tan(double _d) { - return Math.tan(_d); - } - - // the following rsqrt and native_sqrt and native_rsqrt don't exist in java Math - // but added them here for nbody testing, not sure if we want to expose them - /** - * Computes inverse square root using {@link java.lang.Math#sqrt(double)} (Java) or delegates to rsqrt(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _f value to delegate to {@link java.lang.Math#sqrt(double)}/rsqrt(double) - * @return ( 1.0f / {@link java.lang.Math#sqrt(double)} casted to float )/rsqrt(double) - * - * @see java.lang.Math#sqrt(double) - * @see rsqrt(double) - */ - @OpenCLMapping(mapTo = "rsqrt") protected float rsqrt(float _f) { - return (1.0f / (float) Math.sqrt(_f)); - } - - /** - * Computes inverse square root using {@link java.lang.Math#sqrt(double)} (Java) or delegates to rsqrt(double) (OpenCL). - * - * User should note the differences in precision between Java and OpenCL's implementation of arithmetic functions to determine whether the difference in precision is acceptable. - * - * @param _d value to delegate to {@link java.lang.Math#sqrt(double)}/rsqrt(double) - * @return ( 1.0f / {@link java.lang.Math#sqrt(double)} ) /rsqrt(double) - * - * @see java.lang.Math#sqrt(double) - * @see rsqrt(double) - */ - @OpenCLMapping(mapTo = "rsqrt") protected double rsqrt(double _d) { - return (1.0 / Math.sqrt(_d)); - } - - @SuppressWarnings("unused") @OpenCLMapping(mapTo = "native_sqrt") private float native_sqrt(float _f) { - int j = Float.floatToIntBits(_f); - j = (1 << 29) + (j >> 1) - (1 << 22) - 0x4c00; - return (Float.intBitsToFloat(j)); - // could add more precision using one iteration of newton's method, use the following - } - - @SuppressWarnings("unused") @OpenCLMapping(mapTo = "native_rsqrt") private float native_rsqrt(float _f) { - int j = Float.floatToIntBits(_f); - j = 0x5f3759df - (j >> 1); - float x = (Float.intBitsToFloat(j)); - return x; - // if want more precision via one iteration of newton's method, use the following - // float fhalf = 0.5f*_f; - // return (x *(1.5f - fhalf * x * x)); - } - - // Hacked from AtomicIntegerArray.getAndAdd(i, delta) - /** - * Atomically adds _delta value to _index element of array _arr (Java) or delegates to atomic_add(volatile int*, int) (OpenCL). - * - * - * @param _arr array for which an element value needs to be atomically incremented by _delta - * @param _index index of the _arr array that needs to be atomically incremented by _delta - * @param _delta value by which _index element of _arr array needs to be atomically incremented - * @return previous value of _index element of _arr array - * - * @see atomic_add(volatile int*, int) - */ - @OpenCLMapping(atomic32 = true) protected int atomicAdd(int[] _arr, int _index, int _delta) { - - if (!Config.disableUnsafe) { - return UnsafeWrapper.atomicAdd(_arr, _index, _delta); - } else { - synchronized (_arr) { - int previous = _arr[_index]; - _arr[_index] += _delta; - return previous; - } - } - } - - /** - * Wait for all kernels in the current group to rendezvous at this call before continuing execution. - * - * @annotion Experimental - */ - - @OpenCLDelegate @Annotations.Experimental protected final void localBarrier() { - try { - localBarrier.await(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (BrokenBarrierException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * Wait for all kernels in the current group to rendezvous at this call before continuing execution. - * - * - * Java version is identical to localBarrier() - * - * @annotion Experimental - * @deprecated - */ - - @OpenCLDelegate @Annotations.Experimental @Deprecated() protected final void globalBarrier() throws DeprecatedException { - throw new DeprecatedException( - "Kernel.globalBarrier() has been deprecated. It was based an incorrect understanding of OpenCL functionality."); - - } - - private KernelRunner kernelRunner = null; - - KernelRunner getKernelRunner() { - return kernelRunner; - } - - /** - * Determine the execution time of the previous Kernel.execute(range) call. - * - * Note that for the first call this will include the conversion time. - * - * @return The time spent executing the kernel (ms) - * - * @see getConversionTime(); - * @see getAccumulatedExectutionTime(); - * - */ - public synchronized long getExecutionTime() { - return (kernelRunner.getExecutionTime()); - } - - /** - * Determine the total execution time of all previous Kernel.execute(range) calls. - * - * Note that this will include the initial conversion time. - * - * @return The total time spent executing the kernel (ms) - * - * @see getExecutionTime(); - * @see getConversionTime(); - * - */ - public synchronized long getAccumulatedExecutionTime() { - return (kernelRunner.getAccumulatedExecutionTime()); - } - - /** - * Determine the time taken to convert bytecode to OpenCL for first Kernel.execute(range) call. - * @return The time spent preparing the kernel for execution using GPU - * - * @see getExecutionTime(); - * @see getAccumulatedExectutionTime(); - */ - public synchronized long getConversionTime() { - return (kernelRunner.getConversionTime()); - } - - /** - * Start execution of _range kernels. - *

- * When kernel.execute(globalSize) is invoked, Aparapi will schedule the execution of globalSize kernels. If the execution mode is GPU then - * the kernels will execute as OpenCL code on the GPU device. Otherwise, if the mode is JTP, the kernels will execute as a pool of Java threads on the CPU. - *

- * @param range The number of Kernels that we would like to initiate. - * @returnThe Kernel instance (this) so we can chain calls to put(arr).execute(range).get(arr) - * - */ - public synchronized Kernel execute(Range _range) { - return (execute(_range, 1)); - } - - /** - * Start execution of _range kernels. - *

- * When kernel.execute(_range) is invoked, Aparapi will schedule the execution of _range kernels. If the execution mode is GPU then - * the kernels will execute as OpenCL code on the GPU device. Otherwise, if the mode is JTP, the kernels will execute as a pool of Java threads on the CPU. - *

- * Since adding the new Range class this method offers backward compatibility and merely defers to return (execute(Range.create(_range), 1));. - * @param _range The number of Kernels that we would like to initiate. - * @returnThe Kernel instance (this) so we can chain calls to put(arr).execute(range).get(arr) - * - */ - public synchronized Kernel execute(int _range) { - return (execute(Range.create(_range), 1)); - } - - /** - * Start execution of _passes iterations of _range kernels. - *

- * When kernel.execute(_range, _passes) is invoked, Aparapi will schedule the execution of _reange kernels. If the execution mode is GPU then - * the kernels will execute as OpenCL code on the GPU device. Otherwise, if the mode is JTP, the kernels will execute as a pool of Java threads on the CPU. - *

- * @param _globalSize The number of Kernels that we would like to initiate. - * @param _passes The number of passes to make - * @return The Kernel instance (this) so we can chain calls to put(arr).execute(range).get(arr) - * - */ - public synchronized Kernel execute(Range _range, int _passes) { - return (execute("run", _range, _passes)); - } - - /** - * Start execution of _passes iterations over the _range of kernels. - *

- * When kernel.execute(_range) is invoked, Aparapi will schedule the execution of _range kernels. If the execution mode is GPU then - * the kernels will execute as OpenCL code on the GPU device. Otherwise, if the mode is JTP, the kernels will execute as a pool of Java threads on the CPU. - *

- * Since adding the new Range class this method offers backward compatibility and merely defers to return (execute(Range.create(_range), 1));. - * @param _range The number of Kernels that we would like to initiate. - * @returnThe Kernel instance (this) so we can chain calls to put(arr).execute(range).get(arr) - * - */ - public synchronized Kernel execute(int _range, int _passes) { - return (execute(Range.create(_range), _passes)); - } - - /** - * Start execution of globalSize kernels for the given entrypoint. - *

- * When kernel.execute("entrypoint", globalSize) is invoked, Aparapi will schedule the execution of globalSize kernels. If the execution mode is GPU then - * the kernels will execute as OpenCL code on the GPU device. Otherwise, if the mode is JTP, the kernels will execute as a pool of Java threads on the CPU. - *

- * @param _entrypoint is the name of the method we wish to use as the entrypoint to the kernel - * @param _globalSize The number of Kernels that we would like to initiate. - * @return The Kernel instance (this) so we can chain calls to put(arr).execute(range).get(arr) - * - */ - public synchronized Kernel execute(Entry _entry, Range _range) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - - } - return (kernelRunner.execute(_entry, _range, 1)); - } - - /** - * Start execution of globalSize kernels for the given entrypoint. - *

- * When kernel.execute("entrypoint", globalSize) is invoked, Aparapi will schedule the execution of globalSize kernels. If the execution mode is GPU then - * the kernels will execute as OpenCL code on the GPU device. Otherwise, if the mode is JTP, the kernels will execute as a pool of Java threads on the CPU. - *

- * @param _entrypoint is the name of the method we wish to use as the entrypoint to the kernel - * @param _globalSize The number of Kernels that we would like to initiate. - * @return The Kernel instance (this) so we can chain calls to put(arr).execute(range).get(arr) - * - */ - public synchronized Kernel execute(String _entrypoint, Range _range) { - return (execute(_entrypoint, _range, 1)); - - } - - /** - * Start execution of globalSize kernels for the given entrypoint. - *

- * When kernel.execute("entrypoint", globalSize) is invoked, Aparapi will schedule the execution of globalSize kernels. If the execution mode is GPU then - * the kernels will execute as OpenCL code on the GPU device. Otherwise, if the mode is JTP, the kernels will execute as a pool of Java threads on the CPU. - *

- * @param _entrypoint is the name of the method we wish to use as the entrypoint to the kernel - * @param _globalSize The number of Kernels that we would like to initiate. - * @return The Kernel instance (this) so we can chain calls to put(arr).execute(range).get(arr) - * - */ - public synchronized Kernel execute(String _entrypoint, Range _range, int _passes) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - - } - return (kernelRunner.execute(_entrypoint, _range, _passes)); - - } - - /** - * Release any resources associated with this Kernel. - *

- * When the execution mode is CPU or GPU, Aparapi stores some OpenCL resources in a data structure associated with the kernel instance. The - * dispose() method must be called to release these resources. - *

- * If execute(int _globalSize) is called after dispose() is called the results are undefined. - */ - public synchronized void dispose() { - if (kernelRunner != null) { - kernelRunner.dispose(); - kernelRunner = null; - } - - } - - /** - * Return the current execution mode. - * - * Before a Kernel executes, this return value will be the execution mode as determined by the setting of - * the EXECUTION_MODE enumeration. By default, this setting is either GPU - * if OpenCL is available on the target system, or JTP otherwise. This default setting can be - * changed by calling setExecutionMode(). - * - *

- * After a Kernel executes, the return value will be the mode in which the Kernel actually executed. - * - * @return The current execution mode. - * - * @see #setExecutionMode(EXECUTION_MODE) - */ - public EXECUTION_MODE getExecutionMode() { - return (executionMode); - } - - /** - * Set the execution mode. - *

- * This should be regarded as a request. The real mode will be determined at runtime based on the availability of OpenCL and the characteristics of the workload. - * - * @param _executionMode the requested execution mode. - * - * @see #getExecutionMode() - */ - public void setExecutionMode(EXECUTION_MODE _executionMode) { - executionMode = _executionMode; - } - - void setFallbackExecutionMode() { - executionMode = EXECUTION_MODE.getFallbackExecutionMode(); - - } - - final static Map typeToLetterMap = new HashMap(); - - static { - // only primitive types for now - typeToLetterMap.put("double", "D"); - typeToLetterMap.put("float", "F"); - typeToLetterMap.put("int", "I"); - typeToLetterMap.put("long", "J"); - typeToLetterMap.put("boolean", "Z"); - typeToLetterMap.put("byte", "B"); - typeToLetterMap.put("char", "C"); - typeToLetterMap.put("short", "S"); - typeToLetterMap.put("void", "V"); - } - - private static String descriptorToReturnTypeLetter(String desc) { - // find the letter after the closed parenthesis - return desc.substring(desc.lastIndexOf(')') + 1); - } - - private static String getReturnTypeLetter(Method meth) { - Class retClass = meth.getReturnType(); - String strRetClass = retClass.toString(); - String mapping = typeToLetterMap.get(strRetClass); - // System.out.println("strRetClass = <" + strRetClass + ">, mapping = " + mapping); - return mapping; - } - - static String getMappedMethodName(MethodReferenceEntry _methodReferenceEntry) { - String mappedName = null; - String name = _methodReferenceEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8(); - for (Method kernelMethod : Kernel.class.getDeclaredMethods()) { - if (kernelMethod.isAnnotationPresent(OpenCLMapping.class)) { - // ultimately, need a way to constrain this based upon signature (to disambiguate abs(float) from abs(int); - // for Alpha, we will just disambiguate based on the return type - if (false) { - System.out.println("kernelMethod is ... " + kernelMethod.toGenericString()); - System.out.println("returnType = " + kernelMethod.getReturnType()); - System.out.println("returnTypeLetter = " + getReturnTypeLetter(kernelMethod)); - System.out.println("kernelMethod getName = " + kernelMethod.getName()); - System.out.println("methRefName = " + name + " descriptor = " - + _methodReferenceEntry.getNameAndTypeEntry().getDescriptorUTF8Entry().getUTF8()); - System.out - .println("descToReturnTypeLetter = " - + descriptorToReturnTypeLetter(_methodReferenceEntry.getNameAndTypeEntry().getDescriptorUTF8Entry() - .getUTF8())); - } - if (_methodReferenceEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8().equals(kernelMethod.getName()) - && descriptorToReturnTypeLetter(_methodReferenceEntry.getNameAndTypeEntry().getDescriptorUTF8Entry().getUTF8()) - .equals(getReturnTypeLetter(kernelMethod))) { - OpenCLMapping annotation = kernelMethod.getAnnotation(OpenCLMapping.class); - String mapTo = annotation.mapTo(); - if (!mapTo.equals("")) { - mappedName = mapTo; - // System.out.println("mapTo = " + mapTo); - } - } - } - } - // System.out.println("... in getMappedMethodName, returning = " + mappedName); - return (mappedName); - } - - static boolean isMappedMethod(MethodReferenceEntry methodReferenceEntry) { - boolean isMapped = false; - for (Method kernelMethod : Kernel.class.getDeclaredMethods()) { - if (kernelMethod.isAnnotationPresent(OpenCLMapping.class)) { - if (methodReferenceEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8().equals(kernelMethod.getName())) { - - // well they have the same name ;) - isMapped = true; - } - } - } - return (isMapped); - } - - static boolean isOpenCLDelegateMethod(MethodReferenceEntry methodReferenceEntry) { - boolean isMapped = false; - for (Method kernelMethod : Kernel.class.getDeclaredMethods()) { - if (kernelMethod.isAnnotationPresent(OpenCLDelegate.class)) { - if (methodReferenceEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8().equals(kernelMethod.getName())) { - - // well they have the same name ;) - isMapped = true; - } - } - } - return (isMapped); - } - - static boolean usesAtomic32(MethodReferenceEntry methodReferenceEntry) { - for (Method kernelMethod : Kernel.class.getDeclaredMethods()) { - if (kernelMethod.isAnnotationPresent(OpenCLMapping.class)) { - if (methodReferenceEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8().equals(kernelMethod.getName())) { - OpenCLMapping annotation = kernelMethod.getAnnotation(OpenCLMapping.class); - return annotation.atomic32(); - } - } - } - return (false); - } - - // For alpha release atomic64 is not supported - static boolean usesAtomic64(MethodReferenceEntry methodReferenceEntry) { - //for (java.lang.reflect.Method kernelMethod : Kernel.class.getDeclaredMethods()) { - // if (kernelMethod.isAnnotationPresent(Kernel.OpenCLMapping.class)) { - // if (methodReferenceEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8().equals(kernelMethod.getName())) { - // OpenCLMapping annotation = kernelMethod.getAnnotation(Kernel.OpenCLMapping.class); - // return annotation.atomic64(); - // } - // } - //} - return (false); - } - - // the flag useNullForLocalSize is useful for testing that what we compute for localSize is what OpenCL - // would also compute if we passed in null. In non-testing mode, we just call execute with the - // same localSize that we computed in getLocalSizeJNI. We don't want do publicize these of course. - // GRF we can't access this from test classes without exposing in in javadoc so I left the flag but made the test/set of the flag reflectively - boolean useNullForLocalSize = false; - - // Explicit memory management API's follow - - /** - * For dev purposes (we should remove this for production) allow us to define that this Kernel uses explicit memory management - * @param _explicit (true if we want explicit memory management) - */ - public void setExplicit(boolean _explicit) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - - } - kernelRunner.setExplicit(_explicit); - } - - /** - * For dev purposes (we should remove this for production) determine whether this Kernel uses explicit memory management - * @return (true if we kernel is using explicit memory management) - */ - public boolean isExplicit() { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - - } - return (kernelRunner.isExplicit()); - } - - /** - * Tag this array so that it is explicitly enqueued before the kernel is executed - * @param array - * @return This kernel so that we can use the 'fluent' style API - */ - public Kernel put(long[] array) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - - } - kernelRunner.put(array); - return (this); - } - - /** - * Tag this array so that it is explicitly enqueued before the kernel is executed - * @param array - * @return This kernel so that we can use the 'fluent' style API - */ - public Kernel put(double[] array) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - - } - kernelRunner.put(array); - return (this); - } - - /** - * Tag this array so that it is explicitly enqueued before the kernel is executed - * @param array - * @return This kernel so that we can use the 'fluent' style API - */ - public Kernel put(float[] array) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - - } - kernelRunner.put(array); - return (this); - } - - /** - * Tag this array so that it is explicitly enqueued before the kernel is executed - * @param array - * @return This kernel so that we can use the 'fluent' style API - */ - public Kernel put(int[] array) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - - } - kernelRunner.put(array); - return (this); - } - - /** - * Tag this array so that it is explicitly enqueued before the kernel is executed - * @param array - * @return This kernel so that we can use the 'fluent' style API - */ - public Kernel put(byte[] array) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - - } - kernelRunner.put(array); - return (this); - } - - /** - * Tag this array so that it is explicitly enqueued before the kernel is executed - * @param array - * @return This kernel so that we can use the 'fluent' style API - */ - public Kernel put(char[] array) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - } - kernelRunner.put(array); - return (this); - } - - /** - * Tag this array so that it is explicitly enqueued before the kernel is executed - * @param array - * @return This kernel so that we can use the 'fluent' style API - */ - public Kernel put(boolean[] array) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - } - kernelRunner.put(array); - return (this); - } - - /** - * Enqueue a request to return this buffer from the GPU. This method blocks until the array is available. - * @param array - * @return This kernel so that we can use the 'fluent' style API - */ - public Kernel get(long[] array) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - - } - kernelRunner.get(array); - return (this); - } - - /** - * Enqueue a request to return this buffer from the GPU. This method blocks until the array is available. - * @param array - * @return This kernel so that we can use the 'fluent' style API - */ - public Kernel get(double[] array) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - - } - kernelRunner.get(array); - return (this); - } - - /** - * Enqueue a request to return this buffer from the GPU. This method blocks until the array is available. - * @param array - * @return This kernel so that we can use the 'fluent' style API - */ - public Kernel get(float[] array) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - - } - kernelRunner.get(array); - return (this); - } - - /** - * Enqueue a request to return this buffer from the GPU. This method blocks until the array is available. - * @param array - * @return This kernel so that we can use the 'fluent' style API - */ - public Kernel get(int[] array) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - - } - kernelRunner.get(array); - return (this); - } - - /** - * Enqueue a request to return this buffer from the GPU. This method blocks until the array is available. - * @param array - * @return This kernel so that we can use the 'fluent' style API - */ - public Kernel get(byte[] array) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - - } - kernelRunner.get(array); - return (this); - } - - /** - * Enqueue a request to return this buffer from the GPU. This method blocks until the array is available. - * @param array - * @return This kernel so that we can use the 'fluent' style API - */ - public Kernel get(char[] array) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - - } - kernelRunner.get(array); - return (this); - } - - /** - * Enqueue a request to return this buffer from the GPU. This method blocks until the array is available. - * @param array - * @return This kernel so that we can use the 'fluent' style API - */ - public Kernel get(boolean[] array) { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - - } - kernelRunner.get(array); - return (this); - } - - /** - * Get the profiling information from the last successful call to Kernel.execute(). - * @return A list of ProfileInfo records - */ - public List getProfileInfo() { - if (kernelRunner == null) { - kernelRunner = new KernelRunner(this); - } - return (kernelRunner.getProfileInfo()); - } - - private LinkedHashSet executionModes = EXECUTION_MODE.getDefaultExecutionModes(); - - private Iterator currentMode = executionModes.iterator(); - - private EXECUTION_MODE executionMode = currentMode.next(); - - /** - * set possible fallback path for execution modes. - * for example setExecutionFallbackPath(GPU,CPU,JTP) will try to use the GPU - * if it fails it will fall back to OpenCL CPU and finally it will try JTP. - */ - public void addExecutionModes(EXECUTION_MODE... platforms) { - executionModes.addAll(Arrays.asList(platforms)); - currentMode = executionModes.iterator(); - executionMode = currentMode.next(); - } - - /** - * @return is there another execution path we can try - */ - public boolean hasNextExecutionMode() { - return currentMode.hasNext(); - } - - /** - * try the next execution path in the list if there aren't any more than give up - */ - public void tryNextExecutionMode() { - if (currentMode.hasNext()) { - executionMode = currentMode.next(); - } - } - -} diff --git a/com.amd.aparapi/src/java/com/amd/aparapi/KernelRunner.java b/com.amd.aparapi/src/java/com/amd/aparapi/KernelRunner.java index 8091cf52..a719853c 100644 --- a/com.amd.aparapi/src/java/com/amd/aparapi/KernelRunner.java +++ b/com.amd.aparapi/src/java/com/amd/aparapi/KernelRunner.java @@ -37,22 +37,38 @@ to national security controls as identified on the Commerce Control List (curren */ package com.amd.aparapi; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +//import java.lang.invoke.InnerClassLambdaMetafactory; +import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.nio.ByteBuffer; import java.nio.ByteOrder; +import java.util.Arrays; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.StringTokenizer; import java.util.concurrent.BrokenBarrierException; import java.util.concurrent.CyclicBarrier; +import java.util.function.IntBlock; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.BrokenBarrierException; + +import com.amd.aparapi.ClassModel.ConstantPool.MethodEntry; +import com.amd.aparapi.ClassModel.ConstantPool.MethodReferenceEntry; +import com.amd.aparapi.InstructionSet.AccessField; +import com.amd.aparapi.InstructionSet.MethodCall; +import com.amd.aparapi.InstructionSet.VirtualMethodCall; import com.amd.aparapi.InstructionSet.TypeSpec; -import com.amd.aparapi.Kernel.EXECUTION_MODE; +//import com.amd.aparapi.Kernel.EXECUTION_MODE; /** * The class is responsible for executing Kernel implementations.
@@ -214,7 +230,7 @@ class KernelRunner{ * * @author gfrost */ - @Annotations.Experimental @UsedByJNICode public static final int ARG_LOCAL = 1 << 11; + @UsedByJNICode public static final int ARG_LOCAL = 1 << 11; /** * This 'bit' indicates that a particular KernelArg resides in global memory in the generated OpenCL code.
@@ -226,7 +242,7 @@ class KernelRunner{ * * @author gfrost */ - @Annotations.Experimental @UsedByJNICode public static final int ARG_GLOBAL = 1 << 12; + @UsedByJNICode public static final int ARG_GLOBAL = 1 << 12; /** * This 'bit' indicates that a particular KernelArg resides in constant memory in the generated OpenCL code.
@@ -238,7 +254,7 @@ class KernelRunner{ * * @author gfrost */ - @Annotations.Experimental @UsedByJNICode public static final int ARG_CONSTANT = 1 << 13; + @UsedByJNICode public static final int ARG_CONSTANT = 1 << 13; /** * This 'bit' indicates that a particular KernelArg has it's length reference, in which case a synthetic arg is passed (name mangled) to the OpenCL kernel.
@@ -484,9 +500,17 @@ static class KernelArg{ @UsedByJNICode public Object array; /** - * Field in Kernel class corresponding to this arg + * Field in fieldHolder object corresponding to this arg */ @UsedByJNICode public Field field; + + /** + * Field in fieldHolder object corresponding to this arg + * For lambda use, args come from Block, KernelRunner and the + * lambda's own object + */ + @UsedByJNICode public Object fieldHolder; + /** * The byte array for obj conversion passed to opencl @@ -515,10 +539,176 @@ static class KernelArg{ */ int primitiveSize; } + + + enum MappedMethod { + ACOS("acos", "D"), + COS("cos", "D"), + MAX_I("max", "I"), + MAX_J("max", "J"), + MAX_F("max", "F"), + MAX_D("max", "D"), + MIN_I("min", "I"), + SQRT("sqrt", "D"); + + private String mapping; + private String returnType; + + private MappedMethod(String name, String ret) { + mapping = name; + returnType = ret; + } + public String getName() { return mapping; } + public String getReturnType() { return returnType; } + }; + + static boolean isMappedMethod(MethodReferenceEntry methodReferenceEntry) { + boolean isMapped = false; + for (MappedMethod mappedMethod : MappedMethod.values()) { + if (methodReferenceEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8().equals(mappedMethod.getName())) { + + // well they have the same name ;) + isMapped = true; + } + } + + return (isMapped); + } + + private static String descriptorToReturnTypeLetter(String desc) { + // find the letter after the closed parenthesis + return desc.substring(desc.lastIndexOf(')') + 1); + } + + static String getMappedMethodName(MethodReferenceEntry _methodReferenceEntry) { + String mappedName = null; + String name = _methodReferenceEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8(); + for (MappedMethod mappedMethod : MappedMethod.values()) { + if (_methodReferenceEntry.getNameAndTypeEntry().getNameUTF8Entry().getUTF8().equals(mappedMethod.getName()) + && descriptorToReturnTypeLetter(_methodReferenceEntry.getNameAndTypeEntry().getDescriptorUTF8Entry().getUTF8()) + .equals(mappedMethod.getReturnType())) { + String mapTo = mappedMethod.getName(); + if (!mapTo.equals("")) { + mappedName = mapTo; + } + } + } + if (logger.isLoggable(Level.FINE)) { + logger.fine("Selected mapped method " + mappedName); + } + return (mappedName); + } + + + class LambdaKernelCall { + IntBlock block; + String lambdaKernelSource; + String lambdaMethodName; + Field[] lambdaCapturedFields; + Object[] lambdaCapturedArgs; + String lambdaMethodSignature; + + public String getLambdaKernelSource() { return lambdaKernelSource; } + public Object getLambdaKernelThis() { return lambdaCapturedArgs[0]; } + public String getLambdaMethodName() { return lambdaMethodName; } + public String getLambdaMethodSignature() { return lambdaMethodSignature; } + //public Object[] getLambdaCapturedArgs() { return lambdaCapturedArgs; } + //public Object[] getLambdaReferenceArgs() { return lambdaReferencedFields; } + + public String toString() { return getLambdaKernelThis().getClass().getName() + " " + + getLambdaMethodName() + " " + getLambdaMethodSignature() + " from block: " + + block; + } + + public Field[] getLambdaCapturedFields() { return lambdaCapturedFields; } + + public LambdaKernelCall(IntBlock _block) throws AparapiException { + block = _block; + + // Try to do reflection on the block + Class bc = block.getClass(); + System.out.println("# block class:" + bc); + + // The first field is "this" for the lambda call if the lambda + // is not static, the later fields are captured values which will + // become lambda call parameters + Field[] bcf = bc.getDeclaredFields(); + lambdaCapturedArgs = new Object[bcf.length]; + + Field[] allBlockClassFields = block.getClass().getDeclaredFields(); + + Field[] capturedFieldsWithoutThis = new Field[ allBlockClassFields.length - 1 ]; + for(int i=1; i acceptCallSites = acceptModel.getMethodCalls(); + assert acceptCallSites.size() == 1 : "Should only have one call site in this method"; + + + //VirtualMethodCall vCall = (VirtualMethodCall) acceptCallSites.get(0); + MethodCall vCall = acceptCallSites.get(0); + MethodEntry lambdaCallTarget = vCall.getConstantPoolMethodEntry(); + lambdaMethodName = lambdaCallTarget.getNameAndTypeEntry().getNameUTF8Entry().getUTF8(); + lambdaMethodSignature = lambdaCallTarget.getNameAndTypeEntry().getDescriptorUTF8Entry().getUTF8(); + + System.out.println("call target = " + + lambdaCallTarget.getClassEntry().getNameUTF8Entry().getUTF8() + + " " + lambdaMethodName + " " + lambdaMethodSignature); + + String lcNameWithSlashes = lc.getName().replace('.', '/'); + assert lcNameWithSlashes.equals(lambdaCallTarget.getClassEntry().getNameUTF8Entry().getUTF8()) : + "lambda target class name does not match arg in block object"; + + } + } + + private LambdaKernelCall lambdaKernelCall; private long jniContextHandle = 0; - private Kernel kernel; +// private Kernel kernel; private Entrypoint entryPoint; @@ -529,20 +719,35 @@ static class KernelArg{ * * @param _kernel */ - KernelRunner(Kernel _kernel) { - kernel = _kernel; - +// KernelRunner(Kernel _kernel) { +// kernel = _kernel; +// +// } + +// KernelRunner() { +// kernel = null; +// } + + KernelRunner(IntBlock block) throws AparapiException { + //kernel = null; + lambdaKernelCall = new LambdaKernelCall(block); + if (logger.isLoggable(Level.INFO)) { + logger.info("New lambda call is = " + lambdaKernelCall); + } } - + /** * Kernel.dispose() delegates to KernelRunner.dispose() which delegates to disposeJNI() to actually close JNI data structures.
* * @see KernelRunner#disposeJNI() */ void dispose() { - if (kernel.getExecutionMode().isOpenCL()) { - disposeJNI(jniContextHandle); - } + + // Might need to revisit this for Superbowl + +// if (kernel.getExecutionMode().isOpenCL()) { +// disposeJNI(jniContextHandle); +// } } /** @@ -556,12 +761,14 @@ void dispose() { * @param maxJTPLocalSize * @return */ - @Annotations.DocMe private native static synchronized long initJNI(Kernel _kernel, OpenCLDevice device, int _flags); + private native static synchronized long initJNI(Object _kernel, OpenCLDevice device, int _flags); private native long buildProgramJNI(long _jniContextHandle, String _source); private native int setArgsJNI(long _jniContextHandle, KernelArg[] _args, int argc); + private native int updateLambdaBlockJNI(long _jniContextHandle, Object newHolder, int argc); + private native int runKernelJNI(long _jniContextHandle, Range _range, boolean _needSync, int _passes); private native int disposeJNI(long _jniContextHandle); @@ -670,270 +877,6 @@ boolean hasGLSharingSupport() { return capabilitiesSet.contains(CL_KHR_GL_SHARING); } - /** - * Execute using a Java thread pool. Either because we were explicitly asked to do so, or because we 'fall back' after discovering an OpenCL issue. - * - * @param _globalSize - * The globalSize requested by the user (via Kernel.execute(globalSize)) - * @param _passes - * The # of passes requested by the user (via Kernel.execute(globalSize, passes)). Note this is usually defaulted to 1 via Kernel.execute(globalSize). - * @return - */ - private long executeJava(final Range _range, final int _passes) { - if (logger.isLoggable(Level.FINE)) { - logger.fine("executeJava: range = " + _range); - } - - if (kernel.getExecutionMode().equals(EXECUTION_MODE.SEQ)) { - - /** - * SEQ mode is useful for testing trivial logic, but kernels which use SEQ mode cannot be used if the - * product of localSize(0..3) is >1. So we can use multi-dim ranges but only if the local size is 1 in all dimensions. - * - * As a result of this barrier is only ever 1 work item wide and probably should be turned into a no-op. - * - * So we need to check if the range is valid here. If not we have no choice but to punt. - */ - if (_range.getLocalSize(0) * _range.getLocalSize(1) * _range.getLocalSize(2) > 1) { - throw new IllegalStateException("Can't run range with group size >1 sequentially. Barriers would deadlock!"); - } - - Kernel kernelClone = (Kernel) kernel.clone(); - kernelClone.range = _range; - kernelClone.groupId[0] = 0; - kernelClone.groupId[1] = 0; - kernelClone.groupId[2] = 0; - kernelClone.localId[0] = 0; - kernelClone.localId[1] = 0; - kernelClone.localId[2] = 0; - kernelClone.localBarrier = new CyclicBarrier(1); - for (kernelClone.passId = 0; kernelClone.passId < _passes; kernelClone.passId++) { - - if (_range.getDims() == 1) { - for (int id = 0; id < _range.getGlobalSize(0); id++) { - kernelClone.globalId[0] = id; - kernelClone.run(); - } - } else if (_range.getDims() == 2) { - for (int x = 0; x < _range.getGlobalSize(0); x++) { - kernelClone.globalId[0] = x; - for (int y = 0; y < _range.getGlobalSize(1); y++) { - kernelClone.globalId[1] = y; - kernelClone.run(); - } - } - } else if (_range.getDims() == 3) { - for (int x = 0; x < _range.getGlobalSize(0); x++) { - kernelClone.globalId[0] = x; - for (int y = 0; y < _range.getGlobalSize(1); y++) { - kernelClone.globalId[1] = y; - for (int z = 0; z < _range.getGlobalSize(2); z++) { - kernelClone.globalId[2] = z; - kernelClone.run(); - } - kernelClone.run(); - } - } - } - } - - } else { - - final int threads = _range.getLocalSize(0) * _range.getLocalSize(1) * _range.getLocalSize(2); - final int globalGroups = _range.getNumGroups(0) * _range.getNumGroups(1) * _range.getNumGroups(2); - final Thread threadArray[] = new Thread[threads]; - /** - * This joinBarrier is the barrier that we provide for the kernel threads to rendezvous with the current dispatch thread. - * So this barrier is threadCount+1 wide (the +1 is for the dispatch thread) - */ - final CyclicBarrier joinBarrier = new CyclicBarrier(threads + 1); - - /** - * This localBarrier is only ever used by the kernels. If the kernel does not use the barrier the threads - * can get out of sync, we promised nothing in JTP mode. - * - * As with OpenCL all threads within a group must wait at the barrier or none. It is a user error (possible deadlock!) - * if the barrier is in a conditional that is only executed by some of the threads within a group. - * - * Kernel developer must understand this. - * - * This barrier is threadCount wide. We never hit the barrier from the dispatch thread. - */ - final CyclicBarrier localBarrier = new CyclicBarrier(threads); - for (int passId = 0; passId < _passes; passId++) { - - /** - * Note that we emulate OpenCL by creating one thread per localId (across the group). - * - * So threadCount == range.getLocalSize(0)*range.getLocalSize(1)*range.getLocalSize(2); - * - * For a 1D range of 12 groups of 4 we create 4 threads. One per localId(0). - * - * We also clone the kernel 4 times. One per thread. - * - * We create local barrier which has a width of 4 - * - * Thread-0 handles localId(0) (global 0,4,8) - * Thread-1 handles localId(1) (global 1,5,7) - * Thread-2 handles localId(2) (global 2,6,10) - * Thread-3 handles localId(3) (global 3,7,11) - * - * This allows all threads to synchronize using the local barrier. - * - * Initially the use of local buffers seems broken as the buffers appears to be per Kernel. - * Thankfully Kernel.clone() performs a shallow clone of all buffers (local and global) - * So each of the cloned kernels actually still reference the same underlying local/global buffers. - * - * If the kernel uses local buffers but does not use barriers then it is possible for different groups - * to see mutations from each other (unlike OpenCL), however if the kernel does not us barriers then it - * cannot assume any coherence in OpenCL mode either (the failure mode will be different but still wrong) - * - * So even JTP mode use of local buffers will need to use barriers. Not for the same reason as OpenCL but to keep groups in lockstep. - * - **/ - - for (int id = 0; id < threads; id++) { - final int threadId = id; - - /** - * We clone one kernel for each thread. - * - * They will all share references to the same range, localBarrier and global/local buffers because the clone is shallow. - * We need clones so that each thread can assign 'state' (localId/globalId/groupId) without worrying - * about other threads. - */ - final Kernel kernelClone = (Kernel) kernel.clone(); - kernelClone.range = _range; - kernelClone.localBarrier = localBarrier; - kernelClone.passId = passId; - - threadArray[threadId] = new Thread(new Runnable(){ - @Override public void run() { - for (int globalGroupId = 0; globalGroupId < globalGroups; globalGroupId++) { - - if (_range.getDims() == 1) { - kernelClone.localId[0] = threadId % _range.getLocalSize(0); - kernelClone.globalId[0] = threadId + globalGroupId * threads; - kernelClone.groupId[0] = globalGroupId; - } else if (_range.getDims() == 2) { - - /** - * Consider a 12x4 grid of 4*2 local groups - *

-                            *                                             threads = 4*2 = 8
-                            *                                             localWidth=4
-                            *                                             localHeight=2
-                            *                                             globalWidth=12
-                            *                                             globalHeight=4
-                            * 
-                            *    00 01 02 03 | 04 05 06 07 | 08 09 10 11  
-                            *    12 13 14 15 | 16 17 18 19 | 20 21 22 23
-                            *    ------------+-------------+------------
-                            *    24 25 26 27 | 28 29 30 31 | 32 33 34 35
-                            *    36 37 38 39 | 40 41 42 43 | 44 45 46 47  
-                            *    
-                            *    00 01 02 03 | 00 01 02 03 | 00 01 02 03  threadIds : [0..7]*6
-                            *    04 05 06 07 | 04 05 06 07 | 04 05 06 07
-                            *    ------------+-------------+------------
-                            *    00 01 02 03 | 00 01 02 03 | 00 01 02 03
-                            *    04 05 06 07 | 04 05 06 07 | 04 05 06 07  
-                            *    
-                            *    00 00 00 00 | 01 01 01 01 | 02 02 02 02  groupId[0] : 0..6 
-                            *    00 00 00 00 | 01 01 01 01 | 02 02 02 02   
-                            *    ------------+-------------+------------
-                            *    00 00 00 00 | 01 01 01 01 | 02 02 02 02  
-                            *    00 00 00 00 | 01 01 01 01 | 02 02 02 02
-                            *    
-                            *    00 00 00 00 | 00 00 00 00 | 00 00 00 00  groupId[1] : 0..6 
-                            *    00 00 00 00 | 00 00 00 00 | 00 00 00 00   
-                            *    ------------+-------------+------------
-                            *    01 01 01 01 | 01 01 01 01 | 01 01 01 01 
-                            *    01 01 01 01 | 01 01 01 01 | 01 01 01 01
-                            *         
-                            *    00 01 02 03 | 08 09 10 11 | 16 17 18 19  globalThreadIds == threadId + groupId * threads;
-                            *    04 05 06 07 | 12 13 14 15 | 20 21 22 23
-                            *    ------------+-------------+------------
-                            *    24 25 26 27 | 32[33]34 35 | 40 41 42 43
-                            *    28 29 30 31 | 36 37 38 39 | 44 45 46 47   
-                            *          
-                            *    00 01 02 03 | 00 01 02 03 | 00 01 02 03  localX = threadId % localWidth; (for globalThreadId 33 = threadId = 01 : 01%4 =1)
-                            *    00 01 02 03 | 00 01 02 03 | 00 01 02 03   
-                            *    ------------+-------------+------------
-                            *    00 01 02 03 | 00[01]02 03 | 00 01 02 03 
-                            *    00 01 02 03 | 00 01 02 03 | 00 01 02 03
-                            *     
-                            *    00 00 00 00 | 00 00 00 00 | 00 00 00 00  localY = threadId /localWidth  (for globalThreadId 33 = threadId = 01 : 01/4 =0)
-                            *    01 01 01 01 | 01 01 01 01 | 01 01 01 01   
-                            *    ------------+-------------+------------
-                            *    00 00 00 00 | 00[00]00 00 | 00 00 00 00 
-                            *    01 01 01 01 | 01 01 01 01 | 01 01 01 01
-                            *     
-                            *    00 01 02 03 | 04 05 06 07 | 08 09 10 11  globalX=
-                            *    00 01 02 03 | 04 05 06 07 | 08 09 10 11     groupsPerLineWidth=globalWidth/localWidth (=12/4 =3)
-                            *    ------------+-------------+------------     groupInset =groupId%groupsPerLineWidth (=4%3 = 1)
-                            *    00 01 02 03 | 04[05]06 07 | 08 09 10 11 
-                            *    00 01 02 03 | 04 05 06 07 | 08 09 10 11     globalX = groupInset*localWidth+localX (= 1*4+1 = 5)
-                            *     
-                            *    00 00 00 00 | 00 00 00 00 | 00 00 00 00  globalY
-                            *    01 01 01 01 | 01 01 01 01 | 01 01 01 01      
-                            *    ------------+-------------+------------
-                            *    02 02 02 02 | 02[02]02 02 | 02 02 02 02 
-                            *    03 03 03 03 | 03 03 03 03 | 03 03 03 03
-                            *    
-                            * 
- * Assume we are trying to locate the id's for #33 - * - */ - - kernelClone.localId[0] = threadId % _range.getLocalSize(0); // threadId % localWidth = (for 33 = 1 % 4 = 1) - kernelClone.localId[1] = threadId / _range.getLocalSize(0); // threadId / localWidth = (for 33 = 1 / 4 == 0) - - int groupInset = globalGroupId % _range.getNumGroups(0); // 4%3 = 1 - kernelClone.globalId[0] = groupInset * _range.getLocalSize(0) + kernelClone.localId[0]; // 1*4+1=5 - - int completeLines = (globalGroupId / _range.getNumGroups(0)) * _range.getLocalSize(1);// (4/3) * 2 - kernelClone.globalId[1] = completeLines + kernelClone.localId[1]; // 2+0 = 2 - kernelClone.groupId[0] = globalGroupId % _range.getNumGroups(0); - kernelClone.groupId[1] = globalGroupId / _range.getNumGroups(0); - } else if (_range.getDims() == 3) { - - //Same as 2D actually turns out that localId[0] is identical for all three dims so could be hoisted out of conditional code - - kernelClone.localId[0] = threadId % _range.getLocalSize(0); - - kernelClone.localId[1] = (threadId / _range.getLocalSize(0)) % _range.getLocalSize(1); - - // the thread id's span WxHxD so threadId/(WxH) should yield the local depth - kernelClone.localId[2] = threadId / (_range.getLocalSize(0) * _range.getLocalSize(1)); - - kernelClone.globalId[0] = (globalGroupId % _range.getNumGroups(0)) * _range.getLocalSize(0) - + kernelClone.localId[0]; - - kernelClone.globalId[1] = ((globalGroupId / _range.getNumGroups(0)) * _range.getLocalSize(1)) - % _range.getGlobalSize(1) + kernelClone.localId[1]; - - kernelClone.globalId[2] = (globalGroupId / (_range.getNumGroups(0) * _range.getNumGroups(1))) - * _range.getLocalSize(2) + kernelClone.localId[2]; - - kernelClone.groupId[0] = globalGroupId % _range.getNumGroups(0); - kernelClone.groupId[1] = (globalGroupId / _range.getNumGroups(0)) % _range.getNumGroups(1); - kernelClone.groupId[2] = globalGroupId / (_range.getNumGroups(0) * _range.getNumGroups(1)); - } - kernelClone.run(); - - } - await(joinBarrier); // This thread will rendezvous with dispatch thread here. This is effectively a join. - } - }); - threadArray[threadId].setName("aparapi-" + threadId + "/" + threads); - threadArray[threadId].start(); - - } - await(joinBarrier); // This dispatch thread waits for all worker threads here. - } - } // execution mode == JTP - return 0; - } private static void await(CyclicBarrier _barrier) { try { @@ -990,7 +933,7 @@ private boolean prepareOopConversionBuffer(KernelArg arg) throws AparapiExceptio int objArraySize = 0; Object newRef = null; try { - newRef = arg.field.get(kernel); + newRef = arg.field.get(arg.fieldHolder); objArraySize = Array.getLength(newRef); } catch (IllegalAccessException e) { throw new AparapiException(e); @@ -1109,7 +1052,7 @@ private void extractOopConversionBuffer(KernelArg arg) throws AparapiException { int objArraySize = 0; try { - objArraySize = Array.getLength(arg.field.get(kernel)); + objArraySize = Array.getLength(arg.field.get(arg.fieldHolder)); } catch (IllegalAccessException e) { throw new AparapiException(e); } @@ -1209,7 +1152,7 @@ private void restoreObjects() throws AparapiException { } } - private boolean updateKernelArrayRefs() throws AparapiException { + private boolean updateKernelArrayRefs(Object lambdaObject) throws AparapiException { boolean needsSync = false; for (int i = 0; i < argc; i++) { @@ -1217,7 +1160,7 @@ private boolean updateKernelArrayRefs() throws AparapiException { try { if ((arg.type & ARG_ARRAY) != 0) { Object newArrayRef; - newArrayRef = arg.field.get(kernel); + newArrayRef = arg.field.get(lambdaObject); if (newArrayRef == null) { throw new IllegalStateException("Cannot send null refs to kernel, reverting to java"); @@ -1256,104 +1199,203 @@ private boolean updateKernelArrayRefs() throws AparapiException { return needsSync; } - // private int numAvailableProcessors = Runtime.getRuntime().availableProcessors(); - - private Kernel executeOpenCL(final String _entrypointName, final Range _range, final int _passes) throws AparapiException { - /* - if (_range.getDims() > getMaxWorkItemDimensionsJNI(jniContextHandle)) { - throw new RangeException("Range dim size " + _range.getDims() + " > device " - + getMaxWorkItemDimensionsJNI(jniContextHandle)); - } - if (_range.getWorkGroupSize() > getMaxWorkGroupSizeJNI(jniContextHandle)) { - throw new RangeException("Range workgroup size " + _range.getWorkGroupSize() + " > device " - + getMaxWorkGroupSizeJNI(jniContextHandle)); - } - - if (_range.getGlobalSize(0) > getMaxWorkItemSizeJNI(jniContextHandle, 0)) { - throw new RangeException("Range globalsize 0 " + _range.getGlobalSize(0) + " > device " - + getMaxWorkItemSizeJNI(jniContextHandle, 0)); - } - if (_range.getDims() > 1) { - if (_range.getGlobalSize(1) > getMaxWorkItemSizeJNI(jniContextHandle, 1)) { - throw new RangeException("Range globalsize 1 " + _range.getGlobalSize(1) + " > device " - + getMaxWorkItemSizeJNI(jniContextHandle, 1)); - } - if (_range.getDims() > 2) { - if (_range.getGlobalSize(2) > getMaxWorkItemSizeJNI(jniContextHandle, 2)) { - throw new RangeException("Range globalsize 2 " + _range.getGlobalSize(2) + " > device " - + getMaxWorkItemSizeJNI(jniContextHandle, 2)); - } - } - } +// /** +// * There is a new Block for each invocation of the lambda +// * @param callerBlock +// */ +// private void updateCallerBlockParams(Object callerBlock) { +// currentCallerBlock = callerBlock; +// for(int i=0; i type = field.getType(); + if (type.isArray()) { + + + // None of this is used with Lambda kernels + +// if (field.getAnnotation(com.amd.aparapi.Kernel.Local.class) != null +// || currArg.name.endsWith(Kernel.LOCAL_SUFFIX)) { +// currArg.type |= ARG_LOCAL; +// } else if (field.getAnnotation(com.amd.aparapi.Kernel.Constant.class) != null +// || currArg.name.endsWith(Kernel.CONSTANT_SUFFIX)) { +// currArg.type |= ARG_CONSTANT; +// } else { +// currArg.type |= ARG_GLOBAL; +// } + currArg.type |= ARG_GLOBAL; - synchronized private Kernel fallBackAndExecute(String _entrypointName, final Range _range, final int _passes) { - if (kernel.hasNextExecutionMode()) { - kernel.tryNextExecutionMode(); - } else { - kernel.setFallbackExecutionMode(); + currArg.array = null; // will get updated in updateKernelArrayRefs + currArg.type |= ARG_ARRAY; + +// if (isExplicit()) { +// currArg.type |= ARG_EXPLICIT; +// } + + // for now, treat all write arrays as read-write, see bugzilla issue 4859 + // we might come up with a better solution later + currArg.type |= entryPoint.getArrayFieldAssignments().contains(field.getName()) ? (ARG_WRITE | ARG_READ) + : 0; + currArg.type |= entryPoint.getArrayFieldAccesses().contains(field.getName()) ? ARG_READ : 0; + // currArg.type |= ARG_GLOBAL; + currArg.type |= type.isAssignableFrom(float[].class) ? ARG_FLOAT : 0; + + currArg.type |= type.isAssignableFrom(int[].class) ? ARG_INT : 0; + + currArg.type |= type.isAssignableFrom(boolean[].class) ? ARG_BOOLEAN : 0; + + currArg.type |= type.isAssignableFrom(byte[].class) ? ARG_BYTE : 0; + + currArg.type |= type.isAssignableFrom(char[].class) ? ARG_CHAR : 0; + + currArg.type |= type.isAssignableFrom(double[].class) ? ARG_DOUBLE : 0; + + currArg.type |= type.isAssignableFrom(long[].class) ? ARG_LONG : 0; + + currArg.type |= type.isAssignableFrom(short[].class) ? ARG_SHORT : 0; + + // arrays whose length is used will have an int arg holding + // the length as a kernel param + if (entryPoint.getArrayFieldArrayLengthUsed().contains(currArg.name)) { + currArg.type |= ARG_ARRAYLENGTH; + } + + if (type.getName().startsWith("[L")) { + currArg.type |= (ARG_OBJ_ARRAY_STRUCT | ARG_WRITE | ARG_READ); + if (logger.isLoggable(Level.FINE)) { + logger.fine("tagging " + currArg.name + " as (ARG_OBJ_ARRAY_STRUCT | ARG_WRITE | ARG_READ)"); + } + } + } else if (type.isAssignableFrom(float.class)) { + currArg.type |= ARG_PRIMITIVE; + currArg.type |= ARG_FLOAT; + } else if (type.isAssignableFrom(int.class)) { + currArg.type |= ARG_PRIMITIVE; + currArg.type |= ARG_INT; + } else if (type.isAssignableFrom(double.class)) { + currArg.type |= ARG_PRIMITIVE; + currArg.type |= ARG_DOUBLE; + } else if (type.isAssignableFrom(long.class)) { + currArg.type |= ARG_PRIMITIVE; + currArg.type |= ARG_LONG; + } else if (type.isAssignableFrom(boolean.class)) { + currArg.type |= ARG_PRIMITIVE; + currArg.type |= ARG_BOOLEAN; + } else if (type.isAssignableFrom(byte.class)) { + currArg.type |= ARG_PRIMITIVE; + currArg.type |= ARG_BYTE; + } else if (type.isAssignableFrom(char.class)) { + currArg.type |= ARG_PRIMITIVE; + currArg.type |= ARG_CHAR; + } else if (type.isAssignableFrom(short.class)) { + currArg.type |= ARG_PRIMITIVE; + currArg.type |= ARG_SHORT; } + // System.out.printf("in execute, arg %d %s %08x\n", i,currArg.name,currArg.type ); - return execute(_entrypointName, _range, _passes); - } + currArg.primitiveSize = ((currArg.type & ARG_FLOAT) != 0 ? 4 : (currArg.type & ARG_INT) != 0 ? 4 + : (currArg.type & ARG_BYTE) != 0 ? 1 : (currArg.type & ARG_CHAR) != 0 ? 2 + : (currArg.type & ARG_BOOLEAN) != 0 ? 1 : (currArg.type & ARG_SHORT) != 0 ? 2 + : (currArg.type & ARG_LONG) != 0 ? 8 : (currArg.type & ARG_DOUBLE) != 0 ? 8 : 0); - synchronized private Kernel warnFallBackAndExecute(String _entrypointName, final Range _range, final int _passes, - Exception _exception) { - if (logger.isLoggable(Level.WARNING)) { - logger.warning("Reverting to Java Thread Pool (JTP) for " + kernel.getClass() + ": " + _exception.getMessage()); - _exception.printStackTrace(); + if (logger.isLoggable(Level.INFO)) { + logger.info("prepareOneArg : " + currArg.name + ", type=" + Integer.toHexString(currArg.type) + + ", primitiveSize=" + currArg.primitiveSize); } - return fallBackAndExecute(_entrypointName, _range, _passes); + + return currArg; } + + + KernelArg[] prepareLambdaArgs(Object lambdaObject, Object callerBlock, Field[] callerCapturedFields) { + List argsList = new ArrayList(); + + // Add fields in this order: + // 1. captured args from block, + // 2. iteration variable, + // 3. references from lambda's object + try { + + for (Field field : callerCapturedFields) { + field.setAccessible(true); + argsList.add(prepareOneArg(field, callerBlock)); + } + + argsList.add(prepareOneArg(this.getClass().getDeclaredField("iterationVariable"), this)); + + for (Field field : entryPoint.getReferencedFields()) { + field.setAccessible(true); + argsList.add(prepareOneArg(field, lambdaObject)); + } - synchronized private Kernel warnFallBackAndExecute(String _entrypointName, final Range _range, final int _passes, String _excuse) { - logger.warning("Reverting to Java Thread Pool (JTP) for " + kernel.getClass() + ": " + _excuse); - return fallBackAndExecute(_entrypointName, _range, _passes); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + return argsList.toArray(new KernelArg[0]); } + + // Hope for the best! + boolean runnable = true; + public void setRunnable(boolean b) { runnable = b; } + public boolean getRunnable() { return runnable; } - synchronized Kernel execute(String _entrypointName, final Range _range, final int _passes) { + + synchronized boolean execute(Object callerBlock, final Range _range, final int _passes) throws AparapiException { long executeStartTime = System.currentTimeMillis(); @@ -1361,33 +1403,32 @@ synchronized Kernel execute(String _entrypointName, final Range _range, final in throw new IllegalStateException("range can't be null"); } - /* for backward compatibility reasons we still honor execution mode */ - if (kernel.getExecutionMode().isOpenCL()) { - // System.out.println("OpenCL"); - + if (true) { // See if user supplied a Device Device device = _range.getDevice(); - + if ((device == null) || (device instanceof OpenCLDevice)) { if (entryPoint == null) { - try { - ClassModel classModel = new ClassModel(kernel.getClass()); - entryPoint = classModel.getEntrypoint(_entrypointName, kernel); - } catch (Exception exception) { - return warnFallBackAndExecute(_entrypointName, _range, _passes, exception); - } - + + assert lambdaKernelCall != null : "Should not be null"; + assert lambdaKernelCall.getLambdaKernelThis() != null : "Lambda This should not be null"; + Class lambdaClass = lambdaKernelCall.getLambdaKernelThis().getClass(); + ClassModel classModel = new ClassModel(lambdaClass); + + entryPoint = classModel.getEntrypoint(lambdaKernelCall.getLambdaMethodName(), + lambdaKernelCall.getLambdaMethodSignature(), lambdaKernelCall.getLambdaKernelThis()); + if ((entryPoint != null) && !entryPoint.shouldFallback()) { - synchronized (Kernel.class) { // This seems to be needed because of a race condition uncovered with issue #68 http://code.google.com/p/aparapi/issues/detail?id=68 + synchronized (KernelRunner.class) { // This seems to be needed because of a race condition uncovered with issue #68 http://code.google.com/p/aparapi/issues/detail?id=68 if (device != null && !(device instanceof OpenCLDevice)) { throw new IllegalStateException("range's device is not suitable for OpenCL "); } - + OpenCLDevice openCLDevice = (OpenCLDevice) device; // still might be null! - + int jniFlags = 0; if (openCLDevice == null) { - if (kernel.getExecutionMode().equals(EXECUTION_MODE.GPU)) { + if (true) { // We used to treat as before by getting first GPU device // now we get the best GPU openCLDevice = (OpenCLDevice) OpenCLDevice.best(); @@ -1396,8 +1437,7 @@ synchronized Kernel execute(String _entrypointName, final Range _range, final in // We fetch the first CPU device openCLDevice = (OpenCLDevice) OpenCLDevice.firstCPU(); if (openCLDevice == null) { - return warnFallBackAndExecute(_entrypointName, _range, _passes, - "CPU request can't be honored not CPU device"); + throw new AparapiException ("CPU request can't be honored not CPU device"); } } } else { @@ -1405,220 +1445,96 @@ synchronized Kernel execute(String _entrypointName, final Range _range, final in jniFlags |= JNI_FLAG_USE_GPU; // this flag might be redundant now. } } - - // jniFlags |= (Config.enableProfiling ? JNI_FLAG_ENABLE_PROFILING : 0); - // jniFlags |= (Config.enableProfilingCSV ? JNI_FLAG_ENABLE_PROFILING_CSV | JNI_FLAG_ENABLE_PROFILING : 0); - // jniFlags |= (Config.enableVerboseJNI ? JNI_FLAG_ENABLE_VERBOSE_JNI : 0); - // jniFlags |= (Config.enableVerboseJNIOpenCLResourceTracking ? JNI_FLAG_ENABLE_VERBOSE_JNI_OPENCL_RESOURCE_TRACKING :0); - // jniFlags |= (kernel.getExecutionMode().equals(EXECUTION_MODE.GPU) ? JNI_FLAG_USE_GPU : 0); - // Init the device to check capabilities before emitting the - // code that requires the capabilities. - + // synchronized(Kernel.class){ - jniContextHandle = initJNI(kernel, openCLDevice, jniFlags); // openCLDevice will not be null here + jniContextHandle = initJNI(lambdaKernelCall.getLambdaKernelThis(), openCLDevice, jniFlags); // openCLDevice will not be null here } // end of synchronized! issue 68 - + if (jniContextHandle == 0) { - return warnFallBackAndExecute(_entrypointName, _range, _passes, "initJNI failed to return a valid handle"); + throw new AparapiException ("Can't create JNI context"); } - + String extensions = getExtensionsJNI(jniContextHandle); capabilitiesSet = new HashSet(); - + StringTokenizer strTok = new StringTokenizer(extensions); while (strTok.hasMoreTokens()) { capabilitiesSet.add(strTok.nextToken()); } - + if (logger.isLoggable(Level.FINE)) { logger.fine("Capabilities initialized to :" + capabilitiesSet.toString()); } - + if (entryPoint.requiresDoublePragma() && !hasFP64Support()) { - return warnFallBackAndExecute(_entrypointName, _range, _passes, "FP64 required but not supported"); + throw new AparapiException ("FP64 required but not supported"); } - + if (entryPoint.requiresByteAddressableStorePragma() && !hasByteAddressableStoreSupport()) { - return warnFallBackAndExecute(_entrypointName, _range, _passes, - "Byte addressable stores required but not supported"); + throw new AparapiException("Byte addressable stores required but not supported"); } - + boolean all32AtomicsAvailable = hasGlobalInt32BaseAtomicsSupport() && hasGlobalInt32ExtendedAtomicsSupport() && hasLocalInt32BaseAtomicsSupport() && hasLocalInt32ExtendedAtomicsSupport(); - + if (entryPoint.requiresAtomic32Pragma() && !all32AtomicsAvailable) { - - return warnFallBackAndExecute(_entrypointName, _range, _passes, "32 bit Atomics required but not supported"); + throw new AparapiException("32 bit Atomics required but not supported"); } - + + entryPoint.setLambdaActualParamsCount(lambdaKernelCall.getLambdaCapturedFields().length); String openCL = null; - try { - openCL = KernelWriter.writeToString(entryPoint); - } catch (CodeGenException codeGenException) { - return warnFallBackAndExecute(_entrypointName, _range, _passes, codeGenException); - } - + //try { + openCL = KernelWriter.writeToString(entryPoint); + //} catch (CodeGenException codeGenException) { + // return warnFallBackAndExecute(lambdaObject, _entrypointName, _entrypointSignature, capturedArgs, _range, _passes, codeGenException); + //} + if (Config.enableShowGeneratedOpenCL) { System.out.println(openCL); } - + if (logger.isLoggable(Level.INFO)) { logger.info(openCL); } - + // Send the string to OpenCL to compile it if (buildProgramJNI(jniContextHandle, openCL) == 0) { - return warnFallBackAndExecute(_entrypointName, _range, _passes, "OpenCL compile failed"); - } - - args = new KernelArg[entryPoint.getReferencedFields().size()]; - int i = 0; - - for (Field field : entryPoint.getReferencedFields()) { - try { - field.setAccessible(true); - args[i] = new KernelArg(); - args[i].name = field.getName(); - args[i].field = field; - if ((field.getModifiers() & Modifier.STATIC) == Modifier.STATIC) { - args[i].type |= ARG_STATIC; - } - - Class type = field.getType(); - if (type.isArray()) { - if (field.getAnnotation(com.amd.aparapi.Kernel.Local.class) != null - || args[i].name.endsWith(Kernel.LOCAL_SUFFIX)) { - args[i].type |= ARG_LOCAL; - } else if (field.getAnnotation(com.amd.aparapi.Kernel.Constant.class) != null - || args[i].name.endsWith(Kernel.CONSTANT_SUFFIX)) { - args[i].type |= ARG_CONSTANT; - } else { - args[i].type |= ARG_GLOBAL; - } - - args[i].array = null; // will get updated in updateKernelArrayRefs - args[i].type |= ARG_ARRAY; - - if (isExplicit()) { - args[i].type |= ARG_EXPLICIT; - } - - // for now, treat all write arrays as read-write, see bugzilla issue 4859 - // we might come up with a better solution later - args[i].type |= entryPoint.getArrayFieldAssignments().contains(field.getName()) ? (ARG_WRITE | ARG_READ) - : 0; - args[i].type |= entryPoint.getArrayFieldAccesses().contains(field.getName()) ? ARG_READ : 0; - // args[i].type |= ARG_GLOBAL; - args[i].type |= type.isAssignableFrom(float[].class) ? ARG_FLOAT : 0; - - args[i].type |= type.isAssignableFrom(int[].class) ? ARG_INT : 0; - - args[i].type |= type.isAssignableFrom(boolean[].class) ? ARG_BOOLEAN : 0; - - args[i].type |= type.isAssignableFrom(byte[].class) ? ARG_BYTE : 0; - - args[i].type |= type.isAssignableFrom(char[].class) ? ARG_CHAR : 0; - - args[i].type |= type.isAssignableFrom(double[].class) ? ARG_DOUBLE : 0; - - args[i].type |= type.isAssignableFrom(long[].class) ? ARG_LONG : 0; - - args[i].type |= type.isAssignableFrom(short[].class) ? ARG_SHORT : 0; - - // arrays whose length is used will have an int arg holding - // the length as a kernel param - if (entryPoint.getArrayFieldArrayLengthUsed().contains(args[i].name)) { - args[i].type |= ARG_ARRAYLENGTH; - } - - if (type.getName().startsWith("[L")) { - args[i].type |= (ARG_OBJ_ARRAY_STRUCT | ARG_WRITE | ARG_READ); - if (logger.isLoggable(Level.FINE)) { - logger.fine("tagging " + args[i].name + " as (ARG_OBJ_ARRAY_STRUCT | ARG_WRITE | ARG_READ)"); - } - } - } else if (type.isAssignableFrom(float.class)) { - args[i].type |= ARG_PRIMITIVE; - args[i].type |= ARG_FLOAT; - } else if (type.isAssignableFrom(int.class)) { - args[i].type |= ARG_PRIMITIVE; - args[i].type |= ARG_INT; - } else if (type.isAssignableFrom(double.class)) { - args[i].type |= ARG_PRIMITIVE; - args[i].type |= ARG_DOUBLE; - } else if (type.isAssignableFrom(long.class)) { - args[i].type |= ARG_PRIMITIVE; - args[i].type |= ARG_LONG; - } else if (type.isAssignableFrom(boolean.class)) { - args[i].type |= ARG_PRIMITIVE; - args[i].type |= ARG_BOOLEAN; - } else if (type.isAssignableFrom(byte.class)) { - args[i].type |= ARG_PRIMITIVE; - args[i].type |= ARG_BYTE; - } else if (type.isAssignableFrom(char.class)) { - args[i].type |= ARG_PRIMITIVE; - args[i].type |= ARG_CHAR; - } else if (type.isAssignableFrom(short.class)) { - args[i].type |= ARG_PRIMITIVE; - args[i].type |= ARG_SHORT; - } - // System.out.printf("in execute, arg %d %s %08x\n", i,args[i].name,args[i].type ); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } - - args[i].primitiveSize = ((args[i].type & ARG_FLOAT) != 0 ? 4 : (args[i].type & ARG_INT) != 0 ? 4 - : (args[i].type & ARG_BYTE) != 0 ? 1 : (args[i].type & ARG_CHAR) != 0 ? 2 - : (args[i].type & ARG_BOOLEAN) != 0 ? 1 : (args[i].type & ARG_SHORT) != 0 ? 2 - : (args[i].type & ARG_LONG) != 0 ? 8 : (args[i].type & ARG_DOUBLE) != 0 ? 8 : 0); - - if (logger.isLoggable(Level.FINE)) { - logger.fine("arg " + i + ", " + args[i].name + ", type=" + Integer.toHexString(args[i].type) - + ", primitiveSize=" + args[i].primitiveSize); - } - - i++; + //return warnFallBackAndExecute(lambdaObject, _entrypointName, _entrypointSignature, capturedArgs, _range, _passes, + //"OpenCL compile failed"); + throw new AparapiException("OpenCL compile failed"); } - - // at this point, i = the actual used number of arguments - // (private buffers do not get treated as arguments) - - argc = i; - + + args = prepareLambdaArgs(lambdaKernelCall.getLambdaKernelThis(), callerBlock, lambdaKernelCall.getLambdaCapturedFields()); + + argc = args.length; + setArgsJNI(jniContextHandle, args, argc); - + conversionTime = System.currentTimeMillis() - executeStartTime; - - try { - executeOpenCL(_entrypointName, _range, _passes); - } catch (final AparapiException e) { - warnFallBackAndExecute(_entrypointName, _range, _passes, e); + + executeOpenCL(lambdaKernelCall.getLambdaKernelThis(), callerBlock, _range, _passes); + + if (logger.isLoggable(Level.INFO)) { + logger.info("First run done. "); } + } else { - warnFallBackAndExecute(_entrypointName, _range, _passes, "failed to locate entrypoint"); + throw new AparapiException("failed to locate entrypoint"); + } } else { - try { - executeOpenCL(_entrypointName, _range, _passes); - } catch (final AparapiException e) { - warnFallBackAndExecute(_entrypointName, _range, _passes, e); - } + + executeOpenCL(lambdaKernelCall.getLambdaKernelThis(), callerBlock, _range, _passes); } } else { - warnFallBackAndExecute(_entrypointName, _range, _passes, "OpenCL was requested but Device supplied was not an OpenCLDevice"); + throw new AparapiException("OpenCL was requested but Device supplied was not an OpenCLDevice"); } - } else { - executeJava(_range, _passes); - } - - if (Config.enableExecutionModeReporting) { - System.out.println(kernel.getClass().getCanonicalName() + ":" + kernel.getExecutionMode()); } executionTime = System.currentTimeMillis() - executeStartTime; accumulatedExecutionTime += executionTime; - return (kernel); + return true; } private Set puts = new HashSet(); @@ -1643,22 +1559,23 @@ synchronized Kernel execute(String _entrypointName, final Range _range, final in * @see Kernel#get(char[] arr) * @see Kernel#get(boolean[] arr) */ - protected void get(Object array) { - if (explicit - && ((kernel.getExecutionMode() == Kernel.EXECUTION_MODE.GPU) || (kernel.getExecutionMode() == Kernel.EXECUTION_MODE.CPU))) { - // Only makes sense when we are using OpenCL - getJNI(jniContextHandle, array); - } - } - - protected List getProfileInfo() { - if (((kernel.getExecutionMode() == Kernel.EXECUTION_MODE.GPU) || (kernel.getExecutionMode() == Kernel.EXECUTION_MODE.CPU))) { - // Only makes sense when we are using OpenCL - return (getProfileInfoJNI(jniContextHandle)); - } else { - return (null); - } - } + +// protected void get(Object array) { +// if (explicit +// && ((kernel.getExecutionMode() == Kernel.EXECUTION_MODE.GPU) || (kernel.getExecutionMode() == Kernel.EXECUTION_MODE.CPU))) { +// // Only makes sense when we are using OpenCL +// getJNI(jniContextHandle, array); +// } +// } + +// protected List getProfileInfo() { +// if (((kernel.getExecutionMode() == Kernel.EXECUTION_MODE.GPU) || (kernel.getExecutionMode() == Kernel.EXECUTION_MODE.CPU))) { +// // Only makes sense when we are using OpenCL +// return (getProfileInfoJNI(jniContextHandle)); +// } else { +// return (null); +// } +// } /** * Tag this array so that it is explicitly enqueued before the kernel is executed.
@@ -1676,23 +1593,23 @@ protected List getProfileInfo() { * @see Kernel#put(boolean[] arr) */ - protected void put(Object array) { - if (explicit - && ((kernel.getExecutionMode() == Kernel.EXECUTION_MODE.GPU) || (kernel.getExecutionMode() == Kernel.EXECUTION_MODE.CPU))) { - // Only makes sense when we are using OpenCL - puts.add(array); - } - } - - private boolean explicit = false; - - protected void setExplicit(boolean _explicit) { - explicit = _explicit; - } - - protected boolean isExplicit() { - return (explicit); - } +// protected void put(Object array) { +// if (explicit +// && ((kernel.getExecutionMode() == Kernel.EXECUTION_MODE.GPU) || (kernel.getExecutionMode() == Kernel.EXECUTION_MODE.CPU))) { +// // Only makes sense when we are using OpenCL +// puts.add(array); +// } +// } + +// private boolean explicit = false; +// +// protected void setExplicit(boolean _explicit) { +// explicit = _explicit; +// } +// +// protected boolean isExplicit() { +// return (explicit); +// } /** * Determine the time taken to convert bytecode to OpenCL for first Kernel.execute(range) call. diff --git a/com.amd.aparapi/src/java/com/amd/aparapi/KernelWriter.java b/com.amd.aparapi/src/java/com/amd/aparapi/KernelWriter.java index 2f6ff442..8f9d8d60 100644 --- a/com.amd.aparapi/src/java/com/amd/aparapi/KernelWriter.java +++ b/com.amd.aparapi/src/java/com/amd/aparapi/KernelWriter.java @@ -65,27 +65,27 @@ to national security controls as identified on the Commerce Control List (curren abstract class KernelWriter extends BlockWriter{ - final String cvtBooleanToChar = "char "; + final static String cvtBooleanToChar = "char "; - final String cvtBooleanArrayToCharStar = "char* "; + final static String cvtBooleanArrayToCharStar = "char* "; - final String cvtByteToChar = "char "; + final static String cvtByteToChar = "char "; - final String cvtByteArrayToCharStar = "char* "; + final static String cvtByteArrayToCharStar = "char* "; - final String cvtCharToShort = "unsigned short "; + final static String cvtCharToShort = "unsigned short "; - final String cvtCharArrayToShortStar = "unsigned short* "; + final static String cvtCharArrayToShortStar = "unsigned short* "; - final String cvtIntArrayToIntStar = "int* "; + final static String cvtIntArrayToIntStar = "int* "; - final String cvtFloatArrayToFloatStar = "float* "; + final static String cvtFloatArrayToFloatStar = "float* "; - final String cvtDoubleArrayToDoubleStar = "double* "; + final static String cvtDoubleArrayToDoubleStar = "double* "; - final String cvtLongArrayToLongStar = "long* "; + final static String cvtLongArrayToLongStar = "long* "; - final String cvtShortArrayToShortStar = "short* "; + final static String cvtShortArrayToShortStar = "short* "; // private static Logger logger = Logger.getLogger(Config.getLoggerName()); @@ -148,6 +148,10 @@ abstract class KernelWriter extends BlockWriter{ * @return Suitably converted string, "char*", etc */ @Override protected String convertType(String _typeDesc, boolean useClassModel) { + return KernelWriter.convertType0(_typeDesc, useClassModel); + } + + public static String convertType0(String _typeDesc, boolean useClassModel) { if (_typeDesc.equals("Z") || _typeDesc.equals("boolean")) { return (cvtBooleanToChar); } else if (_typeDesc.equals("[Z") || _typeDesc.equals("boolean[]")) { @@ -160,8 +164,12 @@ abstract class KernelWriter extends BlockWriter{ return (cvtCharToShort); } else if (_typeDesc.equals("[C") || _typeDesc.equals("char[]")) { return (cvtCharArrayToShortStar); + } else if (_typeDesc.equals("I")) { + return ("int "); } else if (_typeDesc.equals("[I") || _typeDesc.equals("int[]")) { return (cvtIntArrayToIntStar); + } else if (_typeDesc.equals("F")) { + return ("float "); } else if (_typeDesc.equals("[F") || _typeDesc.equals("float[]")) { return (cvtFloatArrayToFloatStar); } else if (_typeDesc.equals("[D") || _typeDesc.equals("double[]")) { @@ -176,9 +184,9 @@ abstract class KernelWriter extends BlockWriter{ return (ClassModel.convert(_typeDesc, "", true)); } else { return _typeDesc; - } + } } - + @Override protected void writeMethod(MethodCall _methodCall, MethodEntry _methodEntry) throws CodeGenException { // System.out.println("_methodEntry = " + _methodEntry); @@ -209,14 +217,14 @@ abstract class KernelWriter extends BlockWriter{ } } else { - String intrinsicMapping = Kernel.getMappedMethodName(_methodEntry); + String intrinsicMapping = KernelRunner.getMappedMethodName(_methodEntry); // System.out.println("getMappedMethodName for " + methodName + " returned " + mapping); boolean isIntrinsic = false; if (intrinsicMapping == null) { assert entryPoint != null : "entryPoint should not be null"; boolean isSpecial = _methodCall instanceof I_INVOKESPECIAL; - boolean isMapped = Kernel.isMappedMethod(_methodEntry); + boolean isMapped = KernelRunner.isMappedMethod(_methodEntry); MethodModel m = entryPoint.getCallTarget(_methodEntry, isSpecial); if (m != null) { @@ -269,16 +277,14 @@ void writePragma(String _name, boolean _enable) { newLine(); } - public final static String __local = "__local"; public final static String __global = "__global"; - public final static String __constant = "__constant"; - - public final static String LOCAL_ANNOTATION_NAME = "L" + Kernel.Local.class.getName().replace(".", "/") + ";"; - - public final static String CONSTANT_ANNOTATION_NAME = "L" + Kernel.Constant.class.getName().replace(".", "/") + ";"; + + static String lambdaIterationIntArgName = null; + String getLambdaIterationIntArgName() { return lambdaIterationIntArgName; } + @Override void write(Entrypoint _entryPoint) throws CodeGenException { List thisStruct = new ArrayList(); List argLines = new ArrayList(); @@ -286,6 +292,56 @@ void writePragma(String _name, boolean _enable) { entryPoint = _entryPoint; + // Add code to collect lambda formal arguments + // The local variables are the java args to the method + { + MethodModel mm = entryPoint.getMethodModel(); + + boolean alreadyHasFirstArg = !mm.getMethod().isStatic(); + + int argsCount = 1; + Iterator lvit = mm.getLocalVariableTableEntry().iterator(); + while (lvit.hasNext()) { + LocalVariableInfo lvi = lvit.next(); + StringBuilder thisStructLine = new StringBuilder(); + StringBuilder argLine = new StringBuilder(); + StringBuilder assignLine = new StringBuilder(); + if ((lvi.getStart() == 0) && ((lvi.getVariableIndex() != 0) || mm.getMethod().isStatic())) { // full scope but skip this + String descriptor = lvi.getVariableDescriptor(); + argLine.append(convertType(ClassModel.typeName(descriptor.charAt(0)), false)); + thisStructLine.append(convertType(ClassModel.typeName(descriptor.charAt(0)), false)); + + argLine.append(" "); + thisStructLine.append(" "); + + assignLine.append("this->"); + assignLine.append(lvi.getVariableName()); + assignLine.append(" = "); + assignLine.append(lvi.getVariableName()); + + argLine.append(lvi.getVariableName()); + + thisStructLine.append(lvi.getVariableName()); + + assigns.add(assignLine.toString()); + argLines.add(argLine.toString()); + thisStruct.add(thisStructLine.toString()); + + // Note the last arg is an int which should be equivalent to the opencl gid + System.out.println("## argsCount = " + argsCount + " / " + entryPoint.getLambdaActualParamsCount()); + if (argsCount == ( entryPoint.getLambdaActualParamsCount() + 1 )) { + if ((lvi != null) && lvi.getVariableDescriptor().equals("I")) { + if (lambdaIterationIntArgName == null) { + lambdaIterationIntArgName = lvi.getVariableName(); + System.out.println("## lambdaIterationIntArgName = " + lambdaIterationIntArgName); + } + } + } + argsCount++; + } + } + } + for (ClassModelField field : _entryPoint.getReferencedClassModelFields()) { // Field field = _entryPoint.getClassModel().getField(f.getName()); StringBuilder thisStructLine = new StringBuilder(); @@ -296,21 +352,8 @@ void writePragma(String _name, boolean _enable) { boolean isPointer = false; - // check the suffix - String type = field.getName().endsWith(Kernel.LOCAL_SUFFIX) ? __local - : (field.getName().endsWith(Kernel.CONSTANT_SUFFIX) ? __constant : __global); - RuntimeAnnotationsEntry visibleAnnotations = field.fieldAttributePool.getRuntimeVisibleAnnotationsEntry(); - - if (visibleAnnotations != null) { - for (AnnotationInfo ai : visibleAnnotations) { - String typeDescriptor = ai.getTypeDescriptor(); - if (typeDescriptor.equals(LOCAL_ANNOTATION_NAME)) { - type = __local; - } else if (typeDescriptor.equals(CONSTANT_ANNOTATION_NAME)) { - type = __constant; - } - } - } + // No local or constant for lambda demo + String type = __global; if (signature.startsWith("[")) { argLine.append(type + " "); @@ -475,13 +518,18 @@ void writePragma(String _name, boolean _enable) { write(line); writeln(";"); } + + // The passid is the OpenCL gid write("int passid"); out(); writeln(";"); - // out(); - // newLine(); + + //out(); + //newLine(); + write("}This;"); newLine(); + write("int get_pass_id(This *this){"); in(); { @@ -493,6 +541,7 @@ void writePragma(String _name, boolean _enable) { write("}"); newLine(); + for (MethodModel mm : _entryPoint.getCalledMethods()) { // write declaration :) @@ -549,7 +598,10 @@ void writePragma(String _name, boolean _enable) { newLine(); } - write("__kernel void " + _entryPoint.getMethodModel().getSimpleName() + "("); + // For the purpose of a quick demo rename the lambda kernel enrtrypoint to "run" + // to keep in synch with JNI code + //write("__kernel void " + _entryPoint.getMethodModel().getSimpleName() + "("); + write("__kernel void run("); in(); boolean first = true; @@ -571,9 +623,11 @@ void writePragma(String _name, boolean _enable) { write(", "); } newLine(); + write("int passid"); out(); newLine(); + write("){"); in(); newLine(); diff --git a/com.amd.aparapi/src/java/com/amd/aparapi/MethodModel.java b/com.amd.aparapi/src/java/com/amd/aparapi/MethodModel.java index d5ee20a4..35721ec8 100644 --- a/com.amd.aparapi/src/java/com/amd/aparapi/MethodModel.java +++ b/com.amd.aparapi/src/java/com/amd/aparapi/MethodModel.java @@ -53,6 +53,7 @@ to national security controls as identified on the Commerce Control List (curren import com.amd.aparapi.ClassModel.ClassModelMethod; import com.amd.aparapi.ClassModel.ConstantPool; +import com.amd.aparapi.ClassModel.AttributePool.CodeEntry; import com.amd.aparapi.ClassModel.ConstantPool.FieldEntry; import com.amd.aparapi.ClassModel.ConstantPool.MethodReferenceEntry; import com.amd.aparapi.ClassModel.ConstantPool.MethodReferenceEntry.Arg; @@ -281,7 +282,7 @@ Map createListOfInstructions() throws ClassParseException MethodCall methodCall = (MethodCall) instruction; MethodReferenceEntry methodReferenceEntry = methodCall.getConstantPoolMethodEntry(); - if (!Kernel.isMappedMethod(methodReferenceEntry)) { // we will allow trusted methods to violate this rule + if (!KernelRunner.isMappedMethod(methodReferenceEntry)) { // we will allow trusted methods to violate this rule for (Arg arg : methodReferenceEntry.getArgs()) { if (arg.isArray()) { throw new ClassParseException(instruction, ClassParseException.TYPE.METHODARRAYARG); @@ -1408,6 +1409,11 @@ void checkForSetter(Map pcMap) throws ClassParseException if (prev instanceof AccessLocalVariable) { FieldEntry field = ((AssignToInstanceField) instruction).getConstantPoolFieldEntry(); accessedFieldName = field.getNameAndTypeEntry().getNameUTF8Entry().getUTF8(); + + if (logger.isLoggable(Level.FINE)) { + logger.fine("Looking for setter variable: " + methodName + " accessedFieldName: " + accessedFieldName + ", varNameCandidateCamelCased: " + varNameCandidateCamelCased); + } + if (accessedFieldName.equals(varNameCandidateCamelCased)) { // Verify field type matches setter arg type @@ -1630,10 +1636,19 @@ String getVariableName(int _pc, int _index) { private void init(ClassModelMethod _method) throws AparapiException { try { method = _method; + + assert method != null : "method should not be null"; + expressionList = new ExpressionList(this); - + + assert expressionList != null : "expressionList should not be null"; + // check if we have any exception handlers - int exceptionsSize = method.getCodeEntry().getExceptionPoolEntries().size(); + CodeEntry c = method.getCodeEntry(); + + assert c != null : "should not be null"; + + int exceptionsSize = c.getExceptionPoolEntries().size(); if (exceptionsSize > 0) { if (logger.isLoggable(Level.FINE)) { logger.fine("exception size for " + method + " = " + exceptionsSize); @@ -1659,6 +1674,20 @@ private void init(ClassModelMethod _method) throws AparapiException { + 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!!"); } + +// { +// // ecaspole 121211 +// System.out.println("MethodModel.init of " + method); +// +// Iterator instIterator = pcMap.values().iterator(); +// while(instIterator.hasNext()) { +// Instruction instr = instIterator.next(); +// System.out.println(" Inst = " + instr); +// } +// +// } + + // pass #2 build branch graph buildBranchGraphs(pcMap); @@ -1767,6 +1796,18 @@ List getMethodCalls() { return (methodCalls); } + List getFieldAccesses() { + List accessedFields = new ArrayList(); + + for (Instruction i = getPCHead(); i != null; i = i.getNextPC()) { + if (i instanceof AccessField) { + AccessField accessField = (AccessField) i; + accessedFields.add(accessField); + } + } + return (accessedFields); + } + Instruction getPCHead() { return (pcHead); } diff --git a/examples/effects/.classpath b/examples/effects/.classpath deleted file mode 100644 index 2b3d4294..00000000 --- a/examples/effects/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/examples/effects/.project b/examples/effects/.project deleted file mode 100644 index 525cddc8..00000000 --- a/examples/effects/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - effects - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/examples/effects/build.xml b/examples/effects/build.xml deleted file mode 100644 index 7874c120..00000000 --- a/examples/effects/build.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/effects/src/com/amd/aparapi/examples/effects/Main.java b/examples/effects/src/com/amd/aparapi/examples/effects/Main.java deleted file mode 100644 index 5543d94c..00000000 --- a/examples/effects/src/com/amd/aparapi/examples/effects/Main.java +++ /dev/null @@ -1,285 +0,0 @@ -/* -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.amd.aparapi.examples.effects; - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Point; -import java.awt.event.MouseEvent; -import java.awt.event.MouseMotionAdapter; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.image.BufferedImage; -import java.awt.image.DataBufferInt; - -import javax.swing.JComponent; -import javax.swing.JFrame; - -import com.amd.aparapi.Kernel; -import com.amd.aparapi.Range; - -/** - * An example Aparapi application which tracks the mouse and updates the color pallete of the window based on the distance from the mouse pointer. - * - * On GPU, additional computing units will offer a better viewing experience. On the other hand on CPU, this example - * application might suffer with sub-optimal frame refresh rate as compared to GPU. - * - * @author gfrost - * - */ - -public class Main{ - - /** - * An Aparapi Kernel implementation for tracking the mouse position and coloring each pixel of a window depending on proximity to the mouse position. - * - * @author gfrost - * - */ - - public static class MouseTrackKernel extends Kernel{ - - /** RGB buffer used to store the screen image. This buffer holds (width * height) RGB values. */ - final private int rgb[]; - - /** image width. */ - final private int width; - - /** image height. */ - final private int height; - - /** Palette used for points */ - final private int pallette[]; - - /** Maximum iterations we will check for. */ - final private int palletteSize; - - /** Mutable values of scale, offsetx and offsety so that we can modify the zoom level and position of a view. */ - - final private float[] trailx; - - final private float[] traily; - - final private int trail; - - /** - * Initialize the Kernel. - * - * @param _width image width - * @param _height image height - * @param _rgb image RGB buffer - * @param _pallette image palette - * @param _trailx float array holding x ordinates for mouse trail positions - * @param _traily float array holding y ordinates for mouse trail positions - */ - public MouseTrackKernel(int _width, int _height, int[] _rgb, int[] _pallette, float[] _trailx, float[] _traily) { - width = _width; - height = _height; - rgb = _rgb; - pallette = _pallette; - palletteSize = pallette.length - 1; - trailx = _trailx; - traily = _traily; - trail = trailx.length; - } - - @Override public void run() { - - /** Determine which RGB value we are going to process (0..RGB.length). */ - int gid = getGlobalId(); - - /** Translate the gid into an x an y value. */ - float x = (gid % width); - - float y = (gid / height); - - float minRadius = 1024f; - - /** determine the minimum radius between this pixel position (x,y) and each of the trail positions _trailx[0..n],_traily[0..n] **/ - for (int i = 0; i < trail; i++) { - float dx = x - trailx[i]; - float dy = y - traily[i]; - minRadius = min(sqrt(dx * dx + dy * dy), minRadius); - } - - /** convert the radius length into an index into the pallete array **/ - int palletteIndex = min((int) minRadius, palletteSize); - - /** set the rgb value for this color **/ - rgb[gid] = pallette[palletteIndex]; - - } - - } - - /** We track the latest mouse position here. */ - public static volatile Point mousePosition = null; - - @SuppressWarnings("serial") public static void main(String[] _args) { - - JFrame frame = new JFrame("MouseTracker"); - - /** Width of Mandelbrot view. */ - final int width = 1024; - - /** Height of Mandelbrot view. */ - final int height = 1024; - - final Range range = Range.create2D(width, height); - - /** The size of the pallette of pixel colors we choose from. */ - final int palletteSize = 128; - - /** Palette which maps iteration values to RGB values. */ - final int pallette[] = new int[palletteSize + 1]; - - /** Initialize palette values **/ - for (int i = 0; i < palletteSize; i++) { - float h = i / (float) palletteSize; - float b = 1.0f - h * h; - pallette[i] = Color.HSBtoRGB(h, 1f, b); - } - - /** We will keep a trail of 64 mouse positions **/ - final float trailx[] = new float[64]; - final float traily[] = new float[trailx.length]; - - /** Image for view. */ - final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - final BufferedImage offscreen = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - - /** Override the paint handler to just copy the image **/ - JComponent viewer = new JComponent(){ - @Override public void paintComponent(Graphics g) { - - g.drawImage(image, 0, 0, width, height, this); - } - }; - - /** Set the size of JComponent which displays the image **/ - viewer.setPreferredSize(new Dimension(width, height)); - - /** We use this to synchronize access from Swing display thread **/ - final Object doorBell = new Object(); - - /** Mouse listener which collects the latest the mouse position from Mandelbrot view whenever the mouse is moved **/ - viewer.addMouseMotionListener(new MouseMotionAdapter(){ - - @Override public void mouseMoved(MouseEvent e) { - /** grab the mouse position **/ - mousePosition = e.getPoint(); - - /** tell the waitin thread that we have a new position **/ - synchronized (doorBell) { - doorBell.notify(); - } - } - }); - - /** Swing housework to create the frame **/ - frame.getContentPane().add(viewer); - frame.pack(); - frame.setLocationRelativeTo(null); - frame.setVisible(true); - - /** Extract the underlying RGB buffer from the image. **/ - /** Pass this to the kernel so it operates directly on the RGB buffer of the image **/ - final int[] rgb = ((DataBufferInt) offscreen.getRaster().getDataBuffer()).getData(); - final int[] imageRgb = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); - - /** Create a Kernel passing the size, RGB buffer, the palette and the trail positions **/ - final MouseTrackKernel kernel = new MouseTrackKernel(width, height, rgb, pallette, trailx, traily); - - /** initialize the trail positions to center of screen **/ - for (int i = 0; i < trailx.length; i++) { - trailx[i] = (float) width / 2; - traily[i] = (float) width / 2; - } - - /** we use this to track the position where we insert latest mouse position, just a circular buffer **/ - - int trailLastUpdatedPosition = 0; - - kernel.execute(range); - System.arraycopy(rgb, 0, imageRgb, 0, rgb.length); - viewer.repaint(); - - /** Report target execution mode: GPU or JTP (Java Thread Pool). **/ - System.out.println("Execution mode=" + kernel.getExecutionMode()); - - /** Window listener to dispose Kernel resources on user exit. **/ - frame.addWindowListener(new WindowAdapter(){ - public void windowClosing(WindowEvent _windowEvent) { - kernel.dispose(); - System.exit(0); - } - }); - - /** update loop**/ - while (true) { - - /** Wait for the user to move mouse **/ - while (mousePosition == null) { - synchronized (doorBell) { - try { - doorBell.wait(); - } catch (InterruptedException ie) { - ie.getStackTrace(); - } - } - } - /** add the new x,y to the trail arrays and bump the poition **/ - trailx[trailLastUpdatedPosition % trailx.length] = (float) mousePosition.x; - traily[trailLastUpdatedPosition % traily.length] = (float) mousePosition.y; - trailLastUpdatedPosition++; - - /** execute the kernel which calculates new pixel values **/ - kernel.execute(range); - - /** copy the rgb values to the imageRgb buffer **/ - System.arraycopy(rgb, 0, imageRgb, 0, rgb.length); - - /** request a repaint **/ - viewer.repaint(); - } - - } - -} diff --git a/examples/javaonedemo/.classpath b/examples/javaonedemo/.classpath deleted file mode 100644 index 666c40a4..00000000 --- a/examples/javaonedemo/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/examples/javaonedemo/.project b/examples/javaonedemo/.project deleted file mode 100644 index bd14ae41..00000000 --- a/examples/javaonedemo/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - javaonedemo - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/examples/javaonedemo/build.xml b/examples/javaonedemo/build.xml deleted file mode 100644 index 8ccee70e..00000000 --- a/examples/javaonedemo/build.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/javaonedemo/get-jogamp-build.xml b/examples/javaonedemo/get-jogamp-build.xml deleted file mode 100644 index 78b2b35d..00000000 --- a/examples/javaonedemo/get-jogamp-build.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/javaonedemo/jogamp/gluegen-rt-natives-linux-amd64.jar b/examples/javaonedemo/jogamp/gluegen-rt-natives-linux-amd64.jar deleted file mode 100644 index 98177ccc..00000000 Binary files a/examples/javaonedemo/jogamp/gluegen-rt-natives-linux-amd64.jar and /dev/null differ diff --git a/examples/javaonedemo/jogamp/gluegen-rt-natives-linux-i586.jar b/examples/javaonedemo/jogamp/gluegen-rt-natives-linux-i586.jar deleted file mode 100644 index 668bbbb5..00000000 Binary files a/examples/javaonedemo/jogamp/gluegen-rt-natives-linux-i586.jar and /dev/null differ diff --git a/examples/javaonedemo/jogamp/gluegen-rt-natives-macosx-universal.jar b/examples/javaonedemo/jogamp/gluegen-rt-natives-macosx-universal.jar deleted file mode 100644 index 11999bc9..00000000 Binary files a/examples/javaonedemo/jogamp/gluegen-rt-natives-macosx-universal.jar and /dev/null differ diff --git a/examples/javaonedemo/jogamp/gluegen-rt-natives-windows-amd64.jar b/examples/javaonedemo/jogamp/gluegen-rt-natives-windows-amd64.jar deleted file mode 100644 index 43c1a957..00000000 Binary files a/examples/javaonedemo/jogamp/gluegen-rt-natives-windows-amd64.jar and /dev/null differ diff --git a/examples/javaonedemo/jogamp/gluegen-rt-natives-windows-i586.jar b/examples/javaonedemo/jogamp/gluegen-rt-natives-windows-i586.jar deleted file mode 100644 index b9aa1349..00000000 Binary files a/examples/javaonedemo/jogamp/gluegen-rt-natives-windows-i586.jar and /dev/null differ diff --git a/examples/javaonedemo/jogamp/gluegen-rt.jar b/examples/javaonedemo/jogamp/gluegen-rt.jar deleted file mode 100644 index a9957e61..00000000 Binary files a/examples/javaonedemo/jogamp/gluegen-rt.jar and /dev/null differ diff --git a/examples/javaonedemo/jogamp/jogl-all-natives-linux-amd64.jar b/examples/javaonedemo/jogamp/jogl-all-natives-linux-amd64.jar deleted file mode 100644 index 0f914e25..00000000 Binary files a/examples/javaonedemo/jogamp/jogl-all-natives-linux-amd64.jar and /dev/null differ diff --git a/examples/javaonedemo/jogamp/jogl-all-natives-linux-i586.jar b/examples/javaonedemo/jogamp/jogl-all-natives-linux-i586.jar deleted file mode 100644 index e969c9b6..00000000 Binary files a/examples/javaonedemo/jogamp/jogl-all-natives-linux-i586.jar and /dev/null differ diff --git a/examples/javaonedemo/jogamp/jogl-all-natives-macosx-universal.jar b/examples/javaonedemo/jogamp/jogl-all-natives-macosx-universal.jar deleted file mode 100644 index 32f15677..00000000 Binary files a/examples/javaonedemo/jogamp/jogl-all-natives-macosx-universal.jar and /dev/null differ diff --git a/examples/javaonedemo/jogamp/jogl-all-natives-windows-amd64.jar b/examples/javaonedemo/jogamp/jogl-all-natives-windows-amd64.jar deleted file mode 100644 index 8ca36828..00000000 Binary files a/examples/javaonedemo/jogamp/jogl-all-natives-windows-amd64.jar and /dev/null differ diff --git a/examples/javaonedemo/jogamp/jogl-all-natives-windows-i586.jar b/examples/javaonedemo/jogamp/jogl-all-natives-windows-i586.jar deleted file mode 100644 index 1ff12893..00000000 Binary files a/examples/javaonedemo/jogamp/jogl-all-natives-windows-i586.jar and /dev/null differ diff --git a/examples/javaonedemo/jogamp/jogl-all.jar b/examples/javaonedemo/jogamp/jogl-all.jar deleted file mode 100644 index 977f5f15..00000000 Binary files a/examples/javaonedemo/jogamp/jogl-all.jar and /dev/null differ diff --git a/examples/javaonedemo/jogamp/linux-amd64/libgluegen-rt.so b/examples/javaonedemo/jogamp/linux-amd64/libgluegen-rt.so deleted file mode 100644 index e24d5e0b..00000000 Binary files a/examples/javaonedemo/jogamp/linux-amd64/libgluegen-rt.so and /dev/null differ diff --git a/examples/javaonedemo/jogamp/linux-amd64/libjogl_desktop.so b/examples/javaonedemo/jogamp/linux-amd64/libjogl_desktop.so deleted file mode 100644 index f91d7c69..00000000 Binary files a/examples/javaonedemo/jogamp/linux-amd64/libjogl_desktop.so and /dev/null differ diff --git a/examples/javaonedemo/jogamp/linux-amd64/libjogl_mobile.so b/examples/javaonedemo/jogamp/linux-amd64/libjogl_mobile.so deleted file mode 100644 index 3da6eec9..00000000 Binary files a/examples/javaonedemo/jogamp/linux-amd64/libjogl_mobile.so and /dev/null differ diff --git a/examples/javaonedemo/jogamp/linux-amd64/libnativewindow_awt.so b/examples/javaonedemo/jogamp/linux-amd64/libnativewindow_awt.so deleted file mode 100644 index be10b141..00000000 Binary files a/examples/javaonedemo/jogamp/linux-amd64/libnativewindow_awt.so and /dev/null differ diff --git a/examples/javaonedemo/jogamp/linux-amd64/libnativewindow_x11.so b/examples/javaonedemo/jogamp/linux-amd64/libnativewindow_x11.so deleted file mode 100644 index 53100afc..00000000 Binary files a/examples/javaonedemo/jogamp/linux-amd64/libnativewindow_x11.so and /dev/null differ diff --git a/examples/javaonedemo/jogamp/linux-amd64/libnewt.so b/examples/javaonedemo/jogamp/linux-amd64/libnewt.so deleted file mode 100644 index d7579381..00000000 Binary files a/examples/javaonedemo/jogamp/linux-amd64/libnewt.so and /dev/null differ diff --git a/examples/javaonedemo/jogamp/linux-i586/libgluegen-rt.so b/examples/javaonedemo/jogamp/linux-i586/libgluegen-rt.so deleted file mode 100644 index b58b5e1f..00000000 Binary files a/examples/javaonedemo/jogamp/linux-i586/libgluegen-rt.so and /dev/null differ diff --git a/examples/javaonedemo/jogamp/linux-i586/libjogl_desktop.so b/examples/javaonedemo/jogamp/linux-i586/libjogl_desktop.so deleted file mode 100644 index 1fe60d53..00000000 Binary files a/examples/javaonedemo/jogamp/linux-i586/libjogl_desktop.so and /dev/null differ diff --git a/examples/javaonedemo/jogamp/linux-i586/libjogl_mobile.so b/examples/javaonedemo/jogamp/linux-i586/libjogl_mobile.so deleted file mode 100644 index db2849cf..00000000 Binary files a/examples/javaonedemo/jogamp/linux-i586/libjogl_mobile.so and /dev/null differ diff --git a/examples/javaonedemo/jogamp/linux-i586/libnativewindow_awt.so b/examples/javaonedemo/jogamp/linux-i586/libnativewindow_awt.so deleted file mode 100644 index 1a5446d6..00000000 Binary files a/examples/javaonedemo/jogamp/linux-i586/libnativewindow_awt.so and /dev/null differ diff --git a/examples/javaonedemo/jogamp/linux-i586/libnativewindow_x11.so b/examples/javaonedemo/jogamp/linux-i586/libnativewindow_x11.so deleted file mode 100644 index 9e18ccd0..00000000 Binary files a/examples/javaonedemo/jogamp/linux-i586/libnativewindow_x11.so and /dev/null differ diff --git a/examples/javaonedemo/jogamp/linux-i586/libnewt.so b/examples/javaonedemo/jogamp/linux-i586/libnewt.so deleted file mode 100644 index 9d00b7d5..00000000 Binary files a/examples/javaonedemo/jogamp/linux-i586/libnewt.so and /dev/null differ diff --git a/examples/javaonedemo/jogamp/macosx-universal/libgluegen-rt.jnilib b/examples/javaonedemo/jogamp/macosx-universal/libgluegen-rt.jnilib deleted file mode 100644 index 4d5eac66..00000000 Binary files a/examples/javaonedemo/jogamp/macosx-universal/libgluegen-rt.jnilib and /dev/null differ diff --git a/examples/javaonedemo/jogamp/macosx-universal/libjogl_desktop.jnilib b/examples/javaonedemo/jogamp/macosx-universal/libjogl_desktop.jnilib deleted file mode 100644 index ebc22dcd..00000000 Binary files a/examples/javaonedemo/jogamp/macosx-universal/libjogl_desktop.jnilib and /dev/null differ diff --git a/examples/javaonedemo/jogamp/macosx-universal/libjogl_mobile.jnilib b/examples/javaonedemo/jogamp/macosx-universal/libjogl_mobile.jnilib deleted file mode 100644 index 9a4be3a7..00000000 Binary files a/examples/javaonedemo/jogamp/macosx-universal/libjogl_mobile.jnilib and /dev/null differ diff --git a/examples/javaonedemo/jogamp/macosx-universal/libnativewindow_awt.jnilib b/examples/javaonedemo/jogamp/macosx-universal/libnativewindow_awt.jnilib deleted file mode 100644 index 90607796..00000000 Binary files a/examples/javaonedemo/jogamp/macosx-universal/libnativewindow_awt.jnilib and /dev/null differ diff --git a/examples/javaonedemo/jogamp/macosx-universal/libnativewindow_macosx.jnilib b/examples/javaonedemo/jogamp/macosx-universal/libnativewindow_macosx.jnilib deleted file mode 100644 index 9b5c146f..00000000 Binary files a/examples/javaonedemo/jogamp/macosx-universal/libnativewindow_macosx.jnilib and /dev/null differ diff --git a/examples/javaonedemo/jogamp/macosx-universal/libnewt.jnilib b/examples/javaonedemo/jogamp/macosx-universal/libnewt.jnilib deleted file mode 100644 index 2396a034..00000000 Binary files a/examples/javaonedemo/jogamp/macosx-universal/libnewt.jnilib and /dev/null differ diff --git a/examples/javaonedemo/jogamp/windows-amd64/gluegen-rt.dll b/examples/javaonedemo/jogamp/windows-amd64/gluegen-rt.dll deleted file mode 100644 index 9ea63b1c..00000000 Binary files a/examples/javaonedemo/jogamp/windows-amd64/gluegen-rt.dll and /dev/null differ diff --git a/examples/javaonedemo/jogamp/windows-amd64/jogl_desktop.dll b/examples/javaonedemo/jogamp/windows-amd64/jogl_desktop.dll deleted file mode 100644 index 2b278207..00000000 Binary files a/examples/javaonedemo/jogamp/windows-amd64/jogl_desktop.dll and /dev/null differ diff --git a/examples/javaonedemo/jogamp/windows-amd64/jogl_mobile.dll b/examples/javaonedemo/jogamp/windows-amd64/jogl_mobile.dll deleted file mode 100644 index 9705b641..00000000 Binary files a/examples/javaonedemo/jogamp/windows-amd64/jogl_mobile.dll and /dev/null differ diff --git a/examples/javaonedemo/jogamp/windows-amd64/nativewindow_awt.dll b/examples/javaonedemo/jogamp/windows-amd64/nativewindow_awt.dll deleted file mode 100644 index bf675633..00000000 Binary files a/examples/javaonedemo/jogamp/windows-amd64/nativewindow_awt.dll and /dev/null differ diff --git a/examples/javaonedemo/jogamp/windows-amd64/nativewindow_win32.dll b/examples/javaonedemo/jogamp/windows-amd64/nativewindow_win32.dll deleted file mode 100644 index 044d0800..00000000 Binary files a/examples/javaonedemo/jogamp/windows-amd64/nativewindow_win32.dll and /dev/null differ diff --git a/examples/javaonedemo/jogamp/windows-amd64/newt.dll b/examples/javaonedemo/jogamp/windows-amd64/newt.dll deleted file mode 100644 index aa7e2f9c..00000000 Binary files a/examples/javaonedemo/jogamp/windows-amd64/newt.dll and /dev/null differ diff --git a/examples/javaonedemo/jogamp/windows-x86/gluegen-rt.dll b/examples/javaonedemo/jogamp/windows-x86/gluegen-rt.dll deleted file mode 100644 index 409fd662..00000000 Binary files a/examples/javaonedemo/jogamp/windows-x86/gluegen-rt.dll and /dev/null differ diff --git a/examples/javaonedemo/jogamp/windows-x86/jogl_desktop.dll b/examples/javaonedemo/jogamp/windows-x86/jogl_desktop.dll deleted file mode 100644 index 415602e9..00000000 Binary files a/examples/javaonedemo/jogamp/windows-x86/jogl_desktop.dll and /dev/null differ diff --git a/examples/javaonedemo/jogamp/windows-x86/jogl_mobile.dll b/examples/javaonedemo/jogamp/windows-x86/jogl_mobile.dll deleted file mode 100644 index 5cb0d6b3..00000000 Binary files a/examples/javaonedemo/jogamp/windows-x86/jogl_mobile.dll and /dev/null differ diff --git a/examples/javaonedemo/jogamp/windows-x86/nativewindow_awt.dll b/examples/javaonedemo/jogamp/windows-x86/nativewindow_awt.dll deleted file mode 100644 index d3868c7b..00000000 Binary files a/examples/javaonedemo/jogamp/windows-x86/nativewindow_awt.dll and /dev/null differ diff --git a/examples/javaonedemo/jogamp/windows-x86/nativewindow_win32.dll b/examples/javaonedemo/jogamp/windows-x86/nativewindow_win32.dll deleted file mode 100644 index a9c0174d..00000000 Binary files a/examples/javaonedemo/jogamp/windows-x86/nativewindow_win32.dll and /dev/null differ diff --git a/examples/javaonedemo/jogamp/windows-x86/newt.dll b/examples/javaonedemo/jogamp/windows-x86/newt.dll deleted file mode 100644 index 46f5f8e7..00000000 Binary files a/examples/javaonedemo/jogamp/windows-x86/newt.dll and /dev/null differ diff --git a/examples/javaonedemo/life.bat b/examples/javaonedemo/life.bat deleted file mode 100644 index 7b3bd0bf..00000000 --- a/examples/javaonedemo/life.bat +++ /dev/null @@ -1,7 +0,0 @@ -@echo off -java ^ - -Djava.library.path=../../com.amd.aparapi.jni/dist ^ - -classpath ../../com.amd.aparapi/dist/aparapi.jar;javaonedemo.jar ^ - com.amd.aparapi.examples.javaonedemo.Life - - diff --git a/examples/javaonedemo/life.sh b/examples/javaonedemo/life.sh deleted file mode 100644 index 22e92a52..00000000 --- a/examples/javaonedemo/life.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -java \ - -Djava.library.path=../../com.amd.aparapi.jni/dist \ - -classpath ../../com.amd.aparapi/dist/aparapi.jar:javaonedemo.jar \ - com.amd.aparapi.examples.javaonedemo.Life diff --git a/examples/javaonedemo/mandel.bat b/examples/javaonedemo/mandel.bat deleted file mode 100644 index f8372d85..00000000 --- a/examples/javaonedemo/mandel.bat +++ /dev/null @@ -1,7 +0,0 @@ -@echo off -java ^ - -Djava.library.path=../../com.amd.aparapi.jni/dist ^ - -classpath ../../com.amd.aparapi/dist/aparapi.jar;javaonedemo.jar ^ - com.amd.aparapi.examples.javaonedemo.Mandel - - diff --git a/examples/javaonedemo/mandel.sh b/examples/javaonedemo/mandel.sh deleted file mode 100644 index bc386096..00000000 --- a/examples/javaonedemo/mandel.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -java \ - -Djava.library.path=../../com.amd.aparapi.jni/dist \ - -classpath ../../com.amd.aparapi/dist/aparapi.jar:javaonedemo.jar \ - com.amd.aparapi.examples.javaonedemo.Mandel diff --git a/examples/javaonedemo/nbody.bat b/examples/javaonedemo/nbody.bat deleted file mode 100644 index a8fd8d4a..00000000 --- a/examples/javaonedemo/nbody.bat +++ /dev/null @@ -1,7 +0,0 @@ -@echo off -java ^ - -Djava.library.path=..\..\com.amd.aparapi.jni\dist;jogamp\windows-%PROCESSOR_ARCHITECTURE% ^ - -classpath jogamp\gluegen-rt.jar;jogamp\jogl-all.jar;..\..\com.amd.aparapi\dist\aparapi.jar;javaonedemo.jar ^ - com.amd.aparapi.examples.javaonedemo.NBody - - diff --git a/examples/javaonedemo/nbody.sh b/examples/javaonedemo/nbody.sh deleted file mode 100644 index d3ac3c82..00000000 --- a/examples/javaonedemo/nbody.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -case $(uname -i) in - x86_64 ) - export ARCH=linux-amd64 ;; - *) - export ARCH=linux-i586 ;; -esac - -java \ - -Djava.library.path=../../com.amd.aparapi.jni/dist:jogamp/${ARCH} \ - -classpath jogamp/gluegen-rt.jar:jogamp/jogl-all.jar:../../com.amd.aparapi/dist/aparapi.jar:javaonedemo.jar \ - com.amd.aparapi.examples.javaonedemo.NBody diff --git a/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/Life.java b/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/Life.java deleted file mode 100644 index fafb309f..00000000 --- a/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/Life.java +++ /dev/null @@ -1,300 +0,0 @@ -/* -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.amd.aparapi.examples.javaonedemo; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.image.BufferedImage; -import java.awt.image.DataBufferInt; -import java.util.Arrays; -import java.util.List; - -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.WindowConstants; - -import com.amd.aparapi.Kernel; -import com.amd.aparapi.ProfileInfo; -import com.amd.aparapi.Range; - -/** - * An example Aparapi application which demonstrates Conways 'Game Of Life'. - * - * Original code from Witold Bolt's site https://github.com/houp/aparapi/tree/master/samples/gameoflife. - * - * Converted to use int buffer and some performance tweaks by Gary Frost - * - * @author Wiltold Bolt - * @author Gary Frost - */ -public class Life{ - - /** - * LifeKernel represents the data parallel algorithm describing by Conway's game of life. - * - * http://en.wikipedia.org/wiki/Conway's_Game_of_Life - * - * We examine the state of each pixel and its 8 neighbors and apply the following rules. - * - * if pixel is dead (off) and number of neighbors == 3 { - * pixel is turned on - * } else if pixel is alive (on) and number of neighbors is neither 2 or 3 - * pixel is turned off - * } - * - * We use an image buffer which is 2*width*height the size of screen and we use fromBase and toBase to track which half of the buffer is being mutated for each pass. We basically - * copy from getGlobalId()+fromBase to getGlobalId()+toBase; - * - * - * Prior to each pass the values of fromBase and toBase are swapped. - * - */ - - public static class LifeKernel extends Kernel{ - - private static final int ALIVE = 0xffffff; - - private static final int DEAD = 0; - - private final int[] imageData; - - private final int width; - - private final int height; - - private final Range range; - - private int fromBase; - - private int toBase; - - public LifeKernel(int _width, int _height, BufferedImage _image) { - - imageData = ((DataBufferInt) _image.getRaster().getDataBuffer()).getData(); - width = _width; - height = _height; - range = Range.create(width * height, 256); - System.out.println("range = " + range); - - setExplicit(true); // This gives us a performance boost for GPU mode. - - fromBase = height * width; - toBase = 0; - Arrays.fill(imageData, LifeKernel.DEAD); - /** draw a line across the image **/ - for (int i = width * (height / 2) + width / 10; i < width * (height / 2 + 1) - width / 10; i++) { - imageData[toBase + i] = LifeKernel.ALIVE; - imageData[fromBase + i] = LifeKernel.ALIVE; - } - - put(imageData); // Because we are using explicit buffer management we must put the imageData array - - } - - @Override public void run() { - int gid = getGlobalId(); - int to = gid + toBase; - int from = gid + fromBase; - int x = gid % width; - int y = gid / width; - - if ((x == 0 || x == width - 1 || y == 0 || y == height - 1)) { - // This pixel is on the border of the view, just keep existing value - imageData[to] = imageData[from]; - } else { - // Count the number of neighbors. We use (value&1x) to turn pixel value into either 0 or 1 - int neighbors = (imageData[from - 1] & 1) + // EAST - (imageData[from + 1] & 1) + // WEST - (imageData[from - width - 1] & 1) + // NORTHEAST - (imageData[from - width] & 1) + // NORTH - (imageData[from - width + 1] & 1) + // NORTHWEST - (imageData[from + width - 1] & 1) + // SOUTHEAST - (imageData[from + width] & 1) + // SOUTH - (imageData[from + width + 1] & 1); // SOUTHWEST - - // The game of life logic - if (neighbors == 3 || (neighbors == 2 && imageData[from] == ALIVE)) { - imageData[to] = ALIVE; - } else { - imageData[to] = DEAD; - } - - } - - } - - public void nextGeneration() { - // swap fromBase and toBase - int swap = fromBase; - fromBase = toBase; - toBase = swap; - - execute(range); - - } - - } - - static boolean running = false; - - // static LifeKernel lifeKernel = null; - - static long start= 0L; - static int generations= 0; - static double generationsPerSecondField = 0; - - public static void main(String[] _args) { - - JFrame frame = new JFrame("Game of Life"); - final int width = Integer.getInteger("width", 1024 + 256); - - final int height = Integer.getInteger("height", 768 - 64 -32); - - // Buffer is twice the size as the screen. We will alternate between mutating data from top to bottom - // and bottom to top in alternate generation passses. The LifeKernel will track which pass is which - final BufferedImage image = new BufferedImage(width, height * 2, BufferedImage.TYPE_INT_RGB); - - final LifeKernel lifeKernel = new LifeKernel(width, height, image); - lifeKernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP); - - final Font font = new Font("Garamond", Font.BOLD, 100); - // Create a component for viewing the offsecreen image - @SuppressWarnings("serial") JComponent viewer = new JComponent(){ - @Override public void paintComponent(Graphics g) { - g.setFont(font); - g.setColor(Color.WHITE); - if (lifeKernel.isExplicit()) { - lifeKernel.get(lifeKernel.imageData); // We only pull the imageData when we intend to use it. - List profileInfo = lifeKernel.getProfileInfo(); - if (profileInfo != null) { - for (ProfileInfo p : profileInfo) { - System.out.print(" " + p.getType() + " " + p.getLabel() + " " + (p.getStart() / 1000) + " .. " - + (p.getEnd() / 1000) + " " + (p.getEnd() - p.getStart()) / 1000 + "us"); - } - System.out.println(); - } - } - // We copy one half of the offscreen buffer to the viewer, we copy the half that we just mutated. - if (lifeKernel.fromBase == 0) { - g.drawImage(image, 0, 0, width, height, 0, 0, width, height, this); - } else { - g.drawImage(image, 0, 0, width, height, 0, height, width, 2 * height, this); - } - long now = System.currentTimeMillis(); - if (now - start > 1000) { - generationsPerSecondField = (generations * 1000.0) / (now - start); - start = now; - generations = 0; - } - g.drawString(String.format("%5.2f", generationsPerSecondField), 20, 100); - - } - }; - - JPanel controlPanel = new JPanel(new FlowLayout()); - frame.getContentPane().add(controlPanel, BorderLayout.SOUTH); - - final JButton startButton = new JButton("Start"); - - startButton.addActionListener(new ActionListener(){ - @Override public void actionPerformed(ActionEvent e) { - running = true; - startButton.setEnabled(false); - } - }); - controlPanel.add(startButton); - - final String[] choices = new String[] { - "Java Threads", - "GPU OpenCL" - }; - - final JComboBox modeButton = new JComboBox(choices); - - modeButton.addItemListener(new ItemListener(){ - @Override public void itemStateChanged(ItemEvent e) { - String item = (String) modeButton.getSelectedItem(); - if (item.equals(choices[0])) { - lifeKernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP); - } else if (item.equals(choices[1])) { - lifeKernel.setExecutionMode(Kernel.EXECUTION_MODE.GPU); - } - } - - }); - controlPanel.add(modeButton); - - // Set the default size and add to the frames content pane - viewer.setPreferredSize(new Dimension(width, height)); - frame.getContentPane().add(viewer); - - // Swing housekeeping - frame.pack(); - frame.setVisible(true); - frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - - while (!running) { - try { - Thread.sleep(10); - viewer.repaint(); - } catch (InterruptedException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - start = System.currentTimeMillis(); - while (true) { - lifeKernel.nextGeneration(); // Work is performed here - generations++; - viewer.repaint(); // Request a repaint of the viewer (causes paintComponent(Graphics) to be called later not synchronous - } - - } -} diff --git a/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/Mandel.java b/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/Mandel.java deleted file mode 100644 index 7ea0d3fc..00000000 --- a/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/Mandel.java +++ /dev/null @@ -1,346 +0,0 @@ -/* -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.amd.aparapi.examples.javaonedemo; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Point; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.image.BufferedImage; -import java.awt.image.DataBufferInt; -import java.util.List; - -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JPanel; - -import com.amd.aparapi.Kernel; -import com.amd.aparapi.ProfileInfo; -import com.amd.aparapi.Range; - -/** - * An example Aparapi application which displays a view of the Mandelbrot set and lets the user zoom in to a particular point. - * - * When the user clicks on the view, this example application will zoom in to the clicked point and zoom out there after. - * On GPU, additional computing units will offer a better viewing experience. On the other hand on CPU, this example - * application might suffer with sub-optimal frame refresh rate as compared to GPU. - * - * @author gfrost - * - */ - -public class Mandel{ - - /** - * An Aparapi Kernel implementation for creating a scaled view of the mandelbrot set. - * - * @author gfrost - * - */ - - public static class MandelKernel extends Kernel{ - - /** RGB buffer used to store the Mandelbrot image. This buffer holds (width * height) RGB values. */ - final private int rgb[]; - - /** Mandelbrot image width. */ - final private int width; - - /** Mandelbrot image height. */ - final private int height; - - /** Maximum iterations for Mandelbrot. */ - final private int maxIterations = 64; - - /** Palette which maps iteration values to RGB values. */ - @Constant final private int pallette[] = new int[maxIterations + 1]; - - /** Mutable values of scale, offsetx and offsety so that we can modify the zoom level and position of a view. */ - private float scale = .0f; - - private float offsetx = .0f; - - private float offsety = .0f; - - /** - * Initialize the Kernel. - * - * @param _width Mandelbrot image width - * @param _height Mandelbrot image height - * @param _rgb Mandelbrot image RGB buffer - * @param _pallette Mandelbrot image palette - */ - public MandelKernel(int _width, int _height, int[] _rgb) { - //Initialize palette values - for (int i = 0; i < maxIterations; i++) { - float h = i / (float) maxIterations; - float b = 1.0f - h * h; - pallette[i] = Color.HSBtoRGB(h, 1f, b); - } - - width = _width; - height = _height; - rgb = _rgb; - - } - - @Override public void run() { - - /** Determine which RGB value we are going to process (0..RGB.length). */ - int gid = getGlobalId(); - - /** Translate the gid into an x an y value. */ - float x = (((gid % width * scale) - ((scale / 2) * width)) / width) + offsetx; - - float y = (((gid / height * scale) - ((scale / 2) * height)) / height) + offsety; - - int count = 0; - - float zx = x; - float zy = y; - float new_zx = 0f; - - // Iterate until the algorithm converges or until maxIterations are reached. - while (count < maxIterations && zx * zx + zy * zy < 8) { - new_zx = zx * zx - zy * zy + x; - zy = 2 * zx * zy + y; - zx = new_zx; - count++; - } - - // Pull the value out of the palette for this iteration count. - rgb[gid] = pallette[count]; - } - - public void setScaleAndOffset(float _scale, float _offsetx, float _offsety) { - offsetx = _offsetx; - offsety = _offsety; - scale = _scale; - } - - } - - /** User selected zoom-in point on the Mandelbrot view. */ - public static volatile Point to = null; - - public static int frameCount = 0; - - public static long start = 0; - - @SuppressWarnings("serial") public static void main(String[] _args) { - - JFrame frame = new JFrame("MandelBrot"); - - /** Width of Mandelbrot view. */ - final int width = 768-64-32; - - /** Height of Mandelbrot view. */ - final int height = 768-64-32; - - /** Mandelbrot image height. */ - final Range range = Range.create(width * height); - - /** Image for Mandelbrot view. */ - final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - final BufferedImage offscreen = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - // Extract the underlying RGB buffer from the image. - // Pass this to the kernel so it operates directly on the RGB buffer of the image - final int[] rgb = ((DataBufferInt) offscreen.getRaster().getDataBuffer()).getData(); - final int[] imageRgb = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); - // Create a Kernel passing the size, RGB buffer and the palette. - final MandelKernel kernel = new MandelKernel(width, height, rgb); - - final Font font = new Font("Garamond", Font.BOLD, 100); - // Draw Mandelbrot image - JComponent viewer = new JComponent(){ - @Override public void paintComponent(Graphics g) { - - g.drawImage(image, 0, 0, width, height, this); - g.setFont(font); - g.setColor(Color.WHITE); - long now = System.currentTimeMillis(); - // if (now - start > 1000) { - double framesPerSecond = (frameCount * 1000.0) / (now - start); - g.drawString(String.format("%5.2f", framesPerSecond), 20, 100); - // generationsPerSecond.setText(String.format("%5.2f", generationsPerSecondField)); - - // frames++; - // } - } - }; - - JPanel controlPanel = new JPanel(new FlowLayout()); - frame.getContentPane().add(controlPanel, BorderLayout.SOUTH); - - final String[] choices = new String[] { - // "Java Sequential", - "Java Threads", - "GPU OpenCL" - }; - - final JComboBox modeButton = new JComboBox(choices); - - modeButton.addItemListener(new ItemListener(){ - @Override public void itemStateChanged(ItemEvent e) { - String item = (String) modeButton.getSelectedItem(); - - // if (item.equals(choices[2])) { - // modeButton = gpuMandelBrot; - // } else - if (item.equals(choices[0])) { - kernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP); - frameCount = 0; - start = System.currentTimeMillis(); - - // modeButton = javaMandelBrot; - } else if (item.equals(choices[1])) { - kernel.setExecutionMode(Kernel.EXECUTION_MODE.GPU); - frameCount = 0; - start = System.currentTimeMillis(); - // modeButton = javaMandelBrotMultiThread; - } - } - - }); - controlPanel.add(modeButton); - - // Set the size of JComponent which displays Mandelbrot image - viewer.setPreferredSize(new Dimension(width, height)); - - final Object doorBell = new Object(); - - // Mouse listener which reads the user clicked zoom-in point on the Mandelbrot view - viewer.addMouseListener(new MouseAdapter(){ - @Override public void mouseClicked(MouseEvent e) { - to = e.getPoint(); - synchronized (doorBell) { - doorBell.notify(); - } - } - }); - - // Swing housework to create the frame - frame.getContentPane().add(viewer, BorderLayout.CENTER); - frame.pack(); - frame.setLocationRelativeTo(null); - frame.setVisible(true); - - float defaultScale = 3f; - - // Set the default scale and offset, execute the kernel and force a repaint of the viewer. - kernel.setScaleAndOffset(defaultScale, -1f, 0f); - kernel.execute(range); - kernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP); - System.arraycopy(rgb, 0, imageRgb, 0, rgb.length); - viewer.repaint(); - - // Window listener to dispose Kernel resources on user exit. - frame.addWindowListener(new WindowAdapter(){ - public void windowClosing(WindowEvent _windowEvent) { - kernel.dispose(); - System.exit(0); - } - }); - - // Wait until the user selects a zoom-in point on the Mandelbrot view. - while (true) { - - // Wait for the user to click somewhere - while (to == null) { - synchronized (doorBell) { - try { - doorBell.wait(); - } catch (InterruptedException ie) { - ie.getStackTrace(); - } - } - } - - float x = -1f; - float y = 0f; - float scale = defaultScale; - float tox = (float) (to.x - width / 2) / width * scale; - float toy = (float) (to.y - height / 2) / height * scale; - - // This is how many frames we will display as we zoom in and out. - int frames = 128; - frameCount = 0; - start = System.currentTimeMillis(); - for (int sign = -1; sign < 2; sign += 2) { - for (int i = 0; i < frames - 4; i++) { - frameCount++; - scale = scale + sign * defaultScale / frames; - x = x - sign * (tox / frames); - y = y - sign * (toy / frames); - - // Set the scale and offset, execute the kernel and force a repaint of the viewer. - kernel.setScaleAndOffset(scale, x, y); - kernel.execute(range); - List profileInfo = kernel.getProfileInfo(); - if (profileInfo != null && profileInfo.size() > 0) { - for (ProfileInfo p : profileInfo) { - System.out.print(" " + p.getType() + " " + p.getLabel() + " " + (p.getStart() / 1000) + " .. " - + (p.getEnd() / 1000) + " " + (p.getEnd() - p.getStart()) / 1000 + "us"); - } - System.out.println(); - } - - System.arraycopy(rgb, 0, imageRgb, 0, rgb.length); - viewer.repaint(); - } - } - - // Reset zoom-in point. - to = null; - - } - - } - -} diff --git a/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/NBody.java b/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/NBody.java deleted file mode 100644 index 44cbc037..00000000 --- a/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/NBody.java +++ /dev/null @@ -1,380 +0,0 @@ -/* -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.amd.aparapi.examples.javaonedemo; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -import javax.media.opengl.GL; -import javax.media.opengl.GL2; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLException; -import javax.media.opengl.GLProfile; -import javax.media.opengl.awt.GLCanvas; -import javax.media.opengl.fixedfunc.GLLightingFunc; -import javax.media.opengl.glu.GLU; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.WindowConstants; - -import com.amd.aparapi.Kernel; -import com.amd.aparapi.ProfileInfo; -import com.amd.aparapi.Range; -import com.jogamp.opengl.util.FPSAnimator; -import com.jogamp.opengl.util.gl2.GLUT; -import com.jogamp.opengl.util.texture.Texture; -import com.jogamp.opengl.util.texture.TextureIO; - -/** - * NBody implementing demonstrating Aparapi kernels. - * - * For a description of the NBody problem. - * @see http://en.wikipedia.org/wiki/N-body_problem - * - * We use JOGL to render the bodies. - * @see http://jogamp.org/jogl/www/ - * - * @author gfrost - * - */ -public class NBody{ - - public static class NBodyKernel extends Kernel{ - protected final float delT = .005f; - - protected final float espSqr = 1.0f; - - protected final float mass = 5f; - - private final Range range; - - private final float[] xyz; // positions xy and z of bodies - - private final float[] vxyz; // velocity component of x,y and z of bodies - - /** - * Constructor initializes xyz and vxyz arrays. - * @param _bodies - */ - public NBodyKernel(Range _range) { - range = _range; - // range = Range.create(bodies); - xyz = new float[range.getGlobalSize(0) * 3]; - vxyz = new float[range.getGlobalSize(0) * 3]; - float maxDist = 20f; - for (int body = 0; body < range.getGlobalSize(0) * 3; body += 3) { - - float theta = (float) (Math.random() * Math.PI * 2); - float phi = (float) (Math.random() * Math.PI * 2); - float radius = (float) (Math.random() * maxDist); - - // get the 3D dimensional coordinates - xyz[body + 0] = (float) (radius * Math.cos(theta) * Math.sin(phi)); - xyz[body + 1] = (float) (radius * Math.sin(theta) * Math.sin(phi)); - xyz[body + 2] = (float) (radius * Math.cos(phi)); - - // divide into two 'spheres of bodies' by adjusting x - - if (body % 2 == 0) { - xyz[body + 0] += maxDist * 1.5; - } else { - xyz[body + 0] -= maxDist * 1.5; - } - } - setExplicit(true); - } - - /** - * Here is the kernel entrypoint. Here is where we calculate the position of each body - */ - @Override public void run() { - int body = getGlobalId(); - int count = getGlobalSize(0) * 3; - int globalId = body * 3; - - float accx = 0.f; - float accy = 0.f; - float accz = 0.f; - - float myPosx = xyz[globalId + 0]; - float myPosy = xyz[globalId + 1]; - float myPosz = xyz[globalId + 2]; - for (int i = 0; i < count; i += 3) { - float dx = xyz[i + 0] - myPosx; - float dy = xyz[i + 1] - myPosy; - float dz = xyz[i + 2] - myPosz; - float invDist = rsqrt((dx * dx) + (dy * dy) + (dz * dz) + espSqr); - float s = mass * invDist * invDist * invDist; - accx = accx + s * dx; - accy = accy + s * dy; - accz = accz + s * dz; - } - accx = accx * delT; - accy = accy * delT; - accz = accz * delT; - xyz[globalId + 0] = myPosx + vxyz[globalId + 0] * delT + accx * .5f * delT; - xyz[globalId + 1] = myPosy + vxyz[globalId + 1] * delT + accy * .5f * delT; - xyz[globalId + 2] = myPosz + vxyz[globalId + 2] * delT + accz * .5f * delT; - - vxyz[globalId + 0] = vxyz[globalId + 0] + accx; - vxyz[globalId + 1] = vxyz[globalId + 1] + accy; - vxyz[globalId + 2] = vxyz[globalId + 2] + accz; - } - - /** - * Render all particles to the OpenGL context - * @param gl - */ - - protected void render(GL2 gl) { - gl.glBegin(GL2.GL_QUADS); - - for (int i = 0; i < range.getGlobalSize(0) * 3; i += 3) { - gl.glTexCoord2f(0, 1); - gl.glVertex3f(xyz[i + 0], xyz[i + 1] + 1, xyz[i + 2]); - gl.glTexCoord2f(0, 0); - gl.glVertex3f(xyz[i + 0], xyz[i + 1], xyz[i + 2]); - gl.glTexCoord2f(1, 0); - gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1], xyz[i + 2]); - gl.glTexCoord2f(1, 1); - gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1] + 1, xyz[i + 2]); - } - gl.glEnd(); - } - - } - - public static int width; - - public static int height; - - public static boolean running; - - public static Texture texture; - - public static void main(String _args[]) { - - final NBodyKernel kernel = new NBodyKernel(Range.create(Integer.getInteger("bodies", 10000))); - kernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP); - JFrame frame = new JFrame("NBody"); - - JPanel panel = new JPanel(new BorderLayout()); - JPanel controlPanel = new JPanel(new FlowLayout()); - panel.add(controlPanel, BorderLayout.SOUTH); - - final JButton startButton = new JButton("Start"); - - startButton.addActionListener(new ActionListener(){ - @Override public void actionPerformed(ActionEvent e) { - running = true; - startButton.setEnabled(false); - } - }); - controlPanel.add(startButton); - - // controlPanel.add(new JLabel(" Particles")); - - final String[] choices = new String[] { - // "Java Sequential", - "Java Threads", - "GPU OpenCL" - }; - - final JComboBox modeButton = new JComboBox(choices); - - modeButton.addItemListener(new ItemListener(){ - @Override public void itemStateChanged(ItemEvent e) { - String item = (String) modeButton.getSelectedItem(); - - // if (item.equals(choices[2])) { - // modeButton = gpuMandelBrot; - // } else - if (item.equals(choices[0])) { - kernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP); - - // modeButton = javaMandelBrot; - } else if (item.equals(choices[1])) { - // lifeKernel = lifeKernelGPU; - // modeButton = javaMandelBrotMultiThread; - kernel.setExecutionMode(Kernel.EXECUTION_MODE.GPU); - } - } - - }); - controlPanel.add(modeButton); - - controlPanel.add(new JLabel(" " + kernel.range.getGlobalSize(0) + " Particles")); - - GLCapabilities caps = new GLCapabilities(null); - final GLProfile profile = caps.getGLProfile(); - caps.setDoubleBuffered(true); - caps.setHardwareAccelerated(true); - final GLCanvas canvas = new GLCanvas(caps); - - final GLUT glut = new GLUT(); - - Dimension dimension = new Dimension(Integer.getInteger("width", 1024 + 256), Integer.getInteger("height", 768 - 64-32)); - canvas.setPreferredSize(dimension); - - canvas.addGLEventListener(new GLEventListener(){ - private double ratio; - - private final float xeye = 0f; - - private final float yeye = 0f; - - private final float zeye = 100f; - - private final float xat = 0f; - - private final float yat = 0f; - - private final float zat = 0f; - - public final float zoomFactor = 1.0f; - - private int frames; - - private long last = System.currentTimeMillis(); - - @Override public void dispose(GLAutoDrawable drawable) { - - } - - @Override public void display(GLAutoDrawable drawable) { - - GL2 gl = drawable.getGL().getGL2(); - texture.enable(gl); - texture.bind(gl); - - gl.glLoadIdentity(); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - gl.glColor3f(1f, 1f, 1f); - - GLU glu = new GLU(); - glu.gluPerspective(45f, ratio, 0f, 1000f); - - glu.gluLookAt(xeye, yeye, zeye * zoomFactor, xat, yat, zat, 0f, 1f, 0f); - if (running) { - kernel.execute(kernel.range); - if (kernel.isExplicit()) { - kernel.get(kernel.xyz); - } - List profileInfo = kernel.getProfileInfo(); - if (profileInfo != null && profileInfo.size() > 0) { - for (ProfileInfo p : profileInfo) { - System.out.print(" " + p.getType() + " " + p.getLabel() + (p.getEnd() - p.getStart()) / 1000 + "us"); - } - System.out.println(); - } - } - kernel.render(gl); - - long now = System.currentTimeMillis(); - long time = now - last; - frames++; - - if (running) { - float framesPerSecond = (float) ((frames * 1000.0f) / time); - - gl.glColor3f(.5f, .5f, .5f); - gl.glRasterPos2i(-40, 38); - glut.glutBitmapString(8, String.format("%5.2f fps", framesPerSecond)); - gl.glFlush(); - } - frames = 0; - last = now; - - } - - @Override public void init(GLAutoDrawable drawable) { - final GL2 gl = drawable.getGL().getGL2(); - - gl.glShadeModel(GLLightingFunc.GL_SMOOTH); - gl.glEnable(GL.GL_BLEND); - gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); - try { - InputStream textureStream = NBody.class.getResourceAsStream("particle.jpg"); - texture = TextureIO.newTexture(textureStream, false, null); - } catch (IOException e) { - e.printStackTrace(); - } catch (GLException e) { - e.printStackTrace(); - } - - } - - @Override public void reshape(GLAutoDrawable drawable, int x, int y, int _width, int _height) { - width = _width; - height = _height; - - GL2 gl = drawable.getGL().getGL2(); - gl.glViewport(0, 0, width, height); - - ratio = (double) width / (double) height; - - } - - }); - - panel.add(canvas, BorderLayout.CENTER); - frame.getContentPane().add(panel, BorderLayout.CENTER); - final FPSAnimator animator = new FPSAnimator(canvas, 100); - - frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - frame.pack(); - frame.setVisible(true); - - animator.start(); - - } - -} diff --git a/examples/movie/.classpath b/examples/movie/.classpath deleted file mode 100644 index bea7a293..00000000 --- a/examples/movie/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/examples/movie/build.xml b/examples/movie/build.xml deleted file mode 100644 index b873dcc0..00000000 --- a/examples/movie/build.xml +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/movie/movie.bat b/examples/movie/movie.bat deleted file mode 100644 index f1a0c333..00000000 --- a/examples/movie/movie.bat +++ /dev/null @@ -1,15 +0,0 @@ -SETLOCAL -if /I %PROCESSOR_ARCHITECTURE%==x86 goto win32 -echo "win64!" -set PATH=%PATH%;ffmpeg\ffmpeg-git-9c2651a-win64-shared\bin -set PATH=%PATH%;jjmpeg\jjmpeg-0.0\native\mswin-amd64 -goto win64 -:win32 -echo "win32!" -set PATH=%PATH%;ffmpeg\ffmpeg-git-9c2651a-win32-shared\bin -set PATH=%PATH%;jjmpeg\jjmpeg-0.0\native\mswin-i386 -:win64 -set PATH=%PATH%;..\..\com.amd.aparapi.jni\dist -java -classpath jjmpeg\jjmpeg-0.0\dist\jjmpeg.jar;..\..\com.amd.aparapi\dist\aparapi.jar;movie.jar; com.amd.aparapi.examples.movie.%1 %2 - -ENDLOCAL diff --git a/examples/movie/src/com/amd/aparapi/examples/movie/AparapiSolution.java b/examples/movie/src/com/amd/aparapi/examples/movie/AparapiSolution.java deleted file mode 100644 index 6c689252..00000000 --- a/examples/movie/src/com/amd/aparapi/examples/movie/AparapiSolution.java +++ /dev/null @@ -1,131 +0,0 @@ -/* -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.amd.aparapi.examples.movie; - -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.awt.image.DataBufferByte; - - -import com.amd.aparapi.Kernel; -import com.amd.aparapi.Range; - -public class AparapiSolution{ - - public static class AparapiConvolution extends Kernel{ - - private byte[] inputData; - - private byte[] outputData; - - private int width; - - private int height; - - private Range range; - - float[] convMatrix3x3; - - public AparapiConvolution(BufferedImage _imageIn, BufferedImage _imageOut) { - inputData = ((DataBufferByte) _imageIn.getRaster().getDataBuffer()).getData(); - outputData = ((DataBufferByte) _imageOut.getRaster().getDataBuffer()).getData(); - width = _imageIn.getWidth(); - height = _imageIn.getHeight(); - range = Range.create2D(width * 3, height); - setExplicit(true); - - } - - public void processPixel(int x, int y, int w, int h) { - float accum = 0; - int count = 0; - for (int dx = -3; dx < 6; dx += 3) { - for (int dy = -1; dy < 2; dy += 1) { - int rgb = 0xff & inputData[((y + dy) * w) + (x + dx)]; - accum += rgb * convMatrix3x3[count++]; - } - } - outputData[y * w + x] = (byte) Math.max(0, Math.min((int) accum, 255)); - } - - public void run() { - int x = getGlobalId(0); - int y = getGlobalId(1); - int w = getGlobalSize(0); - int h = getGlobalSize(1); - if (x > 3 && x < (w - 3) && y > 1 && y < (h - 1)) { - processPixel(x, y, w, h); - } else { - outputData[y * w + x] = inputData[(y * w) + x]; - } - } - - public void apply(float[] _convMatrix3x3) { - convMatrix3x3 = _convMatrix3x3; - put(convMatrix3x3).put(inputData).execute(range).get(outputData); - } - - } - - public static void main(final String[] _args) { - String fileName = _args.length == 1 ? _args[0] : "Leo720p.wmv"; - - float[] convMatrix3x3 = new float[] { - 0f, - -10f, - 0f, - -10f, - 41f, - -10f, - 0f, - -10f, - 0f - }; - new JJMPEGPlayer("Aparapi - Solution", fileName, convMatrix3x3){ - AparapiConvolution kernel = null; - - @Override protected void processFrame(Graphics2D gc, float[] _convMatrix3x3, BufferedImage in, BufferedImage out) { - if (kernel == null) { - kernel = new AparapiConvolution(in, out); - } - kernel.apply(_convMatrix3x3); - } - }; - - } -} diff --git a/examples/movie/src/com/amd/aparapi/examples/movie/JJMPEGPlayer.java b/examples/movie/src/com/amd/aparapi/examples/movie/JJMPEGPlayer.java deleted file mode 100644 index 0957eef0..00000000 --- a/examples/movie/src/com/amd/aparapi/examples/movie/JJMPEGPlayer.java +++ /dev/null @@ -1,147 +0,0 @@ -/* -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.amd.aparapi.examples.movie; - -import java.awt.BorderLayout; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.SwingUtilities; - -import au.notzed.jjmpeg.io.JJMediaReader; -import au.notzed.jjmpeg.io.JJMediaReader.JJReaderVideo; - -/** - * Code based on Demo of JJVideoScanner class from jjmpeg - * - * See http://code.google.com/p/jjmpeg/ - * - * @author notzed - * @author gfrost - */ -public abstract class JJMPEGPlayer{ - - public JJMPEGPlayer(final String _title, final String _fileName, final float[] _convMatrix3x3) { - SwingUtilities.invokeLater(new Runnable(){ - final Object doorBell = new Object(); - - public void run() { - - JFrame frame = new JFrame(_title); - frame.getContentPane().setLayout(new BorderLayout()); - final JLabel label = new JLabel(){ - @Override public void paint(Graphics GC) { - super.paint(GC); - synchronized (doorBell) { - doorBell.notify(); - } - } - }; - frame.getContentPane().add(label, BorderLayout.CENTER); - - ConvMatrix3x3Editor editor = new ConvMatrix3x3Editor(_convMatrix3x3){ - @Override protected void updated(float[] _convMatrix3x3) { - - } - }; - frame.getContentPane().add(editor.component, BorderLayout.WEST); - - try { - final JJMediaReader reader = new JJMediaReader(_fileName); - final JJReaderVideo vs = reader.openFirstVideoStream(); - final BufferedImage in = vs.createImage(); - final BufferedImage out = vs.createImage(); - - label.setIcon(new ImageIcon(out)); - - new Thread(new Runnable(){ - public void run() { - int frames = 0; - long start = System.currentTimeMillis() - 1; - try { - while (true) { - JJMediaReader.JJReaderStream rs = reader.readFrame(); - if (rs != null) { - vs.getOutputFrame(in); - Graphics2D gc = in.createGraphics(); - frames++; - long fps = (frames * 1000) / (System.currentTimeMillis() - start); - gc.drawString("" + fps, 20, 20); - - processFrame(gc, _convMatrix3x3, in, out); - - label.repaint(); - synchronized (doorBell) { - try { - doorBell.wait(); - } catch (InterruptedException ie) { - ie.getStackTrace(); - } - } - } else { - reader.dispose(); - System.exit(1); - } - Thread.sleep(1); - } - } catch (Exception ex) { - ex.printStackTrace(); - Logger.getLogger(JJMPEGPlayer.class.getName()).log(Level.SEVERE, null, ex); - } - } - }).start(); - frame.pack(); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.setVisible(true); - } catch (Exception ex) { - Logger.getLogger(JJMPEGPlayer.class.getName()).log(Level.SEVERE, null, ex); - } - - } - }); - } - - protected abstract void processFrame(Graphics2D gc, float[] _convMatrix, BufferedImage in, BufferedImage _out); - -} diff --git a/examples/movie/src/com/amd/aparapi/examples/movie/PureJavaSolution.java b/examples/movie/src/com/amd/aparapi/examples/movie/PureJavaSolution.java deleted file mode 100644 index 21f16eff..00000000 --- a/examples/movie/src/com/amd/aparapi/examples/movie/PureJavaSolution.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.amd.aparapi.examples.movie; - -import java.awt.Graphics2D; -import java.awt.image.ConvolveOp; - -import java.awt.image.BufferedImage; - -public class PureJavaSolution{ - - public static void main(final String[] _args) { - String fileName = _args.length == 1 ? _args[0] : "Leo720p.wmv"; - - float[] convMatrix3x3 = new float[] { - 0f, - -10f, - 0f, - -10f, - 41f, - -10f, - 0f, - -10f, - 0f - }; - - new JJMPEGPlayer("lab_6.alternate", fileName, convMatrix3x3){ - - @Override protected void processFrame(Graphics2D _gc, float[] _convMatrix3x3, BufferedImage _in, BufferedImage _out) { - java.awt.image.Kernel conv = new java.awt.image.Kernel(3, 3, _convMatrix3x3); - ConvolveOp convOp = new ConvolveOp(conv, ConvolveOp.EDGE_NO_OP, null); - convOp.filter(_in, _out); - } - }; - - - } -} diff --git a/examples/movie/src/com/amd/aparapi/examples/movie/ReferenceSolution.java b/examples/movie/src/com/amd/aparapi/examples/movie/ReferenceSolution.java deleted file mode 100644 index fd82ca95..00000000 --- a/examples/movie/src/com/amd/aparapi/examples/movie/ReferenceSolution.java +++ /dev/null @@ -1,137 +0,0 @@ -/* -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.amd.aparapi.examples.movie; - -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.awt.image.DataBufferByte; - - -import com.amd.aparapi.Kernel; -import com.amd.aparapi.Range; - -public class ReferenceSolution{ - - public static class Convolution extends Kernel{ - - private byte[] inputData; - - private byte[] outputData; - - private int width; - - private int height; - - private Range range; - - float[] convMatrix3x3; - - public Convolution(BufferedImage _imageIn, BufferedImage _imageOut) { - inputData = ((DataBufferByte) _imageIn.getRaster().getDataBuffer()).getData(); - outputData = ((DataBufferByte) _imageOut.getRaster().getDataBuffer()).getData(); - width = _imageIn.getWidth(); - height = _imageIn.getHeight(); - range = Range.create2D(width * 3, height); - setExplicit(true); - - } - - public void processPixel(int x, int y, int w, int h) { - float accum = 0; - int count = 0; - for (int dx = -3; dx < 6; dx += 3) { - for (int dy = -1; dy < 2; dy += 1) { - int rgb = 0xff & inputData[((y + dy) * w) + (x + dx)]; - accum += rgb * convMatrix3x3[count++]; - } - } - outputData[y * w + x] = (byte) Math.max(0, Math.min((int) accum, 255)); - } - - public void run() { - int x = getGlobalId(0); - int y = getGlobalId(1); - int w = getGlobalSize(0); - int h = getGlobalSize(1); - if (x > 3 && x < (w - 3) && y > 1 && y < (h - 1)) { - processPixel(x, y, w, h); - } else { - outputData[y * w + x] = inputData[(y * w) + x]; - } - } - - public void apply(float[] _convMatrix3x3) { - convMatrix3x3 = _convMatrix3x3; - for (int x = 0; x < width * 3; x++) { - for (int y = 0; y < height; y++) { - if (x > 3 && x < (width * 3 - 3) && y > 1 && y < (height - 1)) { - processPixel(x, y, width * 3, height); - } - } - } - } - - } - - public static void main(final String[] _args) { - String fileName = _args.length == 1 ? _args[0] : "Leo720p.wmv"; - - float[] convMatrix3x3 = new float[] { - 0f, - -10f, - 0f, - -10f, - 41f, - -10f, - 0f, - -10f, - 0f - }; - new JJMPEGPlayer("Aparapi - Solution", fileName, convMatrix3x3){ - Convolution kernel = null; - - @Override protected void processFrame(Graphics2D gc, float[] _convMatrix3x3, BufferedImage in, BufferedImage out) { - if (kernel == null) { - kernel = new Convolution(in, out); - } - kernel.apply(_convMatrix3x3); - } - }; - - } -} diff --git a/examples/nbody/.classpath b/examples/nbody/.classpath deleted file mode 100644 index 8581fd92..00000000 --- a/examples/nbody/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/examples/nbody/.project b/examples/nbody/.project deleted file mode 100644 index f3cf594d..00000000 --- a/examples/nbody/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - nbody - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/examples/nbody/local.bat b/examples/nbody/local.bat deleted file mode 100644 index 92c58b91..00000000 --- a/examples/nbody/local.bat +++ /dev/null @@ -1,15 +0,0 @@ -@echo off - -java ^ - -Djava.library.path=..\..\com.amd.aparapi.jni\dist;jogamp ^ - -Dcom.amd.aparapi.executionMode=%1 ^ - -Dcom.amd.aparapi.enableShowGeneratedOpenCL=true ^ - -Dcom.amd.aparapi.enableVerboseJNI=false ^ - -Dcom.amd.aparapi.enableProfiling=true ^ - -Dbodies=%2 ^ - -Dheight=600 ^ - -Dwidth=600 ^ - -classpath jogamp\gluegen-rt.jar;jogamp\jogl.all.jar;..\..\com.amd.aparapi\dist\aparapi.jar;nbody.jar ^ - com.amd.aparapi.examples.nbody.Local - - diff --git a/examples/nbody/nbody.bat b/examples/nbody/nbody.bat deleted file mode 100644 index 9c5cca74..00000000 --- a/examples/nbody/nbody.bat +++ /dev/null @@ -1,14 +0,0 @@ -@echo off - -java ^ - -Djava.library.path=..\..\com.amd.aparapi.jni\dist;jogamp ^ - -Dcom.amd.aparapi.executionMode=%1 ^ - -Dcom.amd.aparapi.enableProfiling=false ^ - -Dcom.amd.aparapi.enableShowGeneratedOpenCL=true ^ - -Dbodies=%2 ^ - -Dheight=600 ^ - -Dwidth=600 ^ - -classpath jogamp\gluegen-rt.jar;jogamp\jogl-all.jar;..\..\com.amd.aparapi\dist\aparapi.jar;nbody.jar ^ - com.amd.aparapi.examples.nbody.Main - - diff --git a/examples/nbody/nbody.sh b/examples/nbody/nbody.sh deleted file mode 100644 index 53131f1c..00000000 --- a/examples/nbody/nbody.sh +++ /dev/null @@ -1,10 +0,0 @@ - -java \ - -Djava.library.path=../../com.amd.aparapi.jni/dist:jogamp \ - -Dcom.amd.aparapi.executionMode=$1 \ - -Dbodies=$1 \ - -Dheight=600 \ - -Dwidth=600 \ - -classpath jogamp/jogl-all.jar:jogamp/gluegen-rt.jar:../../com.amd.aparapi/dist/aparapi.jar:nbody.jar \ - com.amd.aparapi.examples.nbody.Main - diff --git a/examples/nbody/src/com/amd/aparapi/examples/nbody/Local.java b/examples/nbody/src/com/amd/aparapi/examples/nbody/Local.java deleted file mode 100644 index bd4ca9ba..00000000 --- a/examples/nbody/src/com/amd/aparapi/examples/nbody/Local.java +++ /dev/null @@ -1,365 +0,0 @@ -/* -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.amd.aparapi.examples.nbody; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -import javax.media.opengl.GL; -import javax.media.opengl.GL2; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLException; -import javax.media.opengl.awt.GLCanvas; -import javax.media.opengl.fixedfunc.GLLightingFunc; -import javax.media.opengl.glu.GLU; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.WindowConstants; - -import com.amd.aparapi.Kernel; -import com.amd.aparapi.ProfileInfo; -import com.amd.aparapi.Range; -import com.jogamp.opengl.util.FPSAnimator; -import com.jogamp.opengl.util.texture.Texture; -import com.jogamp.opengl.util.texture.TextureIO; - -/** - * An NBody clone which uses local memory to cache NBody positions for execution. - * - * http://www.browndeertechnology.com/docs/BDT_OpenCL_Tutorial_NBody-rev3.html - * - * @see com.amd.aparapi.examples.nbody.Main - * - * @author gfrost - * - */ -public class Local{ - - public static class NBodyKernel extends Kernel{ - protected final float delT = .005f; - - protected final float espSqr = 1.0f; - - protected final float mass = 5f; - - private final Range range; - - private final float[] xyz; // positions xy and z of bodies - - private final float[] vxyz; // velocity component of x,y and z of bodies - - @Local private final float[] localStuff; // local memory - - /** - * Constructor initializes xyz and vxyz arrays. - * @param _bodies - */ - public NBodyKernel(Range _range) { - range = _range; - localStuff = new float[range.getLocalSize(0) * 3]; - - xyz = new float[range.getGlobalSize(0) * 3]; - vxyz = new float[range.getGlobalSize(0) * 3]; - float maxDist = 20f; - for (int body = 0; body < range.getGlobalSize(0) * 3; body += 3) { - float theta = (float) (Math.random() * Math.PI * 2); - float phi = (float) (Math.random() * Math.PI * 2); - float radius = (float) (Math.random() * maxDist); - - // get the 3D dimensional coordinates - xyz[body + 0] = (float) (radius * Math.cos(theta) * Math.sin(phi)); - xyz[body + 1] = (float) (radius * Math.sin(theta) * Math.sin(phi)); - xyz[body + 2] = (float) (radius * Math.cos(phi)); - - // divide into two 'spheres of bodies' by adjusting x - if (body % 2 == 0) { - xyz[body + 0] += maxDist * 1.5; - } else { - xyz[body + 0] -= maxDist * 1.5; - } - } - setExplicit(true); - } - - /** - * Here is the kernel entrypoint. Here is where we calculate the position of each body - */ - @Override public void run() { - - int globalId = getGlobalId(0) * 3; - - float accx = 0.f; - float accy = 0.f; - float accz = 0.f; - float myPosx = xyz[globalId + 0]; - float myPosy = xyz[globalId + 1]; - float myPosz = xyz[globalId + 2]; - - for (int tile = 0; tile < getGlobalSize(0) / getLocalSize(0); tile++) { - // load one tile into local memory - int gidx = (tile * getLocalSize(0) + getLocalId()) * 3; - int lidx = getLocalId(0) * 3; - localStuff[lidx + 0] = xyz[gidx + 0]; - localStuff[lidx + 1] = xyz[gidx + 1]; - localStuff[lidx + 2] = xyz[gidx + 2]; - // Synchronize to make sure data is available for processing - localBarrier(); - - for (int i = 0; i < getLocalSize() * 3; i += 3) { - float dx = localStuff[i + 0] - myPosx; - float dy = localStuff[i + 1] - myPosy; - float dz = localStuff[i + 2] - myPosz; - float invDist = rsqrt((dx * dx) + (dy * dy) + (dz * dz) + espSqr); - float s = mass * invDist * invDist * invDist; - accx = accx + s * dx; - accy = accy + s * dy; - accz = accz + s * dz; - } - localBarrier(); - } - accx = accx * delT; - accy = accy * delT; - accz = accz * delT; - xyz[globalId + 0] = myPosx + vxyz[globalId + 0] * delT + accx * .5f * delT; - xyz[globalId + 1] = myPosy + vxyz[globalId + 1] * delT + accy * .5f * delT; - xyz[globalId + 2] = myPosz + vxyz[globalId + 2] * delT + accz * .5f * delT; - - vxyz[globalId + 0] = vxyz[globalId + 0] + accx; - vxyz[globalId + 1] = vxyz[globalId + 1] + accy; - vxyz[globalId + 2] = vxyz[globalId + 2] + accz; - } - - /** - * Render all particles to the OpenGL context - * @param gl - */ - - protected void render(GL2 gl) { - gl.glBegin(GL2.GL_QUADS); - - for (int i = 0; i < range.getGlobalSize(0) * 3; i += 3) { - gl.glTexCoord2f(0, 1); - gl.glVertex3f(xyz[i + 0], xyz[i + 1] + 1, xyz[i + 2]); - gl.glTexCoord2f(0, 0); - gl.glVertex3f(xyz[i + 0], xyz[i + 1], xyz[i + 2]); - gl.glTexCoord2f(1, 0); - gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1], xyz[i + 2]); - gl.glTexCoord2f(1, 1); - gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1] + 1, xyz[i + 2]); - } - gl.glEnd(); - } - - } - - public static int width; - - public static int height; - - public static boolean running; - - public static void main(String _args[]) { - - final NBodyKernel kernel = new NBodyKernel(Range.create(Integer.getInteger("bodies", 8192), 256)); - - JFrame frame = new JFrame("NBody"); - - JPanel panel = new JPanel(new BorderLayout()); - JPanel controlPanel = new JPanel(new FlowLayout()); - panel.add(controlPanel, BorderLayout.SOUTH); - - final JButton startButton = new JButton("Start"); - - startButton.addActionListener(new ActionListener(){ - @Override public void actionPerformed(ActionEvent e) { - running = true; - startButton.setEnabled(false); - } - }); - controlPanel.add(startButton); - controlPanel.add(new JLabel(kernel.getExecutionMode().toString())); - - controlPanel.add(new JLabel(" Particles")); - controlPanel.add(new JTextField("" + kernel.range.getGlobalSize(0), 5)); - - controlPanel.add(new JLabel("FPS")); - final JTextField framesPerSecondTextField = new JTextField("0", 5); - - controlPanel.add(framesPerSecondTextField); - controlPanel.add(new JLabel("Score(")); - JLabel miniLabel = new JLabel("calcs
µsec"); - - controlPanel.add(miniLabel); - controlPanel.add(new JLabel(")")); - - final JTextField positionUpdatesPerMicroSecondTextField = new JTextField("0", 5); - - controlPanel.add(positionUpdatesPerMicroSecondTextField); - GLCapabilities caps = new GLCapabilities(null); - caps.setDoubleBuffered(true); - caps.setHardwareAccelerated(true); - final GLCanvas canvas = new GLCanvas(caps); - Dimension dimension = new Dimension(Integer.getInteger("width", 742), Integer.getInteger("height", 742)); - canvas.setPreferredSize(dimension); - - canvas.addGLEventListener(new GLEventListener(){ - private double ratio; - - private final float xeye = 0f; - - private final float yeye = 0f; - - private final float zeye = 100f; - - private final float xat = 0f; - - private final float yat = 0f; - - private final float zat = 0f; - - public final float zoomFactor = 1.0f; - - private int frames; - - private long last = System.currentTimeMillis(); - - @Override public void dispose(GLAutoDrawable drawable) { - - } - - @Override public void display(GLAutoDrawable drawable) { - - GL2 gl = drawable.getGL().getGL2(); - - gl.glLoadIdentity(); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - gl.glColor3f(1f, 1f, 1f); - - GLU glu = new GLU(); - glu.gluPerspective(45f, ratio, 0f, 1000f); - - glu.gluLookAt(xeye, yeye, zeye * zoomFactor, xat, yat, zat, 0f, 1f, 0f); - if (running) { - kernel.execute(kernel.range); - if (kernel.isExplicit()) { - kernel.get(kernel.xyz); - } - List profileInfo = kernel.getProfileInfo(); - if (profileInfo != null && profileInfo.size() > 0) { - for (ProfileInfo p : profileInfo) { - System.out.print(" " + p.getType() + " " + p.getLabel() + (p.getEnd() - p.getStart()) / 1000 + "us"); - } - System.out.println(); - } - } - kernel.render(gl); - - long now = System.currentTimeMillis(); - long time = now - last; - frames++; - - if (time > 1000) { // We update the frames/sec every second - if (running) { - float framesPerSecond = (frames * 1000.0f) / time; - int updatesPerMicroSecond = (int) ((framesPerSecond * kernel.range.getGlobalSize(0) * kernel.range - .getGlobalSize(0)) / 1000000); - framesPerSecondTextField.setText(String.format("%5.2f", framesPerSecond)); - positionUpdatesPerMicroSecondTextField.setText(String.format("%4d", updatesPerMicroSecond)); - } - frames = 0; - last = now; - } - gl.glFlush(); - - } - - @Override public void init(GLAutoDrawable drawable) { - final GL2 gl = drawable.getGL().getGL2(); - - gl.glShadeModel(GLLightingFunc.GL_SMOOTH); - gl.glEnable(GL.GL_BLEND); - gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); - try { - InputStream textureStream = Local.class.getResourceAsStream("particle.jpg"); - Texture texture = TextureIO.newTexture(textureStream, false, null); - texture.enable(gl); - } catch (IOException e) { - e.printStackTrace(); - } catch (GLException e) { - e.printStackTrace(); - } - - } - - @Override public void reshape(GLAutoDrawable drawable, int x, int y, int _width, int _height) { - width = _width; - height = _height; - - GL2 gl = drawable.getGL().getGL2(); - gl.glViewport(0, 0, width, height); - - ratio = (double) width / (double) height; - - } - - }); - - panel.add(canvas, BorderLayout.CENTER); - frame.getContentPane().add(panel, BorderLayout.CENTER); - - frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - frame.pack(); - frame.setVisible(true); - - FPSAnimator animator = new FPSAnimator(canvas, 100); - animator.start(); - - } - -} diff --git a/examples/nbody/src/com/amd/aparapi/examples/nbody/duke.jpg b/examples/nbody/src/com/amd/aparapi/examples/nbody/duke.jpg deleted file mode 100644 index 2729fd2f..00000000 Binary files a/examples/nbody/src/com/amd/aparapi/examples/nbody/duke.jpg and /dev/null differ diff --git a/examples/nbody/src/com/amd/aparapi/examples/nbody/particle.jpg b/examples/nbody/src/com/amd/aparapi/examples/nbody/particle.jpg deleted file mode 100644 index 70e28ac5..00000000 Binary files a/examples/nbody/src/com/amd/aparapi/examples/nbody/particle.jpg and /dev/null differ diff --git a/examples/movie/.project b/examples/oopnbody/.project similarity index 89% rename from examples/movie/.project rename to examples/oopnbody/.project index 6be55d8c..87e9909a 100644 --- a/examples/movie/.project +++ b/examples/oopnbody/.project @@ -1,6 +1,6 @@ - movie + oopnbody diff --git a/examples/oopnbody/README.txt b/examples/oopnbody/README.txt new file mode 100644 index 00000000..d5fa2430 --- /dev/null +++ b/examples/oopnbody/README.txt @@ -0,0 +1,20 @@ +oopnbody readme - December 2012 + +This demo is an example of an Aparapi experimental feature to allow some +limited use of java objects in kernels, based on the regular nbody demo. + +There is limited support in Aparapi for using arrays of java objects in kernels, +where a kernel accesses the objects by indexing into the object array and the +only member functions on the objects that can be called +are bean-style getters and setters, where if the object +has a data member "foo" the getter will be named "getFoo" and so on. + +The types of the object fields accessed in a kernel in this way must be basic +types otherwise in line with Aparapi usage. + +This may allow a more natural java programming style. This is implemented by +copying the referenced object fields into C-style arrays of structs to pass to +OpenCL. Then when the kernel completes the data is replaced into the original +java object. The extra copying may result in lower performance than explicit +use of basic type arrays in the original java source. + diff --git a/examples/nbody/build.xml b/examples/oopnbody/build.xml similarity index 92% rename from examples/nbody/build.xml rename to examples/oopnbody/build.xml index def8a4fe..3862c0c9 100644 --- a/examples/nbody/build.xml +++ b/examples/oopnbody/build.xml @@ -1,6 +1,6 @@ - + @@ -164,10 +164,10 @@ - + - + @@ -177,7 +177,7 @@ - + @@ -188,7 +188,7 @@ - + diff --git a/examples/oopnbody/nbody.sh b/examples/oopnbody/nbody.sh new file mode 100755 index 00000000..7f360e71 --- /dev/null +++ b/examples/oopnbody/nbody.sh @@ -0,0 +1,13 @@ +# -Dcom.amd.aparapi.executionMode=$1 \ + +${JAVA_HOME}/bin/java -ea \ + -Djava.library.path=../../com.amd.aparapi.jni/dist:jogamp \ + -Dcom.amd.aparapi.logLevel=INFO \ + -Dcom.amd.aparapi.enableShowGeneratedOpenCL=true \ + -Dbodies=$1 \ + -Dheight=800 \ + -Dwidth=1200 \ + -javaagent:../../com.amd.aparapi/dist/aparapi-agent.jar \ + -classpath jogamp/jogl-all.jar:jogamp/gluegen-rt.jar:../../com.amd.aparapi/dist/aparapi.jar:oopnbody.jar \ + com.amd.aparapi.examples.oopnbody.Main + diff --git a/examples/oopnbody/src/com/amd/aparapi/examples/oopnbody/Body.java b/examples/oopnbody/src/com/amd/aparapi/examples/oopnbody/Body.java new file mode 100644 index 00000000..ba02d159 --- /dev/null +++ b/examples/oopnbody/src/com/amd/aparapi/examples/oopnbody/Body.java @@ -0,0 +1,37 @@ +package com.amd.aparapi.examples.oopnbody; + +import java.util.List; + +public final class Body{ + protected final float delT = .005f; + protected final float espSqr = 1.0f; + public static Body[] allBodies; + + public Body(float _x, float _y, float _z, float _m) { + x = _x; + y = _y; + z = _z; + m = _m; + } + + float x, y, z, m, vx, vy, vz; + + public float getX() { return x; } + public float getY() { return y; } + public float getZ() { return z; } + + public float getVx() { return vx; } + public float getVy() { return vy; } + public float getVz() { return vz; } + + public float getM() { return m; } + public void setM(float _m) { m = _m; } + + public void setX(float _x) { x = _x; } + public void setY(float _y) { y = _y; } + public void setZ(float _z) { z = _z; } + + public void setVx(float _vx) { vx = _vx; } + public void setVy(float _vy) { vy = _vy; } + public void setVz(float _vz) { vz = _vz; } +} diff --git a/examples/nbody/src/com/amd/aparapi/examples/nbody/Main.java b/examples/oopnbody/src/com/amd/aparapi/examples/oopnbody/Main.java similarity index 63% rename from examples/nbody/src/com/amd/aparapi/examples/nbody/Main.java rename to examples/oopnbody/src/com/amd/aparapi/examples/oopnbody/Main.java index 0d5ae836..40cd133d 100644 --- a/examples/nbody/src/com/amd/aparapi/examples/nbody/Main.java +++ b/examples/oopnbody/src/com/amd/aparapi/examples/oopnbody/Main.java @@ -35,7 +35,7 @@ to national security controls as identified on the Commerce Control List (curren under those regulations, please refer to the U.S. Bureau of Industry and Security's website at http://www.bis.doc.gov/. */ -package com.amd.aparapi.examples.nbody; +package com.amd.aparapi.examples.oopnbody; import java.awt.BorderLayout; import java.awt.Dimension; @@ -45,6 +45,8 @@ to national security controls as identified on the Commerce Control List (curren import java.io.IOException; import java.io.InputStream; import java.util.List; +import java.util.ArrayList; +import java.util.Arrays; import javax.media.opengl.GL; import javax.media.opengl.GL2; @@ -63,14 +65,13 @@ to national security controls as identified on the Commerce Control List (curren import javax.swing.JTextField; import javax.swing.WindowConstants; -import com.amd.aparapi.Kernel; -import com.amd.aparapi.ProfileInfo; -import com.amd.aparapi.Range; import com.jogamp.opengl.util.FPSAnimator; import com.jogamp.opengl.util.texture.Texture; -import com.jogamp.opengl.util.texture.TextureData; import com.jogamp.opengl.util.texture.TextureIO; +import com.amd.aparapi.Aparapi; + + /** * NBody implementing demonstrating Aparapi kernels. * @@ -86,90 +87,46 @@ to national security controls as identified on the Commerce Control List (curren */ public class Main { - public static class NBodyKernel extends Kernel { protected final float delT = .005f; - protected final float espSqr = 1.0f; - protected final float mass = 5f; - private final Range range; - - private final float[] xyz; // positions xy and z of bodies - - private final float[] vxyz; // velocity component of x,y and z of bodies - + int range; + public Body[] bodies = null; + /** * Constructor initializes xyz and vxyz arrays. * * @param _bodies */ - public NBodyKernel(Range _range) { + public Main(int _range) { range = _range; - // range = Range.create(bodies); - xyz = new float[range.getGlobalSize(0) * 3]; - vxyz = new float[range.getGlobalSize(0) * 3]; + bodies = new Body[range]; + final float maxDist = 20f; - for (int body = 0; body < (range.getGlobalSize(0) * 3); body += 3) { - + for (int body = 0; body < range; body ++) { final float theta = (float) (Math.random() * Math.PI * 2); final float phi = (float) (Math.random() * Math.PI * 2); final float radius = (float) (Math.random() * maxDist); // get the 3D dimensional coordinates - xyz[body + 0] = (float) (radius * Math.cos(theta) * Math.sin(phi)); - xyz[body + 1] = (float) (radius * Math.sin(theta) * Math.sin(phi)); - xyz[body + 2] = (float) (radius * Math.cos(phi)); - + float x = (float) (radius * Math.cos(theta) * Math.sin(phi)); + float y = (float) (radius * Math.sin(theta) * Math.sin(phi)); + float z = (float) (radius * Math.cos(phi)); + // divide into two 'spheres of bodies' by adjusting x - if ((body % 2) == 0) { - xyz[body + 0] += maxDist * 1.5; + x += maxDist * 1.5; } else { - xyz[body + 0] -= maxDist * 1.5; + x -= maxDist * 1.5; } + bodies[body] = new Body(x,y,z, 5f); } - setExplicit(true); - } - /** - * Here is the kernel entrypoint. Here is where we calculate the position of each body - */ - @Override - public void run() { - final int body = getGlobalId(); - final int count = getGlobalSize(0) * 3; - final int globalId = body * 3; - - float accx = 0.f; - float accy = 0.f; - float accz = 0.f; - - final float myPosx = xyz[globalId + 0]; - final float myPosy = xyz[globalId + 1]; - final float myPosz = xyz[globalId + 2]; - for (int i = 0; i < count; i += 3) { - final float dx = xyz[i + 0] - myPosx; - final float dy = xyz[i + 1] - myPosy; - final float dz = xyz[i + 2] - myPosz; - final float invDist = rsqrt((dx * dx) + (dy * dy) + (dz * dz) + espSqr); - final float s = mass * invDist * invDist * invDist; - accx = accx + (s * dx); - accy = accy + (s * dy); - accz = accz + (s * dz); - } - accx = accx * delT; - accy = accy * delT; - accz = accz * delT; - xyz[globalId + 0] = myPosx + (vxyz[globalId + 0] * delT) + (accx * .5f * delT); - xyz[globalId + 1] = myPosy + (vxyz[globalId + 1] * delT) + (accy * .5f * delT); - xyz[globalId + 2] = myPosz + (vxyz[globalId + 2] * delT) + (accz * .5f * delT); - - vxyz[globalId + 0] = vxyz[globalId + 0] + accx; - vxyz[globalId + 1] = vxyz[globalId + 1] + accy; - vxyz[globalId + 2] = vxyz[globalId + 2] + accz; + Body.allBodies = bodies; } + /** * Render all particles to the OpenGL context * @@ -178,33 +135,86 @@ public void run() { protected void render(GL2 gl) { gl.glBegin(GL2.GL_QUADS); - - for (int i = 0; i < (range.getGlobalSize(0) * 3); i += 3) { - gl.glTexCoord2f(0, 1); - gl.glVertex3f(xyz[i + 0], xyz[i + 1] + 1, xyz[i + 2]); - gl.glTexCoord2f(0, 0); - gl.glVertex3f(xyz[i + 0], xyz[i + 1], xyz[i + 2]); - gl.glTexCoord2f(1, 0); - gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1], xyz[i + 2]); - gl.glTexCoord2f(1, 1); - gl.glVertex3f(xyz[i + 0] + 1, xyz[i + 1] + 1, xyz[i + 2]); + int sz = range; + for (int i = 0; i < range; i++) { + + if (i < (sz / 2)) { + gl.glColor3f(1f, 0f, 0f); + } else if (i < (sz * 0.666)) { + gl.glColor3f(0f, 1f, 0f); + } else { + gl.glColor3f(0f, 0f, 1f); + } + + Body currBody = bodies[i]; + + gl.glTexCoord2f(0, 1); + gl.glVertex3f(currBody.getX(), currBody.getY() + 1, currBody.getZ()); + gl.glTexCoord2f(0, 0); + gl.glVertex3f(currBody.getX(), currBody.getY(), currBody.getZ()); + gl.glTexCoord2f(1, 0); + gl.glVertex3f(currBody.getX() + 1, currBody.getY(), currBody.getZ()); + gl.glTexCoord2f(1, 1); + gl.glVertex3f(currBody.getX() + 1, currBody.getY() + 1, currBody.getZ()); + } gl.glEnd(); } - } public static int width; public static int height; - public static boolean running; - static Texture texture; - public static void main(String _args[]) { - //System.load("/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/jre/lib/libawt.dylib"); - //System.load("/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/jre/lib/libjawt.dylib"); + public static boolean running; + + void doOneUpdate() { - final NBodyKernel kernel = new NBodyKernel(Range.create(Integer.getInteger("bodies", 8192))); + //Arrays.parallel(bodies.toArray(new Body[1])).forEach(b -> {b.nextMove();}); + Aparapi.forEach(range, p -> { + + int currIndex = p; + + float accx = 0.f; + float accy = 0.f; + float accz = 0.f; + + final float myPosx = bodies[currIndex].getX(); + final float myPosy = bodies[currIndex].getY(); + final float myPosz = bodies[currIndex].getZ(); + + //allBodies.parallel().forEach( b -> { + for(int b=0; b profileInfo = kernel.getProfileInfo(); - if ((profileInfo != null) && (profileInfo.size() > 0)) { - for (final ProfileInfo p : profileInfo) { - System.out.print(" " + p.getType() + " " + p.getLabel() + ((p.getEnd() - p.getStart()) / 1000) + "us"); - } - System.out.println(); - } + kernel.doOneUpdate(); } kernel.render(gl); @@ -311,8 +310,7 @@ public void display(GLAutoDrawable drawable) { if (time > 1000) { // We update the frames/sec every second if (running) { final float framesPerSecond = (frames * 1000.0f) / time; - final int updatesPerMicroSecond = (int) ((framesPerSecond * kernel.range.getGlobalSize(0) * kernel.range - .getGlobalSize(0)) / 1000000); + final int updatesPerMicroSecond = (int) ((framesPerSecond * bodyCount * bodyCount) / 1000000); framesPerSecondTextField.setText(String.format("%5.2f", framesPerSecond)); positionUpdatesPerMicroSecondTextField.setText(String.format("%4d", updatesPerMicroSecond)); } @@ -328,26 +326,12 @@ public void init(GLAutoDrawable drawable) { final GL2 gl = drawable.getGL().getGL2(); gl.glShadeModel(GLLightingFunc.GL_SMOOTH); - gl.glEnable(GL.GL_BLEND ); + gl.glEnable(GL.GL_BLEND); gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE); - - gl.glEnable(GL.GL_TEXTURE_2D); - gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); - gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); try { final InputStream textureStream = Main.class.getResourceAsStream("particle.jpg"); - - TextureData data = TextureIO.newTextureData(profile,textureStream, false, "jpg"); - texture = TextureIO.newTexture(data); - //final Texture texture = TextureIO.newTexture(textureStream, false, null); - // texture.enable(gl); - // texture.bind(gl); - - // gl.glEnable(GL.GL_TEXTURE_2D); - //gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); - //gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); - // gl.glBindTexture(GL.GL_TEXTURE_2D, texture.); - + final Texture texture = TextureIO.newTexture(textureStream, false, null); + texture.enable(gl); } catch (final IOException e) { e.printStackTrace(); } catch (final GLException e) { diff --git a/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/duke.jpg b/examples/oopnbody/src/com/amd/aparapi/examples/oopnbody/duke.jpg similarity index 100% rename from examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/duke.jpg rename to examples/oopnbody/src/com/amd/aparapi/examples/oopnbody/duke.jpg diff --git a/examples/nbody/src/com/amd/aparapi/examples/nbody/moon.jpg b/examples/oopnbody/src/com/amd/aparapi/examples/oopnbody/moon.jpg similarity index 100% rename from examples/nbody/src/com/amd/aparapi/examples/nbody/moon.jpg rename to examples/oopnbody/src/com/amd/aparapi/examples/oopnbody/moon.jpg diff --git a/examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/particle.jpg b/examples/oopnbody/src/com/amd/aparapi/examples/oopnbody/particle.jpg similarity index 100% rename from examples/javaonedemo/src/com/amd/aparapi/examples/javaonedemo/particle.jpg rename to examples/oopnbody/src/com/amd/aparapi/examples/oopnbody/particle.jpg diff --git a/lambda-root/.cproject b/lambda-root/.cproject new file mode 100644 index 00000000..0156e94e --- /dev/null +++ b/lambda-root/.cproject @@ -0,0 +1,225 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lambda-root/.project b/lambda-root/.project new file mode 100644 index 00000000..76530b6f --- /dev/null +++ b/lambda-root/.project @@ -0,0 +1,27 @@ + + + lambda-hotspot + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/lambda-root/bld-all.bash b/lambda-root/bld-all.bash new file mode 100755 index 00000000..e5a30ec8 --- /dev/null +++ b/lambda-root/bld-all.bash @@ -0,0 +1,5 @@ +#!/bin/bash +. ./setvars.bash +pushd lambda +make DEBUG_NAME=fastdebug NO_DOCS=true NO_IMAGES=true DEV_ONLY=true +popd diff --git a/lambda-root/bld-cdt.bash b/lambda-root/bld-cdt.bash new file mode 100755 index 00000000..2a58547c --- /dev/null +++ b/lambda-root/bld-cdt.bash @@ -0,0 +1,55 @@ +#!/bin/bash +. ./setvars.bash + +find lambda -name *.cpp -o -name *.c \ + | grep -v "/hotspot/src/cpu/sparc/" \ + | grep -v "/hotspot/src/cpu/zero/" \ + | grep -v "/hotspot/src/os_cpu/bsd_x86/" \ + | grep -v "/hotspot/src/os_cpu/bsd_zero/" \ + | grep -v "/hotspot/src/os_cpu/solaris_x86/" \ + | grep -v "/hotspot/src/os_cpu/windows_x86/" \ + | grep -v "/hotspot/src/os_cpu/linux_zero/" \ + | grep -v "/hotspot/src/os_cpu/linux_sparc/" \ + | grep -v "/hotspot/src/os_cpu/solaris_sparc/" \ + | grep -v "/hotspot/src/os/windows/" \ + | grep -v "/hotspot/src/os/solaris/" \ + | grep -v "/hotspot/src/os/bsd/" \ + | grep -v "/jdk/src/" \ + | grep -v "/jdk/make/" \ + | grep -v "/jdk/test/" \ + | grep -v "/build/.*/democlasses/" \ + | sed "s:^:${PWD}/:" \ + | tee sFiles \ + | sed "s:/[^/]*$::" \ + | sort -u > sDirs + +find lambda -name *.h -o -name *.hpp \ + | grep -v "/hotspot/src/cpu/sparc/" \ + | grep -v "/hotspot/src/cpu/zero/" \ + | grep -v "/hotspot/src/os_cpu/bsd_x86/" \ + | grep -v "/hotspot/src/os_cpu/bsd_zero/" \ + | grep -v "/hotspot/src/os_cpu/solaris_x86/" \ + | grep -v "/hotspot/src/os_cpu/windows_x86/" \ + | grep -v "/hotspot/src/os_cpu/linux_zero/" \ + | grep -v "/hotspot/src/os_cpu/linux_sparc/" \ + | grep -v "/hotspot/src/os_cpu/solaris_sparc/" \ + | grep -v "/hotspot/src/os/windows/" \ + | grep -v "/hotspot/src/os/solaris/" \ + | grep -v "/hotspot/src/os/bsd/" \ + | grep -v "/hotspot/agent/src/os/solaris/" \ + | grep -v "/hotspot/agent/src/os/bsd/" \ + | grep -v "/jdk/src/" \ + | grep -v "/jdk/make/" \ + | grep -v "/jdk/test/" \ + | grep -v "/build/.*/democlasses/" \ + | sed "s:[^/]*$::" \ + | sed "s:^:-I${PWD}/:" \ + | sort -u > hDirs + +touch $(cat sFiles) +pushd lambda +make DEBUG_NAME=fastdebug NO_DOCS=true NO_IMAGES=true DEV_ONLY=true hotspot 2>/dev/null \ + | tr " " "\n"\ + | grep "^-D" \ + | sort -u > ../hOpts +popd diff --git a/lambda-root/bld-debug.bash b/lambda-root/bld-debug.bash new file mode 100755 index 00000000..72091066 --- /dev/null +++ b/lambda-root/bld-debug.bash @@ -0,0 +1,3 @@ +#!/bin/bash +. ./setvars.bash +DEBUG_NAME=fastdebug NO_DOCS=true NO_IMAGES=true DEV_ONLY=true LANG=C ZIP_DEBUGINFO_FILES=0 HOTSPOT_BUILD_JOBS=4 ALLOW_DOWNLOADS=true HOTSPOT_BUILD_JOBS=4 PARALLEL_COMPILE_JOBS=4 NO_DOCS=true NO_IMAGES=true DEV_ONLY=true ALT_BOOTDIR=/usr/lib/jvm/java-7-openjdk-amd64 make -C lambda $* diff --git a/lambda-root/bld-hotspot.bash b/lambda-root/bld-hotspot.bash new file mode 100755 index 00000000..0c7fc4dd --- /dev/null +++ b/lambda-root/bld-hotspot.bash @@ -0,0 +1,8 @@ +#!/bin/bash +. ./setvars.bash +pushd lambda +# if we want to build all in hotspot uncomment next line +# touch $(find . -name "*.cpp" -o -name "*.c" -o -name "*.h" -o -name "*.hpp") +make DEBUG_NAME=fastdebug NO_DOCS=true NO_IMAGES=true DEV_ONLY=true hotspot +popd + diff --git a/lambda-root/eclipse/projects/hotspot/.cproject b/lambda-root/eclipse/projects/hotspot/.cproject new file mode 100644 index 00000000..df6a73cf --- /dev/null +++ b/lambda-root/eclipse/projects/hotspot/.cproject @@ -0,0 +1,251 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lambda-root/eclipse/projects/hotspot/.project b/lambda-root/eclipse/projects/hotspot/.project new file mode 100644 index 00000000..12e13de2 --- /dev/null +++ b/lambda-root/eclipse/projects/hotspot/.project @@ -0,0 +1,65 @@ + + + hotspot + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + generated + 2 + LAMBDA_HOME/build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2/generated + + + hotspot-src-cpu-x86-vm + 2 + LAMBDA_HOME/hotspot/src/cpu/x86/vm + + + hotspot-src-os-linux-vm + 2 + LAMBDA_HOME/hotspot/src/os/linux/vm + + + hotspot-src-os-posix-vm + 2 + LAMBDA_HOME/hotspot/src/os/posix/vm + + + hotspot-src-os_cpu-linux_x86-vm + 2 + LAMBDA_HOME/hotspot/src/os_cpu/linux_x86/vm + + + hotspot-src-share-vm + 2 + LAMBDA_HOME/hotspot/src/share/vm + + + + + LAMBDA_HOME + file:/home/gfrost/aparapi/branches/SumatraExperiments/lambda-root/lambda + + + diff --git a/lambda-root/eclipse/projects/hotspot/.settings/org.eclipse.cdt.codan.core.prefs b/lambda-root/eclipse/projects/hotspot/.settings/org.eclipse.cdt.codan.core.prefs new file mode 100644 index 00000000..d1c7b011 --- /dev/null +++ b/lambda-root/eclipse/projects/hotspot/.settings/org.eclipse.cdt.codan.core.prefs @@ -0,0 +1,67 @@ +eclipse.preferences.version=1 +org.eclipse.cdt.codan.checkers.errnoreturn=Warning +org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} +org.eclipse.cdt.codan.checkers.errreturnvalue=Error +org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.checkers.noreturn=Error +org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false} +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error +org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error +org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error +org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning +org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>true,empty_case_param\=>false} +org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning +org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error +org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning +org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true} +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error +org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error +org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error +org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info +org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning +org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error +org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error +org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning +org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning +org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()} +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false} +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning +org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false} +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true} +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning +org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")} +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error +org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}} diff --git a/lambda-root/eclipse/projects/hotspot/.settings/org.eclipse.cdt.core.prefs b/lambda-root/eclipse/projects/hotspot/.settings/org.eclipse.cdt.core.prefs new file mode 100644 index 00000000..c4f4571b --- /dev/null +++ b/lambda-root/eclipse/projects/hotspot/.settings/org.eclipse.cdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +environment/project/cdt.managedbuild.config.gnu.exe.debug.1129526054/CWD/delimiter=\: +environment/project/cdt.managedbuild.config.gnu.exe.debug.1129526054/CWD/operation=replace +environment/project/cdt.managedbuild.config.gnu.exe.debug.1129526054/CWD/value=/home/gfrost/lambda +environment/project/cdt.managedbuild.config.gnu.exe.debug.1129526054/PWD/delimiter=\: +environment/project/cdt.managedbuild.config.gnu.exe.debug.1129526054/PWD/operation=replace +environment/project/cdt.managedbuild.config.gnu.exe.debug.1129526054/PWD/value=/home/gfrost/lambda/lambda +environment/project/cdt.managedbuild.config.gnu.exe.debug.1129526054/append=true +environment/project/cdt.managedbuild.config.gnu.exe.debug.1129526054/appendContributed=true diff --git a/lambda-root/eclipse/projects/hotspot/Makefile b/lambda-root/eclipse/projects/hotspot/Makefile new file mode 100644 index 00000000..e7b22993 --- /dev/null +++ b/lambda-root/eclipse/projects/hotspot/Makefile @@ -0,0 +1,13 @@ +TO=../../../lambda/build/linux-amd64/lib/amd64/server +FROM=../../../lambda/build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2/fastdebug + +all: + #rm -f ${FROM}/libjvm.so ${FROM}/libjvm.diz ${FROM}/libjvm.debuginfo ${FROM}/libjvm_g.debuginfo + LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-7-openjdk-amd64 ALLOW_DOWNLOADS=true CORES=6 HOTSPOT_BUILD_JOBS=6 PARALLEL_COMPILE_JOBS=6 make -C ../../../lambda DEBUG_NAME=fastdebug NO_DOCS=true NO_IMAGES=true DEV_ONLY=true hotspot + rm -f ${TO}/libjvm.so ${TO}/libjvm.diz ${TO}/libjvm.debuginfo ${TO}/libjvm_g.debuginfo + cp ${FROM}/libjvm.so ${FROM}/libjvm_g.so ${TO} + unzip -d ${TO} ${FROM}/libjvm.diz + ls -l ${TO}/libjvm.debuginfo ${TO}/libjvm_g.debuginfo + +clean: + LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-7-openjdk-amd64 ALLOW_DOWNLOADS=true CORES=4 HOTSPOT_BUILD_JOBS=4 PARALLEL_COMPILE_JOBS=4 echo make -C ../../../lambda _NAME=fastdebug NO_DOCS=true NO_IMAGES=true DEV_ONLY=true clean diff --git a/lambda-root/get-lambda.bash b/lambda-root/get-lambda.bash new file mode 100755 index 00000000..70a04eb5 --- /dev/null +++ b/lambda-root/get-lambda.bash @@ -0,0 +1,6 @@ +#!/bin/bash +rm -rf lambda +hg clone http://hg.openjdk.java.net/lambda/lambda +pushd lambda +sh get_source.sh +popd diff --git a/lambda-root/run-gdb b/lambda-root/run-gdb new file mode 100755 index 00000000..0bb22331 --- /dev/null +++ b/lambda-root/run-gdb @@ -0,0 +1,33 @@ +#!/bin/bash +export JAVA_HOME=${PWD}/lambda/build/linux-amd64 +export FAST_DEBUG_DIR=${JAVA_HOME}/hotspot/outputdir/linux_amd64_compiler2/fastdebug +export LD_LIBRARY_PATH=${FAST_DEBUG_DIR}:${JAVA_HOME}/lib/amd64 +export GDB_SCRIPT=gdb_script_$$ +rm -f $GDB_SCRIPT +cat >>$GDB_SCRIPT <" +cat $GDB_SCRIPT +echo "----[$GDB_SCRIPT]" +echo LD_LIBRARY_PATH=${LD_LIBRARY_PATH} +echo ---- +gdb -x $GDB_SCRIPT +#rm -f $GDB_SCRIPT +export RETVAL=$? +exit $RETVAL diff --git a/lambda-root/setvars.bash b/lambda-root/setvars.bash new file mode 100755 index 00000000..f5e1d082 --- /dev/null +++ b/lambda-root/setvars.bash @@ -0,0 +1,82 @@ +#!/bin/bash +unset JAVA_HOME +export LANG=C +export ALT_BOOTDIR=/usr/lib/jvm/java-7-openjdk-amd64 +export ALLOW_DOWNLOADS=true +export CORES=$(grep "cpu cores" /proc/cpuinfo | sort -u | sed "s/^.*: *//") +export HOTSPOT_BUILD_JOBS=${CORES} +export PARALLEL_COMPILE_JOBS=${CORES} + +export CDT_GCC_SOURCE_DIRS=\ + build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2/generated/generated/adfiles\ + build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2/generated/generated/jvmtifiles\ + hotspot/src/cpu/x86/vm\ + hotspot/src/os_cpu/linux_x86/vm\ + hotspot/src/os/linux/vm\ + hotspot/src/os/posix/vm\ + hotspot/src/share/vm/adlc\ + hotspot/src/share/vm/asm\ + hotspot/src/share/vm/c1\ + hotspot/src/share/vm/ci\ + hotspot/src/share/vm/classfile\ + hotspot/src/share/vm/code\ + hotspot/src/share/vm/compiler\ + hotspot/src/share/vm/gc_implementation/concurrentMarkSweep\ + hotspot/src/share/vm/gc_implementation/g1\ + hotspot/src/share/vm/gc_implementation/parallelScavenge\ + hotspot/src/share/vm/gc_implementation/parNew\ + hotspot/src/share/vm/gc_implementation/shared\ + hotspot/src/share/vm/gc_interface\ + hotspot/src/share/vm/interpreter\ + hotspot/src/share/vm/libadt\ + hotspot/src/share/vm/memory\ + hotspot/src/share/vm/oops\ + hotspot/src/share/vm/opto\ + hotspot/src/share/vm/prims\ + hotspot/src/share/vm/prims/wbtestmethods\ + hotspot/src/share/vm/runtime\ + hotspot/src/share/vm/services\ + hotspot/src/share/vm/utilities + +export CDT_GCC_INCLUDE_DIRS=\ + build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2/generated/generated/adfiles\ + hotspot/src/cpu/x86/vm\ + hotspot/src/os_cpu/linux_x86/vm\ + hotspot/src/os/linux/vm\ + hotspot/src/os/posix/vm\ + hotspot/src/share/vm\ + +export CDT_GCC_OPTS=\ + -DAMD64 \ + -DARCH=\"amd64\" \ + -DASSERT \ + -DCOMPILER1 \ + -DCOMPILER2 + -DFASTDEBUG + -DFULL_VERSION=\"25.0-b05\" + -DGAMMA + -DHOTSPOT_BUILD_TARGET=\"fastdebug\" + -DHOTSPOT_BUILD_USER=\"gfrost\" + -DHOTSPOT_LIB_ARCH=\"amd64\" + -DHOTSPOT_RELEASE_VERSION=\"25.0-b05\" + -DHOTSPOT_VM_DISTRO=\"OpenJDK\" + -DINCLUDE_TRACE + -DJDK_MAJOR_VERSION=\"1\" + -DJDK_MINOR_VERSION=\"8\" + -DJRE_RELEASE_VERSION=\"1.8.0-internal-fastdebug-gfrost_2012_12_04_14_11-b00\" + -DLAUNCHER_TYPE=\"gamma\" + -DLINK_INTO_LIBJVM + -DLINUX + -DTARGET_ARCH_MODEL_x86_64 + -DTARGET_ARCH_x86 + -DTARGET_COMPILER_gcc + -DTARGET_OS_ARCH_MODEL_linux_x86_64 + -DTARGET_OS_ARCH_linux_x86 + -DTARGET_OS_FAMILY_linux + -DVM_LITTLE_ENDIAN + -D_FILE_OFFSET_BITS=64 + -D_GNU_SOURCE + -D_LP64 + -D_LP64=1 + -D_REENTRANT + -Damd64 diff --git a/samples/add/.classpath b/samples/add/.classpath deleted file mode 100644 index 2b3d4294..00000000 --- a/samples/add/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/samples/add/.project b/samples/add/.project deleted file mode 100644 index 11a89faa..00000000 --- a/samples/add/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - add - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/samples/add/add.bat b/samples/add/add.bat deleted file mode 100644 index 13fcb3c3..00000000 --- a/samples/add/add.bat +++ /dev/null @@ -1,7 +0,0 @@ -java ^ - -Djava.library.path=../../com.amd.aparapi.jni/dist ^ - -Dcom.amd.aparapi.executionMode=%1 ^ - -Dcom.amd.aparapi.enableShowGeneratedOpenCL=true ^ - -classpath ../../com.amd.aparapi/dist/aparapi.jar;add.jar ^ - com.amd.aparapi.sample.add.Main - diff --git a/samples/add/add.sh b/samples/add/add.sh deleted file mode 100644 index df37f681..00000000 --- a/samples/add/add.sh +++ /dev/null @@ -1,5 +0,0 @@ -java \ - -Djava.library.path=../../com.amd.aparapi.jni/dist \ - -Dcom.amd.aparapi.executionMode=%1 \ - -classpath ../../com.amd.aparapi/dist/aparapi.jar:add.jar \ - com.amd.aparapi.sample.add.Main diff --git a/samples/add/build.xml b/samples/add/build.xml deleted file mode 100644 index 2b0d1eee..00000000 --- a/samples/add/build.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/samples/add/src/com/amd/aparapi/sample/add/Main.java b/samples/add/src/com/amd/aparapi/sample/add/Main.java deleted file mode 100644 index a362a10e..00000000 --- a/samples/add/src/com/amd/aparapi/sample/add/Main.java +++ /dev/null @@ -1,76 +0,0 @@ -/* -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.amd.aparapi.sample.add; - -import com.amd.aparapi.Kernel; -import com.amd.aparapi.Range; - -public class Main{ - - public static void main(String[] _args) { - - final int size = 512; - - final float[] a = new float[size]; - final float[] b = new float[size]; - - for (int i = 0; i < size; i++) { - a[i] = (float)(Math.random()*100); - b[i] = (float)(Math.random()*100); - } - - final float[] sum = new float[size]; - - Kernel kernel = new Kernel(){ - @Override public void run() { - int gid = getGlobalId(); - sum[gid] = a[gid] + b[gid]; - } - }; - - kernel.execute(Range.create(512)); - - for (int i = 0; i < size; i++) { - System.out.printf("%6.2f + %6.2f = %8.2f\n", a[i], b[i], sum[i]); - } - - kernel.dispose(); - } - -} diff --git a/samples/blackscholes/blackscholes.sh b/samples/blackscholes/blackscholes.sh old mode 100644 new mode 100755 index abf0f0a6..bd7036f3 --- a/samples/blackscholes/blackscholes.sh +++ b/samples/blackscholes/blackscholes.sh @@ -1,7 +1,10 @@ -java \ - -Djava.library.path=..\..\com.amd.aparapi.jni\dist \ - -Dcom.amd.aparapi.executionMode=$1 \ - -Dsize=$2 \ - -Diterations=$3 \ - -classpath blackscholes.jar:..\..\com.amd.aparapi\dist\aparapi.jar \ - com.amd.aparapi.samples.blackscholes.Main +#!/bin/sh + +set -x + +java \ + -Dsize=$1 \ + -Diterations=$2 \ + -Dcom.amd.aparapi.logLevel=INFO \ + -classpath blackscholes.jar \ + com.amd.aparapi.samples.blackscholes.Main diff --git a/samples/blackscholes/build.xml b/samples/blackscholes/build.xml index 14ac01d6..33449730 100644 --- a/samples/blackscholes/build.xml +++ b/samples/blackscholes/build.xml @@ -4,7 +4,7 @@ - + diff --git a/samples/blackscholes/src/com/amd/aparapi/samples/blackscholes/Main.java b/samples/blackscholes/src/com/amd/aparapi/samples/blackscholes/Main.java index 60c31142..7f3cedd8 100644 --- a/samples/blackscholes/src/com/amd/aparapi/samples/blackscholes/Main.java +++ b/samples/blackscholes/src/com/amd/aparapi/samples/blackscholes/Main.java @@ -37,12 +37,12 @@ to national security controls as identified on the Commerce Control List (curren */ package com.amd.aparapi.samples.blackscholes; -import com.amd.aparapi.Kernel; -import com.amd.aparapi.Range; +import java.lang.Math; +import com.amd.aparapi.Aparapi; public class Main{ - public static class BlackScholesKernel extends Kernel{ + public static class BlackScholesKernel /* extends Kernel */ { /* * For a description of the algorithm and the terms used, please see the @@ -92,10 +92,10 @@ float phi(float X) { final float oneBySqrt2pi = 0.398942280f; - float absX = abs(X); + float absX = (float)Math.abs(X); float t = one / (one + temp4 * absX); - float y = one - oneBySqrt2pi * exp(-X * X / two) * t * (c1 + t * (c2 + t * (c3 + t * (c4 + t * c5)))); + float y = one - oneBySqrt2pi * (float)Math.exp(-X * X / two) * t * (c1 + t * (c2 + t * (c3 + t * (c4 + t * c5)))); float result = (X < zero) ? (one - y) : y; @@ -113,38 +113,38 @@ float phi(float X) { * @param call Array of calculated call price values * @param put Array of calculated put price values */ - @Override public void run() { - float d1, d2; - float phiD1, phiD2; - float sigmaSqrtT; - float KexpMinusRT; - - int gid = getGlobalId(); - float two = 2.0f; - float inRand = randArray[gid]; - float S = S_LOWER_LIMIT * inRand + S_UPPER_LIMIT * (1.0f - inRand); - float K = K_LOWER_LIMIT * inRand + K_UPPER_LIMIT * (1.0f - inRand); - float T = T_LOWER_LIMIT * inRand + T_UPPER_LIMIT * (1.0f - inRand); - float R = R_LOWER_LIMIT * inRand + R_UPPER_LIMIT * (1.0f - inRand); - float sigmaVal = SIGMA_LOWER_LIMIT * inRand + SIGMA_UPPER_LIMIT * (1.0f - inRand); - - sigmaSqrtT = sigmaVal * sqrt(T); - - d1 = (log(S / K) + (R + sigmaVal * sigmaVal / two) * T) / sigmaSqrtT; - d2 = d1 - sigmaSqrtT; - - KexpMinusRT = K * exp(-R * T); - - phiD1 = phi(d1); - phiD2 = phi(d2); - - call[gid] = S * phiD1 - KexpMinusRT * phiD2; - - phiD1 = phi(-d1); - phiD2 = phi(-d2); - - put[gid] = KexpMinusRT * phiD2 - S * phiD1; - } +// @Override public void run() { +// float d1, d2; +// float phiD1, phiD2; +// float sigmaSqrtT; +// float KexpMinusRT; +// +// int gid = getGlobalId(); +// float two = 2.0f; +// float inRand = randArray[gid]; +// float S = S_LOWER_LIMIT * inRand + S_UPPER_LIMIT * (1.0f - inRand); +// float K = K_LOWER_LIMIT * inRand + K_UPPER_LIMIT * (1.0f - inRand); +// float T = T_LOWER_LIMIT * inRand + T_UPPER_LIMIT * (1.0f - inRand); +// float R = R_LOWER_LIMIT * inRand + R_UPPER_LIMIT * (1.0f - inRand); +// float sigmaVal = SIGMA_LOWER_LIMIT * inRand + SIGMA_UPPER_LIMIT * (1.0f - inRand); +// +// sigmaSqrtT = sigmaVal * sqrt(T); +// +// d1 = (log(S / K) + (R + sigmaVal * sigmaVal / two) * T) / sigmaSqrtT; +// d2 = d1 - sigmaSqrtT; +// +// KexpMinusRT = K * exp(-R * T); +// +// phiD1 = phi(d1); +// phiD2 = phi(d2); +// +// call[gid] = S * phiD1 - KexpMinusRT * phiD2; +// +// phiD1 = phi(-d1); +// phiD2 = phi(-d2); +// +// put[gid] = KexpMinusRT * phiD2 - S * phiD1; +// } private float randArray[]; @@ -177,12 +177,49 @@ public void showResults(int count) { showArray(call, "Call Prices", count); showArray(put, "Put Prices", count); } + + public void doIt(int size) { + + Aparapi.forEach( size, p ->{ + float d1, d2; + float phiD1, phiD2; + float sigmaSqrtT; + float KexpMinusRT; + + int gid = p; + float two = 2.0f; + float inRand = randArray[gid]; + float S = S_LOWER_LIMIT * inRand + S_UPPER_LIMIT * (1.0f - inRand); + float K = K_LOWER_LIMIT * inRand + K_UPPER_LIMIT * (1.0f - inRand); + float T = T_LOWER_LIMIT * inRand + T_UPPER_LIMIT * (1.0f - inRand); + float R = R_LOWER_LIMIT * inRand + R_UPPER_LIMIT * (1.0f - inRand); + float sigmaVal = SIGMA_LOWER_LIMIT * inRand + SIGMA_UPPER_LIMIT * (1.0f - inRand); + + sigmaSqrtT = sigmaVal * (float)Math.sqrt(T); + + d1 = ((float)Math.log(S / K) + (R + sigmaVal * sigmaVal / two) * T) / sigmaSqrtT; + d2 = d1 - sigmaSqrtT; + + KexpMinusRT = K * (float)Math.exp(-R * T); + + phiD1 = phi(d1); + phiD2 = phi(d2); + + call[gid] = S * phiD1 - KexpMinusRT * phiD2; + + phiD1 = phi(-d1); + phiD2 = phi(-d2); + + put[gid] = KexpMinusRT * phiD2 - S * phiD1; + + }); + } + } public static void main(String[] _args) throws ClassNotFoundException, InstantiationException, IllegalAccessException { int size = Integer.getInteger("size", 512); - Range range = Range.create(size); int iterations = Integer.getInteger("iterations", 5); System.out.println("size =" + size); System.out.println("iterations =" + iterations); @@ -190,16 +227,12 @@ public static void main(String[] _args) throws ClassNotFoundException, Instantia long totalExecTime = 0; long iterExecTime = 0; - /* - for (int i = 0; i < iterations; i++) { - iterExecTime = kernel.execute(size).getExecutionTime(); - totalExecTime += iterExecTime; - }*/ - kernel.execute(range, iterations); - System.out.println("Average execution time " + kernel.getAccumulatedExecutionTime() / iterations); + + kernel.doIt(size); + kernel.showResults(10); - kernel.dispose(); + //kernel.dispose(); } } diff --git a/samples/convolution/.classpath b/samples/convolution/.classpath deleted file mode 100644 index 2b3d4294..00000000 --- a/samples/convolution/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/samples/convolution/.project b/samples/convolution/.project deleted file mode 100644 index a304e12f..00000000 --- a/samples/convolution/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - convolution - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/samples/convolution/build.xml b/samples/convolution/build.xml deleted file mode 100644 index 0bf8e643..00000000 --- a/samples/convolution/build.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/convolution/conv.bat b/samples/convolution/conv.bat deleted file mode 100644 index 3d11f2de..00000000 --- a/samples/convolution/conv.bat +++ /dev/null @@ -1,7 +0,0 @@ -java ^ - -Djava.library.path=../../com.amd.aparapi.jni/dist ^ - -Dcom.amd.aparapi.executionMode=%1 ^ - -Dcom.amd.aparapi.enableShowGeneratedOpenCL=true ^ - -classpath ../../com.amd.aparapi/dist/aparapi.jar;convolution.jar ^ - com.amd.aparapi.sample.convolution.Convolution %2 - diff --git a/samples/convolution/knight.png b/samples/convolution/knight.png deleted file mode 100644 index 46d06cb4..00000000 Binary files a/samples/convolution/knight.png and /dev/null differ diff --git a/samples/convolution/opencl.bat b/samples/convolution/opencl.bat deleted file mode 100644 index c0ada67f..00000000 --- a/samples/convolution/opencl.bat +++ /dev/null @@ -1,6 +0,0 @@ -java ^ - -Djava.library.path=../../com.amd.aparapi.jni/dist ^ - -Dcom.amd.aparapi.executionMode=%1 ^ - -classpath ../../com.amd.aparapi/dist/aparapi.jar;convolution.jar ^ - com.amd.aparapi.sample.convolution.ConvolutionOpenCL %2 - diff --git a/samples/convolution/pureJava.bat b/samples/convolution/pureJava.bat deleted file mode 100644 index 5699f497..00000000 --- a/samples/convolution/pureJava.bat +++ /dev/null @@ -1,6 +0,0 @@ -java ^ - -Djava.library.path=../../com.amd.aparapi.jni/dist ^ - -Dcom.amd.aparapi.executionMode=%1 ^ - -classpath ../../com.amd.aparapi/dist/aparapi.jar;convolution.jar ^ - com.amd.aparapi.sample.convolution.PureJava %2 - diff --git a/samples/convolution/src/com/amd/aparapi/sample/convolution/ConvMatrix3x3Editor.java b/samples/convolution/src/com/amd/aparapi/sample/convolution/ConvMatrix3x3Editor.java deleted file mode 100644 index 05f3e47c..00000000 --- a/samples/convolution/src/com/amd/aparapi/sample/convolution/ConvMatrix3x3Editor.java +++ /dev/null @@ -1,152 +0,0 @@ - -/* -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.amd.aparapi.sample.convolution; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Arrays; - -import javax.swing.BoxLayout; -import javax.swing.JComboBox; -import javax.swing.JPanel; -import javax.swing.JSpinner; -import javax.swing.SpinnerModel; -import javax.swing.SpinnerNumberModel; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -public class ConvMatrix3x3Editor{ - Component component; - - float[] default3x3; - - float[] none3x3 = new float[] { - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0 - }; - - float[] blur3x3 = new float[] { - .1f, - .1f, - .1f, - .1f, - .1f, - .1f, - .1f, - .1f, - .1f - }; - - JSpinner[] spinners = new JSpinner[9]; - - protected void updated(float[] _convMatrix3x3) { - - }; - - void set(float[] _to, float[] _from) { - for (int i = 0; i < 9; i++) { - _to[i] = _from[i]; - spinners[i].setValue((Double) (double) _to[i]); - - } - updated(_to); - } - - ConvMatrix3x3Editor(final float[] _convMatrix3x3) { - default3x3 = Arrays.copyOf(_convMatrix3x3, _convMatrix3x3.length); - JPanel leftPanel = new JPanel(); - JPanel controlPanel = new JPanel(); - BoxLayout layout = new BoxLayout(controlPanel, BoxLayout.Y_AXIS); - controlPanel.setLayout(layout); - component = leftPanel; - JPanel grid3x3Panel = new JPanel(); - controlPanel.add(grid3x3Panel); - grid3x3Panel.setLayout(new GridLayout(3, 3)); - for (int i = 0; i < 9; i++) { - final int index = i; - SpinnerModel model = new SpinnerNumberModel(_convMatrix3x3[index], -50f, 50f, 1f); - JSpinner spinner = new JSpinner(model); - spinners[i] = spinner; - spinner.addChangeListener(new ChangeListener(){ - public void stateChanged(ChangeEvent ce) { - JSpinner source = (JSpinner) ce.getSource(); - double value = ((Double) source.getValue()); - _convMatrix3x3[index] = (float) value; - updated(_convMatrix3x3); - } - }); - grid3x3Panel.add(spinner); - } - String[] options = new String[] { - "DEFAULT", - "NONE", - "BLUR" - }; - JComboBox combo = new JComboBox(options); - combo.addActionListener(new ActionListener(){ - - @Override public void actionPerformed(ActionEvent e) { - JComboBox cb = (JComboBox) e.getSource(); - String value = (String) cb.getSelectedItem(); - if (value.equals("DEFAULT")) { - set(_convMatrix3x3, default3x3); - } else if (value.equals("NONE")) { - set(_convMatrix3x3, none3x3); - } else if (value.equals("BLUR")) { - set(_convMatrix3x3, blur3x3); - } - } - - }); - controlPanel.add(combo); - - leftPanel.add(controlPanel, BorderLayout.NORTH); - } -} diff --git a/samples/convolution/src/com/amd/aparapi/sample/convolution/Convolution.java b/samples/convolution/src/com/amd/aparapi/sample/convolution/Convolution.java deleted file mode 100644 index 4d322f7b..00000000 --- a/samples/convolution/src/com/amd/aparapi/sample/convolution/Convolution.java +++ /dev/null @@ -1,118 +0,0 @@ -/* -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.amd.aparapi.sample.convolution; - -import java.io.File; - -import com.amd.aparapi.Kernel; - -public class Convolution{ - - final static class ImageConvolution extends Kernel{ - private float convMatrix3x3[]; - - private int width, height; - - private byte imageIn[], imageOut[]; - - public void processPixel(int x, int y, int w, int h) { - float accum = 0f; - int count = 0; - for (int dx = -3; dx < 6; dx += 3) { - for (int dy = -1; dy < 2; dy += 1) { - int rgb = 0xff & imageIn[((y + dy) * w) + (x + dx)]; - - accum += rgb * convMatrix3x3[count++]; - } - } - byte value = (byte) (max(0, min((int) accum, 255))); - imageOut[y * w + x] = value; - - } - - @Override public void run() { - int x = getGlobalId(0) % (width * 3); - int y = getGlobalId(0) / (width * 3); - - if (x > 3 && x < (width * 3 - 3) && y > 1 && y < (height - 1)) { - processPixel(x, y, width * 3, height); - } - - } - - public void applyConvolution(float[] _convMatrix3x3, byte[] _imageIn, byte[] _imageOut, int _width, int _height) { - imageIn = _imageIn; - imageOut = _imageOut; - width = _width; - height = _height; - convMatrix3x3 = _convMatrix3x3; - execute(3 * width * height); - } - - } - - public static void main(final String[] _args) { - File file = new File(_args.length == 1 ? _args[0] : "testcard.jpg"); - - final ImageConvolution convolution = new ImageConvolution(); - - float convMatrix3x3[] = new float[] { - 0f, - -10f, - 0f, - -10f, - 40f, - -10f, - 0f, - -10f, - 0f, - }; - - - - new ConvolutionViewer(file, convMatrix3x3){ - @Override protected void applyConvolution(float[] _convMatrix3x3, byte[] _inBytes, byte[] _outBytes, int _width, - int _height) { - convolution.applyConvolution(_convMatrix3x3, _inBytes, _outBytes, _width, _height); - } - }; - - } - -} diff --git a/samples/convolution/src/com/amd/aparapi/sample/convolution/ConvolutionOpenCL.java b/samples/convolution/src/com/amd/aparapi/sample/convolution/ConvolutionOpenCL.java deleted file mode 100644 index 54b096e6..00000000 --- a/samples/convolution/src/com/amd/aparapi/sample/convolution/ConvolutionOpenCL.java +++ /dev/null @@ -1,93 +0,0 @@ - -/* -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.amd.aparapi.sample.convolution; - -import java.io.File; - -import com.amd.aparapi.Device; -import com.amd.aparapi.OpenCL; -import com.amd.aparapi.OpenCLDevice; -import com.amd.aparapi.Range; - -public class ConvolutionOpenCL{ - - @OpenCL.Resource("com/amd/aparapi/sample/convolution/convolution.cl") interface Convolution extends OpenCL{ - Convolution applyConvolution(// - Range range, // - @GlobalReadOnly("_convMatrix3x3") float[] _convMatrix3x3,//// only read from kernel - @GlobalReadOnly("_imagIn") byte[] _imageIn,// only read from kernel (actually char[]) - @GlobalWriteOnly("_imagOut") byte[] _imageOut, // only written to (never read) from kernel (actually char[]) - @Arg("_width") int _width,// - @Arg("_height") int _height); - } - - public static void main(final String[] _args) { - File file = new File(_args.length == 1 ? _args[0] : "testcard.jpg"); - - final OpenCLDevice openclDevice = (OpenCLDevice) Device.best(); - - final Convolution convolution = openclDevice.bind(Convolution.class); - float convMatrix3x3[] = new float[] { - 0f, - -10f, - 0f, - -10f, - 40f, - -10f, - 0f, - -10f, - 0f, - }; - - new ConvolutionViewer(file, convMatrix3x3){ - Range range = null; - - @Override protected void applyConvolution(float[] _convMatrix3x3, byte[] _inBytes, byte[] _outBytes, int _width, - int _height) { - if (range == null) { - range = openclDevice.createRange(_width * _height * 3); - } - convolution.applyConvolution(range, _convMatrix3x3, _inBytes, _outBytes, _width, _height); - } - }; - - } - -} diff --git a/samples/convolution/src/com/amd/aparapi/sample/convolution/ConvolutionViewer.java b/samples/convolution/src/com/amd/aparapi/sample/convolution/ConvolutionViewer.java deleted file mode 100644 index 679189b4..00000000 --- a/samples/convolution/src/com/amd/aparapi/sample/convolution/ConvolutionViewer.java +++ /dev/null @@ -1,132 +0,0 @@ - -/* -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.amd.aparapi.sample.convolution; - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.awt.image.DataBufferByte; -import java.io.File; -import java.io.IOException; - -import javax.imageio.ImageIO; -import javax.swing.ImageIcon; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.WindowConstants; - -@SuppressWarnings("serial") public abstract class ConvolutionViewer extends JFrame{ - - private int height; - - private int width; - - private BufferedImage outputImage; - - private BufferedImage inputImage; - - private byte[] inBytes; - - private byte[] outBytes; - - private Graphics2D gc; - - private float[] convMatrix3x3; - - public ConvolutionViewer(File _file, float[] _convMatrix3x3) { - - JFrame frame = new JFrame("Convolution Viewer"); - - convMatrix3x3 = _convMatrix3x3; - try { - inputImage = ImageIO.read(_file); - - // System.out.println(inputImage); - - height = inputImage.getHeight(); - - width = inputImage.getWidth(); - - outputImage = new BufferedImage(width, height, inputImage.getType()); - - gc = outputImage.createGraphics(); - - inBytes = ((DataBufferByte) inputImage.getRaster().getDataBuffer()).getData(); - outBytes = ((DataBufferByte) outputImage.getRaster().getDataBuffer()).getData(); - - final JLabel imageLabel = new JLabel(); - imageLabel.setIcon(new ImageIcon(outputImage)); - - ConvMatrix3x3Editor editor = new ConvMatrix3x3Editor(_convMatrix3x3){ - @Override protected void updated(float[] _convMatrix3x3) { - convMatrix3x3 = _convMatrix3x3; - long start = System.currentTimeMillis(); - - applyConvolution(convMatrix3x3, inBytes, outBytes, width, height); - long end = System.currentTimeMillis(); - gc.setColor(Color.BLACK); - gc.fillRect(0, 0, 50, 40); - gc.setColor(Color.YELLOW); - gc.drawString("" + (end - start) + "ms", 10, 20); - - imageLabel.repaint(); - } - }; - frame.getContentPane().add(editor.component, BorderLayout.WEST); - - frame.getContentPane().add(imageLabel, BorderLayout.CENTER); - frame.pack(); - frame.setVisible(true); - frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - - applyConvolution(convMatrix3x3, inBytes, outBytes, width, height); - - imageLabel.repaint(); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - - } - - abstract protected void applyConvolution(float[] convMatrix3x3, byte[] _inBytes, byte[] _outBytes, int _width, int _height); - -} diff --git a/samples/convolution/src/com/amd/aparapi/sample/convolution/PureJava.java b/samples/convolution/src/com/amd/aparapi/sample/convolution/PureJava.java deleted file mode 100644 index 5c0158df..00000000 --- a/samples/convolution/src/com/amd/aparapi/sample/convolution/PureJava.java +++ /dev/null @@ -1,117 +0,0 @@ -/* -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.amd.aparapi.sample.convolution; - -import java.io.File; - -import com.amd.aparapi.Kernel; - -public class PureJava{ - - final static class ImageConvolution extends Kernel{ - private float convMatrix3x3[]; - - private int width, height; - - private byte imageIn[], imageOut[]; - - public void processPixel(int x, int y, int w, int h) { - float accum = 0f; - int count = 0; - for (int dx = -3; dx < 6; dx += 3) { - for (int dy = -1; dy < 2; dy += 1) { - int rgb = 0xff & imageIn[((y + dy) * w) + (x + dx)]; - - accum += rgb * convMatrix3x3[count++]; - } - } - byte value = (byte) (max(0, min((int) accum, 255))); - imageOut[y * w + x] = value; - - } - - @Override public void run() { - int x = getGlobalId(0) % (width * 3); - int y = getGlobalId(0) / (width * 3); - - if (x > 3 && x < (width * 3 - 3) && y > 1 && y < (height - 1)) { - processPixel(x, y, width * 3, height); - } - - } - - public void applyConvolution(float[] _convMatrix3x3, byte[] _imageIn, byte[] _imageOut, int _width, int _height) { - imageIn = _imageIn; - imageOut = _imageOut; - width = _width; - height = _height; - convMatrix3x3 = _convMatrix3x3; - - execute(3 * width * height); - } - - } - - public static void main(final String[] _args) { - File file = new File(_args.length == 1 ? _args[0] : "testcard.jpg"); - - final ImageConvolution convolution = new ImageConvolution(); - - float convMatrix3x3[] = new float[] { - 0f, - -10f, - 0f, - -10f, - 40f, - -10f, - 0f, - -10f, - 0f, - }; - - new ConvolutionViewer(file, convMatrix3x3){ - @Override protected void applyConvolution(float[] _convMatrix3x3, byte[] _inBytes, byte[] _outBytes, int _width, - int _height) { - convolution.applyConvolution(_convMatrix3x3, _inBytes, _outBytes, _width, _height); - } - }; - - } - -} diff --git a/samples/convolution/src/com/amd/aparapi/sample/convolution/convolution.cl b/samples/convolution/src/com/amd/aparapi/sample/convolution/convolution.cl deleted file mode 100644 index e1acfa8f..00000000 --- a/samples/convolution/src/com/amd/aparapi/sample/convolution/convolution.cl +++ /dev/null @@ -1,28 +0,0 @@ -void processPixel(__global float* _convMatrix3x3, __global char* _imageIn, __global char* _imageOut, int _width, int _height, int _x, int _y){ - float accum = 0.0f; - int count = 0; - for (int dx = -3; dx<6; dx+=3){ - for (int dy = -1; dy<2; dy++){ - int rgb = 0xff & _imageIn[(((_y + dy) * _width) + (_x + dx))]; - accum = accum + ((float)rgb * _convMatrix3x3[count++]); - } - } - char value = (char )max(0, min((int)accum, 255)); - _imageOut[(_y * _width) + _x] = value; - return; -} - -__kernel void applyConvolution( - __global float *_convMatrix3x3, // only read from kernel - __global char *_imageIn, // only read from kernel - __global char *_imageOut, // only written to (never read) from kernel - int _width, - int _height -){ - int x = get_global_id(0) % (_width * 3); - int y = get_global_id(0) / (_width * 3); - if (x>3 && x<((_width * 3) - 3) && y>1 && y<(_height - 1)){ - processPixel(_convMatrix3x3, _imageIn, _imageOut, _width*3, _height, x, y); - } -} - diff --git a/samples/extension/.classpath b/samples/extension/.classpath deleted file mode 100644 index 2b3d4294..00000000 --- a/samples/extension/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/samples/extension/.project b/samples/extension/.project deleted file mode 100644 index 1e2c59dc..00000000 --- a/samples/extension/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - extension - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/samples/extension/build.xml b/samples/extension/build.xml deleted file mode 100644 index a89c798f..00000000 --- a/samples/extension/build.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/extension/fft.bat b/samples/extension/fft.bat deleted file mode 100644 index fe645429..00000000 --- a/samples/extension/fft.bat +++ /dev/null @@ -1,9 +0,0 @@ -java ^ - -Djava.library.path=../../com.amd.aparapi.jni/dist ^ - -Dcom.amd.aparapi.executionMode=%1 ^ - -Dcom.amd.aparapi.enableProfiling=false ^ - -Dcom.amd.aparapi.enableShowGeneratedOpenCL=true ^ - -classpath ../../com.amd.aparapi/dist/aparapi.jar;extension.jar ^ - com.amd.aparapi.sample.extension.FFTExample - - diff --git a/samples/extension/histo.bat b/samples/extension/histo.bat deleted file mode 100644 index e7df7760..00000000 --- a/samples/extension/histo.bat +++ /dev/null @@ -1,7 +0,0 @@ -java ^ - -Xmx1024M^ - -Djava.library.path=../../com.amd.aparapi.jni/dist ^ - -classpath ../../com.amd.aparapi/dist/aparapi.jar;extension.jar ^ - com.amd.aparapi.sample.extension.Histogram - - diff --git a/samples/extension/histo.sh b/samples/extension/histo.sh deleted file mode 100644 index 6d7a3dbd..00000000 --- a/samples/extension/histo.sh +++ /dev/null @@ -1,4 +0,0 @@ -java\ - -Djava.library.path=../../com.amd.aparapi.jni/dist\ - -classpath ../../com.amd.aparapi/dist/aparapi.jar:extension.jar\ - com.amd.aparapi.sample.extension.Histogram diff --git a/samples/extension/histoideal.bat b/samples/extension/histoideal.bat deleted file mode 100644 index 7b66486f..00000000 --- a/samples/extension/histoideal.bat +++ /dev/null @@ -1,7 +0,0 @@ -java ^ - -Xmx1024M^ - -Djava.library.path=../../com.amd.aparapi.jni/dist ^ - -classpath ../../com.amd.aparapi/dist/aparapi.jar;extension.jar ^ - com.amd.aparapi.sample.extension.HistogramIdeal - - diff --git a/samples/extension/mandel.bat b/samples/extension/mandel.bat deleted file mode 100644 index 7cbefb99..00000000 --- a/samples/extension/mandel.bat +++ /dev/null @@ -1,9 +0,0 @@ -java ^ - -Djava.library.path=../../com.amd.aparapi.jni/dist ^ - -Dcom.amd.aparapi.executionMode=%1 ^ - -Dcom.amd.aparapi.enableProfiling=false ^ - -Dcom.amd.aparapi.enableShowGeneratedOpenCL=true ^ - -classpath ../../com.amd.aparapi/dist/aparapi.jar;extension.jar ^ - com.amd.aparapi.sample.extension.MandelExample - - diff --git a/samples/extension/mandel.sh b/samples/extension/mandel.sh deleted file mode 100644 index d593465d..00000000 --- a/samples/extension/mandel.sh +++ /dev/null @@ -1,5 +0,0 @@ -java\ - -Djava.library.path=../../com.amd.aparapi.jni/dist\ - -Dcom.amd.aparapi.executionMode=$1\ - -classpath ../../com.amd.aparapi/dist/aparapi.jar:extension.jar\ - com.amd.aparapi.sample.extension.MandelExample diff --git a/samples/extension/square.bat b/samples/extension/square.bat deleted file mode 100644 index 01fd7b2a..00000000 --- a/samples/extension/square.bat +++ /dev/null @@ -1,9 +0,0 @@ -java ^ - -Djava.library.path=../../com.amd.aparapi.jni/dist ^ - -Dcom.amd.aparapi.executionMode=%1 ^ - -Dcom.amd.aparapi.enableProfiling=false ^ - -Dcom.amd.aparapi.enableShowGeneratedOpenCL=true ^ - -classpath ../../com.amd.aparapi/dist/aparapi.jar;extension.jar ^ - com.amd.aparapi.sample.extension.SquareExample - - diff --git a/samples/extension/src/com/amd/aparapi/sample/extension/FFTExample.java b/samples/extension/src/com/amd/aparapi/sample/extension/FFTExample.java deleted file mode 100644 index 2538082b..00000000 --- a/samples/extension/src/com/amd/aparapi/sample/extension/FFTExample.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.amd.aparapi.sample.extension; - -import java.util.Arrays; - -import com.amd.aparapi.Device; -import com.amd.aparapi.OpenCL; -import com.amd.aparapi.OpenCLDevice; -import com.amd.aparapi.Range; - -public class FFTExample{ - @OpenCL.Resource("com/amd/aparapi/sample/extension/fft.cl") interface FFT extends OpenCL{ - - public FFT forward(// - Range _range,// - @GlobalReadWrite("real") float[] real,// - @GlobalReadWrite("imaginary") float[] imaginary// - ); - } - - static void fft(float[] x, float[] y) { - short dir = 1; - long m = 10; - int n, i, i1, j, k, i2, l, l1, l2; - double c1, c2, tx, ty, t1, t2, u1, u2, z; - - /* Calculate the number of points */ - n = 1; - for (i = 0; i < m; i++) - n *= 2; - - /* Do the bit reversal */ - i2 = n >> 1; - j = 0; - for (i = 0; i < n - 1; i++) { - if (i < j) { - tx = x[i]; - ty = y[i]; - x[i] = x[j]; - y[i] = y[j]; - x[j] = (float) tx; - y[j] = (float) ty; - } - k = i2; - while (k <= j) { - j -= k; - k >>= 1; - } - j += k; - } - - /* Compute the FFT */ - c1 = -1.0; - c2 = 0.0; - l2 = 1; - for (l = 0; l < m; l++) { - l1 = l2; - l2 <<= 1; - u1 = 1.0; - u2 = 0.0; - for (j = 0; j < l1; j++) { - for (i = j; i < n; i += l2) { - i1 = i + l1; - t1 = u1 * x[i1] - u2 * y[i1]; - t2 = u1 * y[i1] + u2 * x[i1]; - x[i1] = (float) (x[i] - t1); - y[i1] = (float) (y[i] - t2); - x[i] += (float) t1; - y[i] += (float) t2; - } - z = u1 * c1 - u2 * c2; - u2 = u1 * c2 + u2 * c1; - u1 = z; - } - c2 = Math.sqrt((1.0 - c1) / 2.0); - if (dir == 1) - c2 = -c2; - c1 = Math.sqrt((1.0 + c1) / 2.0); - } - - /* Scaling for forward transform */ - /*if (dir == 1) { - for (i=0;i 0.01) { - System.out.printf("%d %5.2f %5.2f %5.2f\n", i, initial[i], real[i], referenceReal[i]); - } - } - - } -} diff --git a/samples/extension/src/com/amd/aparapi/sample/extension/Histogram.java b/samples/extension/src/com/amd/aparapi/sample/extension/Histogram.java deleted file mode 100644 index 367c8d42..00000000 --- a/samples/extension/src/com/amd/aparapi/sample/extension/Histogram.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.amd.aparapi.sample.extension; - -import com.amd.aparapi.Device; -import com.amd.aparapi.Kernel; -import com.amd.aparapi.OpenCL; -import com.amd.aparapi.OpenCLDevice; -import com.amd.aparapi.Range; - -public class Histogram{ - - @OpenCL.Resource("com/amd/aparapi/sample/extension/HistogramKernel.cl") interface HistogramKernel extends - OpenCL{ - - public HistogramKernel histogram256(// - Range _range,// - @GlobalReadOnly("data") byte[] data,// - @Local("sharedArray") byte[] sharedArray,// - @GlobalWriteOnly("binResult") int[] binResult,// - @Arg("binSize") int binSize); - - public HistogramKernel bin256(// - Range _range,// - @GlobalWriteOnly("histo") int[] histo,// - @GlobalReadOnly("binResult") int[] binResult,// - @Arg("subHistogramSize") int subHistogramSize); - } - - public static void main(String[] args) { - final int WIDTH = 1024 * 16; - final int HEIGHT = 1024 * 8; - final int BIN_SIZE = 128; - final int GROUP_SIZE = 128; - final int SUB_HISTOGRAM_COUNT = ((WIDTH * HEIGHT) / (GROUP_SIZE * BIN_SIZE)); - - byte[] data = new byte[WIDTH * HEIGHT]; - for (int i = 0; i < WIDTH * HEIGHT; i++) { - data[i] = (byte) (Math.random() * BIN_SIZE / 2); - } - byte[] sharedArray = new byte[GROUP_SIZE * BIN_SIZE]; - final int[] binResult = new int[SUB_HISTOGRAM_COUNT * BIN_SIZE]; - System.out.println("binResult size=" + binResult.length); - final int[] histo = new int[BIN_SIZE]; - int[] refHisto = new int[BIN_SIZE]; - Device device = Device.firstGPU(); - Kernel k = new Kernel(){ - - @Override public void run() { - int j = getGlobalId(0); - for (int i = 0; i < SUB_HISTOGRAM_COUNT; ++i) - histo[j] += binResult[i * BIN_SIZE + j]; - } - - }; - Range range2 = device.createRange(BIN_SIZE); - k.execute(range2); - - Range range = Range.create((WIDTH * HEIGHT) / BIN_SIZE, GROUP_SIZE); - - if (device instanceof OpenCLDevice) { - OpenCLDevice openclDevice = (OpenCLDevice) device; - - HistogramKernel histogram = openclDevice.bind(HistogramKernel.class); - - StopWatch timer = new StopWatch(); - timer.start(); - - histogram.histogram256(range, data, sharedArray, binResult, BIN_SIZE); - boolean java = false; - boolean aparapiKernel = false; - if (java) { - // Calculate final histogram bin - for (int j = 0; j < BIN_SIZE; ++j) - for (int i = 0; i < SUB_HISTOGRAM_COUNT; ++i) - histo[j] += binResult[i * BIN_SIZE + j]; - } else if (aparapiKernel) { - k.execute(range2); - } else { - histogram.bin256(range2, histo, binResult, SUB_HISTOGRAM_COUNT); - } - timer.print("opencl"); - timer.start(); - for (int i = 0; i < WIDTH * HEIGHT; i++) { - refHisto[data[i]]++; - } - timer.print("java"); - for (int i = 0; i < 128; i++) { - if (refHisto[i] != histo[i]) { - System.out.println(i + " " + histo[i] + " " + refHisto[i]); - } - } - } - } -} diff --git a/samples/extension/src/com/amd/aparapi/sample/extension/HistogramIdeal.java b/samples/extension/src/com/amd/aparapi/sample/extension/HistogramIdeal.java deleted file mode 100644 index 6c90e0bc..00000000 --- a/samples/extension/src/com/amd/aparapi/sample/extension/HistogramIdeal.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.amd.aparapi.sample.extension; - -import com.amd.aparapi.Device; -import com.amd.aparapi.OpenCL; -import com.amd.aparapi.OpenCLDevice; -import com.amd.aparapi.Range; - -public class HistogramIdeal{ - - // @OpenCL.Resource("com/amd/aparapi/sample/extension/HistogramKernel.cl") - interface HistogramKernel extends OpenCL{ - - public HistogramKernel histogram256(// - Range _range,// - @GlobalReadOnly("data") byte[] data,// - @Local("sharedArray") byte[] sharedArray,// - @GlobalWriteOnly("binResult") int[] binResult,// - @Arg("binSize") int binSize); - - public HistogramKernel bin256(// - Range _range,// - @GlobalWriteOnly("histo") int[] histo,// - @GlobalReadOnly("binResult") int[] binResult,// - @Arg("subHistogramSize") int subHistogramSize); - } - - public static void main(String[] args) { - final int WIDTH = 1024 * 16; - final int HEIGHT = 1024 * 8; - final int BIN_SIZE = 128; - final int GROUP_SIZE = 128; - final int SUB_HISTOGRAM_COUNT = ((WIDTH * HEIGHT) / (GROUP_SIZE * BIN_SIZE)); - - byte[] data = new byte[WIDTH * HEIGHT]; - for (int i = 0; i < WIDTH * HEIGHT; i++) { - data[i] = (byte) (Math.random() * BIN_SIZE / 2); - } - byte[] sharedArray = new byte[GROUP_SIZE * BIN_SIZE]; - final int[] binResult = new int[SUB_HISTOGRAM_COUNT * BIN_SIZE]; - System.out.println("binResult size=" + binResult.length); - final int[] histo = new int[BIN_SIZE]; - int[] refHisto = new int[BIN_SIZE]; - Device device = Device.best(); - - if (device != null) { - - System.out.println(((OpenCLDevice) device).getPlatform().getName()); - Range rangeBinSize = device.createRange(BIN_SIZE); - - Range range = Range.create((WIDTH * HEIGHT) / BIN_SIZE, GROUP_SIZE); - - if (device instanceof OpenCLDevice) { - OpenCLDevice openclDevice = (OpenCLDevice) device; - - HistogramKernel histogram = openclDevice.bind(HistogramKernel.class, Histogram.class.getClassLoader() - .getResourceAsStream("com/amd/aparapi/sample/extension/HistogramKernel.cl")); - long start = System.nanoTime(); - histogram.begin()// - .put(data)// - .histogram256(range, data, sharedArray, binResult, BIN_SIZE)// - // by leaving binResult on the GPU we can save two 1Mb transfers - .bin256(rangeBinSize, histo, binResult, SUB_HISTOGRAM_COUNT)// - .get(histo)// - .end(); - System.out.println("opencl " + ((System.nanoTime() - start) / 1000000)); - start = System.nanoTime(); - for (int i = 0; i < WIDTH * HEIGHT; i++) { - refHisto[data[i]]++; - } - System.out.println("java " + ((System.nanoTime() - start) / 1000000)); - for (int i = 0; i < 128; i++) { - if (refHisto[i] != histo[i]) { - System.out.println(i + " " + histo[i] + " " + refHisto[i]); - } - } - - } - } else { - System.out.println("no GPU device"); - } - } -} diff --git a/samples/extension/src/com/amd/aparapi/sample/extension/HistogramKernel.cl b/samples/extension/src/com/amd/aparapi/sample/extension/HistogramKernel.cl deleted file mode 100644 index aaa5c154..00000000 --- a/samples/extension/src/com/amd/aparapi/sample/extension/HistogramKernel.cl +++ /dev/null @@ -1,166 +0,0 @@ -/* ============================================================ - -Copyright (c) 2009-2010 Advanced Micro Devices, Inc. All rights reserved. - -Redistribution and use of this material is permitted under the following -conditions: - -Redistributions must retain the above copyright notice and all terms of this -license. - -In no event shall anyone redistributing or accessing or using this material -commence or participate in any arbitration or legal action relating to this -material against Advanced Micro Devices, Inc. or any copyright holders or -contributors. The foregoing shall survive any expiration or termination of -this license or any agreement or access or use related to this material. - -ANY BREACH OF ANY TERM OF THIS LICENSE SHALL RESULT IN THE IMMEDIATE REVOCATION -OF ALL RIGHTS TO REDISTRIBUTE, ACCESS OR USE THIS MATERIAL. - -THIS MATERIAL IS PROVIDED BY ADVANCED MICRO DEVICES, INC. AND ANY COPYRIGHT -HOLDERS AND CONTRIBUTORS "AS IS" IN ITS CURRENT CONDITION AND WITHOUT ANY -REPRESENTATIONS, GUARANTEE, OR WARRANTY OF ANY KIND OR IN ANY WAY RELATED TO -SUPPORT, INDEMNITY, ERROR FREE OR UNINTERRUPTED OPERA TION, OR THAT IT IS FREE -FROM DEFECTS OR VIRUSES. ALL OBLIGATIONS ARE HEREBY DISCLAIMED - WHETHER -EXPRESS, IMPLIED, OR STATUTORY - INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED -WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, -ACCURACY, COMPLETENESS, OPERABILITY, QUALITY OF SERVICE, OR NON-INFRINGEMENT. -IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. OR ANY COPYRIGHT HOLDERS OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, REVENUE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED OR BASED ON ANY THEORY OF LIABILITY -ARISING IN ANY WAY RELATED TO THIS MATERIAL, EVEN IF ADVISED OF THE POSSIBILITY -OF SUCH DAMAGE. THE ENTIRE AND AGGREGATE LIABILITY OF ADVANCED MICRO DEVICES, -INC. AND ANY COPYRIGHT HOLDERS AND CONTRIBUTORS SHALL NOT EXCEED TEN DOLLARS -(US $10.00). ANYONE REDISTRIBUTING OR ACCESSING OR USING THIS MATERIAL ACCEPTS -THIS ALLOCATION OF RISK AND AGREES TO RELEASE ADVANCED MICRO DEVICES, INC. AND -ANY COPYRIGHT HOLDERS AND CONTRIBUTORS FROM ANY AND ALL LIABILITIES, -OBLIGATIONS, CLAIMS, OR DEMANDS IN EXCESS OF TEN DOLLARS (US $10.00). THE -FOREGOING ARE ESSENTIAL TERMS OF THIS LICENSE AND, IF ANY OF THESE TERMS ARE -CONSTRUED AS UNENFORCEABLE, FAIL IN ESSENTIAL PURPOSE, OR BECOME VOID OR -DETRIMENTAL TO ADVANCED MICRO DEVICES, INC. OR ANY COPYRIGHT HOLDERS OR -CONTRIBUTORS FOR ANY REASON, THEN ALL RIGHTS TO REDISTRIBUTE, ACCESS OR USE -THIS MATERIAL SHALL TERMINATE IMMEDIATELY. MOREOVER, THE FOREGOING SHALL -SURVIVE ANY EXPIRATION OR TERMINATION OF THIS LICENSE OR ANY AGREEMENT OR -ACCESS OR USE RELATED TO THIS MATERIAL. - -NOTICE IS HEREBY PROVIDED, AND BY REDISTRIBUTING OR ACCESSING OR USING THIS -MATERIAL SUCH NOTICE IS ACKNOWLEDGED, THAT THIS MATERIAL MAY BE SUBJECT TO -RESTRICTIONS UNDER THE LAWS AND REGULATIONS OF THE UNITED STATES OR OTHER -COUNTRIES, WHICH INCLUDE BUT ARE NOT LIMITED TO, U.S. EXPORT CONTROL LAWS SUCH -AS THE EXPORT ADMINISTRATION REGULATIONS AND NATIONAL SECURITY CONTROLS AS -DEFINED THEREUNDER, AS WELL AS STATE DEPARTMENT CONTROLS UNDER THE U.S. -MUNITIONS LIST. THIS MATERIAL MAY NOT BE USED, RELEASED, TRANSFERRED, IMPORTED, -EXPORTED AND/OR RE-EXPORTED IN ANY MANNER PROHIBITED UNDER ANY APPLICABLE LAWS, -INCLUDING U.S. EXPORT CONTROL LAWS REGARDING SPECIFICALLY DESIGNATED PERSONS, -COUNTRIES AND NATIONALS OF COUNTRIES SUBJECT TO NATIONAL SECURITY CONTROLS. -MOREOVER, THE FOREGOING SHALL SURVIVE ANY EXPIRATION OR TERMINATION OF ANY -LICENSE OR AGREEMENT OR ACCESS OR USE RELATED TO THIS MATERIAL. - -NOTICE REGARDING THE U.S. GOVERNMENT AND DOD AGENCIES: This material is -provided with "RESTRICTED RIGHTS" and/or "LIMITED RIGHTS" as applicable to -computer software and technical data, respectively. Use, duplication, -distribution or disclosure by the U.S. Government and/or DOD agencies is -subject to the full extent of restrictions in all applicable regulations, -including those found at FAR52.227 and DFARS252.227 et seq. and any successor -regulations thereof. Use of this material by the U.S. Government and/or DOD -agencies is acknowledgment of the proprietary rights of any copyright holders -and contributors, including those of Advanced Micro Devices, Inc., as well as -the provisions of FAR52.227-14 through 23 regarding privately developed and/or -commercial computer software. - -This license forms the entire agreement regarding the subject matter hereof and -supersedes all proposals and prior discussions and writings between the parties -with respect thereto. This license does not affect any ownership, rights, title, -or interest in, or relating to, this material. No terms of this license can be -modified or waived, and no breach of this license can be excused, unless done -so in a writing signed by all affected parties. Each term of this license is -separately enforceable. If any term of this license is determined to be or -becomes unenforceable or illegal, such term shall be reformed to the minimum -extent necessary in order for this license to remain in effect in accordance -with its terms as modified by such reformation. This license shall be governed -by and construed in accordance with the laws of the State of Texas without -regard to rules on conflicts of law of any state or jurisdiction or the United -Nations Convention on the International Sale of Goods. All disputes arising out -of this license shall be subject to the jurisdiction of the federal and state -courts in Austin, Texas, and all defenses are hereby waived concerning personal -jurisdiction and venue of these courts. - -============================================================ */ - -/* - * For a description of the algorithm and the terms used, please see the - * documentation for this sample. - * - * On invocation of kernel blackScholes, each work thread calculates - * thread-histogram bin and finally all thread-histograms merged into - * block-histogram bin. Outside the kernel, All block-histograms merged - * into final histogram - */ - -#define LINEAR_MEM_ACCESS -#pragma OPENCL EXTENSION cl_khr_byte_addressable_store : enable - - - -/** - * @brief Calculates block-histogram bin whose bin size is 256 - * @param data input data pointer - * @param sharedArray shared array for thread-histogram bins - * @param binResult block-histogram array - */ -__kernel -void histogram256(__global const uchar* data, - __local uchar* sharedArray, - __global uint* binResult, - uint binSize) -{ - size_t localId = get_local_id(0); - size_t globalId = get_global_id(0); - size_t groupId = get_group_id(0); - size_t groupSize = get_local_size(0); - - /* initialize shared array to zero */ - for(int i = 0; i < binSize; ++i) - sharedArray[localId * binSize + i] = 0; - - barrier(CLK_LOCAL_MEM_FENCE); - - /* calculate thread-histograms */ - for(int i = 0; i < binSize; ++i) - { -#ifdef LINEAR_MEM_ACCESS - uchar value = data[groupId * groupSize * binSize + i * groupSize + localId]; -#else - uchar value = data[globalId * binSize + i]; -#endif // LINEAR_MEM_ACCESS - sharedArray[localId * binSize + value]++; - } - - barrier(CLK_LOCAL_MEM_FENCE); - - /* merge all thread-histograms into block-histogram */ - for(int i = 0; i < binSize / groupSize; ++i) - { - uint binCount = 0; - for(int j = 0; j < groupSize; ++j) - binCount += sharedArray[j * binSize + i * groupSize + localId]; - - binResult[groupId * binSize + i * groupSize + localId] = binCount; - } -} - -__kernel -void bin256(__global uint* histo, - __global const uint* binResult, - uint subHistogramSize ) -{ - size_t j = get_local_id(0); - size_t binSize=get_global_size(0); - uint histValue=0; - for(int i = 0; i < subHistogramSize; ++i){ - histValue += binResult[i * binSize + j]; - } - histo[j]=histValue; -} diff --git a/samples/extension/src/com/amd/aparapi/sample/extension/MandelExample.java b/samples/extension/src/com/amd/aparapi/sample/extension/MandelExample.java deleted file mode 100644 index 49540b42..00000000 --- a/samples/extension/src/com/amd/aparapi/sample/extension/MandelExample.java +++ /dev/null @@ -1,526 +0,0 @@ -/* -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.amd.aparapi.sample.extension; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Graphics; -import java.awt.Point; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.image.BufferedImage; -import java.awt.image.DataBufferInt; -import java.util.concurrent.BrokenBarrierException; -import java.util.concurrent.CyclicBarrier; - -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; - -import com.amd.aparapi.Device; -import com.amd.aparapi.OpenCL; -import com.amd.aparapi.OpenCLAdapter; -import com.amd.aparapi.OpenCLDevice; -import com.amd.aparapi.OpenCLPlatform; -import com.amd.aparapi.Range; - -/** - * An example Aparapi application which displays a view of the Mandelbrot set and lets the user zoom in to a particular point. - * - * When the user clicks on the view, this example application will zoom in to the clicked point and zoom out there after. - * On GPU, additional computing units will offer a better viewing experience. On the other hand on CPU, this example - * application might suffer with sub-optimal frame refresh rate as compared to GPU. - * - * @author gfrost - * - */ - -@OpenCL.Resource("com/amd/aparapi/sample/extension/mandel2.cl") interface MandelBrot extends OpenCL{ - MandelBrot createMandleBrot(// - Range range,// - @Arg("scale") float scale, // - @Arg("offsetx") float offsetx, // - @Arg("offsety") float offsety, // - @GlobalWriteOnly("rgb") int[] rgb - - ); -} - -class JavaMandelBrot extends OpenCLAdapter implements MandelBrot{ - final int MAX_ITERATIONS = 64; - - final int pallette[] = new int[] { - -65536, - -59392, - -53248, - -112640, - -106752, - -166144, - -160256, - -219904, - -279552, - -339200, - -399104, - -985344, - -2624000, - -4197376, - -5770496, - -7343872, - -8851712, - -10425088, - -11932928, - -13375232, - -14817792, - -16260096, - -16719602, - -16720349, - -16721097, - -16721846, - -16722595, - -16723345, - -16724351, - -16725102, - -16726110, - -16727119, - -16728129, - -16733509, - -16738889, - -16744269, - -16749138, - -16754006, - -16758619, - -16762976, - -16767077, - -16771178, - -16774767, - -16514932, - -15662970, - -14942079, - -14221189, - -13631371, - -13107088, - -12648342, - -12320669, - -11992995, - -11796393, - -11665328, - -11993019, - -12386248, - -12845011, - -13303773, - -13762534, - -14286830, - -14745588, - -15269881, - -15728637, - -16252927, - 0 - }; - - @Override public MandelBrot createMandleBrot(Range range, float scale, float offsetx, float offsety, int[] rgb) { - - int width = range.getGlobalSize(0); - int height = range.getGlobalSize(1); - for (int gridy = 0; gridy < height; gridy++) { - for (int gridx = 0; gridx < width; gridx++) { - float x = ((((float) (gridx) * scale) - ((scale / 2.0f) * (float) width)) / (float) width) + offsetx; - float y = ((((float) (gridy) * scale) - ((scale / 2.0f) * (float) height)) / (float) height) + offsety; - int count = 0; - float zx = x; - float zy = y; - float new_zx = 0.0f; - for (; count < MAX_ITERATIONS && ((zx * zx) + (zy * zy)) < 8.0f; count++) { - new_zx = ((zx * zx) - (zy * zy)) + x; - zy = ((2.0f * zx) * zy) + y; - zx = new_zx; - } - rgb[gridx + gridy * width] = pallette[count]; - - } - } - return (this); - } - -} - -class JavaMandelBrotMultiThread extends OpenCLAdapter implements MandelBrot{ - final int MAX_ITERATIONS = 64; - - final int pallette[] = new int[] { - -65536, - -59392, - -53248, - -112640, - -106752, - -166144, - -160256, - -219904, - -279552, - -339200, - -399104, - -985344, - -2624000, - -4197376, - -5770496, - -7343872, - -8851712, - -10425088, - -11932928, - -13375232, - -14817792, - -16260096, - -16719602, - -16720349, - -16721097, - -16721846, - -16722595, - -16723345, - -16724351, - -16725102, - -16726110, - -16727119, - -16728129, - -16733509, - -16738889, - -16744269, - -16749138, - -16754006, - -16758619, - -16762976, - -16767077, - -16771178, - -16774767, - -16514932, - -15662970, - -14942079, - -14221189, - -13631371, - -13107088, - -12648342, - -12320669, - -11992995, - -11796393, - -11665328, - -11993019, - -12386248, - -12845011, - -13303773, - -13762534, - -14286830, - -14745588, - -15269881, - -15728637, - -16252927, - 0 - }; - - @Override public MandelBrot createMandleBrot(final Range range, final float scale, final float offsetx, final float offsety, - final int[] rgb) { - - final int width = range.getGlobalSize(0); - final int height = range.getGlobalSize(1); - final int threadCount = 8; - Thread[] threads = new Thread[threadCount]; - final CyclicBarrier barrier = new CyclicBarrier(threadCount + 1); - for (int thread = 0; thread < threadCount; thread++) { - final int threadId = thread; - final int groupHeight = height / threadCount; - (threads[threadId] = new Thread(new Runnable(){ - public void run() { - for (int gridy = threadId * groupHeight; gridy < (threadId + 1) * groupHeight; gridy++) { - for (int gridx = 0; gridx < width; gridx++) { - float x = ((((float) (gridx) * scale) - ((scale / 2.0f) * (float) width)) / (float) width) + offsetx; - float y = ((((float) (gridy) * scale) - ((scale / 2.0f) * (float) height)) / (float) height) + offsety; - int count = 0; - float zx = x; - float zy = y; - float new_zx = 0.0f; - for (; count < MAX_ITERATIONS && ((zx * zx) + (zy * zy)) < 8.0f; count++) { - new_zx = ((zx * zx) - (zy * zy)) + x; - zy = ((2.0f * zx) * zy) + y; - zx = new_zx; - } - rgb[gridx + gridy * width] = pallette[count]; - } - } - try { - barrier.await(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (BrokenBarrierException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - })).start(); - } - try { - barrier.await(); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (BrokenBarrierException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return (this); - } - -} - -public class MandelExample{ - - /** User selected zoom-in point on the Mandelbrot view. */ - public static volatile Point to = null; - - public static MandelBrot mandelBrot = null; - - public static MandelBrot gpuMandelBrot = null; - - public static MandelBrot javaMandelBrot = null; - - public static MandelBrot javaMandelBrotMultiThread = null; - - // new JavaMandelBrot(); - //new JavaMandelBrotMultiThread(); - @SuppressWarnings("serial") public static void main(String[] _args) { - - JFrame frame = new JFrame("MandelBrot"); - - /** Width of Mandelbrot view. */ - final int width = 768; - - /** Height of Mandelbrot view. */ - final int height = 768; - - /** Mandelbrot image height. */ - - /** Image for Mandelbrot view. */ - final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - - final Object framePaintedDoorBell = new Object(); - JComponent viewer = new JComponent(){ - @Override public void paintComponent(Graphics g) { - - g.drawImage(image, 0, 0, width, height, this); - synchronized (framePaintedDoorBell) { - framePaintedDoorBell.notify(); - } - } - }; - - // Set the size of JComponent which displays Mandelbrot image - viewer.setPreferredSize(new Dimension(width, height)); - - final Object userClickDoorBell = new Object(); - - // Mouse listener which reads the user clicked zoom-in point on the Mandelbrot view - viewer.addMouseListener(new MouseAdapter(){ - @Override public void mouseClicked(MouseEvent e) { - to = e.getPoint(); - synchronized (userClickDoorBell) { - userClickDoorBell.notify(); - } - } - }); - - JPanel controlPanel = new JPanel(new FlowLayout()); - - final String[] choices = new String[] { - "Java Sequential", - "Java Threads", - "GPU OpenCL" - }; - - final JComboBox startButton = new JComboBox(choices); - - startButton.addItemListener(new ItemListener(){ - @Override public void itemStateChanged(ItemEvent e) { - String item = (String) startButton.getSelectedItem(); - - if (item.equals(choices[2])) { - mandelBrot = gpuMandelBrot; - } else if (item.equals(choices[0])) { - mandelBrot = javaMandelBrot; - } else if (item.equals(choices[1])) { - mandelBrot = javaMandelBrotMultiThread; - } - } - - }); - controlPanel.add(startButton); - - controlPanel.add(new JLabel("FPS")); - final JTextField framesPerSecondTextField = new JTextField("0", 5); - - controlPanel.add(framesPerSecondTextField); - - // Swing housework to create the frame - frame.getContentPane().add(viewer); - frame.getContentPane().add(controlPanel, BorderLayout.SOUTH); - frame.pack(); - frame.setLocationRelativeTo(null); - frame.setVisible(true); - - // Extract the underlying RGB buffer from the image. - // Pass this to the kernel so it operates directly on the RGB buffer of the image - - final int[] imageRgb = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); - - /** Mutable values of scale, offsetx and offsety so that we can modify the zoom level and position of a view. */ - float scale = .0f; - - float offsetx = .0f; - - float offsety = .0f; - //Device device = Device.firstGPU(); - Device device = null; - /* - device = OpenCLDevice.select(new OpenCLDevice.DeviceSelector(){ - @Override public OpenCLDevice select(OpenCLDevice device) { - return((device.getType()==Device.TYPE.GPU - // && device.getPlatform().getVendor().equals("NVIDIA Corporation") - && device.getPlatform().getVendor().equals("Advanced Micro Devices, Inc.") - )?device:null); - }}); - */ - for (OpenCLPlatform p : OpenCLPlatform.getPlatforms()) { - // if (p.getVendor().equals("NVIDIA Corporation")){ - if (p.getVendor().equals("Advanced Micro Devices, Inc.")) { - for (OpenCLDevice d : p.getDevices()) { - if (d.getType().equals(Device.TYPE.GPU)) { - device = d; - break; - } - } - } - } - - if (device instanceof OpenCLDevice) { - OpenCLDevice openclDevice = (OpenCLDevice) device; - - System.out.println("max memory = " + openclDevice.getGlobalMemSize()); - System.out.println("max mem alloc size = " + openclDevice.getMaxMemAllocSize()); - gpuMandelBrot = openclDevice.bind(MandelBrot.class); - } - - javaMandelBrot = new JavaMandelBrot(); - javaMandelBrotMultiThread = new JavaMandelBrotMultiThread(); - mandelBrot = javaMandelBrot; - float defaultScale = 3f; - scale = defaultScale; - offsetx = -1f; - offsety = 0f; - final Range range = device.createRange2D(width, height); - mandelBrot.createMandleBrot(range, scale, offsetx, offsety, imageRgb); - viewer.repaint(); - - // Window listener to dispose Kernel resources on user exit. - frame.addWindowListener(new WindowAdapter(){ - public void windowClosing(WindowEvent _windowEvent) { - // mandelBrot.dispose(); - System.exit(0); - } - }); - - while (true) { - // Wait for the user to click somewhere - while (to == null) { - synchronized (userClickDoorBell) { - try { - userClickDoorBell.wait(); - } catch (InterruptedException ie) { - ie.getStackTrace(); - } - } - } - - float x = -1f; - float y = 0f; - float tox = (float) (to.x - width / 2) / width * scale; - float toy = (float) (to.y - height / 2) / height * scale; - - // This is how many frames we will display as we zoom in and out. - int frames = 128; - long startMillis = System.currentTimeMillis(); - int frameCount = 0; - for (int sign = -1; sign < 2; sign += 2) { - for (int i = 0; i < frames - 4; i++) { - scale = scale + sign * defaultScale / frames; - x = x - sign * (tox / frames); - y = y - sign * (toy / frames); - offsetx = x; - offsety = y; - mandelBrot.createMandleBrot(range, scale, offsetx, offsety, imageRgb); - viewer.repaint(); - synchronized (framePaintedDoorBell) { - try { - framePaintedDoorBell.wait(); - } catch (InterruptedException ie) { - ie.getStackTrace(); - } - } - frameCount++; - long endMillis = System.currentTimeMillis(); - long elapsedMillis = endMillis - startMillis; - if (elapsedMillis > 1000) { - framesPerSecondTextField.setText("" + frameCount * 1000 / elapsedMillis); - frameCount = 0; - startMillis = endMillis; - } - } - } - - // Reset zoom-in point. - to = null; - - } - - } - -} diff --git a/samples/extension/src/com/amd/aparapi/sample/extension/MandelSimple.java b/samples/extension/src/com/amd/aparapi/sample/extension/MandelSimple.java deleted file mode 100644 index 8d62ed9b..00000000 --- a/samples/extension/src/com/amd/aparapi/sample/extension/MandelSimple.java +++ /dev/null @@ -1,239 +0,0 @@ -/* -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.amd.aparapi.sample.extension; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Graphics; -import java.awt.Point; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.image.BufferedImage; -import java.awt.image.DataBufferInt; - -import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JTextField; - -import com.amd.aparapi.Device; -import com.amd.aparapi.OpenCL; -import com.amd.aparapi.OpenCLDevice; -import com.amd.aparapi.Range; - -/** - * An example Aparapi application which displays a view of the Mandelbrot set and lets the user zoom in to a particular point. - * - * When the user clicks on the view, this example application will zoom in to the clicked point and zoom out there after. - * On GPU, additional computing units will offer a better viewing experience. On the other hand on CPU, this example - * application might suffer with sub-optimal frame refresh rate as compared to GPU. - * - * @author gfrost - * - */ - -@OpenCL.Resource("com/amd/aparapi/sample/extension/mandel2.cl") interface Mandel extends OpenCL{ - Mandel createMandleBrot(// - Range range,// - @Arg("scale") float scale, // - @Arg("offsetx") float offsetx, // - @Arg("offsety") float offsety, // - @GlobalWriteOnly("rgb") int[] rgb - - ); -} - -public class MandelSimple{ - - /** User selected zoom-in point on the Mandelbrot view. */ - public static volatile Point to = null; - - public static Mandel mandelBrot = null; - - @SuppressWarnings("serial") public static void main(String[] _args) { - - JFrame frame = new JFrame("MandelBrot"); - - /** Width of Mandelbrot view. */ - final int width = 768; - - /** Height of Mandelbrot view. */ - final int height = 768; - - /** Mandelbrot image height. */ - - /** Image for Mandelbrot view. */ - final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - - final Object framePaintedDoorBell = new Object(); - JComponent viewer = new JComponent(){ - @Override public void paintComponent(Graphics g) { - - g.drawImage(image, 0, 0, width, height, this); - synchronized (framePaintedDoorBell) { - framePaintedDoorBell.notify(); - } - } - }; - - // Set the size of JComponent which displays Mandelbrot image - viewer.setPreferredSize(new Dimension(width, height)); - - final Object userClickDoorBell = new Object(); - - // Mouse listener which reads the user clicked zoom-in point on the Mandelbrot view - viewer.addMouseListener(new MouseAdapter(){ - @Override public void mouseClicked(MouseEvent e) { - to = e.getPoint(); - synchronized (userClickDoorBell) { - userClickDoorBell.notify(); - } - } - }); - - JPanel controlPanel = new JPanel(new FlowLayout()); - - controlPanel.add(new JLabel("FPS")); - final JTextField framesPerSecondTextField = new JTextField("0", 5); - - controlPanel.add(framesPerSecondTextField); - - // Swing housework to create the frame - frame.getContentPane().add(viewer); - frame.getContentPane().add(controlPanel, BorderLayout.SOUTH); - frame.pack(); - frame.setLocationRelativeTo(null); - frame.setVisible(true); - - // Extract the underlying RGB buffer from the image. - // Pass this to the kernel so it operates directly on the RGB buffer of the image - - final int[] imageRgb = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); - - /** Mutable values of scale, offsetx and offsety so that we can modify the zoom level and position of a view. */ - float scale = .0f; - - float offsetx = .0f; - - float offsety = .0f; - Device device = Device.best(); - if (device instanceof OpenCLDevice) { - OpenCLDevice openclDevice = (OpenCLDevice) device; - - System.out.println("max memory = " + openclDevice.getGlobalMemSize()); - System.out.println("max mem alloc size = " + openclDevice.getMaxMemAllocSize()); - mandelBrot = openclDevice.bind(Mandel.class); - - float defaultScale = 3f; - scale = defaultScale; - offsetx = -1f; - offsety = 0f; - final Range range = device.createRange2D(width, height); - mandelBrot.createMandleBrot(range, scale, offsetx, offsety, imageRgb); - viewer.repaint(); - - // Window listener to dispose Kernel resources on user exit. - frame.addWindowListener(new WindowAdapter(){ - public void windowClosing(WindowEvent _windowEvent) { - // mandelBrot.dispose(); - System.exit(0); - } - }); - - while (true) { - // Wait for the user to click somewhere - while (to == null) { - synchronized (userClickDoorBell) { - try { - userClickDoorBell.wait(); - } catch (InterruptedException ie) { - ie.getStackTrace(); - } - } - } - - float x = -1f; - float y = 0f; - float tox = (float) (to.x - width / 2) / width * scale; - float toy = (float) (to.y - height / 2) / height * scale; - - // This is how many frames we will display as we zoom in and out. - int frames = 128; - long startMillis = System.currentTimeMillis(); - int frameCount = 0; - for (int sign = -1; sign < 2; sign += 2) { - for (int i = 0; i < frames - 4; i++) { - scale = scale + sign * defaultScale / frames; - x = x - sign * (tox / frames); - y = y - sign * (toy / frames); - offsetx = x; - offsety = y; - mandelBrot.createMandleBrot(range, scale, offsetx, offsety, imageRgb); - viewer.repaint(); - synchronized (framePaintedDoorBell) { - try { - framePaintedDoorBell.wait(); - } catch (InterruptedException ie) { - ie.getStackTrace(); - } - } - frameCount++; - long endMillis = System.currentTimeMillis(); - long elapsedMillis = endMillis - startMillis; - if (elapsedMillis > 1000) { - framesPerSecondTextField.setText("" + frameCount * 1000 / elapsedMillis); - frameCount = 0; - startMillis = endMillis; - } - } - } - - // Reset zoom-in point. - to = null; - - } - } - - } - -} diff --git a/samples/extension/src/com/amd/aparapi/sample/extension/Pow4Example.java b/samples/extension/src/com/amd/aparapi/sample/extension/Pow4Example.java deleted file mode 100644 index 9dde2495..00000000 --- a/samples/extension/src/com/amd/aparapi/sample/extension/Pow4Example.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.amd.aparapi.sample.extension; - -import com.amd.aparapi.Device; -import com.amd.aparapi.OpenCL; -import com.amd.aparapi.OpenCLDevice; -import com.amd.aparapi.Range; - -public class Pow4Example{ - - @OpenCL.Resource("com/amd/aparapi/sample/extension/squarer.cl") interface Squarer extends OpenCL{ - - public Squarer square(// - Range _range,// - @GlobalReadWrite("in") float[] in,// - @GlobalReadWrite("out") float[] out); - } - - public static void main(String[] args) { - - int size = 32; - float[] in = new float[size]; - for (int i = 0; i < size; i++) { - in[i] = i; - } - float[] squares = new float[size]; - Range range = Range.create(size); - - Device device = Device.best(); - - if (device instanceof OpenCLDevice) { - OpenCLDevice openclDevice = (OpenCLDevice) device; - - Squarer squarer = openclDevice.bind(Squarer.class); - squarer.square(range, in, squares); - - for (int i = 0; i < size; i++) { - System.out.println(in[i] + " " + squares[i]); - } - - squarer.square(range, squares, in); - - for (int i = 0; i < size; i++) { - System.out.println(i + " " + squares[i] + " " + in[i]); - } - } - } - -} diff --git a/samples/extension/src/com/amd/aparapi/sample/extension/SquareExample.java b/samples/extension/src/com/amd/aparapi/sample/extension/SquareExample.java deleted file mode 100644 index caed746e..00000000 --- a/samples/extension/src/com/amd/aparapi/sample/extension/SquareExample.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.amd.aparapi.sample.extension; - -import com.amd.aparapi.Device; -import com.amd.aparapi.OpenCL; -import com.amd.aparapi.OpenCLDevice; -import com.amd.aparapi.Range; - -public class SquareExample{ - - interface Squarer extends OpenCL{ - @Kernel("{\n"// - + " const size_t id = get_global_id(0);\n"// - + " out[id] = in[id]*in[id];\n"// - + "}\n")// - public Squarer square(// - Range _range,// - @GlobalReadWrite("in") float[] in,// - @GlobalReadWrite("out") float[] out); - } - - @OpenCL.Resource("com/amd/aparapi/sample/extension/squarer.cl") interface SquarerWithResource extends - OpenCL{ - - public SquarerWithResource square(// - Range _range,// - @GlobalReadWrite("in") float[] in,// - @GlobalReadWrite("out") float[] out); - } - - @OpenCL.Source("\n"// - + "__kernel void square (\n" // - + " __global float *in,\n"// - + " __global float *out\n" + "){\n"// - + " const size_t id = get_global_id(0);\n"// - + " out[id] = in[id]*in[id];\n"// - + "}\n") interface SquarerWithSource extends OpenCL{ - - public SquarerWithSource square(// - Range _range,// - @GlobalReadOnly("in") float[] in,// - @GlobalWriteOnly("out") float[] out); - } - - public static void main(String[] args) { - - int size = 32; - float[] in = new float[size]; - for (int i = 0; i < size; i++) { - in[i] = i; - } - float[] squares = new float[size]; - float[] quads = new float[size]; - Range range = Range.create(size); - - Device device = Device.best(); - - if (device instanceof OpenCLDevice) { - OpenCLDevice openclDevice = (OpenCLDevice) device; - - SquarerWithResource squarer = openclDevice.bind(SquarerWithResource.class); - squarer.square(range, in, squares); - - for (int i = 0; i < size; i++) { - System.out.println(in[i] + " " + squares[i]); - } - - squarer.square(range, squares, quads); - - for (int i = 0; i < size; i++) { - System.out.println(in[i] + " " + squares[i] + " " + quads[i]); - } - } - } - -} diff --git a/samples/extension/src/com/amd/aparapi/sample/extension/StopWatch.java b/samples/extension/src/com/amd/aparapi/sample/extension/StopWatch.java deleted file mode 100644 index 4d1db1cb..00000000 --- a/samples/extension/src/com/amd/aparapi/sample/extension/StopWatch.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.amd.aparapi.sample.extension; - -public class StopWatch{ - long start=0L; - public void start() { - start = System.nanoTime(); - } - public void print(String _str) { - long end = (System.nanoTime()-start)/1000000; - System.out.println(_str+" "+end); - } - -} diff --git a/samples/extension/src/com/amd/aparapi/sample/extension/SwapExample.java b/samples/extension/src/com/amd/aparapi/sample/extension/SwapExample.java deleted file mode 100644 index 453c2892..00000000 --- a/samples/extension/src/com/amd/aparapi/sample/extension/SwapExample.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.amd.aparapi.sample.extension; - -import com.amd.aparapi.Device; -import com.amd.aparapi.OpenCL; -import com.amd.aparapi.OpenCLDevice; -import com.amd.aparapi.Range; - -public class SwapExample{ - - interface Swapper extends OpenCL{ - @Kernel("{\n"// - + " const size_t id = get_global_id(0);\n"// - + " float temp=lhs[id];" + " lhs[id] = rhs[id];\n"// - + " rhs[id] = temp;\n"// - + "}\n")// - public Swapper swap(// - Range _range,// - @GlobalReadWrite("lhs") float[] lhs,// - @GlobalReadWrite("rhs") float[] rhs); - } - - public static void main(String[] args) { - - int size = 32; - float[] lhs = new float[size]; - for (int i = 0; i < size; i++) { - lhs[i] = i; - } - float[] rhs = new float[size]; - Range range = Range.create(size); - - Device device = Device.best(); - - if (device instanceof OpenCLDevice) { - OpenCLDevice openclDevice = (OpenCLDevice) device; - - Swapper swapper = openclDevice.bind(Swapper.class); - for (int i = 0; i < size; i++) { - System.out.println(lhs[i] + " " + rhs[i]); - } - - swapper.swap(range, lhs, rhs); - - for (int i = 0; i < size; i++) { - System.out.println(lhs[i] + " " + rhs[i]); - } - - swapper.swap(range, lhs, rhs); - - for (int i = 0; i < size; i++) { - System.out.println(lhs[i] + " " + rhs[i]); - } - - swapper.swap(range, rhs, lhs); - - for (int i = 0; i < size; i++) { - System.out.println(lhs[i] + " " + rhs[i]); - } - - } - } - -} diff --git a/samples/extension/src/com/amd/aparapi/sample/extension/fft.cl b/samples/extension/src/com/amd/aparapi/sample/extension/fft.cl deleted file mode 100644 index f4085983..00000000 --- a/samples/extension/src/com/amd/aparapi/sample/extension/fft.cl +++ /dev/null @@ -1,737 +0,0 @@ -/* ============================================================ - -Copyright (c) 2009-2010 Advanced Micro Devices, Inc. All rights reserved. - -Redistribution and use of this material is permitted under the following -conditions: - -Redistributions must retain the above copyright notice and all terms of this -license. - -In no event shall anyone redistributing or accessing or using this material -commence or participate in any arbitration or legal action relating to this -material against Advanced Micro Devices, Inc. or any copyright holders or -contributors. The foregoing shall survive any expiration or termination of -this license or any agreement or access or use related to this material. - -ANY BREACH OF ANY TERM OF THIS LICENSE SHALL RESULT IN THE IMMEDIATE REVOCATION -OF ALL RIGHTS TO REDISTRIBUTE, ACCESS OR USE THIS MATERIAL. - -THIS MATERIAL IS PROVIDED BY ADVANCED MICRO DEVICES, INC. AND ANY COPYRIGHT -HOLDERS AND CONTRIBUTORS "AS IS" IN ITS CURRENT CONDITION AND WITHOUT ANY -REPRESENTATIONS, GUARANTEE, OR WARRANTY OF ANY KIND OR IN ANY WAY RELATED TO -SUPPORT, INDEMNITY, ERROR FREE OR UNINTERRUPTED OPERA TION, OR THAT IT IS FREE -FROM DEFECTS OR VIRUSES. ALL OBLIGATIONS ARE HEREBY DISCLAIMED - WHETHER -EXPRESS, IMPLIED, OR STATUTORY - INCLUDING, BUT NOT LIMITED TO, ANY IMPLIED -WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, -ACCURACY, COMPLETENESS, OPERABILITY, QUALITY OF SERVICE, OR NON-INFRINGEMENT. -IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. OR ANY COPYRIGHT HOLDERS OR -CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, REVENUE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED OR BASED ON ANY THEORY OF LIABILITY -ARISING IN ANY WAY RELATED TO THIS MATERIAL, EVEN IF ADVISED OF THE POSSIBILITY -OF SUCH DAMAGE. THE ENTIRE AND AGGREGATE LIABILITY OF ADVANCED MICRO DEVICES, -INC. AND ANY COPYRIGHT HOLDERS AND CONTRIBUTORS SHALL NOT EXCEED TEN DOLLARS -(US $10.00). ANYONE REDISTRIBUTING OR ACCESSING OR USING THIS MATERIAL ACCEPTS -THIS ALLOCATION OF RISK AND AGREES TO RELEASE ADVANCED MICRO DEVICES, INC. AND -ANY COPYRIGHT HOLDERS AND CONTRIBUTORS FROM ANY AND ALL LIABILITIES, -OBLIGATIONS, CLAIMS, OR DEMANDS IN EXCESS OF TEN DOLLARS (US $10.00). THE -FOREGOING ARE ESSENTIAL TERMS OF THIS LICENSE AND, IF ANY OF THESE TERMS ARE -CONSTRUED AS UNENFORCEABLE, FAIL IN ESSENTIAL PURPOSE, OR BECOME VOID OR -DETRIMENTAL TO ADVANCED MICRO DEVICES, INC. OR ANY COPYRIGHT HOLDERS OR -CONTRIBUTORS FOR ANY REASON, THEN ALL RIGHTS TO REDISTRIBUTE, ACCESS OR USE -THIS MATERIAL SHALL TERMINATE IMMEDIATELY. MOREOVER, THE FOREGOING SHALL -SURVIVE ANY EXPIRATION OR TERMINATION OF THIS LICENSE OR ANY AGREEMENT OR -ACCESS OR USE RELATED TO THIS MATERIAL. - -NOTICE IS HEREBY PROVIDED, AND BY REDISTRIBUTING OR ACCESSING OR USING THIS -MATERIAL SUCH NOTICE IS ACKNOWLEDGED, THAT THIS MATERIAL MAY BE SUBJECT TO -RESTRICTIONS UNDER THE LAWS AND REGULATIONS OF THE UNITED STATES OR OTHER -COUNTRIES, WHICH INCLUDE BUT ARE NOT LIMITED TO, U.S. EXPORT CONTROL LAWS SUCH -AS THE EXPORT ADMINISTRATION REGULATIONS AND NATIONAL SECURITY CONTROLS AS -DEFINED THEREUNDER, AS WELL AS STATE DEPARTMENT CONTROLS UNDER THE U.S. -MUNITIONS LIST. THIS MATERIAL MAY NOT BE USED, RELEASED, TRANSFERRED, IMPORTED, -EXPORTED AND/OR RE-EXPORTED IN ANY MANNER PROHIBITED UNDER ANY APPLICABLE LAWS, -INCLUDING U.S. EXPORT CONTROL LAWS REGARDING SPECIFICALLY DESIGNATED PERSONS, -COUNTRIES AND NATIONALS OF COUNTRIES SUBJECT TO NATIONAL SECURITY CONTROLS. -MOREOVER, THE FOREGOING SHALL SURVIVE ANY EXPIRATION OR TERMINATION OF ANY -LICENSE OR AGREEMENT OR ACCESS OR USE RELATED TO THIS MATERIAL. - -NOTICE REGARDING THE U.S. GOVERNMENT AND DOD AGENCIES: This material is -provided with "RESTRICTED RIGHTS" and/or "LIMITED RIGHTS" as applicable to -computer software and technical data, respectively. Use, duplication, -distribution or disclosure by the U.S. Government and/or DOD agencies is -subject to the full extent of restrictions in all applicable regulations, -including those found at FAR52.227 and DFARS252.227 et seq. and any successor -regulations thereof. Use of this material by the U.S. Government and/or DOD -agencies is acknowledgment of the proprietary rights of any copyright holders -and contributors, including those of Advanced Micro Devices, Inc., as well as -the provisions of FAR52.227-14 through 23 regarding privately developed and/or -commercial computer software. - -This license forms the entire agreement regarding the subject matter hereof and -supersedes all proposals and prior discussions and writings between the parties -with respect thereto. This license does not affect any ownership, rights, title, -or interest in, or relating to, this material. No terms of this license can be -modified or waived, and no breach of this license can be excused, unless done -so in a writing signed by all affected parties. Each term of this license is -separately enforceable. If any term of this license is determined to be or -becomes unenforceable or illegal, such term shall be reformed to the minimum -extent necessary in order for this license to remain in effect in accordance -with its terms as modified by such reformation. This license shall be governed -by and construed in accordance with the laws of the State of Texas without -regard to rules on conflicts of law of any state or jurisdiction or the United -Nations Convention on the International Sale of Goods. All disputes arising out -of this license shall be subject to the jurisdiction of the federal and state -courts in Austin, Texas, and all defenses are hereby waived concerning personal -jurisdiction and venue of these courts. - -============================================================ */ - - -// This is 2 PI / 1024 -#define ANGLE 0x1.921fb6p-8F - -// Return sin and cos of -2*pi*i/1024 -__attribute__((always_inline)) float -k_sincos(int i, float *cretp) -{ - if (i > 512) - i -= 1024; - - float x = i * -ANGLE; - *cretp = native_cos(x); - return native_sin(x); -} - -__attribute__((always_inline)) float4 -k_sincos4(int4 i, float4 *cretp) -{ - i -= (i > 512) & 1024; - float4 x = convert_float4(i) * -ANGLE; - *cretp = native_cos(x); - return native_sin(x); -} - -// Twiddle factor stuff -#define TWGEN(I,C,S) \ - float C; \ - float S = k_sincos(tbase * I, &C) - -#define TW4GEN(I,C,S) \ - float4 C; \ - float4 S = k_sincos4(tbase * I, &C) - -#define TWAPPLY(ZR, ZI, C, S) \ - do { \ - float4 __r = C * ZR - S * ZI; \ - ZI = C * ZI + S * ZR; \ - ZR = __r; \ - } while (0) - -# define TW4IDDLE4() \ - do { \ - TW4GEN(1, c1, s1); \ - TWAPPLY(zr1, zi1, c1, s1); \ - TW4GEN(2, c2, s2); \ - TWAPPLY(zr2, zi2, c2, s2); \ - TW4GEN(3, c3, s3); \ - TWAPPLY(zr3, zi3, c3, s3); \ - } while (0) - -# define TWIDDLE4() \ - do { \ - TWGEN(1, c1, s1); \ - TWAPPLY(zr1, zi1, c1, s1); \ - TWGEN(2, c2, s2); \ - TWAPPLY(zr2, zi2, c2, s2); \ - TWGEN(3, c3, s3); \ - TWAPPLY(zr3, zi3, c3, s3); \ - } while (0) - -// 4 point FFT -#define FFT4() \ - do { \ - float4 ar0 = zr0 + zr2; \ - float4 ar2 = zr1 + zr3; \ - float4 br0 = ar0 + ar2; \ - float4 br1 = zr0 - zr2; \ - float4 br2 = ar0 - ar2; \ - float4 br3 = zr1 - zr3; \ - float4 ai0 = zi0 + zi2; \ - float4 ai2 = zi1 + zi3; \ - float4 bi0 = ai0 + ai2; \ - float4 bi1 = zi0 - zi2; \ - float4 bi2 = ai0 - ai2; \ - float4 bi3 = zi1 - zi3; \ - zr0 = br0; \ - zi0 = bi0; \ - zr1 = br1 + bi3; \ - zi1 = bi1 - br3; \ - zr3 = br1 - bi3; \ - zi3 = br3 + bi1; \ - zr2 = br2; \ - zi2 = bi2; \ - } while (0) - -// First pass of 1K FFT -__attribute__((always_inline)) void -kfft_pass1(uint me, - const __global float *gr, const __global float *gi, - __local float *lds) -{ - const __global float4 *gp; - __local float *lp; - - // Pull in transform data - gp = (const __global float4 *)(gr + (me << 2)); - float4 zr0 = gp[0*64]; - float4 zr1 = gp[1*64]; - float4 zr2 = gp[2*64]; - float4 zr3 = gp[3*64]; - - gp = (const __global float4 *)(gi + (me << 2)); - float4 zi0 = gp[0*64]; - float4 zi1 = gp[1*64]; - float4 zi2 = gp[2*64]; - float4 zi3 = gp[3*64]; - - FFT4(); - - int4 tbase = (int)(me << 2) + (int4)(0, 1, 2, 3); - TW4IDDLE4(); - - // Save registers - // Note that this pointer is not aligned enough to be cast to a float4* - lp = lds + ((me << 2) + (me >> 3)); - - lp[0] = zr0.x; - lp[1] = zr0.y; - lp[2] = zr0.z; - lp[3] = zr0.w; - lp += 66*4; - - lp[0] = zr1.x; - lp[1] = zr1.y; - lp[2] = zr1.z; - lp[3] = zr1.w; - lp += 66*4; - - lp[0] = zr2.x; - lp[1] = zr2.y; - lp[2] = zr2.z; - lp[3] = zr2.w; - lp += 66*4; - - lp[0] = zr3.x; - lp[1] = zr3.y; - lp[2] = zr3.z; - lp[3] = zr3.w; - lp += 66*4; - - // Imaginary part - lp[0] = zi0.x; - lp[1] = zi0.y; - lp[2] = zi0.z; - lp[3] = zi0.w; - lp += 66*4; - - lp[0] = zi1.x; - lp[1] = zi1.y; - lp[2] = zi1.z; - lp[3] = zi1.w; - lp += 66*4; - - lp[0] = zi2.x; - lp[1] = zi2.y; - lp[2] = zi2.z; - lp[3] = zi2.w; - lp += 66*4; - - lp[0] = zi3.x; - lp[1] = zi3.y; - lp[2] = zi3.z; - lp[3] = zi3.w; - - barrier(CLK_LOCAL_MEM_FENCE); -} - -// Second pass of 1K FFT -__attribute__((always_inline)) void -kfft_pass2(uint me, __local float *lds) -{ - __local float *lp; - - // Load registers - lp = lds + (me + (me >> 5)); - - float4 zr0, zr1, zr2, zr3; - - zr0.x = lp[0*66]; - zr1.x = lp[1*66]; - zr2.x = lp[2*66]; - zr3.x = lp[3*66]; - lp += 66*4; - - zr0.y = lp[0*66]; - zr1.y = lp[1*66]; - zr2.y = lp[2*66]; - zr3.y = lp[3*66]; - lp += 66*4; - - zr0.z = lp[0*66]; - zr1.z = lp[1*66]; - zr2.z = lp[2*66]; - zr3.z = lp[3*66]; - lp += 66*4; - - zr0.w = lp[0*66]; - zr1.w = lp[1*66]; - zr2.w = lp[2*66]; - zr3.w = lp[3*66]; - lp += 66*4; - - float4 zi0, zi1, zi2, zi3; - - zi0.x = lp[0*66]; - zi1.x = lp[1*66]; - zi2.x = lp[2*66]; - zi3.x = lp[3*66]; - lp += 66*4; - - zi0.y = lp[0*66]; - zi1.y = lp[1*66]; - zi2.y = lp[2*66]; - zi3.y = lp[3*66]; - lp += 66*4; - - zi0.z = lp[0*66]; - zi1.z = lp[1*66]; - zi2.z = lp[2*66]; - zi3.z = lp[3*66]; - lp += 66*4; - - zi0.w = lp[0*66]; - zi1.w = lp[1*66]; - zi2.w = lp[2*66]; - zi3.w = lp[3*66]; - - // Transform and twiddle - FFT4(); - - int tbase = (int)(me << 2); - TWIDDLE4(); - - barrier(CLK_LOCAL_MEM_FENCE); - - // Store registers - lp = lds + ((me << 2) + (me >> 3)); - - lp[0] = zr0.x; - lp[1] = zr1.x; - lp[2] = zr2.x; - lp[3] = zr3.x; - lp += 66*4; - - lp[0] = zr0.y; - lp[1] = zr1.y; - lp[2] = zr2.y; - lp[3] = zr3.y; - lp += 66*4; - - lp[0] = zr0.z; - lp[1] = zr1.z; - lp[2] = zr2.z; - lp[3] = zr3.z; - lp += 66*4; - - lp[0] = zr0.w; - lp[1] = zr1.w; - lp[2] = zr2.w; - lp[3] = zr3.w; - lp += 66*4; - - // Imaginary part - lp[0] = zi0.x; - lp[1] = zi1.x; - lp[2] = zi2.x; - lp[3] = zi3.x; - lp += 66*4; - - lp[0] = zi0.y; - lp[1] = zi1.y; - lp[2] = zi2.y; - lp[3] = zi3.y; - lp += 66*4; - - lp[0] = zi0.z; - lp[1] = zi1.z; - lp[2] = zi2.z; - lp[3] = zi3.z; - lp += 66*4; - - lp[0] = zi0.w; - lp[1] = zi1.w; - lp[2] = zi2.w; - lp[3] = zi3.w; - - barrier(CLK_LOCAL_MEM_FENCE); -} - -// Third pass of 1K FFT -__attribute__((always_inline)) void -kfft_pass3(uint me, __local float *lds) -{ - __local float *lp; - - // Load registers - lp = lds + (me + (me >> 5)); - - float4 zr0, zr1, zr2, zr3; - - zr0.x = lp[0*66]; - zr1.x = lp[1*66]; - zr2.x = lp[2*66]; - zr3.x = lp[3*66]; - lp += 66*4; - - zr0.y = lp[0*66]; - zr1.y = lp[1*66]; - zr2.y = lp[2*66]; - zr3.y = lp[3*66]; - lp += 66*4; - - zr0.z = lp[0*66]; - zr1.z = lp[1*66]; - zr2.z = lp[2*66]; - zr3.z = lp[3*66]; - lp += 66*4; - - zr0.w = lp[0*66]; - zr1.w = lp[1*66]; - zr2.w = lp[2*66]; - zr3.w = lp[3*66]; - lp += 66*4; - - float4 zi0, zi1, zi2, zi3; - - zi0.x = lp[0*66]; - zi1.x = lp[1*66]; - zi2.x = lp[2*66]; - zi3.x = lp[3*66]; - lp += 66*4; - - zi0.y = lp[0*66]; - zi1.y = lp[1*66]; - zi2.y = lp[2*66]; - zi3.y = lp[3*66]; - lp += 66*4; - - zi0.z = lp[0*66]; - zi1.z = lp[1*66]; - zi2.z = lp[2*66]; - zi3.z = lp[3*66]; - lp += 66*4; - - zi0.w = lp[0*66]; - zi1.w = lp[1*66]; - zi2.w = lp[2*66]; - zi3.w = lp[3*66]; - - // Transform and twiddle - FFT4(); - - int tbase = (int)((me >> 2) << 4); - TWIDDLE4(); - - barrier(CLK_LOCAL_MEM_FENCE); - - // Save registers - lp = lds + me; - - lp[0*66] = zr0.x; - lp[1*66] = zr0.y; - lp[2*66] = zr0.z; - lp[3*66] = zr0.w; - lp += 66*4; - - lp[0*66] = zr1.x; - lp[1*66] = zr1.y; - lp[2*66] = zr1.z; - lp[3*66] = zr1.w; - lp += 66*4; - - lp[0*66] = zr2.x; - lp[1*66] = zr2.y; - lp[2*66] = zr2.z; - lp[3*66] = zr2.w; - lp += 66*4; - - lp[0*66] = zr3.x; - lp[1*66] = zr3.y; - lp[2*66] = zr3.z; - lp[3*66] = zr3.w; - lp += 66*4; - - // Imaginary part - lp[0*66] = zi0.x; - lp[1*66] = zi0.y; - lp[2*66] = zi0.z; - lp[3*66] = zi0.w; - lp += 66*4; - - lp[0*66] = zi1.x; - lp[1*66] = zi1.y; - lp[2*66] = zi1.z; - lp[3*66] = zi1.w; - lp += 66*4; - - lp[0*66] = zi2.x; - lp[1*66] = zi2.y; - lp[2*66] = zi2.z; - lp[3*66] = zi2.w; - lp += 66*4; - - lp[0*66] = zi3.x; - lp[1*66] = zi3.y; - lp[2*66] = zi3.z; - lp[3*66] = zi3.w; - - barrier(CLK_LOCAL_MEM_FENCE); -} - -// Fourth pass of 1K FFT -__attribute__((always_inline)) void -kfft_pass4(uint me, __local float *lds) -{ - __local float *lp; - - // Load registers - lp = lds + ((me & 0x3) + ((me >> 2) & 0x3)*(66*4) + ((me >> 4) << 2)); - - float4 zr0, zr1, zr2, zr3; - - zr0.x = lp[0*66]; - zr0.y = lp[1*66]; - zr0.z = lp[2*66]; - zr0.w = lp[3*66]; - lp += 16; - - zr1.x = lp[0*66]; - zr1.y = lp[1*66]; - zr1.z = lp[2*66]; - zr1.w = lp[3*66]; - lp += 16; - - zr2.x = lp[0*66]; - zr2.y = lp[1*66]; - zr2.z = lp[2*66]; - zr2.w = lp[3*66]; - lp += 16; - - zr3.x = lp[0*66]; - zr3.y = lp[1*66]; - zr3.z = lp[2*66]; - zr3.w = lp[3*66]; - lp += 66*4*4 - 3*16; - - float4 zi0, zi1, zi2, zi3; - - zi0.x = lp[0*66]; - zi0.y = lp[1*66]; - zi0.z = lp[2*66]; - zi0.w = lp[3*66]; - lp += 16; - - zi1.x = lp[0*66]; - zi1.y = lp[1*66]; - zi1.z = lp[2*66]; - zi1.w = lp[3*66]; - lp += 16; - - zi2.x = lp[0*66]; - zi2.y = lp[1*66]; - zi2.z = lp[2*66]; - zi2.w = lp[3*66]; - lp += 16; - - zi3.x = lp[0*66]; - zi3.y = lp[1*66]; - zi3.z = lp[2*66]; - zi3.w = lp[3*66]; - - // Transform and twiddle - FFT4(); - - int tbase = (int)((me >> 4) << 6); - TWIDDLE4(); - - barrier(CLK_LOCAL_MEM_FENCE); - - // Save registers in conflict free manner - lp = lds + me; - - lp[0*68] = zr0.x; - lp[1*68] = zr0.y; - lp[2*68] = zr0.z; - lp[3*68] = zr0.w; - lp += 68*4; - - lp[0*68] = zr1.x; - lp[1*68] = zr1.y; - lp[2*68] = zr1.z; - lp[3*68] = zr1.w; - lp += 68*4; - - lp[0*68] = zr2.x; - lp[1*68] = zr2.y; - lp[2*68] = zr2.z; - lp[3*68] = zr2.w; - lp += 68*4; - - lp[0*68] = zr3.x; - lp[1*68] = zr3.y; - lp[2*68] = zr3.z; - lp[3*68] = zr3.w; - lp += 68*4; - - // Imaginary part - lp[0*68] = zi0.x; - lp[1*68] = zi0.y; - lp[2*68] = zi0.z; - lp[3*68] = zi0.w; - lp += 68*4; - - lp[0*68] = zi1.x; - lp[1*68] = zi1.y; - lp[2*68] = zi1.z; - lp[3*68] = zi1.w; - lp += 68*4; - - lp[0*68] = zi2.x; - lp[1*68] = zi2.y; - lp[2*68] = zi2.z; - lp[3*68] = zi2.w; - lp += 68*4; - - lp[0*68] = zi3.x; - lp[1*68] = zi3.y; - lp[2*68] = zi3.z; - lp[3*68] = zi3.w; - - barrier(CLK_LOCAL_MEM_FENCE); -} - -// Fifth and last pass of 1K FFT -__attribute__((always_inline)) void -kfft_pass5(uint me, - const __local float *lds, - __global float *gr, __global float *gi) -{ - const __local float *lp; - - // Load registers - lp = lds + ((me & 0xf) + (me >> 4)*(68*4)); - - float4 zr0, zr1, zr2, zr3; - - zr0.x = lp[0*68]; - zr0.y = lp[1*68]; - zr0.z = lp[2*68]; - zr0.w = lp[3*68]; - lp += 16; - - zr1.x = lp[0*68]; - zr1.y = lp[1*68]; - zr1.z = lp[2*68]; - zr1.w = lp[3*68]; - lp += 16; - - zr2.x = lp[0*68]; - zr2.y = lp[1*68]; - zr2.z = lp[2*68]; - zr2.w = lp[3*68]; - lp += 16; - - zr3.x = lp[0*68]; - zr3.y = lp[1*68]; - zr3.z = lp[2*68]; - zr3.w = lp[3*68]; - - lp += 68*4*4 - 3*16; - - float4 zi0, zi1, zi2, zi3; - - zi0.x = lp[0*68]; - zi0.y = lp[1*68]; - zi0.z = lp[2*68]; - zi0.w = lp[3*68]; - lp += 16; - - zi1.x = lp[0*68]; - zi1.y = lp[1*68]; - zi1.z = lp[2*68]; - zi1.w = lp[3*68]; - lp += 16; - - zi2.x = lp[0*68]; - zi2.y = lp[1*68]; - zi2.z = lp[2*68]; - zi2.w = lp[3*68]; - lp += 16; - - zi3.x = lp[0*68]; - zi3.y = lp[1*68]; - zi3.z = lp[2*68]; - zi3.w = lp[3*68]; - - // Transform - FFT4(); - - // Save result - __global float4 *gp = (__global float4 *)(gr + (me << 2)); - gp[0*64] = zr0; - gp[1*64] = zr1; - gp[2*64] = zr2; - gp[3*64] = zr3; - - gp = (__global float4 *)(gi + (me << 2)); - gp[0*64] = zi0; - gp[1*64] = zi1; - gp[2*64] = zi2; - gp[3*64] = zi3; -} - -// Distance between first real element of successive 1K vectors -// It must be >= 1024, and a multiple of 4 -#define VSTRIDE (1024+0) - -// Performs a 1K complex FFT with every 64 global ids. -// Each vector is a multiple of VSTRIDE from the first -// Number of global ids must be a multiple of 64, e.g. 1024*64 -// -// greal - pointer to input and output real part of data -// gimag - pointer to input and output imaginary part of data -__kernel void -forward(__global float *greal, __global float *gimag) -{ - // This is 8704 bytes - __local float lds[68*4*4*2]; - - __global float *gr; - __global float *gi; - uint gid = get_global_id(0); - uint me = gid & 0x3fU; - uint dg = (gid >> 6) * VSTRIDE; - - gr = greal + dg; - gi = gimag + dg; - - kfft_pass1(me, gr, gi, lds); - kfft_pass2(me, lds); - kfft_pass3(me, lds); - kfft_pass4(me, lds); - kfft_pass5(me, lds, gr, gi); -} - diff --git a/samples/extension/src/com/amd/aparapi/sample/extension/mandel.cl b/samples/extension/src/com/amd/aparapi/sample/extension/mandel.cl deleted file mode 100644 index b6c1da01..00000000 --- a/samples/extension/src/com/amd/aparapi/sample/extension/mandel.cl +++ /dev/null @@ -1,91 +0,0 @@ -#define MAX_ITERATIONS 64 - -__constant const int pallette[]={ - -65536, - -59392, - -53248, - -112640, - -106752, - -166144, - -160256, - -219904, - -279552, - -339200, - -399104, - -985344, - -2624000, - -4197376, - -5770496, - -7343872, - -8851712, - -10425088, - -11932928, - -13375232, - -14817792, - -16260096, - -16719602, - -16720349, - -16721097, - -16721846, - -16722595, - -16723345, - -16724351, - -16725102, - -16726110, - -16727119, - -16728129, - -16733509, - -16738889, - -16744269, - -16749138, - -16754006, - -16758619, - -16762976, - -16767077, - -16771178, - -16774767, - -16514932, - -15662970, - -14942079, - -14221189, - -13631371, - -13107088, - -12648342, - -12320669, - -11992995, - -11796393, - -11665328, - -11993019, - -12386248, - -12845011, - -13303773, - -13762534, - -14286830, - -14745588, - -15269881, - -15728637, - -16252927, - 0 -}; - -__kernel void createMandleBrot( - float scale, - float offsetx, - float offsety, - __global int *rgb -){ - int gid = get_global_id(0) + get_global_id(1)*get_global_size(0); - float x = ((((float)(get_global_id(0)) * scale) - ((scale / 2.0f) * (float)get_global_size(0))) / (float)get_global_size(0)) + offsetx; - float y = ((((float)(get_global_id(1)) * scale) - ((scale / 2.0f) * (float)get_global_size(1))) / (float)get_global_size(1)) + offsety; - int count = 0; - float zx = x; - float zy = y; - float new_zx = 0.0f; - for (; count - - - - - - - diff --git a/samples/life/.project b/samples/life/.project deleted file mode 100644 index 01f51c90..00000000 --- a/samples/life/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - life - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/samples/life/build.xml b/samples/life/build.xml deleted file mode 100644 index a64631df..00000000 --- a/samples/life/build.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/samples/life/life.bat b/samples/life/life.bat deleted file mode 100644 index f5ae763f..00000000 --- a/samples/life/life.bat +++ /dev/null @@ -1,11 +0,0 @@ -java ^ - -Djava.library.path=../../com.amd.aparapi.jni/dist ^ - -Dsequential=false^ - -Dcom.amd.aparapi.executionMode=%1 ^ - -Dcom.amd.aparapi.enableProfiling=false ^ - -Dcom.amd.aparapi.enableVerboseJNI=false ^ - -Dcom.amd.aparapi.enableShowGeneratedOpenCL=true ^ - -classpath ../../com.amd.aparapi/dist/aparapi.jar;life.jar ^ - com.amd.aparapi.sample.life.Main - - diff --git a/samples/life/life.sh b/samples/life/life.sh deleted file mode 100644 index 9cf1daf1..00000000 --- a/samples/life/life.sh +++ /dev/null @@ -1,5 +0,0 @@ -java\ - -Djava.library.path=../../com.amd.aparapi.jni/dist\ - -Dcom.amd.aparapi.executionMode=$1\ - -classpath ../../com.amd.aparapi/dist/aparapi.jar:life.jar\ - com.amd.aparapi.sample.life.Main diff --git a/samples/life/src/com/amd/aparapi/sample/life/Main.java b/samples/life/src/com/amd/aparapi/sample/life/Main.java deleted file mode 100644 index 58b294c7..00000000 --- a/samples/life/src/com/amd/aparapi/sample/life/Main.java +++ /dev/null @@ -1,281 +0,0 @@ -/* -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.amd.aparapi.sample.life; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Graphics; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.image.BufferedImage; -import java.awt.image.DataBufferInt; -import java.util.List; - -import javax.swing.JButton; -import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.WindowConstants; - -import com.amd.aparapi.Kernel; -import com.amd.aparapi.ProfileInfo; -import com.amd.aparapi.Range; - -/** - * An example Aparapi application which demonstrates Conways 'Game Of Life'. - * - * Original code from Witold Bolt's site https://github.com/houp/aparapi/tree/master/samples/gameoflife. - * - * Converted to use int buffer and some performance tweaks by Gary Frost - * - * @author Wiltold Bolt - * @author Gary Frost - */ -public class Main{ - - /** - * LifeKernel represents the data parallel algorithm describing by Conway's game of life. - * - * http://en.wikipedia.org/wiki/Conway's_Game_of_Life - * - * We examine the state of each pixel and its 8 neighbors and apply the following rules. - * - * if pixel is dead (off) and number of neighbors == 3 { - * pixel is turned on - * } else if pixel is alive (on) and number of neighbors is neither 2 or 3 - * pixel is turned off - * } - * - * We use an image buffer which is 2*width*height the size of screen and we use fromBase and toBase to track which half of the buffer is being mutated for each pass. We basically - * copy from getGlobalId()+fromBase to getGlobalId()+toBase; - * - * - * Prior to each pass the values of fromBase and toBase are swapped. - * - */ - - public static class LifeKernel extends Kernel{ - - private static final int ALIVE = 0xffffff; - - private static final int DEAD = 0; - - private final int[] imageData; - - private final int width; - - private final int height; - - private final Range range; - - private int fromBase; - - private int toBase; - - public LifeKernel(int _width, int _height, BufferedImage _image) { - imageData = ((DataBufferInt) _image.getRaster().getDataBuffer()).getData(); - width = _width; - height = _height; - if (System.getProperty("com.amd.aparapi.executionMode").equals("JTP")){ - range = Range.create(width * height, 4); - }else{ - range = Range.create(width * height); - } - System.out.println("range = " + range); - fromBase = height * width; - toBase = 0; - setExplicit(true); // This gives us a performance boost - - /** draw a line across the image **/ - for (int i = width * (height / 2) + width / 10; i < width * (height / 2 + 1) - width / 10; i++) { - imageData[i] = LifeKernel.ALIVE; - } - - put(imageData); // Because we are using explicit buffer management we must put the imageData array - - } - - public void processPixel(int gid){ - int to = gid + toBase; - int from = gid + fromBase; - int x = gid % width; - int y = gid / width; - - if ((x == 0 || x == width - 1 || y == 0 || y == height - 1)) { - // This pixel is on the border of the view, just keep existing value - imageData[to] = imageData[from]; - } else { - // Count the number of neighbors. We use (value&1x) to turn pixel value into either 0 or 1 - int neighbors = (imageData[from - 1] & 1) + // EAST - (imageData[from + 1] & 1) + // WEST - (imageData[from - width - 1] & 1) + // NORTHEAST - (imageData[from - width] & 1) + // NORTH - (imageData[from - width + 1] & 1) + // NORTHWEST - (imageData[from + width - 1] & 1) + // SOUTHEAST - (imageData[from + width] & 1) + // SOUTH - (imageData[from + width + 1] & 1); // SOUTHWEST - - // The game of life logic - if (neighbors == 3 || (neighbors == 2 && imageData[from] == ALIVE)) { - imageData[to] = ALIVE; - } else { - imageData[to] = DEAD; - } - - } - } - - @Override public void run() { - int gid = getGlobalId(); - processPixel(gid); - } - - boolean sequential = Boolean.getBoolean("sequential"); - - public void nextGeneration() { - // swap fromBase and toBase - int swap = fromBase; - fromBase = toBase; - toBase = swap; - if (sequential){ - for(int gid = 0; gid<(width*height); gid++){ - processPixel(gid); - } - - }else{ - execute(range); - } - - } - - } - - static boolean running = false; - - public static void main(String[] _args) { - - JFrame frame = new JFrame("Game of Life"); - final int width = Integer.getInteger("width", 1024 + 512+256+128); - - final int height = Integer.getInteger("height", 768+256); - - // Buffer is twice the size as the screen. We will alternate between mutating data from top to bottom - // and bottom to top in alternate generation passses. The LifeKernel will track which pass is which - final BufferedImage image = new BufferedImage(width, height * 2, BufferedImage.TYPE_INT_RGB); - - final LifeKernel lifeKernel = new LifeKernel(width, height, image); - - // Create a component for viewing the offsecreen image - @SuppressWarnings("serial") JComponent viewer = new JComponent(){ - @Override public void paintComponent(Graphics g) { - if (lifeKernel.isExplicit()) { - lifeKernel.get(lifeKernel.imageData); // We only pull the imageData when we intend to use it. - List profileInfo = lifeKernel.getProfileInfo(); - if (profileInfo != null) { - for (ProfileInfo p : profileInfo) { - System.out.print(" " + p.getType() + " " + p.getLabel() + " " + (p.getStart() / 1000) + " .. " - + (p.getEnd() / 1000) + " " + (p.getEnd() - p.getStart()) / 1000 + "us"); - } - System.out.println(); - } - } - // We copy one half of the offscreen buffer to the viewer, we copy the half that we just mutated. - if (lifeKernel.fromBase == 0) { - g.drawImage(image, 0, 0, width, height, 0, 0, width, height, this); - } else { - g.drawImage(image, 0, 0, width, height, 0, height, width, 2 * height, this); - } - } - }; - - JPanel controlPanel = new JPanel(new FlowLayout()); - frame.getContentPane().add(controlPanel, BorderLayout.SOUTH); - - final JButton startButton = new JButton("Start"); - - startButton.addActionListener(new ActionListener(){ - @Override public void actionPerformed(ActionEvent e) { - running = true; - startButton.setEnabled(false); - } - }); - controlPanel.add(startButton); - controlPanel.add(new JLabel(lifeKernel.getExecutionMode().toString())); - - controlPanel.add(new JLabel(" Generations/Second=")); - JLabel generationsPerSecond = new JLabel("0.00"); - controlPanel.add(generationsPerSecond); - - // Set the default size and add to the frames content pane - viewer.setPreferredSize(new Dimension(width, height)); - frame.getContentPane().add(viewer); - - // Swing housekeeping - frame.pack(); - frame.setVisible(true); - frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - - long start = System.currentTimeMillis(); - long generations = 0; - while (!running) { - try { - Thread.sleep(10); - viewer.repaint(); - } catch (InterruptedException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } - while (true) { - - lifeKernel.nextGeneration(); // Work is performed here - viewer.repaint(); // Request a repaint of the viewer (causes paintComponent(Graphics) to be called later not synchronous - generations++; - long now = System.currentTimeMillis(); - if (now - start > 1000) { - generationsPerSecond.setText(String.format("%5.2f", (generations * 1000.0) / (now - start))); - start = now; - generations = 0; - } - } - - } -} diff --git a/samples/mandel/build.xml b/samples/mandel/build.xml index 046dfb00..585428d9 100644 --- a/samples/mandel/build.xml +++ b/samples/mandel/build.xml @@ -3,7 +3,7 @@ - + diff --git a/samples/mandel/mandel.sh b/samples/mandel/mandel.sh index 892969df..094af703 100644 --- a/samples/mandel/mandel.sh +++ b/samples/mandel/mandel.sh @@ -1,5 +1,18 @@ -java\ - -Djava.library.path=../../com.amd.aparapi.jni/dist\ - -Dcom.amd.aparapi.executionMode=$1\ - -classpath ../../com.amd.aparapi/dist/aparapi.jar:mandel.jar\ +#!/bin/sh +set -x + +# Note this sample requires JDK 8 +# JAVA_HOME=/home/ecaspole/views/lambda/lambda/build/linux-x86_64-normal-server-release/images/j2sdk-image/ +JAVA=$JAVA_HOME/bin/java + + +# -Dcom.amd.aparapi.enableVerboseJNI=true \ +# -Dcom.amd.aparapi.enableInstructionDecodeViewer=true \ + +$JAVA -ea \ + -Dcom.amd.aparapi.logLevel=INFO \ + -Dcom.amd.aparapi.enableShowGeneratedOpenCL=true \ + -Djava.library.path=../../com.amd.aparapi.jni/dist/ \ + -javaagent:../../com.amd.aparapi/dist/aparapi-agent.jar \ + -classpath mandel.jar:../../com.amd.aparapi/dist/aparapi.jar \ com.amd.aparapi.sample.mandel.Main diff --git a/samples/mandel/src/com/amd/aparapi/sample/mandel/Main.java b/samples/mandel/src/com/amd/aparapi/sample/mandel/Main.java index 0b39ef9d..f3245736 100644 --- a/samples/mandel/src/com/amd/aparapi/sample/mandel/Main.java +++ b/samples/mandel/src/com/amd/aparapi/sample/mandel/Main.java @@ -34,7 +34,7 @@ to national security controls as identified on the Commerce Control List (curren 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.amd.aparapi.sample.mandel; @@ -48,153 +48,339 @@ to national security controls as identified on the Commerce Control List (curren import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; -import java.util.List; +//import java.util.ArrayList; +import java.util.Arrays; +//import java.util.List; +//import java.util.stream.primitive.IntStream; import javax.swing.JComponent; import javax.swing.JFrame; -import com.amd.aparapi.Kernel; -import com.amd.aparapi.ProfileInfo; -import com.amd.aparapi.Range; - -/** - * An example Aparapi application which displays a view of the Mandelbrot set and lets the user zoom in to a particular point. - * - * When the user clicks on the view, this example application will zoom in to the clicked point and zoom out there after. - * On GPU, additional computing units will offer a better viewing experience. On the other hand on CPU, this example - * application might suffer with sub-optimal frame refresh rate as compared to GPU. - * - * @author gfrost - * - */ +import com.amd.aparapi.Aparapi; public class Main{ - /** - * An Aparapi Kernel implementation for creating a scaled view of the mandelbrot set. - * - * @author gfrost - * - */ + /** Width of Mandelbrot view. */ + static final int width = 768; - public static class MandelKernel extends Kernel{ + /** Height of Mandelbrot view. */ + static final int height = 768; - /** RGB buffer used to store the Mandelbrot image. This buffer holds (width * height) RGB values. */ - final private int rgb[]; + /** Image for Mandelbrot view. */ + static final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + static final BufferedImage offscreen = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - /** Mandelbrot image width. */ - final private int width; + // Extract the underlying RGB buffer from the image. + final int[] rgb = ((DataBufferInt) offscreen.getRaster().getDataBuffer()).getData(); + final int[] imageRgb = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); - /** Mandelbrot image height. */ - final private int height; + float defaultScale = 3f; + /** Maximum iterations for Mandelbrot. */ + final private int maxIterations = 64; - /** Maximum iterations for Mandelbrot. */ - final private int maxIterations = 64; + /** Palette which maps iteration values to RGB values. */ + final int pallette[] = new int[maxIterations + 1]; - /** Palette which maps iteration values to RGB values. */ - @Constant final private int pallette[] = new int[maxIterations + 1]; + /** User selected zoom-in point on the Mandelbrot view. */ + public static volatile Point to = null; - /** Mutable values of scale, offsetx and offsety so that we can modify the zoom level and position of a view. */ - private float scale = .0f; + // This is how many frames we will display as we zoom in and out. + static final int frames = 128; - private float offsetx = .0f; + // These are members so zoom out continues from where zoom in stopped + float scale = defaultScale; + float x = -1f; + float y = 0f; - private float offsety = .0f; + static int[] phonyGid = new int[width*height]; + + // Draw Mandelbrot image + static JComponent viewer = new JComponent(){ + @Override public void paintComponent(Graphics g) { + g.drawImage(image, 0, 0, width, height, this); + } + }; - /** - * Initialize the Kernel. - * - * @param _width Mandelbrot image width - * @param _height Mandelbrot image height - * @param _rgb Mandelbrot image RGB buffer - * @param _pallette Mandelbrot image palette - */ - public MandelKernel(int _width, int _height, int[] _rgb) { - //Initialize palette values - for (int i = 0; i < maxIterations; i++) { - float h = i / (float) maxIterations; - float b = 1.0f - h * h; - pallette[i] = Color.HSBtoRGB(h, 1f, b); - } - width = _width; - height = _height; - rgb = _rgb; + enum ZoomDirection { + ZOOM_IN(-1), ZOOM_OUT(1); - } + private int sign; - public int getCount(float x, float y){ - int count =0; - float zx = x; - float zy = y; - float new_zx = 0f; - - // Iterate until the algorithm converges or until maxIterations are reached. - while (count < maxIterations && zx * zx + zy * zy < 8) { - new_zx = zx * zx - zy * zy + x; - zy = 2 * zx * zy + y; - zx = new_zx; - count++; - } - return(count); - } + private ZoomDirection(int c) { sign = c; } + public int getSign() { return sign; } + } - @Override public void run() { + void getNextImage(float x, float y, float scale) { + +// Here is some explanation of the sequence of calls to implement the parallel forEach +// +// Arrays.parallel delegates to public Stream parallel() { return Streams.parallel(a); } +// +// public static Stream parallel(T[] source, int offset, int length) { +// return new ValuePipeline<>(new ArraySpliterator<>(source, offset, length), +// StreamOpFlags.IS_SIZED | StreamOpFlags.IS_ORDERED | StreamOpFlags.IS_PARALLEL); +// } +// +// calls +// +// public ValuePipeline(Spliterator spliterator, int sourceFlags) { +// super(spliterator, sourceFlags, StreamShape.VALUE); +// } +// +// calls +// +// protected AbstractPipeline(Spliterator spliterator, int sourceFlags, StreamShape shape); +// +// so now we have a ValuePipeline stream which is the reciever for forEach +// +// @Override +// public void forEach(Block block) { +// pipeline(ForEachOp.make(block)); +// } +// +// creates a ForEachOp for the Block (the block is the code in the statement lambda) +// +// public static ForEachOp make(final Block block) +// ... +// return new ForEachOp<>(new TerminalSink() { +// +// +// public Stream pipeline(IntermediateOp op) { +// // @@@ delegate to shape to do instantiation +// return new ValuePipeline<>(this, op); +// } +// +// using +// +// public ValuePipeline(AbstractPipeline upstream, IntermediateOp op) { +// super(upstream, op); +// } +// +// ForEachOp is a subclass of TerminalOp +// +// share/classes/java/util/streams/AbstractPipeline.java: + +// public R pipeline(TerminalOp terminal) { +// assert getShape() == terminal.inputShape(); +// return evaluate(terminal); +// } + +// This stream is parallel, remember parallel flag was set back in Arrays.parallel: +// +// protected R evaluate(TerminalOp terminal) { +// // @@@ NYI If the source size estimate is small, don't bother going parallel +// if (StreamOpFlags.PARALLEL.isKnown(sourceFlags)) { +// return evaluateParallel(terminal); +// } +// else +// return evaluateSequential(terminal); +// } + +// private R evaluateParallel(Node node, +// Spliterator spliterator, +// int sourceFlags, +// int[] opsFlags, +// IntermediateOp[] ops, int from, int upTo, +// StreamOp terminal) { +// return (R) terminal.evaluateParallel(new ParallelImplPipelineHelper(node, spliterator, sourceFlags, +// opsFlags, ops, from, upTo)); +// } +// +// Note ParallelImplPipelineHelper is an inner class in AbstractPipeline +// terminal is the ForEachOp +// +// Back to ForEachOp: +// +// @Override +// public Void evaluateParallel(ParallelPipelineHelper helper) { +// OpUtils.parallelForEach(helper, helper.wrapSink(sink)); +// return null; +// } +// +// share/classes/java/util/streams/ops/OpUtils.java: +// +// public static void parallelForEach(ParallelPipelineHelper helper, Sink sink) { +// helper.invoke(new ForEachTask<>(helper, sink)); +// } +// +// +// Note ForEachTask is a inner class in OpUtils +// ForEachTask is a subclass of "AbstractTask extends CountedCompleter" which +// is a j.u.c.ForkJoinTask +// share/classes/java/util/streams/ops/AbstractTask.java +// +// ParallelImplPipelineHelper.invoke(ForkJoinTask task) { +// return task.invoke(); +// } +// +// Now we are in java.util.concurrent running a ForkJoinTask waiting for completion on the main thread +// So the java stack trace at that point is: +// +// "main" #1 prio=5 os_prio=0 tid=0x00007fdab4009000 nid=0x39d1 in Object.wait() [0x00007fdabd771000] +// java.lang.Thread.State: WAITING (on object monitor) +// at java.lang.Object.wait(Native Method) +// - waiting on <0x00000007c3676b48> (a java.util.streams.ops.OpUtils$ForEachTask) +// at java.lang.Object.wait(Object.java:502) +// at java.util.concurrent.ForkJoinTask.externalAwaitDone(ForkJoinTask.java:296) +// - locked <0x00000007c3676b48> (a java.util.streams.ops.OpUtils$ForEachTask) +// at java.util.concurrent.ForkJoinTask.doInvoke(ForkJoinTask.java:362) +// at java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:668) +// at java.util.streams.AbstractPipeline$ParallelImplPipelineHelper.invoke(AbstractPipeline.java:396) +// at java.util.streams.ops.OpUtils.parallelForEach(OpUtils.java:83) +// at java.util.streams.ops.ForEachOp.evaluateParallel(ForEachOp.java:74) +// at java.util.streams.ops.ForEachOp.evaluateParallel(ForEachOp.java:37) +// at java.util.streams.AbstractPipeline.evaluateParallel(AbstractPipeline.java:189) +// at java.util.streams.AbstractPipeline.evaluateParallel(AbstractPipeline.java:177) +// at java.util.streams.AbstractPipeline.evaluate(AbstractPipeline.java:131) +// at java.util.streams.AbstractPipeline.pipeline(AbstractPipeline.java:487) +// at java.util.streams.ValuePipeline.forEach(ValuePipeline.java:89) +// at com.amd.aparapi.sample.mandel.Main.getNextImage(Main.java:244) +// + //IntStream str = Arrays.parallel(phonyGid); + //str.forEach(p -> { + + //Aparapi.forEach(phonyGid, p -> { + Aparapi.forEach(width*height, p -> { + +// The Block that gets executed here becomes: +// +// private void lambda$0(float, float, float, int); +// +// The stack of a thread in the pool doing the lambda is: +// +// "ForkJoinPool.commonPool-worker-13" #28 daemon prio=5 os_prio=0 tid=0x00007fdab4246800 nid=0x3a12 runnable [0x00007fda9fafb000] +// java.lang.Thread.State: RUNNABLE +// at com.amd.aparapi.sample.mandel.Main.lambda$0(Main.java:261) +// at com.amd.aparapi.sample.mandel.Main$$Lambda$1.apply(Unknown Source) +// at java.util.streams.ops.ForEachOp$1.accept(ForEachOp.java:52) +// at java.util.streams.Sink.apply(Sink.java:58) +// at java.util.streams.ops.ForEachOp$1.apply(ForEachOp.java) +// +// Now we are getting closer to doing some work: +// +// ArraySpliterator.forEach(Block block) { +// traversing = true; +// for (int i= curOffset; i is used to break data structures into chunks that +// can be processed independently. + +// at java.util.streams.ops.OpUtils.intoWrapped(OpUtils.java:78) +// at java.util.streams.ops.OpUtils$ForEachTask.doLeaf(OpUtils.java:107) + +// Each task can be a leaf, actually calling the user lambda block, or a task further +// splitting the work and forking new tasks which may further split or be leaves. + +// at java.util.streams.ops.OpUtils$ForEachTask.doLeaf(OpUtils.java:86) +// at java.util.streams.ops.AbstractTask.compute(AbstractTask.java:90) +// at java.util.streams.ops.AbstractTask.compute(AbstractTask.java:110) +// at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:484) +// at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:260) +// at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1055) +// at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1708) +// at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104) +// +// The thread pool is not named like the lambda's class -- seems like +// that would be helpful for debugging. + + //System.out.println("Curr = " + p); + /** Determine which RGB value we are going to process (0..RGB.length). */ - int gid = getGlobalId(); + int gid = p; /** Translate the gid into an x an y value. */ - float x = (((gid % width * scale) - ((scale / 2) * width)) / width) + offsetx; - - float y = (((gid / width * scale) - ((scale / 2) * height)) / height) + offsety; - - int count = getCount(x,y); - + float lx = (((gid % width * scale) - ((scale / 2) * width)) / width) + x; + float ly = (((gid / width * scale) - ((scale / 2) * height)) / height) + y; + + //int count = getCount(lx,ly); + int count = 0; + { + float zx = lx; + float zy = ly; + float new_zx = 0f; + + // Iterate until the algorithm converges or until maxIterations are reached. + while (count < maxIterations && zx * zx + zy * zy < 8) { + new_zx = zx * zx - zy * zy + lx; + zy = 2 * zx * zy + ly; + zx = new_zx; + count++; + } + } // Pull the value out of the palette for this iteration count. rgb[gid] = pallette[count]; - } + }); + } - public void setScaleAndOffset(float _scale, float _offsetx, float _offsety) { - offsetx = _offsetx; - offsety = _offsety; - scale = _scale; - } + void doZoom(int sign, float tox, float toy) { + // Zoom in or out per iteration + for (int i = 0; i < frames - 4; i++) { + scale = scale + sign * defaultScale / frames; + x = x - sign * (tox / frames); + y = y - sign * (toy / frames); + getNextImage(x, y, scale); + System.arraycopy(rgb, 0, imageRgb, 0, rgb.length); + viewer.repaint(); + } } - /** User selected zoom-in point on the Mandelbrot view. */ - public static volatile Point to = null; - @SuppressWarnings("serial") public static void main(String[] _args) { + void zoomInAndOut(Point to, int[] rgb, int[] imageRgb) { + float tox = (float) (to.x - width / 2) / width * defaultScale; + float toy = (float) (to.y - height / 2) / height * defaultScale; + + // This cannot be parallel lambda or you will get a headache!! + // It will zoom in on the clicked point, then zoom out back to the start position + + + // NOTE: in the future we will use a (non-parallel) lambda here when stream API gets into JDK8. + // Arrays.stream(ZoomDirection.values()).forEach( e -> { + for (ZoomDirection e: ZoomDirection.values()) { + +// Here is the stack at this point of running the lambda +// +// at com.amd.aparapi.sample.mandel.Main.doZoom(Main.java:277) +// at com.amd.aparapi.sample.mandel.Main.lambda$1(Main.java:291) +// at com.amd.aparapi.sample.mandel.Main$$Lambda$2.apply(Unknown Source) +// at java.util.streams.ops.ForEachOp$1.accept(ForEachOp.java:52) +// at java.util.streams.Sink.apply(Sink.java:58) +// at java.util.streams.ops.ForEachOp$1.apply(ForEachOp.java) +// at java.util.streams.Streams$ArraySpliterator.forEach(Streams.java:550) +// at java.util.streams.AbstractPipeline$AbstractPipelineHelper.into(AbstractPipeline.java:256) +// at java.util.streams.AbstractPipeline$SequentialImplPipelineHelper.into(AbstractPipeline.java:321) + +// Note there are SequentialImplPipelineHelper here and ParallelImplPipelineHelper +// in the parallel case above. + +// at java.util.streams.ops.ForEachOp.evaluateSequential(ForEachOp.java:69) +// at java.util.streams.ops.ForEachOp.evaluateSequential(ForEachOp.java:37) +// at java.util.streams.AbstractPipeline.evaluateSequential(AbstractPipeline.java:206) +// at java.util.streams.AbstractPipeline.evaluate(AbstractPipeline.java:134) +// at java.util.streams.AbstractPipeline.pipeline(AbstractPipeline.java:487) +// at java.util.streams.ValuePipeline.forEach(ValuePipeline.java:89) +// at com.amd.aparapi.sample.mandel.Main.zoomInAndOut(Main.java:290) +// at com.amd.aparapi.sample.mandel.Main.main(Main.java:361) + + doZoom(e.getSign(), tox, toy); + System.out.println("inner done, sign=" + e.getSign() ); + } + } + void doIt() { JFrame frame = new JFrame("MandelBrot"); - - /** Width of Mandelbrot view. */ - final int width = 768; - - /** Height of Mandelbrot view. */ - final int height = 768; - - /** Mandelbrot image height. */ - final Range range = Range.create(width * height); - - /** Image for Mandelbrot view. */ - final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - final BufferedImage offscreen = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); - // Draw Mandelbrot image - JComponent viewer = new JComponent(){ - @Override public void paintComponent(Graphics g) { - - g.drawImage(image, 0, 0, width, height, this); - } - }; - // Set the size of JComponent which displays Mandelbrot image viewer.setPreferredSize(new Dimension(width, height)); - final Object doorBell = new Object(); - // Mouse listener which reads the user clicked zoom-in point on the Mandelbrot view viewer.addMouseListener(new MouseAdapter(){ @Override public void mouseClicked(MouseEvent e) { @@ -211,29 +397,27 @@ public void setScaleAndOffset(float _scale, float _offsetx, float _offsety) { frame.setLocationRelativeTo(null); frame.setVisible(true); - // Extract the underlying RGB buffer from the image. - // Pass this to the kernel so it operates directly on the RGB buffer of the image - final int[] rgb = ((DataBufferInt) offscreen.getRaster().getDataBuffer()).getData(); - final int[] imageRgb = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); - // Create a Kernel passing the size, RGB buffer and the palette. - final MandelKernel kernel = new MandelKernel(width, height, rgb); + //Initialize palette values + for (int i = 0; i < maxIterations; i++) { + float h = i / (float) maxIterations; + float b = 1.0f - h * h; + pallette[i] = Color.HSBtoRGB(h, 1f, b); + } - float defaultScale = 3f; + // Used to find the index in the rgb array when processing + // each element in the lambda + for(int i=0; i - - - - - - - diff --git a/samples/squares/.project b/samples/squares/.project deleted file mode 100644 index af343471..00000000 --- a/samples/squares/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - squares - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/samples/squares/build.xml b/samples/squares/build.xml deleted file mode 100644 index df44d67b..00000000 --- a/samples/squares/build.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/samples/squares/squares.bat b/samples/squares/squares.bat deleted file mode 100644 index 9e45a96d..00000000 --- a/samples/squares/squares.bat +++ /dev/null @@ -1,6 +0,0 @@ -java ^ - -Djava.library.path=../../com.amd.aparapi.jni/dist ^ - -Dcom.amd.aparapi.executionMode=%1 ^ - -classpath ../../com.amd.aparapi/dist/aparapi.jar;squares.jar ^ - com.amd.aparapi.sample.squares.Main - diff --git a/samples/squares/squares.sh b/samples/squares/squares.sh deleted file mode 100644 index 3fe88051..00000000 --- a/samples/squares/squares.sh +++ /dev/null @@ -1,5 +0,0 @@ -java \ - -Djava.library.path=../../com.amd.aparapi.jni/dist \ - -Dcom.amd.aparapi.executionMode=%1 \ - -classpath ../../com.amd.aparapi/dist/aparapi.jar:squares.jar \ - com.amd.aparapi.sample.squares.Main diff --git a/samples/squares/src/com/amd/aparapi/sample/squares/Main.java b/samples/squares/src/com/amd/aparapi/sample/squares/Main.java deleted file mode 100644 index 32a1b70b..00000000 --- a/samples/squares/src/com/amd/aparapi/sample/squares/Main.java +++ /dev/null @@ -1,96 +0,0 @@ -/* -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.amd.aparapi.sample.squares; - -import com.amd.aparapi.Kernel; -import com.amd.aparapi.Range; - -/** - * An example Aparapi application which computes and displays squares of a set of 512 input values. - * While executing on GPU using Aparpi framework, each square value is computed in a separate kernel invocation and - * can thus maximize performance by optimally utilizing all GPU computing units - * - * @author gfrost - * - */ - -public class Main{ - - public static void main(String[] _args) { - - final int size = 512; - - /** Input float array for which square values need to be computed. */ - final float[] values = new float[size]; - - /** Initialize input array. */ - for (int i = 0; i < size; i++) { - values[i] = i; - } - - /** Output array which will be populated with square values of corresponding input array elements. */ - final float[] squares = new float[size]; - - /** Aparapi Kernel which computes squares of input array elements and populates them in corresponding elements of - * output array. - **/ - Kernel kernel = new Kernel(){ - @Override public void run() { - int gid = getGlobalId(); - squares[gid] = values[gid] * values[gid]; - } - }; - - // Execute Kernel. - - kernel.execute(Range.create(512)); - - // Report target execution mode: GPU or JTP (Java Thread Pool). - System.out.println("Execution mode=" + kernel.getExecutionMode()); - - // Display computed square values. - for (int i = 0; i < size; i++) { - System.out.printf("%6.0f %8.0f\n", values[i], squares[i]); - } - - // Dispose Kernel resources. - kernel.dispose(); - } - -} diff --git a/streamapi-examples/agent-convolution.bash b/streamapi-examples/agent-convolution.bash new file mode 100755 index 00000000..f3d8fca4 --- /dev/null +++ b/streamapi-examples/agent-convolution.bash @@ -0,0 +1,3 @@ +#!/bin/bash +. ./java-home.bash +${JAVA_HOME}/bin/java -javaagent:agent.jar -classpath examples.jar convolution.Convolution diff --git a/streamapi-examples/agent-mandel.bash b/streamapi-examples/agent-mandel.bash new file mode 100755 index 00000000..78b8a2e7 --- /dev/null +++ b/streamapi-examples/agent-mandel.bash @@ -0,0 +1,3 @@ +#!/bin/bash +. ./java-home.bash +${JAVA_HOME}/bin/java -javaagent:agent.jar -classpath examples.jar mandel.Mandel diff --git a/streamapi-examples/agent-predicates.bash b/streamapi-examples/agent-predicates.bash new file mode 100755 index 00000000..ceb94673 --- /dev/null +++ b/streamapi-examples/agent-predicates.bash @@ -0,0 +1,3 @@ +#!/bin/bash +. ./java-home.bash +${JAVA_HOME}/bin/java -javaagent:agent.jar -classpath examples.jar predicates.PredicateTest diff --git a/streamapi-examples/agent-twelve.bash b/streamapi-examples/agent-twelve.bash new file mode 100755 index 00000000..d1fac5f7 --- /dev/null +++ b/streamapi-examples/agent-twelve.bash @@ -0,0 +1,3 @@ +#!/bin/bash +. ./java-home.bash +${JAVA_HOME}/bin/java -javaagent:agent.jar -classpath examples.jar twelve.Twelve diff --git a/streamapi-examples/build.xml b/streamapi-examples/build.xml new file mode 100644 index 00000000..8fd6f2af --- /dev/null +++ b/streamapi-examples/build.xml @@ -0,0 +1,34 @@ + + + + + + OS Name: ${os.name} + OS Version: ${os.version} + OS Arch: ${os.arch} + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/streamapi-examples/java-home.bash b/streamapi-examples/java-home.bash new file mode 100644 index 00000000..2dd00d91 --- /dev/null +++ b/streamapi-examples/java-home.bash @@ -0,0 +1,4 @@ +export JAVA_HOME=/Users/garyfrost/projectlambda/lambda/build/macosx-x86_64-fastdebug +export JAVA_HOME=/home/gfrost/lambda/lambda/build/linux-amd64 +export JAVA_HOME=/home/gfrost/aparapi/branches/SumatraExperiments/lambda-root/lambda/build/linux-amd64 +export JAVA_HOME=/Users/garyfrost/projectlambda/lambda/build/macosx-x86_64 diff --git a/streamapi-examples/run-convolution.bash b/streamapi-examples/run-convolution.bash new file mode 100755 index 00000000..b0254c84 --- /dev/null +++ b/streamapi-examples/run-convolution.bash @@ -0,0 +1,3 @@ +#!/bin/bash +. ./java-home.bash +${JAVA_HOME}/bin/java -classpath examples.jar convolution.Convolution diff --git a/streamapi-examples/run-mandel.bash b/streamapi-examples/run-mandel.bash new file mode 100755 index 00000000..07fdbdfb --- /dev/null +++ b/streamapi-examples/run-mandel.bash @@ -0,0 +1,3 @@ +#!/bin/bash +. ./java-home.bash +${JAVA_HOME}/bin/java -classpath examples.jar mandel.Mandel diff --git a/streamapi-examples/run-predicates.bash b/streamapi-examples/run-predicates.bash new file mode 100755 index 00000000..e9a06e2b --- /dev/null +++ b/streamapi-examples/run-predicates.bash @@ -0,0 +1,3 @@ +#!/bin/bash +. ./java-home.bash +${JAVA_HOME}/bin/java -classpath examples.jar predicates.PredicateTest diff --git a/streamapi-examples/run-twelve.bash b/streamapi-examples/run-twelve.bash new file mode 100755 index 00000000..f525be9d --- /dev/null +++ b/streamapi-examples/run-twelve.bash @@ -0,0 +1,3 @@ +#!/bin/bash +. ./java-home.bash +${JAVA_HOME}/bin/java -classpath examples.jar twelve.Twelve diff --git a/streamapi-examples/src/MANIFEST.MF b/streamapi-examples/src/MANIFEST.MF new file mode 100644 index 00000000..859a7442 --- /dev/null +++ b/streamapi-examples/src/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Premain-Class: agent.Agent +Created-By: Gary diff --git a/streamapi-examples/src/agent/Agent.java b/streamapi-examples/src/agent/Agent.java new file mode 100644 index 00000000..12f72b14 --- /dev/null +++ b/streamapi-examples/src/agent/Agent.java @@ -0,0 +1,39 @@ +package agent; + +import java.lang.instrument.Instrumentation; +import java.lang.instrument.ClassFileTransformer; +import java.lang.ClassLoader; +import java.security.ProtectionDomain; +import java.util.Map; +import java.util.HashMap; +import java.util.Arrays; + +public class Agent { + + static Map map = new HashMap(); + + static class Transformer implements ClassFileTransformer{ + @Override public byte[] transform(ClassLoader loader, String name, Class clazz, ProtectionDomain domain, byte[] bytes){ + if (name != null && name.contains("$$")){ + map.put(name.replace('/','.'), bytes); + System.out.println("+"+name+" length="+bytes.length); + } + return(bytes); + } + } + static void premain(String agentArgs, Instrumentation inst){ + System.out.println("inside premain!"); + inst.addTransformer(new Transformer()); + } + + static public byte[] getBytes(Class clazz){ + byte[] bytes = map.get(clazz.getName()); + if (bytes == null){ + System.out.println("can't get bytes for ="+clazz); + }else{ + System.out.println("getting bytes for ="+clazz+" size="+bytes.length); + } + return(bytes); + } + +} diff --git a/examples/movie/src/com/amd/aparapi/examples/movie/ConvMatrix3x3Editor.java b/streamapi-examples/src/convolution/ConvMatrix3x3Editor.java similarity index 50% rename from examples/movie/src/com/amd/aparapi/examples/movie/ConvMatrix3x3Editor.java rename to streamapi-examples/src/convolution/ConvMatrix3x3Editor.java index 6e537259..6fd0eb3a 100644 --- a/examples/movie/src/com/amd/aparapi/examples/movie/ConvMatrix3x3Editor.java +++ b/streamapi-examples/src/convolution/ConvMatrix3x3Editor.java @@ -1,42 +1,5 @@ -/* -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.amd.aparapi.examples.movie; + +package convolution; import java.awt.BorderLayout; import java.awt.Component; diff --git a/streamapi-examples/src/convolution/Convolution.java b/streamapi-examples/src/convolution/Convolution.java new file mode 100644 index 00000000..f8b591a6 --- /dev/null +++ b/streamapi-examples/src/convolution/Convolution.java @@ -0,0 +1,76 @@ +package convolution; + +import java.io.File; + +public class Convolution{ + + final static class ImageConvolution{ + private float convMatrix3x3[]; + + private int width, height; + + private byte imageIn[], imageOut[]; + + public void processPixel(int x, int y, int w, int h) { + float accum = 0f; + int count = 0; + for (int dx = -3; dx < 6; dx += 3) { + for (int dy = -1; dy < 2; dy += 1) { + int rgb = 0xff & imageIn[((y + dy) * w) + (x + dx)]; + + accum += rgb * convMatrix3x3[count++]; + } + } + byte value = (byte) (Math.max(0, Math.min((int) accum, 255))); + imageOut[y * w + x] = value; + + } + + public void applyConvolution(float[] _convMatrix3x3, byte[] _imageIn, byte[] _imageOut, int _width, int _height) { + imageIn = _imageIn; + imageOut = _imageOut; + width = _width; + height = _height; + convMatrix3x3 = _convMatrix3x3; + java.util.stream.Streams.intRange(0, width*height*3).forEach((i)->{ + //java.util.stream.primitive.PrimitiveStreams.parRange(0, width*height*3).forEach((i)->{ + int x = i % (width * 3); + int y = i/ (width * 3); + + if (x > 3 && x < (width * 3 - 3) && y > 1 && y < (height - 1)) { + processPixel(x, y, width * 3, height); + } + }); + + } + } + + public static void main(final String[] _args) { + File file = new File(_args.length == 1 ? _args[0] : "testcard.jpg"); + + final ImageConvolution convolution = new ImageConvolution(); + + float convMatrix3x3[] = new float[] { + 0f, + -10f, + 0f, + -10f, + 40f, + -10f, + 0f, + -10f, + 0f, + }; + + + + new ConvolutionViewer(file, convMatrix3x3){ + @Override protected void applyConvolution(float[] _convMatrix3x3, byte[] _inBytes, byte[] _outBytes, int _width, + int _height) { + convolution.applyConvolution(_convMatrix3x3, _inBytes, _outBytes, _width, _height); + } + }; + + } + +} diff --git a/streamapi-examples/src/convolution/ConvolutionViewer.java b/streamapi-examples/src/convolution/ConvolutionViewer.java new file mode 100644 index 00000000..11ab8cb7 --- /dev/null +++ b/streamapi-examples/src/convolution/ConvolutionViewer.java @@ -0,0 +1,93 @@ +package convolution; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.awt.image.DataBufferByte; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.WindowConstants; + +@SuppressWarnings("serial") public abstract class ConvolutionViewer extends JFrame{ + + private int height; + + private int width; + + private BufferedImage outputImage; + + private BufferedImage inputImage; + + private byte[] inBytes; + + private byte[] outBytes; + + private Graphics2D gc; + + private float[] convMatrix3x3; + + public ConvolutionViewer(File _file, float[] _convMatrix3x3) { + + JFrame frame = new JFrame("Convolution Viewer"); + + convMatrix3x3 = _convMatrix3x3; + try { + inputImage = ImageIO.read(_file); + + // System.out.println(inputImage); + + height = inputImage.getHeight(); + + width = inputImage.getWidth(); + + outputImage = new BufferedImage(width, height, inputImage.getType()); + + gc = outputImage.createGraphics(); + + inBytes = ((DataBufferByte) inputImage.getRaster().getDataBuffer()).getData(); + outBytes = ((DataBufferByte) outputImage.getRaster().getDataBuffer()).getData(); + + final JLabel imageLabel = new JLabel(); + imageLabel.setIcon(new ImageIcon(outputImage)); + + ConvMatrix3x3Editor editor = new ConvMatrix3x3Editor(_convMatrix3x3){ + @Override protected void updated(float[] _convMatrix3x3) { + convMatrix3x3 = _convMatrix3x3; + long start = System.currentTimeMillis(); + + applyConvolution(convMatrix3x3, inBytes, outBytes, width, height); + long end = System.currentTimeMillis(); + gc.setColor(Color.BLACK); + gc.fillRect(0, 0, 50, 40); + gc.setColor(Color.YELLOW); + gc.drawString("" + (end - start) + "ms", 10, 20); + + imageLabel.repaint(); + } + }; + frame.getContentPane().add(editor.component, BorderLayout.WEST); + + frame.getContentPane().add(imageLabel, BorderLayout.CENTER); + frame.pack(); + frame.setVisible(true); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + + applyConvolution(convMatrix3x3, inBytes, outBytes, width, height); + + imageLabel.repaint(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + + abstract protected void applyConvolution(float[] convMatrix3x3, byte[] _inBytes, byte[] _outBytes, int _width, int _height); + +} diff --git a/streamapi-examples/src/mandel/Mandel.java b/streamapi-examples/src/mandel/Mandel.java new file mode 100644 index 00000000..8b988bd4 --- /dev/null +++ b/streamapi-examples/src/mandel/Mandel.java @@ -0,0 +1,165 @@ +package mandel; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; +import java.awt.image.DataBufferInt; +import java.util.List; + +import javax.swing.JComponent; +import javax.swing.JFrame; + + +public class Mandel{ + + static final int maxIterations = 64; + + static void displayMandel(int width, int height, float offsetx, float offsety, float scale, int rgb[], int[] pallette, JComponent viewer, DoorBell paintedDoorBell){ +// Aparapi.forEach(rgb, (i, value)->{ + // java.util.stream.primitive.PrimitiveStreams.parRange(0, rgb.length).forEach((i)->{ + java.util.stream.Streams.intRange(0, rgb.length).parallel().forEach((i)->{ + float x = ((((i%width) * scale) - ((scale / 2) * width)) / width) + offsetx; + float y = ((((i/width) * scale) - ((scale / 2) * height)) / height) + offsety; + int count = 0; + float zx = x; + float zy = y; + float new_zx = 0f; + // Iterate until the algorithm converges or until maxIterations are reached. + while (count < maxIterations && zx * zx + zy * zy < 8) { + new_zx = zx * zx - zy * zy + x; + zy = 2 * zx * zy + y; + zx = new_zx; + count++; + } + // Pull the value out of the palette for this iteration count. + rgb[i] = pallette[count]; + }); + viewer.repaint(); + paintedDoorBell.waitFor(); + } + + static public class DoorBell{ + T value; + void set(T _value){ + value = _value; + press(); + } + T get(){ + waitFor(); + return(value); + } + private volatile boolean pressed=false; + void waitFor(){ + while(!pressed){ + synchronized (this) { + try { + this.wait(); + } catch (InterruptedException ie) { + } + } + } + pressed = false; + } + void press(){ + pressed = true; + synchronized (this) { + this.notify(); + } + } + } + + + @SuppressWarnings("serial") public static void main(String[] _args) { + + JFrame frame = new JFrame("MandelBrot"); + + /** Width of Mandelbrot view. */ + final int width = 768; + + /** Height of Mandelbrot view. */ + final int height = 768; + + final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + final DoorBell paintedDoorBell = new DoorBell(); + JComponent viewer = new JComponent(){ + @Override public void paintComponent(Graphics g) { + g.drawImage(image, 0, 0, width, height, this); + paintedDoorBell.press(); + } + }; + + // Set the size of JComponent which displays Mandelbrot image + viewer.setPreferredSize(new Dimension(width, height)); + + final DoorBell doorBell = new DoorBell<>(); + + // Mouse listener which reads the user clicked zoom-in point on the Mandelbrot view + viewer.addMouseListener(new MouseAdapter(){ + @Override public void mouseClicked(MouseEvent e) { + doorBell.set(e.getPoint()); + } + }); + + // Swing housework to create the frame + frame.getContentPane().add(viewer); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + + // Extract the underlying RGB buffer from the image. + // Pass this to the kernel so it operates directly on the RGB buffer of the image + final int[] rgb = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); + + // create pallette + // Initialize palette values + final int[] pallette = new int[maxIterations+1]; + + //java.util.stream.primitive.PrimitiveStreams.parRange(0, maxIterations).forEach((i)->{ + java.util.stream.Streams.intRange(0, maxIterations).forEach((i)->{ + //Aparapi.forEach(maxIterations, (i)->{ + float h = i / (float) maxIterations; + float b = 1.0f - h * h; + pallette[i] = Color.HSBtoRGB(h, 1f, b); + }); + + + displayMandel(width, height, -1f, 0f, 3f, rgb, pallette, viewer, paintedDoorBell); + + // Window listener to dispose Kernel resources on user exit. + frame.addWindowListener(new WindowAdapter(){ + public void windowClosing(WindowEvent _windowEvent) { + System.exit(0); + } + }); + + // Wait until the user selects a zoom-in point on the Mandelbrot view. + while (true) { + Point to = doorBell.get(); + float x = -1f; + float y = 0f; + float defaultScale=3f; + float scale = 3f; + float tox = (float) (to.x - width / 2) / width * scale; + float toy = (float) (to.y - height / 2) / height * scale; + + // This is how many frames we will display as we zoom in and out. + int frames = 128; + long startMillis = System.currentTimeMillis(); + for (int sign = -1; sign < 2; sign += 2) { + for (int i = 0; i < frames - 4; i++) { + scale = scale + sign * defaultScale / frames; + x = x - sign * (tox / frames); + y = y - sign * (toy / frames); + // Set the scale and offset, execute the kernel and force a repaint of the viewer. + displayMandel(width, height, x, y, scale, rgb, pallette, viewer, paintedDoorBell ); + }; + }; + } + } +} diff --git a/streamapi-examples/src/predicates/PredicateTest.java b/streamapi-examples/src/predicates/PredicateTest.java new file mode 100644 index 00000000..4d49b880 --- /dev/null +++ b/streamapi-examples/src/predicates/PredicateTest.java @@ -0,0 +1,27 @@ +package predicates; +//import static java.util.stream.primitive.PrimitiveStreams.range; +import static java.util.stream.Streams.intRange; +import java.util.function.Predicates; +import java.util.function.Predicate; +import java.util.function.IntPredicate; +import java.util.function.IntBlock; + +public class PredicateTest{ + public static void main(String[] _args) { + IntPredicate multipleOfThree = val -> val%3==0; + IntPredicate multipleOfTwo = val -> val%2==0; + + intRange(0, 12).forEach(table -> { + //range(0, 12).filter(multipleOfThree.and(v2->v2%2==0)) + //range(0, 12).filter(multipleOfTwo.and(multipleOfThree)) + intRange(0, 12).filter(multipleOfTwo.and(v -> v%3==0)) +// range(0, 12).filter(Predicates.and(v1 -> v1%2==0, v2->v2%2==0)) + .forEach(value -> { + System.out.printf("%d * %d = %d\n", value, table, (value*table)); + } + ); + System.out.printf("\n"); + } + ); + } +} diff --git a/streamapi-examples/src/test/Test.java b/streamapi-examples/src/test/Test.java new file mode 100644 index 00000000..9d076419 --- /dev/null +++ b/streamapi-examples/src/test/Test.java @@ -0,0 +1,29 @@ +package test; + +import agent.Agent; + + +public class Test{ + static interface SAM{ + void apply(int id); + } + + public static void For(int from, int to, SAM sam){ + byte[] classBytes = Agent.getBytes(sam.getClass()); + System.out.println("sam class is "+sam.getClass()+" "+classBytes.length); + + for (int id=from; id { + For(0,12, value -> { + System.out.printf("%d * %d = %d\n", value, table, (value*table)); + }); + System.out.printf("\n"); + }); + } +} diff --git a/streamapi-examples/src/twelve/Twelve.java b/streamapi-examples/src/twelve/Twelve.java new file mode 100644 index 00000000..1d629317 --- /dev/null +++ b/streamapi-examples/src/twelve/Twelve.java @@ -0,0 +1,24 @@ +package twelve; + +public class Twelve{ + interface SAM{ + void run(int _id); + } + + public static void For(int _count, SAM _sam){ + for (int id = 0; id<_count; id++){ + _sam.run(id); + } + } + + public static void main(String[] _args) { + For(12, table -> { + For(12, value ->{ + System.out.printf("%d * %d = %d\n", value, table, (value*table)); + } + ); + System.out.printf("\n"); + } + ); + } +} diff --git a/samples/convolution/testcard.jpg b/streamapi-examples/testcard.jpg similarity index 100% rename from samples/convolution/testcard.jpg rename to streamapi-examples/testcard.jpg diff --git a/test/codegen/.classpath b/test/codegen/.classpath deleted file mode 100644 index 04de8d49..00000000 --- a/test/codegen/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/test/codegen/.project b/test/codegen/.project deleted file mode 100644 index f89ab716..00000000 --- a/test/codegen/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - test-codegen - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/test/codegen/build.xml b/test/codegen/build.xml deleted file mode 100644 index 7af1dceb..00000000 --- a/test/codegen/build.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - OS Name: ${os.name} - OS Version: ${os.version} - OS Arch: ${os.arch} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/codegen/src/java/com/amd/aparapi/CodeGenJUnitBase.java b/test/codegen/src/java/com/amd/aparapi/CodeGenJUnitBase.java deleted file mode 100644 index c698137d..00000000 --- a/test/codegen/src/java/com/amd/aparapi/CodeGenJUnitBase.java +++ /dev/null @@ -1,110 +0,0 @@ -/* -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.amd.aparapi; - -import static org.junit.Assert.assertTrue; - -public class CodeGenJUnitBase{ - - protected void test(Class _class, Class _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 = new ClassModel(_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; - for (String expected : expectedOpenCL) { - if (Diff.same(actual, expected)) { - break; - } - matched++; - } - boolean same = (matched < expectedOpenCL.length); - - if (!same) { - System.out.println("---" + _class.getName() - + "------------------------------------------------------------------------------"); - boolean first = true; - 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------------------------------------------------------------------------------------------------------"); - - } else { - System.out.println("Matched{" + actual); - System.out - .println("}\n------------------------------------------------------------------------------------------------------"); - - } - assertTrue(_class.getSimpleName(), same); - } else { - assertTrue("Expected exception " + _expectedExceptionType + " Instead we got {\n" + actual + "\n}", false); - } - - } catch (Throwable t) { - if (_expectedExceptionType == null || !t.getClass().isAssignableFrom(_expectedExceptionType)) { - t.printStackTrace(); - assertTrue("Unexpected exception " + t, false); - } - } - } - - protected void test(Class _class, String[] expectedOpenCL) { - test(_class, null, expectedOpenCL); - - } - -} diff --git a/test/codegen/src/java/com/amd/aparapi/CreateJUnitTests.java b/test/codegen/src/java/com/amd/aparapi/CreateJUnitTests.java deleted file mode 100644 index 58a02788..00000000 --- a/test/codegen/src/java/com/amd/aparapi/CreateJUnitTests.java +++ /dev/null @@ -1,127 +0,0 @@ -/* -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.amd.aparapi; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FilenameFilter; -import java.io.IOException; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.List; - -public class CreateJUnitTests{ - public static void main(String[] args) throws ClassNotFoundException, FileNotFoundException, IOException { - File rootDir = new File(System.getProperty("root", ".")); - - String rootPackageName = CreateJUnitTests.class.getPackage().getName(); - String testPackageName = rootPackageName + ".test"; - File sourceDir = new File(rootDir, "src/java"); - System.out.println(sourceDir.getCanonicalPath()); - File testDir = new File(sourceDir, testPackageName.replace(".", "/")); - System.out.println(testDir.getCanonicalPath()); - - List classNames = new ArrayList(); - 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); - - StringBuilder sb = new StringBuilder(); - sb.append("package com.amd.aparapi.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 " + className + " extends com.amd.aparapi.CodeGenJUnitBase{\n"); - sb.append(" @Test public void " + className + "(){\n"); - if (source.getOpenCLSectionCount() > 0) { - - sb.append(" String[] expectedOpenCL = new String[]{\n"); - for (List opencl : source.getOpenCL()) { - sb.append(" \"\"\n"); - for (String line : opencl) { - sb.append(" +\"" + line + "\\n\"\n"); - } - sb.append(" ,\n"); - } - sb.append(" };\n"); - } else { - sb.append(" String[] expectedOpenCL = null;\n"); - } - - String exceptions = source.getExceptionsString(); - if (exceptions.length() > 0) { - sb.append(" Class expectedException = "); - - sb.append("com.amd.aparapi." + exceptions + ".class"); - sb.append(";\n"); - } else { - sb.append(" Class expectedException = null;\n"); - } - sb.append(" test(" + testPackageName + "." + className + ".class, expectedException, expectedOpenCL);\n"); - sb.append(" }\n"); - sb.append("}\n"); - // System.out.println(sb.toString()); - - File generatedFile = new File(codeGenDir, className + ".java"); - PrintStream out = new PrintStream(generatedFile); - out.append(sb.toString()); - out.close(); - - } - - } -} diff --git a/test/codegen/src/java/com/amd/aparapi/Diff.java b/test/codegen/src/java/com/amd/aparapi/Diff.java deleted file mode 100644 index be197442..00000000 --- a/test/codegen/src/java/com/amd/aparapi/Diff.java +++ /dev/null @@ -1,267 +0,0 @@ -/* -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.amd.aparapi; - -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[][] 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(); - 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[][] 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 blocks = new ArrayList(); - - 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[][] 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/test/codegen/src/java/com/amd/aparapi/KernelHelper.java b/test/codegen/src/java/com/amd/aparapi/KernelHelper.java deleted file mode 100644 index ec80168c..00000000 --- a/test/codegen/src/java/com/amd/aparapi/KernelHelper.java +++ /dev/null @@ -1,56 +0,0 @@ -/* -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.amd.aparapi; - -// contains some things that only tests would use -// but in the com.amd.aparapi 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/test/codegen/src/java/com/amd/aparapi/Source.java b/test/codegen/src/java/com/amd/aparapi/Source.java deleted file mode 100644 index a08c2872..00000000 --- a/test/codegen/src/java/com/amd/aparapi/Source.java +++ /dev/null @@ -1,186 +0,0 @@ -/* -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.amd.aparapi; - -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 all = new ArrayList(); - - List> opencl = new ArrayList>(); - - List doc = new ArrayList(); - - List java = new ArrayList(); - - List exceptions = new ArrayList(); - - public Source(Class _clazz, File _rootDir) { - clazz = _clazz; - String srcName = clazz.getPackage().getName().replace(".", "/") + "/" + clazz.getSimpleName() + ".java"; - file = new File(_rootDir, srcName); - try { - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); - - state = STATE.JAVA; - List 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(); - 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 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> getOpenCL() { - return (opencl); - } - - public String getJavaString() { - return (listToString(java)); - } - - public List getJava() { - return (java); - } - - public File getFile() { - return (file); - } - - public String getExceptionsString() { - return (listToString(exceptions)); - } - - public List getExceptions() { - return (exceptions); - } - - public String getDocString() { - return (listToString(doc)); - } - - public List getDoc() { - return (doc); - } - - public int getOpenCLSectionCount() { - return (opencl.size()); - } -} diff --git a/test/codegen/src/java/com/amd/aparapi/SwingDiff.java b/test/codegen/src/java/com/amd/aparapi/SwingDiff.java deleted file mode 100644 index 7a9def1a..00000000 --- a/test/codegen/src/java/com/amd/aparapi/SwingDiff.java +++ /dev/null @@ -1,203 +0,0 @@ -/* -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.amd.aparapi; - -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; - -import com.amd.aparapi.Diff.DiffResult; - -public class SwingDiff{ - JFrame frame; - - public SwingDiff(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"); - - 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 lines = new ArrayList(); - 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/test/codegen/src/java/com/amd/aparapi/test/Access2DIntArray.java b/test/codegen/src/java/com/amd/aparapi/test/Access2DIntArray.java deleted file mode 100644 index a69c0a0d..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/Access2DIntArray.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.amd.aparapi.test; - -public class Access2DIntArray{ - int[][] ints = new int[1024][]; - - public void run() { - int value = ints[0][0]; - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/AccessBooleanArray.java b/test/codegen/src/java/com/amd/aparapi/test/AccessBooleanArray.java deleted file mode 100644 index 32ca87d6..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/AccessBooleanArray.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/AccessByteArray.java b/test/codegen/src/java/com/amd/aparapi/test/AccessByteArray.java deleted file mode 100644 index 890ff6a0..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/AccessByteArray.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/AccessDoubleArray.java b/test/codegen/src/java/com/amd/aparapi/test/AccessDoubleArray.java deleted file mode 100644 index c8cf5364..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/AccessDoubleArray.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/AccessFloatArray.java b/test/codegen/src/java/com/amd/aparapi/test/AccessFloatArray.java deleted file mode 100644 index 45f2de6a..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/AccessFloatArray.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/AccessIntArray.java b/test/codegen/src/java/com/amd/aparapi/test/AccessIntArray.java deleted file mode 100644 index fca5117c..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/AccessIntArray.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/AccessLongArray.java b/test/codegen/src/java/com/amd/aparapi/test/AccessLongArray.java deleted file mode 100644 index ba4d6fd0..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/AccessLongArray.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/AccessNested2DIntArray.java b/test/codegen/src/java/com/amd/aparapi/test/AccessNested2DIntArray.java deleted file mode 100644 index 444900d0..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/AccessNested2DIntArray.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/AccessShortArray.java b/test/codegen/src/java/com/amd/aparapi/test/AccessShortArray.java deleted file mode 100644 index 345a0d1d..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/AccessShortArray.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/AndOrAndPrecedence.java b/test/codegen/src/java/com/amd/aparapi/test/AndOrAndPrecedence.java deleted file mode 100644 index 4aed5153..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/AndOrAndPrecedence.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/AndOrPrecedence.java b/test/codegen/src/java/com/amd/aparapi/test/AndOrPrecedence.java deleted file mode 100644 index f427b54f..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/AndOrPrecedence.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/AndOrPrecedence2.java b/test/codegen/src/java/com/amd/aparapi/test/AndOrPrecedence2.java deleted file mode 100644 index 4e2878bf..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/AndOrPrecedence2.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ArbitraryScope.java b/test/codegen/src/java/com/amd/aparapi/test/ArbitraryScope.java deleted file mode 100644 index 1862abd0..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ArbitraryScope.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.amd.aparapi.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; itermaxIterations; 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/test/codegen/src/java/com/amd/aparapi/test/ArbitraryScope2.java b/test/codegen/src/java/com/amd/aparapi/test/ArbitraryScope2.java deleted file mode 100644 index 6ada6924..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ArbitraryScope2.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.amd.aparapi.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; itermaxIterations; 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/test/codegen/src/java/com/amd/aparapi/test/ArbitraryScopeSimple.java b/test/codegen/src/java/com/amd/aparapi/test/ArbitraryScopeSimple.java deleted file mode 100644 index 82b447ae..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ArbitraryScopeSimple.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ArrayTortureIssue35.java b/test/codegen/src/java/com/amd/aparapi/test/ArrayTortureIssue35.java deleted file mode 100644 index a4841457..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ArrayTortureIssue35.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/Assign2DIntArray.java b/test/codegen/src/java/com/amd/aparapi/test/Assign2DIntArray.java deleted file mode 100644 index cae8c268..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/Assign2DIntArray.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.amd.aparapi.test; - -public class Assign2DIntArray{ - int[][] ints = new int[1024][]; - - public void run() { - ints[0][0] = 1; - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/AssignAndPassAsParameter.java b/test/codegen/src/java/com/amd/aparapi/test/AssignAndPassAsParameter.java deleted file mode 100644 index f30d4ed0..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/AssignAndPassAsParameter.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.amd.aparapi.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 actuallyDoIt(int a) { - return 1; - } - - int y = 2; - - 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/test/codegen/src/java/com/amd/aparapi/test/AssignAndPassAsParameterSimple.java b/test/codegen/src/java/com/amd/aparapi/test/AssignAndPassAsParameterSimple.java deleted file mode 100644 index 90a22bea..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/AssignAndPassAsParameterSimple.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.amd.aparapi.test; - -public class AssignAndPassAsParameterSimple{ - - void actuallyDoIt(int a) { - - } - - public void run() { - @SuppressWarnings("unused") int z; - actuallyDoIt(z = 1); - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/AssignField.java b/test/codegen/src/java/com/amd/aparapi/test/AssignField.java deleted file mode 100644 index ccc177e1..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/AssignField.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.amd.aparapi.test; - -public class AssignField{ - int field = 1024; - - public void run() { - field = 100; - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/Atomic32Pragma.java b/test/codegen/src/java/com/amd/aparapi/test/Atomic32Pragma.java deleted file mode 100644 index 5c9a0068..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/Atomic32Pragma.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.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/test/codegen/src/java/com/amd/aparapi/test/BooleanToggle.java b/test/codegen/src/java/com/amd/aparapi/test/BooleanToggle.java deleted file mode 100644 index 2ed1ede4..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/BooleanToggle.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/Break.java b/test/codegen/src/java/com/amd/aparapi/test/Break.java deleted file mode 100644 index 3f912c3d..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/Break.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ByteParams.java b/test/codegen/src/java/com/amd/aparapi/test/ByteParams.java deleted file mode 100644 index 507a6905..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ByteParams.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ByteParamsSimple.java b/test/codegen/src/java/com/amd/aparapi/test/ByteParamsSimple.java deleted file mode 100644 index 2f8f9ddc..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ByteParamsSimple.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/CallGetPassId.java b/test/codegen/src/java/com/amd/aparapi/test/CallGetPassId.java deleted file mode 100644 index 01e544cd..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/CallGetPassId.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.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/test/codegen/src/java/com/amd/aparapi/test/CallObject.java b/test/codegen/src/java/com/amd/aparapi/test/CallObject.java deleted file mode 100644 index dc7d9dc0..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/CallObject.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class CallObject extends Kernel{ - static class Dummy{ - public int foo() { - return 42; - } - }; - - Dummy dummy = new Dummy(); - - public void run() { - out[0] = dummy.foo(); - } - - int out[] = new int[2]; -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/CallObjectStatic.java b/test/codegen/src/java/com/amd/aparapi/test/CallObjectStatic.java deleted file mode 100644 index 23c66c2d..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/CallObjectStatic.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class CallObjectStatic extends Kernel{ - static class Dummy{ - static public int foo() { - return 42; - } - }; - - public void run() { - out[0] = Dummy.foo(); - } - - int out[] = new int[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_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/test/codegen/src/java/com/amd/aparapi/test/CallRunSuper.java b/test/codegen/src/java/com/amd/aparapi/test/CallRunSuper.java deleted file mode 100644 index fca5c0c0..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/CallRunSuper.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -class CallRunSuperBase extends Kernel{ - @Override public void run() { - out[0] = 2; - } - - int out[] = new int[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/test/codegen/src/java/com/amd/aparapi/test/CallStaticInAnotherClass.java b/test/codegen/src/java/com/amd/aparapi/test/CallStaticInAnotherClass.java deleted file mode 100644 index b6fcac03..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/CallStaticInAnotherClass.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - - -class AnotherClass{ - static public int foo() { - return 42; - } -}; - -public class CallStaticInAnotherClass extends Kernel{ - - public int doodoo() { - return AnotherClass.foo(); - } - - public void run() { - out[0] = AnotherClass.foo() + doodoo(); - } - - int out[] = new int[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_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/test/codegen/src/java/com/amd/aparapi/test/CallSuper.java b/test/codegen/src/java/com/amd/aparapi/test/CallSuper.java deleted file mode 100644 index df91c998..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/CallSuper.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -abstract class CallSuperBase extends Kernel{ - int foo(int n) { - return n * 2; - } -} - -public class CallSuper extends CallSuperBase{ - public void run() { - out[0] = foo(2); - } - - int foo(int n) { - return 1 + super.foo(n); - } - - int out[] = new int[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_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/test/codegen/src/java/com/amd/aparapi/test/CallTwice.java b/test/codegen/src/java/com/amd/aparapi/test/CallTwice.java deleted file mode 100644 index b25adc65..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/CallTwice.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class CallTwice extends Kernel{ - - public int getOne() { - return (1); - } - - @Override public void run() { - out[0] = getOne() + getOne(); - } - - int out[] = new int[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_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/test/codegen/src/java/com/amd/aparapi/test/CharArrayField.java b/test/codegen/src/java/com/amd/aparapi/test/CharArrayField.java deleted file mode 100644 index 55ac9c07..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/CharArrayField.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.amd.aparapi.test; - -public class CharArrayField{ - public void run() { - out[0] = 0; - } - - char out[] = new char[1]; -} - -/**{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/test/codegen/src/java/com/amd/aparapi/test/CharAsParameter.java b/test/codegen/src/java/com/amd/aparapi/test/CharAsParameter.java deleted file mode 100644 index 48e47846..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/CharAsParameter.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/CharType.java b/test/codegen/src/java/com/amd/aparapi/test/CharType.java deleted file mode 100644 index 126de8d1..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/CharType.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class CharType extends Kernel{ - @Override public void run() { - final char c = Character.MAX_VALUE; - this.out[0] = c; - } - - int out[] = new int[1]; -} - -/**{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/test/codegen/src/java/com/amd/aparapi/test/ClassHasStaticFieldAccess.java b/test/codegen/src/java/com/amd/aparapi/test/ClassHasStaticFieldAccess.java deleted file mode 100644 index ea061b7e..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ClassHasStaticFieldAccess.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.amd.aparapi.test; - -public class ClassHasStaticFieldAccess{ - int[] ints = new int[1024]; - - static int foo = 6; - - public void run() { - for (int i = 0; i < 1024; i++) { - if (i % 2 == 0) { - ints[i] = foo; - } - } - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ClassHasStaticMethod.java b/test/codegen/src/java/com/amd/aparapi/test/ClassHasStaticMethod.java deleted file mode 100644 index 3398d3fe..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ClassHasStaticMethod.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ClassHasStaticMethodSimple.java b/test/codegen/src/java/com/amd/aparapi/test/ClassHasStaticMethodSimple.java deleted file mode 100644 index 77197796..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ClassHasStaticMethodSimple.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/CompositeArbitraryScope.java b/test/codegen/src/java/com/amd/aparapi/test/CompositeArbitraryScope.java deleted file mode 100644 index 664db5b5..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/CompositeArbitraryScope.java +++ /dev/null @@ -1,183 +0,0 @@ -package com.amd.aparapi.test; - -// this example gave the following error: -/// com.amd.aparapi.classtools.writer.CodeGenException: composite COMPOSITE_ARBITRARY_SCOPE - -import com.amd.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/test/codegen/src/java/com/amd/aparapi/test/ConstantAssignInExpression.java b/test/codegen/src/java/com/amd/aparapi/test/ConstantAssignInExpression.java deleted file mode 100644 index d3cfeccc..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ConstantAssignInExpression.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/Continue.java b/test/codegen/src/java/com/amd/aparapi/test/Continue.java deleted file mode 100644 index 13728385..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/Continue.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ContinueTorture.java b/test/codegen/src/java/com/amd/aparapi/test/ContinueTorture.java deleted file mode 100644 index 9bbb96b5..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ContinueTorture.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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 actuallyDoIt(int a) { - return 1; - } - - int actuallyDoIt2(int a) { - return -1; - } - - int myId = 34; - - 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}**/ \ No newline at end of file diff --git a/test/codegen/src/java/com/amd/aparapi/test/DirectRecursion.java b/test/codegen/src/java/com/amd/aparapi/test/DirectRecursion.java deleted file mode 100644 index efefdebf..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/DirectRecursion.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class DirectRecursion extends Kernel{ - - public void run() { - intout[0] = fact(10); - @SuppressWarnings("unused") boolean pass = false; - } - - int fact(int n) { - return (n <= 1 ? n : n * fact(n - 1)); - } - - int intout[] = new int[1]; - -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/Drem.java b/test/codegen/src/java/com/amd/aparapi/test/Drem.java deleted file mode 100644 index f7a0fe50..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/Drem.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.amd.aparapi.test; - -public class Drem{ - public void run() { - out[0] = m % n; - } - - double out[] = new double[10]; - - double m; - - double 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/test/codegen/src/java/com/amd/aparapi/test/EarlyReturn.java b/test/codegen/src/java/com/amd/aparapi/test/EarlyReturn.java deleted file mode 100644 index 47e01af0..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/EarlyReturn.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/EmptyWhileWithInc.java b/test/codegen/src/java/com/amd/aparapi/test/EmptyWhileWithInc.java deleted file mode 100644 index 71bc9343..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/EmptyWhileWithInc.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/EntrypointRecursion.java b/test/codegen/src/java/com/amd/aparapi/test/EntrypointRecursion.java deleted file mode 100644 index 76ee6423..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/EntrypointRecursion.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.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/test/codegen/src/java/com/amd/aparapi/test/Ex.java b/test/codegen/src/java/com/amd/aparapi/test/Ex.java deleted file mode 100644 index 80daaec7..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/Ex.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/FirstAssignInExpression.java b/test/codegen/src/java/com/amd/aparapi/test/FirstAssignInExpression.java deleted file mode 100644 index 09a888c5..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/FirstAssignInExpression.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.amd.aparapi.test; - -public class FirstAssignInExpression{ - - void func(int _arg) { - // nada - } - - int y = 2; - - 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/test/codegen/src/java/com/amd/aparapi/test/FirstAssignInExpression2.java b/test/codegen/src/java/com/amd/aparapi/test/FirstAssignInExpression2.java deleted file mode 100644 index f37a8799..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/FirstAssignInExpression2.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/FloatParams.java b/test/codegen/src/java/com/amd/aparapi/test/FloatParams.java deleted file mode 100644 index f838f3dd..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/FloatParams.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/FloatParamsSimple.java b/test/codegen/src/java/com/amd/aparapi/test/FloatParamsSimple.java deleted file mode 100644 index 1b580585..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/FloatParamsSimple.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/For.java b/test/codegen/src/java/com/amd/aparapi/test/For.java deleted file mode 100644 index 4a79388a..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/For.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ForAnd.java b/test/codegen/src/java/com/amd/aparapi/test/ForAnd.java deleted file mode 100644 index 221e4e59..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ForAnd.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ForAndMandel.java b/test/codegen/src/java/com/amd/aparapi/test/ForAndMandel.java deleted file mode 100644 index 95220660..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ForAndMandel.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.amd.aparapi.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 && itermaxIterations; 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/test/codegen/src/java/com/amd/aparapi/test/ForAndMandelNoInitialize.java b/test/codegen/src/java/com/amd/aparapi/test/ForAndMandelNoInitialize.java deleted file mode 100644 index eed60ec2..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ForAndMandelNoInitialize.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.amd.aparapi.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 && itermaxIterations; 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/test/codegen/src/java/com/amd/aparapi/test/ForAsFirst.java b/test/codegen/src/java/com/amd/aparapi/test/ForAsFirst.java deleted file mode 100644 index 21ca4db4..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ForAsFirst.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ForBooleanToggle.java b/test/codegen/src/java/com/amd/aparapi/test/ForBooleanToggle.java deleted file mode 100644 index 76636e4a..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ForBooleanToggle.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ForBreak.java b/test/codegen/src/java/com/amd/aparapi/test/ForBreak.java deleted file mode 100644 index d70d519e..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ForBreak.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ForEach.java b/test/codegen/src/java/com/amd/aparapi/test/ForEach.java deleted file mode 100644 index 4ab0eb0d..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ForEach.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.amd.aparapi.test; - -public class ForEach{ - - public void run() { - int max = Integer.MIN_VALUE; - for (int i : in) { - if (i > max) - max = i; - } - out[0] = max; - } - - int out[] = new int[10]; - - int in[] = new int[10]; -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ForIf.java b/test/codegen/src/java/com/amd/aparapi/test/ForIf.java deleted file mode 100644 index 8cf2f7e3..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ForIf.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ForIfMandel.java b/test/codegen/src/java/com/amd/aparapi/test/ForIfMandel.java deleted file mode 100644 index 8864ad3f..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ForIfMandel.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.amd.aparapi.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; itermaxIterations; 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/test/codegen/src/java/com/amd/aparapi/test/Frem.java b/test/codegen/src/java/com/amd/aparapi/test/Frem.java deleted file mode 100644 index 305f5e5c..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/Frem.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.amd.aparapi.test; - -public class Frem{ - public void run() { - out[0] = m % n; - } - - float out[] = new float[10]; - - float m; - - float 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/test/codegen/src/java/com/amd/aparapi/test/IEEERemainderDouble.java b/test/codegen/src/java/com/amd/aparapi/test/IEEERemainderDouble.java deleted file mode 100644 index a88459e0..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IEEERemainderDouble.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class IEEERemainderDouble extends Kernel{ - public void run() { - out[0] = IEEEremainder(m, n); - } - - double out[] = new double[10]; - - double m; - - double 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/test/codegen/src/java/com/amd/aparapi/test/IEEERemainderFloat.java b/test/codegen/src/java/com/amd/aparapi/test/IEEERemainderFloat.java deleted file mode 100644 index bf3ba63b..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IEEERemainderFloat.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class IEEERemainderFloat extends Kernel{ - public void run() { - out[0] = IEEEremainder(m, n); - } - - float out[] = new float[10]; - - float m; - - float 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/test/codegen/src/java/com/amd/aparapi/test/If.java b/test/codegen/src/java/com/amd/aparapi/test/If.java deleted file mode 100644 index 449c767e..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/If.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfAnd.java b/test/codegen/src/java/com/amd/aparapi/test/IfAnd.java deleted file mode 100644 index c891f00c..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfAnd.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfAndAnd.java b/test/codegen/src/java/com/amd/aparapi/test/IfAndAnd.java deleted file mode 100644 index 344c07ce..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfAndAnd.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfAndAndAnd.java b/test/codegen/src/java/com/amd/aparapi/test/IfAndAndAnd.java deleted file mode 100644 index 34f8028e..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfAndAndAnd.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfAndOrAnd.java b/test/codegen/src/java/com/amd/aparapi/test/IfAndOrAnd.java deleted file mode 100644 index a7044f15..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfAndOrAnd.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfBooleanAndAndAnd.java b/test/codegen/src/java/com/amd/aparapi/test/IfBooleanAndAndAnd.java deleted file mode 100644 index 5bd5a8f6..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfBooleanAndAndAnd.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfBooleanAndAndOr.java b/test/codegen/src/java/com/amd/aparapi/test/IfBooleanAndAndOr.java deleted file mode 100644 index 39e7f3c9..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfBooleanAndAndOr.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfBooleanAndOrAnd.java b/test/codegen/src/java/com/amd/aparapi/test/IfBooleanAndOrAnd.java deleted file mode 100644 index f8a55a25..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfBooleanAndOrAnd.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfBooleanAndOrOr.java b/test/codegen/src/java/com/amd/aparapi/test/IfBooleanAndOrOr.java deleted file mode 100644 index b829a188..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfBooleanAndOrOr.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfBooleanOrAndAnd.java b/test/codegen/src/java/com/amd/aparapi/test/IfBooleanOrAndAnd.java deleted file mode 100644 index aba3cc26..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfBooleanOrAndAnd.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfBooleanOrAndOr.java b/test/codegen/src/java/com/amd/aparapi/test/IfBooleanOrAndOr.java deleted file mode 100644 index cebff431..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfBooleanOrAndOr.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfBooleanOrOrAnd.java b/test/codegen/src/java/com/amd/aparapi/test/IfBooleanOrOrAnd.java deleted file mode 100644 index b180f17a..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfBooleanOrOrAnd.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfBooleanOrOrOr.java b/test/codegen/src/java/com/amd/aparapi/test/IfBooleanOrOrOr.java deleted file mode 100644 index 8d18b789..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfBooleanOrOrOr.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfElse.java b/test/codegen/src/java/com/amd/aparapi/test/IfElse.java deleted file mode 100644 index 773a9d36..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfElse.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfElseAnd.java b/test/codegen/src/java/com/amd/aparapi/test/IfElseAnd.java deleted file mode 100644 index e089c0d5..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfElseAnd.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfElseAndAndAnd.java b/test/codegen/src/java/com/amd/aparapi/test/IfElseAndAndAnd.java deleted file mode 100644 index 4eac6d87..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfElseAndAndAnd.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfElseIfElseIfElse.java b/test/codegen/src/java/com/amd/aparapi/test/IfElseIfElseIfElse.java deleted file mode 100644 index a96015da..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfElseIfElseIfElse.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfElseNot__OrOr_And_.java b/test/codegen/src/java/com/amd/aparapi/test/IfElseNot__OrOr_And_.java deleted file mode 100644 index 0289da06..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfElseNot__OrOr_And_.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfElseOrOrAnd.java b/test/codegen/src/java/com/amd/aparapi/test/IfElseOrOrAnd.java deleted file mode 100644 index dbf8cbac..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfElseOrOrAnd.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfElseOrOrOr.java b/test/codegen/src/java/com/amd/aparapi/test/IfElseOrOrOr.java deleted file mode 100644 index 558a193d..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfElseOrOrOr.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfElse_And_Or_And.java b/test/codegen/src/java/com/amd/aparapi/test/IfElse_And_Or_And.java deleted file mode 100644 index 891e1e5c..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfElse_And_Or_And.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfElse_OrOr_And.java b/test/codegen/src/java/com/amd/aparapi/test/IfElse_OrOr_And.java deleted file mode 100644 index 42c5f442..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfElse_OrOr_And.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfElse_Or_And_Or.java b/test/codegen/src/java/com/amd/aparapi/test/IfElse_Or_And_Or.java deleted file mode 100644 index 8a522c5b..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfElse_Or_And_Or.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfOr.java b/test/codegen/src/java/com/amd/aparapi/test/IfOr.java deleted file mode 100644 index 3f26971b..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfOr.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfOrAndOr.java b/test/codegen/src/java/com/amd/aparapi/test/IfOrAndOr.java deleted file mode 100644 index 9b8408c7..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfOrAndOr.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfOrOr.java b/test/codegen/src/java/com/amd/aparapi/test/IfOrOr.java deleted file mode 100644 index f4f447cd..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfOrOr.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfOrOrAnd.java b/test/codegen/src/java/com/amd/aparapi/test/IfOrOrAnd.java deleted file mode 100644 index 32ce782c..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfOrOrAnd.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IfOrOrOr.java b/test/codegen/src/java/com/amd/aparapi/test/IfOrOrOr.java deleted file mode 100644 index 3f6f051a..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IfOrOrOr.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/If_IfElseIfElseElse_Else.java b/test/codegen/src/java/com/amd/aparapi/test/If_IfElseIfElseElse_Else.java deleted file mode 100644 index e778c809..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/If_IfElseIfElseElse_Else.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/If_IfElse_Else.java b/test/codegen/src/java/com/amd/aparapi/test/If_IfElse_Else.java deleted file mode 100644 index c3b7acd0..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/If_IfElse_Else.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/If_IfElse_Else_IfElse_.java b/test/codegen/src/java/com/amd/aparapi/test/If_IfElse_Else_IfElse_.java deleted file mode 100644 index 5c0ff1ad..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/If_IfElse_Else_IfElse_.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/If_If_Else.java b/test/codegen/src/java/com/amd/aparapi/test/If_If_Else.java deleted file mode 100644 index 937fdf61..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/If_If_Else.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/If_If_Else2.java b/test/codegen/src/java/com/amd/aparapi/test/If_If_Else2.java deleted file mode 100644 index 3576d6da..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/If_If_Else2.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/If_If_Else_If_.java b/test/codegen/src/java/com/amd/aparapi/test/If_If_Else_If_.java deleted file mode 100644 index adee7b9c..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/If_If_Else_If_.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/If_OrOr_And.java b/test/codegen/src/java/com/amd/aparapi/test/If_OrOr_And.java deleted file mode 100644 index 0df343f7..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/If_OrOr_And.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/If_While_Else.java b/test/codegen/src/java/com/amd/aparapi/test/If_While_Else.java deleted file mode 100644 index 56084799..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/If_While_Else.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/If_While_Else_While.java b/test/codegen/src/java/com/amd/aparapi/test/If_While_Else_While.java deleted file mode 100644 index 368533d4..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/If_While_Else_While.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ImplementsInterface.java b/test/codegen/src/java/com/amd/aparapi/test/ImplementsInterface.java deleted file mode 100644 index 8905b303..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ImplementsInterface.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.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/test/codegen/src/java/com/amd/aparapi/test/IncArrayArgContent.java b/test/codegen/src/java/com/amd/aparapi/test/IncArrayArgContent.java deleted file mode 100644 index 2794b344..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IncArrayArgContent.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/IncField.java b/test/codegen/src/java/com/amd/aparapi/test/IncField.java deleted file mode 100644 index 8f4a4e11..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IncField.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.amd.aparapi.test; - -public class IncField{ - int field = 1024; - - public void run() { - field++; - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/IndirectRecursion.java b/test/codegen/src/java/com/amd/aparapi/test/IndirectRecursion.java deleted file mode 100644 index 61a2fd61..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/IndirectRecursion.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class IndirectRecursion extends Kernel{ - - 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); - } - - int intout[] = new int[1]; - -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/Interface.java b/test/codegen/src/java/com/amd/aparapi/test/Interface.java deleted file mode 100644 index ee242847..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/Interface.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.amd.aparapi.test; - -public class Interface{ - - public interface Operator{ - public double operate(double d); - } - - public class SimpleAdder implements Operator{ - public double operate(double d) { - return d + 1.0; - } - } - - public void run() { - out[0] = sa.operate(0.0); - } - - double out[] = new double[1]; - - Operator sa = new SimpleAdder(); -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/LongCompare.java b/test/codegen/src/java/com/amd/aparapi/test/LongCompare.java deleted file mode 100644 index 7466da31..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/LongCompare.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.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/test/codegen/src/java/com/amd/aparapi/test/LongCompares.java b/test/codegen/src/java/com/amd/aparapi/test/LongCompares.java deleted file mode 100644 index d9d5c2bd..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/LongCompares.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/Loops.java b/test/codegen/src/java/com/amd/aparapi/test/Loops.java deleted file mode 100644 index 02bc06bb..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/Loops.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/MathAbs.java b/test/codegen/src/java/com/amd/aparapi/test/MathAbs.java deleted file mode 100644 index 7a45f739..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/MathAbs.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.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/test/codegen/src/java/com/amd/aparapi/test/MathDegRad.java b/test/codegen/src/java/com/amd/aparapi/test/MathDegRad.java deleted file mode 100644 index 4871a2de..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/MathDegRad.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.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/test/codegen/src/java/com/amd/aparapi/test/MathFallThru.java b/test/codegen/src/java/com/amd/aparapi/test/MathFallThru.java deleted file mode 100644 index 931b530a..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/MathFallThru.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class MathFallThru extends Kernel{ - - 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; - } - - long longout[] = new long[1]; - - int intout[] = new int[1]; -} -/**{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/test/codegen/src/java/com/amd/aparapi/test/MathMax.java b/test/codegen/src/java/com/amd/aparapi/test/MathMax.java deleted file mode 100644 index 29e47ee7..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/MathMax.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.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/test/codegen/src/java/com/amd/aparapi/test/MathMin.java b/test/codegen/src/java/com/amd/aparapi/test/MathMin.java deleted file mode 100644 index 33db2291..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/MathMin.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.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/test/codegen/src/java/com/amd/aparapi/test/MathRemainder.java b/test/codegen/src/java/com/amd/aparapi/test/MathRemainder.java deleted file mode 100644 index 0804174e..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/MathRemainder.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.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/test/codegen/src/java/com/amd/aparapi/test/MultiContinue.java b/test/codegen/src/java/com/amd/aparapi/test/MultiContinue.java deleted file mode 100644 index dfb00d14..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/MultiContinue.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/MultipleAssign.java b/test/codegen/src/java/com/amd/aparapi/test/MultipleAssign.java deleted file mode 100644 index 54e762ec..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/MultipleAssign.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/MultipleAssignExpr.java b/test/codegen/src/java/com/amd/aparapi/test/MultipleAssignExpr.java deleted file mode 100644 index 758ebfc0..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/MultipleAssignExpr.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/NaN.java b/test/codegen/src/java/com/amd/aparapi/test/NaN.java deleted file mode 100644 index 19bd7833..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/NaN.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.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/test/codegen/src/java/com/amd/aparapi/test/NewLocalArray.java b/test/codegen/src/java/com/amd/aparapi/test/NewLocalArray.java deleted file mode 100644 index d8567efa..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/NewLocalArray.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/NonNullCheck.java b/test/codegen/src/java/com/amd/aparapi/test/NonNullCheck.java deleted file mode 100644 index 5c6580fe..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/NonNullCheck.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/NullCheck.java b/test/codegen/src/java/com/amd/aparapi/test/NullCheck.java deleted file mode 100644 index 319815a1..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/NullCheck.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayCallHierarchy.java b/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayCallHierarchy.java deleted file mode 100644 index 2cd587ca..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayCallHierarchy.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class ObjectArrayCallHierarchy extends Kernel{ - - final static int size = 16; - - 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(); - } - }; - - 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(); - } -} - -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayCommonSuper.java b/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayCommonSuper.java deleted file mode 100644 index 9fef5b8b..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayCommonSuper.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class ObjectArrayCommonSuper extends Kernel{ - - final static int size = 16; - - 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; - } - }; - - 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(); - } -} - -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberAccess.java b/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberAccess.java deleted file mode 100644 index b721968c..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberAccess.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class ObjectArrayMemberAccess extends Kernel{ - - 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; - } - - }; - - int out[] = new int[2]; - - int something; - - DummyOOA dummy[] = null; - - final int size = 64; - - 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; - } -} - -/**{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/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberBadGetter.java b/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberBadGetter.java deleted file mode 100644 index b2225787..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberBadGetter.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class ObjectArrayMemberBadGetter extends Kernel{ - - final class DummyOOA{ - int mem; - - float floatField; - - float theOtherFloatField; - - public float getFloatField() { - //return floatField; - return theOtherFloatField; - } - - public void setFloatField(float x) { - floatField = x; - } - }; - - DummyOOA dummy[] = null; - - final int size = 64; - - 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); - } -} - -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberBadSetter.java b/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberBadSetter.java deleted file mode 100644 index b8da86a9..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberBadSetter.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class ObjectArrayMemberBadSetter extends Kernel{ - - final class DummyOOA{ - int mem; - - float floatField; - - float theOtherFloatField; - - public float getFloatField() { - return floatField; - } - - public void setFloatField(float x) { - theOtherFloatField = x; - } - }; - - DummyOOA dummy[] = null; - - final int size = 64; - - 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); - } -} - -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberCall.java b/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberCall.java deleted file mode 100644 index ef558902..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberCall.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class ObjectArrayMemberCall extends Kernel{ - - 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(); - } - }; - - int out[] = new int[2]; - - int something; - - DummyOOA dummy[] = null; - - final int size = 64; - - 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); - } -} - -/**{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/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberGetterSetter.java b/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberGetterSetter.java deleted file mode 100644 index b48fdd42..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberGetterSetter.java +++ /dev/null @@ -1,223 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.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{ - - int out[] = new int[2]; - - int something; - - DummyOOA dummy[] = null; - - TheOtherOne other[] = null; - - final int size = 64; - - 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/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberHierarchy.java b/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberHierarchy.java deleted file mode 100644 index b8cb163b..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberHierarchy.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class ObjectArrayMemberHierarchy extends Kernel{ - - final static int size = 16; - - 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; - } - }; - - 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); - } -} - -/**{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/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberNotFinal.java b/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberNotFinal.java deleted file mode 100644 index bcc0621d..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ObjectArrayMemberNotFinal.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.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{ - - int out[] = new int[2]; - - int something; - - DummyOOANF dummy[] = null; - - final int size = 64; - - 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/test/codegen/src/java/com/amd/aparapi/test/ObjectRefCopy.java b/test/codegen/src/java/com/amd/aparapi/test/ObjectRefCopy.java deleted file mode 100644 index 1163b091..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ObjectRefCopy.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class ObjectRefCopy extends Kernel{ - - final static class DummyOOA{ - int mem; - - float floatField; - }; - - final int size = 8; - - DummyOOA dummy[] = new DummyOOA[size]; - - public void run() { - int myId = getGlobalId(); - dummy[myId] = dummy[myId + 1]; - } -} - -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ObjectWithinObject.java b/test/codegen/src/java/com/amd/aparapi/test/ObjectWithinObject.java deleted file mode 100644 index e38658b9..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ObjectWithinObject.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class ObjectWithinObject extends Kernel{ - - final static class DummyOOA{ - int mem; - - float floatField; - - DummyOOA next; - - }; - - final int size = 8; - - DummyOOA dummy[] = new DummyOOA[size]; - - public void run() { - int myId = getGlobalId(); - dummy[myId].mem = dummy[myId].next.mem + 4; - } -} - -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/OrAndOrPrecedence.java b/test/codegen/src/java/com/amd/aparapi/test/OrAndOrPrecedence.java deleted file mode 100644 index 4160bdcc..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/OrAndOrPrecedence.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/OverloadMethod.java b/test/codegen/src/java/com/amd/aparapi/test/OverloadMethod.java deleted file mode 100644 index d14e275f..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/OverloadMethod.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class OverloadMethod extends Kernel{ - 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); - } - - int out[] = new int[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_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/test/codegen/src/java/com/amd/aparapi/test/OverriddenKernelField.java b/test/codegen/src/java/com/amd/aparapi/test/OverriddenKernelField.java deleted file mode 100644 index 3ffec7da..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/OverriddenKernelField.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.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{ - public void run() { - out[0] = foo(2); - } - - int foo(int n) { - return super.foo(n + 1); - } - - int out[] = new int[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/test/codegen/src/java/com/amd/aparapi/test/PlayPen.java b/test/codegen/src/java/com/amd/aparapi/test/PlayPen.java deleted file mode 100644 index bf17b937..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PlayPen.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PostDecArrayItem.java b/test/codegen/src/java/com/amd/aparapi/test/PostDecArrayItem.java deleted file mode 100644 index a1414457..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PostDecArrayItem.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PostDecByte.java b/test/codegen/src/java/com/amd/aparapi/test/PostDecByte.java deleted file mode 100644 index 078cd388..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PostDecByte.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PostDecLocal.java b/test/codegen/src/java/com/amd/aparapi/test/PostDecLocal.java deleted file mode 100644 index 4e71f5a1..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PostDecLocal.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PostDecPostInc.java b/test/codegen/src/java/com/amd/aparapi/test/PostDecPostInc.java deleted file mode 100644 index f66a80a6..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PostDecPostInc.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PostIncArrayIndexAndElement.java b/test/codegen/src/java/com/amd/aparapi/test/PostIncArrayIndexAndElement.java deleted file mode 100644 index 4d589226..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PostIncArrayIndexAndElement.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PostIncArrayItem.java b/test/codegen/src/java/com/amd/aparapi/test/PostIncArrayItem.java deleted file mode 100644 index 7bb1abe8..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PostIncArrayItem.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PostIncArrayItemAsParameter.java b/test/codegen/src/java/com/amd/aparapi/test/PostIncArrayItemAsParameter.java deleted file mode 100644 index 53473341..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PostIncArrayItemAsParameter.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.amd.aparapi.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 actuallyDoIt(int a) { - return 1; - } - - int y = 2; - - 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/test/codegen/src/java/com/amd/aparapi/test/PostIncArrayItemFieldIndex.java b/test/codegen/src/java/com/amd/aparapi/test/PostIncArrayItemFieldIndex.java deleted file mode 100644 index 37ed2bdf..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PostIncArrayItemFieldIndex.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PostIncByte.java b/test/codegen/src/java/com/amd/aparapi/test/PostIncByte.java deleted file mode 100644 index 130e2457..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PostIncByte.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PostIncByteField.java b/test/codegen/src/java/com/amd/aparapi/test/PostIncByteField.java deleted file mode 100644 index 729256f1..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PostIncByteField.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PostIncInt.java b/test/codegen/src/java/com/amd/aparapi/test/PostIncInt.java deleted file mode 100644 index bff8fc0e..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PostIncInt.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PostIncIntField.java b/test/codegen/src/java/com/amd/aparapi/test/PostIncIntField.java deleted file mode 100644 index 80aaaf4d..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PostIncIntField.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.amd.aparapi.test; - -public class PostIncIntField{ - - int _y = 2; - - int incInt(int a) { - return a++; - } - - public void run() { - - incInt(_y++); - - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/PostIncLocal.java b/test/codegen/src/java/com/amd/aparapi/test/PostIncLocal.java deleted file mode 100644 index 9c3c884c..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PostIncLocal.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PostIncLocalStandalone.java b/test/codegen/src/java/com/amd/aparapi/test/PostIncLocalStandalone.java deleted file mode 100644 index 3a9ac0ca..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PostIncLocalStandalone.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PostIncLocalTwice.java b/test/codegen/src/java/com/amd/aparapi/test/PostIncLocalTwice.java deleted file mode 100644 index 3b3beb6a..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PostIncLocalTwice.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PreDecArrayIndexAndElement.java b/test/codegen/src/java/com/amd/aparapi/test/PreDecArrayIndexAndElement.java deleted file mode 100644 index 827d5b3b..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PreDecArrayIndexAndElement.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PreDecArrayItem.java b/test/codegen/src/java/com/amd/aparapi/test/PreDecArrayItem.java deleted file mode 100644 index 7bd88923..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PreDecArrayItem.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PreDecPostInc.java b/test/codegen/src/java/com/amd/aparapi/test/PreDecPostInc.java deleted file mode 100644 index 94cf3dc1..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PreDecPostInc.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PreIncArrayIndexAndElement.java b/test/codegen/src/java/com/amd/aparapi/test/PreIncArrayIndexAndElement.java deleted file mode 100644 index 6438df47..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PreIncArrayIndexAndElement.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PreIncArrayItem.java b/test/codegen/src/java/com/amd/aparapi/test/PreIncArrayItem.java deleted file mode 100644 index 0f1c7d8c..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PreIncArrayItem.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PreIncByte.java b/test/codegen/src/java/com/amd/aparapi/test/PreIncByte.java deleted file mode 100644 index 051cc9f4..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PreIncByte.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PreIncByteField.java b/test/codegen/src/java/com/amd/aparapi/test/PreIncByteField.java deleted file mode 100644 index eefbf749..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PreIncByteField.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PreIncInt.java b/test/codegen/src/java/com/amd/aparapi/test/PreIncInt.java deleted file mode 100644 index 38e732f7..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PreIncInt.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PreIncIntField.java b/test/codegen/src/java/com/amd/aparapi/test/PreIncIntField.java deleted file mode 100644 index 70914b09..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PreIncIntField.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.amd.aparapi.test; - -public class PreIncIntField{ - - int y = 2; - - int preIncInt(int _a) { - return ++_a; - } - - public void run() { - - preIncInt(++y); - - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/PreIncLocal.java b/test/codegen/src/java/com/amd/aparapi/test/PreIncLocal.java deleted file mode 100644 index 80cc0377..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PreIncLocal.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PreIncLocalStandalone.java b/test/codegen/src/java/com/amd/aparapi/test/PreIncLocalStandalone.java deleted file mode 100644 index fee16119..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PreIncLocalStandalone.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/PreIncLocalTwice.java b/test/codegen/src/java/com/amd/aparapi/test/PreIncLocalTwice.java deleted file mode 100644 index eb815bdb..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/PreIncLocalTwice.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ReturnBooleanNewArray.java b/test/codegen/src/java/com/amd/aparapi/test/ReturnBooleanNewArray.java deleted file mode 100644 index 3c33a06d..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ReturnBooleanNewArray.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.amd.aparapi.test; - -public class ReturnBooleanNewArray{ - - boolean[] returnBooleanNewArray() { - - return new boolean[1024]; - } - - public void run() { - returnBooleanNewArray(); - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ReturnBooleanVarArray.java b/test/codegen/src/java/com/amd/aparapi/test/ReturnBooleanVarArray.java deleted file mode 100644 index 5a5572e5..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ReturnBooleanVarArray.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.amd.aparapi.test; - -public class ReturnBooleanVarArray{ - - boolean[] returnBooleanVarArray() { - - boolean[] ba = new boolean[1024]; - - return ba; - } - - public void run() { - returnBooleanVarArray(); - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ReturnByteArrayNew.java b/test/codegen/src/java/com/amd/aparapi/test/ReturnByteArrayNew.java deleted file mode 100644 index ae4bf395..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ReturnByteArrayNew.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.amd.aparapi.test; - -public class ReturnByteArrayNew{ - - byte[] returnByteArrayNew() { - return new byte[1024]; - } - - public void run() { - returnByteArrayNew(); - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ReturnByteArrayVar.java b/test/codegen/src/java/com/amd/aparapi/test/ReturnByteArrayVar.java deleted file mode 100644 index d8abe298..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ReturnByteArrayVar.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.amd.aparapi.test; - -public class ReturnByteArrayVar{ - - byte[] returnByteArrayVar() { - byte[] bytes = new byte[1024]; - return bytes; - } - - public void run() { - - returnByteArrayVar(); - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ReturnDoubleArrayNew.java b/test/codegen/src/java/com/amd/aparapi/test/ReturnDoubleArrayNew.java deleted file mode 100644 index a330d441..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ReturnDoubleArrayNew.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.amd.aparapi.test; - -public class ReturnDoubleArrayNew{ - - double[] returnDoubleArrayNew() { - return new double[1024]; - } - - public void run() { - returnDoubleArrayNew(); - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ReturnDoubleArrayVar.java b/test/codegen/src/java/com/amd/aparapi/test/ReturnDoubleArrayVar.java deleted file mode 100644 index a3d0f1b3..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ReturnDoubleArrayVar.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.amd.aparapi.test; - -public class ReturnDoubleArrayVar{ - - double[] returnDoubleArrayVar() { - double[] doubles = new double[1024]; - return doubles; - } - - public void run() { - - returnDoubleArrayVar(); - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ReturnFloatArrayNew.java b/test/codegen/src/java/com/amd/aparapi/test/ReturnFloatArrayNew.java deleted file mode 100644 index caca36a2..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ReturnFloatArrayNew.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.amd.aparapi.test; - -public class ReturnFloatArrayNew{ - - float[] returnFloatArrayNew() { - return new float[1024]; - } - - public void run() { - returnFloatArrayNew(); - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ReturnFloatArrayVar.java b/test/codegen/src/java/com/amd/aparapi/test/ReturnFloatArrayVar.java deleted file mode 100644 index 5e973244..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ReturnFloatArrayVar.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.amd.aparapi.test; - -public class ReturnFloatArrayVar{ - - float[] returnFloatArrayVar() { - float[] floats = new float[1024]; - return floats; - } - - public void run() { - - returnFloatArrayVar(); - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ReturnIntArrayNew.java b/test/codegen/src/java/com/amd/aparapi/test/ReturnIntArrayNew.java deleted file mode 100644 index 6ca7e75c..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ReturnIntArrayNew.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.amd.aparapi.test; - -public class ReturnIntArrayNew{ - - int[] returnIntArrayNew() { - return new int[1024]; - } - - public void run() { - returnIntArrayNew(); - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ReturnIntArrayVar.java b/test/codegen/src/java/com/amd/aparapi/test/ReturnIntArrayVar.java deleted file mode 100644 index b9e5d7da..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ReturnIntArrayVar.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.amd.aparapi.test; - -public class ReturnIntArrayVar{ - - int[] returnIntArrayVar() { - int[] ints = new int[1024]; - return ints; - } - - public void run() { - - returnIntArrayVar(); - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ReturnLongArrayNew.java b/test/codegen/src/java/com/amd/aparapi/test/ReturnLongArrayNew.java deleted file mode 100644 index 72e108d2..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ReturnLongArrayNew.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.amd.aparapi.test; - -public class ReturnLongArrayNew{ - - long[] returnLongArrayNew() { - return new long[1024]; - } - - public void run() { - returnLongArrayNew(); - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ReturnLongArrayVar.java b/test/codegen/src/java/com/amd/aparapi/test/ReturnLongArrayVar.java deleted file mode 100644 index b5fa36c2..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ReturnLongArrayVar.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.amd.aparapi.test; - -public class ReturnLongArrayVar{ - - long[] returnLongArrayVar() { - long[] longs = new long[1024]; - return longs; - } - - public void run() { - - returnLongArrayVar(); - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ReturnPostIncInt.java b/test/codegen/src/java/com/amd/aparapi/test/ReturnPostIncInt.java deleted file mode 100644 index c06d6ac8..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ReturnPostIncInt.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ReturnPreIncInt.java b/test/codegen/src/java/com/amd/aparapi/test/ReturnPreIncInt.java deleted file mode 100644 index 9f3da31b..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ReturnPreIncInt.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/ReturnShortArrayNew.java b/test/codegen/src/java/com/amd/aparapi/test/ReturnShortArrayNew.java deleted file mode 100644 index 20f33bdd..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ReturnShortArrayNew.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.amd.aparapi.test; - -public class ReturnShortArrayNew{ - - short[] returnShortArrayNew() { - return new short[1024]; - } - - public void run() { - returnShortArrayNew(); - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/ReturnShortArrayVar.java b/test/codegen/src/java/com/amd/aparapi/test/ReturnShortArrayVar.java deleted file mode 100644 index dfa51543..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/ReturnShortArrayVar.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.amd.aparapi.test; - -public class ReturnShortArrayVar{ - - short[] returnShortArrayVar() { - short[] shorts = new short[1024]; - return shorts; - } - - public void run() { - - returnShortArrayVar(); - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/RightShifts.java b/test/codegen/src/java/com/amd/aparapi/test/RightShifts.java deleted file mode 100644 index 34e726d8..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/RightShifts.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.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/test/codegen/src/java/com/amd/aparapi/test/Sequence.java b/test/codegen/src/java/com/amd/aparapi/test/Sequence.java deleted file mode 100644 index 1862e23d..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/Sequence.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/StaticFieldStore.java b/test/codegen/src/java/com/amd/aparapi/test/StaticFieldStore.java deleted file mode 100644 index cdc733d7..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/StaticFieldStore.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.amd.aparapi.test; - -public class StaticFieldStore{ - int[] ints = new int[1024]; - - static int foo = 6; - - public void run() { - foo = ints[0]; - } -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/StaticMethodCall.java b/test/codegen/src/java/com/amd/aparapi/test/StaticMethodCall.java deleted file mode 100644 index ffea520c..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/StaticMethodCall.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class StaticMethodCall extends Kernel{ - public static int add(int i, int j) { - return i + j; - } - - public void run() { - out[0] = add(1, 2); - } - - int out[] = new int[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_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/test/codegen/src/java/com/amd/aparapi/test/SynchronizedMethods.java b/test/codegen/src/java/com/amd/aparapi/test/SynchronizedMethods.java deleted file mode 100644 index 214574d3..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/SynchronizedMethods.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/Ternary.java b/test/codegen/src/java/com/amd/aparapi/test/Ternary.java deleted file mode 100644 index d486a94e..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/Ternary.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/TernaryAnd.java b/test/codegen/src/java/com/amd/aparapi/test/TernaryAnd.java deleted file mode 100644 index a214b7c0..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/TernaryAnd.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/TernaryAndOr.java b/test/codegen/src/java/com/amd/aparapi/test/TernaryAndOr.java deleted file mode 100644 index 4a1674ee..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/TernaryAndOr.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/TernaryNested.java b/test/codegen/src/java/com/amd/aparapi/test/TernaryNested.java deleted file mode 100644 index 7035c0be..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/TernaryNested.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/TernaryOr.java b/test/codegen/src/java/com/amd/aparapi/test/TernaryOr.java deleted file mode 100644 index db2ba4f1..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/TernaryOr.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/TwoForLoops.java b/test/codegen/src/java/com/amd/aparapi/test/TwoForLoops.java deleted file mode 100644 index 5297dc7d..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/TwoForLoops.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class TwoForLoops extends Kernel{ - 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]; - } - } - - final int size = 100; - - int a[] = new int[size]; - -} -/**{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/test/codegen/src/java/com/amd/aparapi/test/UnrelatedIfElsesWithCommonEndByte.java b/test/codegen/src/java/com/amd/aparapi/test/UnrelatedIfElsesWithCommonEndByte.java deleted file mode 100644 index 0170efaf..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/UnrelatedIfElsesWithCommonEndByte.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/UnrelatedIfsWithCommonEndByte.java b/test/codegen/src/java/com/amd/aparapi/test/UnrelatedIfsWithCommonEndByte.java deleted file mode 100644 index da23e2ab..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/UnrelatedIfsWithCommonEndByte.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/UnrelatedNestedIfElses.java b/test/codegen/src/java/com/amd/aparapi/test/UnrelatedNestedIfElses.java deleted file mode 100644 index f71032e5..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/UnrelatedNestedIfElses.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/UseObject.java b/test/codegen/src/java/com/amd/aparapi/test/UseObject.java deleted file mode 100644 index 8af70992..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/UseObject.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class UseObject extends Kernel{ - class Dummy{ - public int n; - }; - - Dummy dummy = new Dummy(); - - public void run() { - out[0] = dummy.n; - out[1] = plainInt; - } - - int out[] = new int[2]; - - int plainInt = -1; - -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/UseObjectArrayLength.java b/test/codegen/src/java/com/amd/aparapi/test/UseObjectArrayLength.java deleted file mode 100644 index 921951de..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/UseObjectArrayLength.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.aparapi.Kernel; - -public class UseObjectArrayLength extends Kernel{ - final class Dummy{ - public int n; - }; - - int out[] = new int[2]; - - Dummy dummy[] = new Dummy[10]; - - public void run() { - out[0] = dummy.length; - } -} -/**{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/test/codegen/src/java/com/amd/aparapi/test/UsesArrayLength.java b/test/codegen/src/java/com/amd/aparapi/test/UsesArrayLength.java deleted file mode 100644 index 1d8f0fcc..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/UsesArrayLength.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.amd.aparapi.test; - -import com.amd.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/test/codegen/src/java/com/amd/aparapi/test/UsesNew.java b/test/codegen/src/java/com/amd/aparapi/test/UsesNew.java deleted file mode 100644 index 527bb2cf..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/UsesNew.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/UsesThrow.java b/test/codegen/src/java/com/amd/aparapi/test/UsesThrow.java deleted file mode 100644 index d9d490b3..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/UsesThrow.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/VarargsForEach.java b/test/codegen/src/java/com/amd/aparapi/test/VarargsForEach.java deleted file mode 100644 index edfc24c8..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/VarargsForEach.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.amd.aparapi.test; - -public class VarargsForEach{ - 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); - } - - int out[] = new int[1]; - -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/VarargsSimple.java b/test/codegen/src/java/com/amd/aparapi/test/VarargsSimple.java deleted file mode 100644 index 6ee4864c..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/VarargsSimple.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.amd.aparapi.test; - -public class VarargsSimple{ - 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); - } - - int out[] = new int[1]; - -} -/**{Throws{ClassParseException}Throws}**/ diff --git a/test/codegen/src/java/com/amd/aparapi/test/While.java b/test/codegen/src/java/com/amd/aparapi/test/While.java deleted file mode 100644 index c76b523d..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/While.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/WhileAndMandel.java b/test/codegen/src/java/com/amd/aparapi/test/WhileAndMandel.java deleted file mode 100644 index 4671173d..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/WhileAndMandel.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.amd.aparapi.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 && itermaxIterations; 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/test/codegen/src/java/com/amd/aparapi/test/WhileEmptyLoop.java b/test/codegen/src/java/com/amd/aparapi/test/WhileEmptyLoop.java deleted file mode 100644 index f4f65684..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/WhileEmptyLoop.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/WhileFloatCompound.java b/test/codegen/src/java/com/amd/aparapi/test/WhileFloatCompound.java deleted file mode 100644 index 9a125745..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/WhileFloatCompound.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/WhileIf.java b/test/codegen/src/java/com/amd/aparapi/test/WhileIf.java deleted file mode 100644 index fe73116a..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/WhileIf.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/WhileIfElse.java b/test/codegen/src/java/com/amd/aparapi/test/WhileIfElse.java deleted file mode 100644 index cf84769f..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/WhileIfElse.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/WhileWithoutMutator.java b/test/codegen/src/java/com/amd/aparapi/test/WhileWithoutMutator.java deleted file mode 100644 index 90d250b5..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/WhileWithoutMutator.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/While_If_IfElseElse.java b/test/codegen/src/java/com/amd/aparapi/test/While_If_IfElseElse.java deleted file mode 100644 index d1789dea..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/While_If_IfElseElse.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/WideInc.java b/test/codegen/src/java/com/amd/aparapi/test/WideInc.java deleted file mode 100644 index 971ea7f5..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/WideInc.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.amd.aparapi.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/test/codegen/src/java/com/amd/aparapi/test/WideLoad.java b/test/codegen/src/java/com/amd/aparapi/test/WideLoad.java deleted file mode 100644 index ac88e358..00000000 --- a/test/codegen/src/java/com/amd/aparapi/test/WideLoad.java +++ /dev/null @@ -1,543 +0,0 @@ -package com.amd.aparapi.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/test/runtime/.classpath b/test/runtime/.classpath deleted file mode 100644 index 58949403..00000000 --- a/test/runtime/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/test/runtime/.project b/test/runtime/.project deleted file mode 100644 index 0b3d5824..00000000 --- a/test/runtime/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - test-runtime - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/test/runtime/build.xml b/test/runtime/build.xml deleted file mode 100644 index b52d42ac..00000000 --- a/test/runtime/build.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - OS Name: ${os.name} - OS Version: ${os.version} - OS Arch: ${os.arch} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/runtime/src/java/com/amd/aparapi/test/runtime/BufferTransfer.java b/test/runtime/src/java/com/amd/aparapi/test/runtime/BufferTransfer.java deleted file mode 100644 index 73f061a9..00000000 --- a/test/runtime/src/java/com/amd/aparapi/test/runtime/BufferTransfer.java +++ /dev/null @@ -1,240 +0,0 @@ -package com.amd.aparapi.test.runtime; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.Arrays; - -import org.junit.BeforeClass; -import org.junit.Test; - -import com.amd.aparapi.Device; -import com.amd.aparapi.Kernel; -import com.amd.aparapi.OpenCLDevice; -import com.amd.aparapi.Range; - -public class BufferTransfer{ - - static OpenCLDevice openCLDevice = null; - - @BeforeClass public static void setUpBeforeClass() throws Exception { - - Device device = Device.best(); - if (device == null || !(device instanceof OpenCLDevice)) { - fail("no opencl device!"); - } - openCLDevice = (OpenCLDevice) device; - } - - public static class InOutKernel extends Kernel{ - - int[] in; - - int[] out; - - @Override public void run() { - int gid = getGlobalId(0); - in[gid] = out[gid]; - - } - - } - - @Test public void inOutOnce() { - - final int SIZE = 1024; - final InOutKernel kernel = new InOutKernel(); - final Range range = openCLDevice.createRange(SIZE); - - kernel.in = new int[SIZE]; - kernel.out = new int[SIZE]; - - Util.fill(kernel.in, new Util.Filler(){ - public void fill(int[] array, int index) { - array[index] = index; - } - }); - kernel.execute(range); - - assertTrue("in == out", Util.same(kernel.in, kernel.out)); - - } - - public static class AddKernel extends Kernel{ - - int[] values; - - int[] result; - - @Override public void run() { - int gid = getGlobalId(0); - result[gid] = result[gid] + values[gid]; - - } - - } - - @Test public void auto() { - - final int SIZE = 1024; - final AddKernel kernel = new AddKernel(); - final Range range = openCLDevice.createRange(SIZE); - - kernel.values = new int[SIZE]; - kernel.result = new int[SIZE]; - Util.zero(kernel.result); - Util.fill(kernel.values, new Util.Filler(){ - public void fill(int[] array, int index) { - array[index] = index; - } - }); - - int[] expectedResult = Arrays.copyOf(kernel.result, kernel.result.length); - - Util.apply(expectedResult, kernel.values, new Util.Operator(){ - - @Override public void apply(int[] lhs, int[] rhs, int index) { - lhs[index] = lhs[index] + rhs[index]; - - } - }); - kernel.execute(range); - - assertTrue("expectedResult == result", Util.same(expectedResult, kernel.result)); - - kernel.execute(range); - - Util.apply(expectedResult, kernel.values, new Util.Operator(){ - - @Override public void apply(int[] lhs, int[] rhs, int index) { - lhs[index] = lhs[index] + rhs[index]; - - } - }); - assertTrue("expectedResult == result", Util.same(expectedResult, kernel.result)); - - Util.zero(kernel.values); - kernel.execute(range); - assertTrue("expectedResult == result", Util.same(expectedResult, kernel.result)); - - } - - @Test public void explicit() { - - final int SIZE = 1024; - final AddKernel kernel = new AddKernel(); - kernel.setExplicit(true); - final Range range = openCLDevice.createRange(SIZE); - - kernel.values = new int[SIZE]; - kernel.result = new int[SIZE]; - Util.zero(kernel.result); - Util.fill(kernel.values, new Util.Filler(){ - public void fill(int[] array, int index) { - array[index] = index; - } - }); - - int[] expectedResult = Arrays.copyOf(kernel.result, kernel.result.length); - - Util.apply(expectedResult, kernel.values, new Util.Operator(){ - - @Override public void apply(int[] lhs, int[] rhs, int index) { - lhs[index] = lhs[index] + rhs[index]; - - } - }); - - kernel.execute(range).get(kernel.result); - - assertTrue("after first explicit add expectedResult == result", Util.same(expectedResult, kernel.result)); - - kernel.execute(range).get(kernel.result); - - Util.apply(expectedResult, kernel.values, new Util.Operator(){ - @Override public void apply(int[] lhs, int[] rhs, int index) { - lhs[index] = lhs[index] + rhs[index]; - - } - }); - assertTrue("after second explicit add expectedResult == result", Util.same(expectedResult, kernel.result)); - - Util.zero(kernel.values); - - kernel.put(kernel.values).execute(range).get(kernel.result); - - assertTrue("after zeroing values and third explici add expectedResult == result", Util.same(expectedResult, kernel.result)); - - Util.zero(kernel.result); - - kernel.put(kernel.result).execute(range).get(kernel.result); - - Util.zero(expectedResult); - - assertTrue("after zeroing values and result and forth explicit add expectedResult == result", - Util.same(expectedResult, kernel.result)); - - } - - private class TestKernel extends Kernel{ - int[] simStep = new int[1]; - - int[] neuronOutputs = new int[3]; - - int[] expected = new int[] { - 3, - 0, - 0, - 0, - 3, - 0, - 0, - 0, - 3, - 0, - 0, - 0, - 3, - 0, - 0, - 0 - }; - - public void step() { - int simSteps = 16; - int[][] log = new int[neuronOutputs.length][simSteps]; - put(neuronOutputs); - for (simStep[0] = 0; simStep[0] < simSteps; simStep[0]++) { - put(simStep).execute(neuronOutputs.length).get(neuronOutputs); - for (int n = 0; n < neuronOutputs.length; n++) - log[n][simStep[0]] = neuronOutputs[n]; - } - System.out.println(getExecutionMode() + (isExplicit() ? ", explicit" : ", auto")); - - for (int n = 0; n < neuronOutputs.length; n++) - System.out.println(Arrays.toString(log[n])); - - assertTrue("log[2] == expected", Util.same(log[2], expected)); - } - - @Override public void run() { - int neuronID = getGlobalId(); - neuronOutputs[neuronID] = (simStep[0] % (neuronID + 2) == 0) ? (neuronID + 1) : 0; - } - } - - @Test public void issue60Explicit() { - - TestKernel kernel = new TestKernel(); - kernel.setExplicit(true); - kernel.step(); - - } - - @Test public void issue60Auto() { - TestKernel kernel = new TestKernel(); - kernel.step(); - - } - -} diff --git a/test/runtime/src/java/com/amd/aparapi/test/runtime/CallStaticFromAnonymousKernel.java b/test/runtime/src/java/com/amd/aparapi/test/runtime/CallStaticFromAnonymousKernel.java deleted file mode 100644 index 3f090dc0..00000000 --- a/test/runtime/src/java/com/amd/aparapi/test/runtime/CallStaticFromAnonymousKernel.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.amd.aparapi.test.runtime; - -import static org.junit.Assert.assertTrue; -import org.junit.Test; -import com.amd.aparapi.Kernel; - -class AnotherClass{ - static public int foo(int i) { - return i + 42; - } -}; - -public class CallStaticFromAnonymousKernel { - - static final int size = 256; - - // This method is a static target in the anonymous - // kernel's containing class - public static int fooBar(int i) { - return i + 20; - } - - @Test public void test() { - final int[] values = new int[size]; - final int[] results = new int[size]; - - for(int i=0; i 0.5; - } - - if (size <= 32) - printArray(k1.input); - - k1.go(); - - if (size <= 32) - printArray(k1.output); - - assertTrue("k1.input == k1.output ", Util.same(k1.output, k1.output)); - - k2.go(); - - if (size <= 32) - printArray(k2.output); - - assertTrue("k1.input == k2.input", Util.same(k1.output, k1.output)); - System.out.println(k1.getExecutionMode()); - } - - private static void printArray(boolean[] a) { - for (int i = 0; i < a.length; i++) { - System.out.print((a[i] ? 1 : 0) + "\t"); - } - System.out.println(); - } - -} diff --git a/test/runtime/src/java/com/amd/aparapi/test/runtime/Issue68.java b/test/runtime/src/java/com/amd/aparapi/test/runtime/Issue68.java deleted file mode 100644 index 31332ccf..00000000 --- a/test/runtime/src/java/com/amd/aparapi/test/runtime/Issue68.java +++ /dev/null @@ -1,225 +0,0 @@ -package com.amd.aparapi.test.runtime; - -import com.amd.aparapi.Kernel; - -abstract class ArrayAccess{ - protected ArrayAccess(int offset, int length) { - this.offset = offset; - this.length = length; - } - - public abstract int[] getIntData(); - - public int getOffset() { - return this.offset; - } - - public int getLength() { - return this.length; - } - - private int offset; - - private int length; -} - -class IntMemoryArrayAccess extends ArrayAccess{ - public IntMemoryArrayAccess(int[] data, int offset, int length) { - super(offset, length); - this.data = data; - } - - public int[] getIntData() { - return this.data; - } - - private int[] data; -} - -public class Issue68{ - // Runnable for calculating the column transforms in parallel - private class ColumnTableFNTRunnable extends Kernel{ - public ColumnTableFNTRunnable(int length, boolean isInverse, ArrayAccess arrayAccess, int[] wTable, int[] permutationTable, - int modulus) { - this.stride = arrayAccess.getLength() / length; - this.length = length; // Transform length - this.isInverse = isInverse; - this.data = arrayAccess.getIntData(); - this.offset = arrayAccess.getOffset(); - this.wTable = wTable; - this.permutationTable = permutationTable; - this.permutationTableLength = (permutationTable == null ? 0 : permutationTable.length); - setModulus(modulus); - } - - public void run() { - if (this.isInverse) { - inverseColumnTableFNT(); - } else { - columnTableFNT(); - } - } - - private void columnTableFNT() { - int nn, istep, mmax, r; - - int offset = this.offset + getGlobalId(); - nn = length; - - if (nn < 2) { - return; - } - - r = 1; - mmax = nn >> 1; - while (mmax > 0) { - istep = mmax << 1; - - // Optimize first step when wr = 1 - - for (int i = offset; i < offset + nn * stride; i += istep * stride) { - int j = i + mmax * stride; - int a = data[i]; - int b = data[j]; - data[i] = modAdd(a, b); - data[j] = modSubtract(a, b); - } - - int t = r; - - for (int m = 1; m < mmax; m++) { - for (int i = offset + m * stride; i < offset + nn * stride; i += istep * stride) { - int j = i + mmax * stride; - int a = data[i]; - int b = data[j]; - data[i] = modAdd(a, b); - data[j] = modMultiply(wTable[t], modSubtract(a, b)); - } - t += r; - } - r <<= 1; - mmax >>= 1; - } - - //if (permutationTable != null) - // { - columnScramble(offset); - // } - } - - private void inverseColumnTableFNT() { - int nn, istep, mmax, r; - - int offset = this.offset + getGlobalId(); - nn = length; - - if (nn < 2) { - return; - } - - // if (permutationTable != null) - // { - columnScramble(offset); - // } - - r = nn; - mmax = 1; - istep = 0; - while (nn > mmax) { - istep = mmax << 1; - r >>= 1; - - // Optimize first step when w = 1 - - for (int i = offset; i < offset + nn * stride; i += istep * stride) { - int j = i + mmax * stride; - int wTemp = data[j]; - data[j] = modSubtract(data[i], wTemp); - data[i] = modAdd(data[i], wTemp); - } - - int t = r; - - for (int m = 1; m < mmax; m++) { - for (int i = offset + m * stride; i < offset + nn * stride; i += istep * stride) { - int j = i + mmax * stride; - int wTemp = modMultiply(wTable[t], data[j]); - data[j] = modSubtract(data[i], wTemp); - data[i] = modAdd(data[i], wTemp); - } - t += r; - } - mmax = istep; - } - } - - private void columnScramble(int offset) { - for (int k = 0; k < this.permutationTableLength; k += 2) { - int i = offset + permutationTable[k] * stride, j = offset + permutationTable[k + 1] * stride; - int tmp = data[i]; - data[i] = data[j]; - data[j] = tmp; - } - } - - public final int modMultiply(int a, int b) { - int r1 = a * b - (int) (this.inverseModulus * (float) a * (float) b) * this.modulus, r2 = r1 - this.modulus; - - return (r2 < 0 ? r1 : r2); - } - - private int modAdd(int a, int b) { - int r1 = a + b, r2 = r1 - this.modulus; - - return (r2 < 0 ? r1 : r2); - } - - private int modSubtract(int a, int b) { - int r1 = a - b, r2 = r1 + this.modulus; - - return (r1 < 0 ? r2 : r1); - } - - private void setModulus(int modulus) { - this.inverseModulus = 1.0f / (modulus + 0.5f); // Round down - this.modulus = modulus; - } - - private int stride; - - private int length; - - private boolean isInverse; - - private int[] data; - - private int offset; - - @Constant private int[] wTable; - - @Constant private int[] permutationTable; - - private int permutationTableLength; - - private int modulus; - - private float inverseModulus; - } - - public static void main(String[] args) { - final int SQRT_LENGTH = 1024; - final int LENGTH = SQRT_LENGTH * SQRT_LENGTH; - ArrayAccess arrayAccess = new IntMemoryArrayAccess(new int[LENGTH], 0, LENGTH); - new Issue68().transformColumns(SQRT_LENGTH, SQRT_LENGTH, false, arrayAccess, new int[SQRT_LENGTH], null); - } - - private void transformColumns(final int length, final int count, final boolean isInverse, final ArrayAccess arrayAccess, - final int[] wTable, final int[] permutationTable) { - Kernel kernel = new ColumnTableFNTRunnable(length, isInverse, arrayAccess, wTable, permutationTable, getModulus()); - kernel.execute(count); - } - - private int getModulus() { - return 2113929217; - } -} diff --git a/test/runtime/src/java/com/amd/aparapi/test/runtime/Issue69.java b/test/runtime/src/java/com/amd/aparapi/test/runtime/Issue69.java deleted file mode 100644 index 770359a1..00000000 --- a/test/runtime/src/java/com/amd/aparapi/test/runtime/Issue69.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.amd.aparapi.test.runtime; - -import com.amd.aparapi.Kernel; -import com.amd.aparapi.Range; - -public class Issue69{ - - public static void main(String[] args) { - final int globalArray[] = new int[512]; - Kernel kernel = new Kernel(){ - @Override public void run() { - globalArray[getGlobalId()] = getGlobalId(); - } - }; - for (int loop = 0; loop < 100; loop++) { - - System.out.printf("%3d free = %10d\n", loop, Runtime.getRuntime().freeMemory()); - kernel.execute(Range.create(512, 64), 1); - for (int i = 0; i < globalArray.length; ++i) { - if (globalArray[i] != i) - System.err.println("Wrong!"); - } - } - for (int loop = 0; loop < 100; loop++) { - - System.out.printf("%3d free = %10d\n", loop, Runtime.getRuntime().freeMemory()); - kernel.execute(Range.create(512, 64), 2); - for (int i = 0; i < globalArray.length; ++i) { - if (globalArray[i] != i) - System.err.println("Wrong!"); - } - } - } - -} diff --git a/test/runtime/src/java/com/amd/aparapi/test/runtime/RangeSize.java b/test/runtime/src/java/com/amd/aparapi/test/runtime/RangeSize.java deleted file mode 100644 index f2ca745f..00000000 --- a/test/runtime/src/java/com/amd/aparapi/test/runtime/RangeSize.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.amd.aparapi.test.runtime; - -import com.amd.aparapi.Range; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class RangeSize{ - - @Test public void test384x384() { - Range range = Range.create2D(384,384); - System.out.println("local[0] "+range.getLocalSize(0)); - System.out.println("local[1] "+range.getLocalSize(1)); - System.out.println("workGroupSize "+range.getWorkGroupSize()); - assertTrue("Range > max work size", range.getLocalSize(0)*range.getLocalSize(1)<=range.getWorkGroupSize()); - } - - @Test public void test384x320() { - Range range = Range.create2D(384,320); - System.out.println("local[0] "+range.getLocalSize(0)); - System.out.println("local[1] "+range.getLocalSize(1)); - System.out.println("workGroupSize "+range.getWorkGroupSize()); - assertTrue("Range > max work size", range.getLocalSize(0)*range.getLocalSize(1)<=range.getWorkGroupSize()); - } - -} diff --git a/test/runtime/src/java/com/amd/aparapi/test/runtime/Test12x4_4x2.java b/test/runtime/src/java/com/amd/aparapi/test/runtime/Test12x4_4x2.java deleted file mode 100644 index 51cee436..00000000 --- a/test/runtime/src/java/com/amd/aparapi/test/runtime/Test12x4_4x2.java +++ /dev/null @@ -1,499 +0,0 @@ -package com.amd.aparapi.test.runtime; - -import org.junit.Test; - -import com.amd.aparapi.Kernel; -import com.amd.aparapi.Range; - -public class Test12x4_4x2{ - @Test public void test() { - // globalThreadId, threadId, globalX, globalY, localX, localY - final int[][] test = new int[][] { - { - 0, //globalThreadId - 0,//threadId - 0,//globalX - 0,//globalY - 0,//localX - 0 - //localY - }, - { - 1,//globalThreadId - 1,//threadId - 1,//globalX - 0,//globalY - 1,//localX - 0 - //localY - }, - { - 2,//globalThreadId - 2,//threadId - 2,//globalX - 0,//globalY - 2,//localX - 0 - //localY - }, - { - 3,//globalThreadId - 3,//threadId - 3,//globalX - 0,//globalY - 3,//localX - 0 - //localY - }, - { - 4,//globalThreadId - 4,//threadId - 0,//globalX - 1,//globalY - 0,//localX - 1 - //localY - }, - { - 5,//globalThreadId - 5,//threadId - 1,//globalX - 1,//globalY - 1,//localX - 1 - //localY - }, - { - 6,//globalThreadId - 6,//threadId - 2,//globalX - 1,//globalY - 2,//localX - 1 - //localY - }, - { - 7,//globalThreadId - 7,//threadId - 3,//globalX - 1,//globalY - 3,//localX - 1 - //localY - }, - { - 8,//globalThreadId - 0,//threadId - 4,//globalX - 0,//globalY - 0,//localX - 0 - //localY - }, - { - 9,//globalThreadId - 1,//threadId - 5,//globalX - 0,//globalY - 1,//localX - 0 - //localY - }, - { - 10,//globalThreadId - 2,//threadId - 6,//globalX - 0,//globalY - 2,//localX - 0 - //localY - }, - { - 11,//globalThreadId - 3,//threadId - 7,//globalX - 0,//globalY - 3,//localX - 0 - //localY - }, - { - 12,//globalThreadId - 4,//threadId - 4,//globalX - 1,//globalY - 0,//localX - 1 - //localY - }, - { - 13,//globalThreadId - 5,//threadId - 5,//globalX - 1,//globalY - 1,//localX - 1 - //localY - }, - { - 14,//globalThreadId - 6,//threadId - 6,//globalX - 1,//globalY - 2,//localX - 1 - //localY - }, - { - 15,//globalThreadId - 7,//threadId - 7,//globalX - 1,//globalY - 3,//localX - 1 - //localY - }, - { - 16,//globalThreadId - 0,//threadId - 8,//globalX - 0,//globalY - 0,//localX - 0 - //localY - }, - { - 17,//globalThreadId - 1,//threadId - 9,//globalX - 0,//globalY - 1,//localX - 0 - //localY - }, - { - 18,//globalThreadId - 2,//threadId - 10,//globalX - 0,//globalY - 2,//localX - 0 - //localY - }, - { - 19,//globalThreadId - 3,//threadId - 11,//globalX - 0,//globalY - 3,//localX - 0 - //localY - }, - - { - 20,//globalThreadId - 4,//threadId - 8,//globalX - 1,//globalY - 0,//localX - 1 - //localY - }, - { - 21,//globalThreadId - 5,//threadId - 9,//globalX - 1,//globalY - 1,//localX - 1 - //localY - }, - { - 22,//globalThreadId - 6,//threadId - 10,//globalX - 1, - 2,//localX - 1 - //localY - }, - { - 23,//globalThreadId - 7,//threadId - 11,//globalX - 1,//globalY - 3,//localX - 1 - //localY - }, - { - 24,//globalThreadId - 0,//threadId - 0,//globalX - 2,//globalY - 0,//localX - 0 - //localY - }, - { - 25,//globalThreadId - 1,//threadId - 1,//globalX - 2,//globalY - 1,//localX - 0 - //localY - }, - { - 26,//globalThreadId - 2,//threadId - 2,//globalX - 2,//globalY - 2,//localX - 0 - //localY - }, - { - 27,//globalThreadId - 3,//threadId - 3,//globalX - 2,//globalY - 3,//localX - 0 - //localY - }, - { - 28,//globalThreadId - 4,//threadId - 0,//globalX - 3,//globalY - 0,//localX - 1 - //localY - }, - { - 29,//globalThreadId - 5,//threadId - 1,//globalX - 3,//globalY - 1,//localX - 1 - //localY - }, - { - 30,//globalThreadId - 6,//threadId - 2,//globalX - 3,//globalY - 2,//localX - 1 - //localY - }, - { - 31,//globalThreadId - 7,//threadId - 3,//globalX - 3,//globalY - 3,//localX - 1 - //localY - }, - { - 32,//globalThreadId - 0,//threadId - 4,//globalX - 2,//globalY - 0,//localX - 0 - //localY - }, - { - 33,//globalThreadId - 1,//threadId - 5,//globalX - 2,//globalY - 1,//localX - 0 - //localY - }, - { - 34,//globalThreadId - 2,//threadId - 6,//globalX - 2,//globalY - 2,//localX - 0 - //localY - }, - { - 35,//globalThreadId - 3,//threadId - 7,//globalX - 2,//globalY - 3,//localX - 0 - //localY - }, - { - 36,//globalThreadId - 4,//threadId - 4,//globalX - 3,//globalY - 0,//localX - 1 - //localY - }, - { - 37,//globalThreadId - 5,//threadId - 5,//globalX - 3,//globalY - 1,//localX - 1 - //localY - }, - { - 38,//globalThreadId - 6,//threadId - 6,//globalX - 3,//globalY - 2,//localX - 1 - //localY - }, - { - 39,//globalThreadId - 7,//threadId - 7,//globalX - 3,//globalY - 3,//localX - 1 - //localY - }, - { - 40,//globalThreadId - 0,//threadId - 8,//globalX - 2,//globalY - 0,//localX - 0 - //localY - }, - { - 41,//globalThreadId - 1,//threadId - 9,//globalX - 2,//globalY - 1,//localX - 0 - //localY - }, - { - 42,//globalThreadId - 2,//threadId - 10,//globalX - 2,//globalY - 2,//localX - 0 - //localY - }, - { - 43,//globalThreadId - 3,//threadId - 11,//globalX - 2,//globalY - 3,//localX - 0 - //localY - }, - - { - 44,//globalThreadId - 4,//threadId - 8,//globalX - 3,//globalY - 0,//localX - 1 - //localY - }, - { - 45,//globalThreadId - 5,//threadId - 9,//globalX - 3,//globalY - 1,//localX - 1 - //localY - }, - { - 46,//globalThreadId - 6,//threadId - 10,//globalX - 3,//globalY - 2,//localX - 1 - //localY - }, - { - 47,//globalThreadId - 7,//threadId - 11,//globalX - 3,//globalY - 3,//localX - 1 - //localY - }, - }; - Kernel kernel = new Kernel(){ - - @Override public void run() { - int x = getGlobalId(0); - int y = getGlobalId(1); - int lx = getLocalId(0); - int ly = getLocalId(1); - int w = getGlobalSize(0); - int h = getGlobalSize(1); - int globalThreadId = getGlobalId(1) * getGlobalSize(0) + getGlobalId(0); - int threadId = getLocalId(1) * getLocalSize(0) + getLocalId(0); - synchronized (test) { - boolean show = false; - if (globalThreadId != test[globalThreadId][0]) { - System.out.println("bad globalThreadId"); - show = true; - } - if (threadId != test[globalThreadId][1]) { - System.out.println("bad threadId"); - show = true; - } - if (x != test[globalThreadId][2]) { - System.out.println("bad globalx"); - show = true; - } - if (y != test[globalThreadId][3]) { - System.out.println("bad globaly"); - show = true; - } - if (lx != test[globalThreadId][4]) { - System.out.println("bad localx"); - show = true; - } - if (ly != test[globalThreadId][5]) { - System.out.println("bad localy"); - show = true; - } - if (show) { - System.out.println("derived =>" + globalThreadId + " " + threadId + " " + x + "," + y + " " + lx + "," + ly + " " - + w + "," + h); - System.out.println("data =>" + test[globalThreadId][0] + " " + test[globalThreadId][1] + " " - + test[globalThreadId][2] + "," + test[globalThreadId][3] + " " + test[globalThreadId][4] + "," - + test[globalThreadId][5] + " " + w + "," + h); - } - } - } - - }; - kernel.setExecutionMode(Kernel.EXECUTION_MODE.JTP); - kernel.execute(Range.create2D(12, 4, 4, 2)); - - } -} diff --git a/test/runtime/src/java/com/amd/aparapi/test/runtime/Util.java b/test/runtime/src/java/com/amd/aparapi/test/runtime/Util.java deleted file mode 100644 index e2a6342b..00000000 --- a/test/runtime/src/java/com/amd/aparapi/test/runtime/Util.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.amd.aparapi.test.runtime; - -import java.util.Arrays; - -public class Util{ - interface Filler{ - void fill(int[] array, int index); - } - - interface Comparer{ - boolean same(int[] lhs, int[] rhs, int index); - } - - interface Operator{ - void apply(int[] lhs, int[] rhs, int index); - } - - static void fill(int[] array, Filler _filler) { - for (int i = 0; i < array.length; i++) { - _filler.fill(array, i); - } - } - - static boolean same(int[] lhs, int[] rhs, Comparer _comparer) { - boolean same = lhs != null && rhs != null && lhs.length == rhs.length; - for (int i = 0; same && i < lhs.length; i++) { - same = _comparer.same(lhs, rhs, i); - } - return (same); - } - - static void zero(int[] array) { - Arrays.fill(array, 0); - } - - static boolean same(int[] lhs, int[] rhs) { - return (same(lhs, rhs, new Comparer(){ - - @Override public boolean same(int[] lhs, int[] rhs, int index) { - - return lhs[index] == rhs[index]; - } - })); - } - - static boolean same(boolean[] lhs, boolean[] rhs) { - boolean same = lhs != null && rhs != null && lhs.length == rhs.length; - for (int i = 0; same && i < lhs.length; i++) { - same = lhs[i] == rhs[i]; - } - return (same); - } - - static void apply(int[] lhs, int[] rhs, Operator _operator) { - for (int i = 0; i < lhs.length; i++) { - _operator.apply(lhs, rhs, i); - } - } - -} diff --git a/wiki-collateral/ProfilingKernelsFormEclipseProject.zip b/wiki-collateral/ProfilingKernelsFormEclipseProject.zip deleted file mode 100644 index 28566548..00000000 Binary files a/wiki-collateral/ProfilingKernelsFormEclipseProject.zip and /dev/null differ