Giter Club home page Giter Club logo

aparapi's Introduction

pipeline status coverage report codecov Codacy Badge License SemVer Javadocs Maven Central Gitter

A framework for executing native Java code on the GPU.

Licensed under the Apache Software License v2

Aparapi allows developers to write native Java code capable of being executed directly on a graphics card GPU by converting Java byte code to an OpenCL kernel dynamically at runtime. Because it is backed by OpenCL Aparapi is compatible with all OpenCL compatible Graphics Cards.

A GPU has a unique architecture that causes them to behave differently than a CPU. One of the most noticeable differences is that while a typical CPU has less than a dozen cores a high end GPU may have hundreds of cores. This makes them uniquely suited for data-parallel computation that can result in speedups hundreds of times more than what is capable with your average CPU. This can mean the difference between needing a whole data center to house your application versus just one or two computers, potentially saving millions in server costs.

Aparapi was originally a project conceived and developed by AMD corporation. It was later abandoned by AMD and sat mostly idle for several years. Despite this there were some failed efforts by the community to keep the project alive, but without a clear community leader no new releases ever came. Eventually we came along and rescued the project. Finally after such a long wait the first Aparapi release in 5 years was published and the community continues to push forward with renewed excitement.

Below you will find two side-by-side comparisons for the nbody problem on a CPU vs a GPU. The simulation is being run on an inexpensive graphics card; you can even run it yourself from the examples project. Its obvious the drastic performance gains that can be achieved with Aparapi.

NBody GPU NBody CPU
GPU Accelerated CPU Multi-threaded (8 cores)

Donating

Beerpay Beerpay

As an open-source project we run entierly off donations. Buy one of our hardworking developers a beer by donating here. All donations go to our bounty fund and allow us to place bounties on important bugs and enhancements. You may also use Beerpay linked via the above badges.

Support and Documentation

This project is officially hosted on QOTO GitLab here however an up-to-date mirror is also maintained on Github here.

Aparapi Javadocs: latest - 3.0.0 - 2.0.0 - 1.10.0 - 1.9.0 - 1.8.0 - 1.7.0 - 1.6.0 - 1.5.0 - 1.4.1 - 1.4.0 - 1.3.4 - 1.3.3 - 1.3.2 - 1.3.1 - 1.3.0 - 1.2.0 - 1.1.2 - 1.1.1 - 1.1.0 - 1.0.0

For detailed documentation see Aparapi.com or check out the latest Javadocs.

For support please use Gitter or the official Aparapi mailing list and Discourse forum.

Please file bugs and feature requests on QOTO GitLab our old archived issues can still be viewed on Github as well.

Aparapi conforms to the Semantic Versioning 2.0.0 standard. That means the version of a release isnt arbitrary but rather describes how the library interfaces have changed. Read more about it at the Semantic Versioning page.

Related Projects

This particular repository only represents the core Java library. There are several other related repositories worth taking a look at.

  • Aparapi Examples - A collection of Java examples to showcase the Aparapi library and help developers get started.
  • Aparapi JNI - A java JAR which embeds and loads the native components at runtime. This prevents the need to seperately install the Aparapi Native library.
  • Aparapi Native - The native library component. Without this the Java library can't talk to the graphics card. This is not a java project but rather a C/C++ project.
  • Aparapi Vagrant - A vagrant environment for compiling aparapi native libraries for linux, both x86 an x64.
  • Aparapi Website - Source for the Aparapi website as hosted at http://aparapi.com. The site also contains our detailed documentation.

Prerequisites

Aparapi will run as-is on the CPU, however in order to access the GPU it requires OpenCL to be installed on the local system. If OpenCL isnt found then the library will just fallback to CPU mode. Aparapi supports, and has been tested on, both OpenCL 1.2, OpenCL 2.0, and OpenCL 2.1.

Aparapi runs on all operating systems and platforms, however GPU acceleration support is currently provided for the following platforms: Windows 64bit, Windows 32bit, Mac OSX 64bit, Linux 64bit, and Linux 32bit.

Note: It is no longer required to manually install the Aparapi JNI native interface, this is now done automatically through maven as a dependency on Aparapi.

Java Dependency

To include Aparapi in your project of choice include the following Maven dependency into your build.

<dependency>
    <groupId>com.aparapi</groupId>
    <artifactId>aparapi</artifactId>
    <version>3.0.0</version>
</dependency>

Obtaining the Source

The official source repository for Aparapi is located in the Syncleus Github repository and can be cloned using the following command.

git clone https://git.qoto.org/aparapi/aparapi.git

Getting Started

With Aparapi we can take a sequential loop such as this (which adds each element from inA and inB arrays and puts the result in result).

final float inA[] = .... // get a float array of data from somewhere
final float inB[] = .... // get a float array of data from somewhere
assert (inA.length == inB.length);
final float result = new float[inA.length];

for (int i = 0; i < array.length; i++) {
    result[i] = inA[i] + inB[i];
}

And refactor the sequential loop to the following form:

Kernel kernel = new Kernel() {
    @Override
    public void run() {
        int i = getGlobalId();
        result[i] = inA[i] + inB[i];
    }
};

Range range = Range.create(result.length);
kernel.execute(range);

aparapi's People

Contributors

barneypitt avatar brenzosa avatar codacy-badger avatar corerasurae avatar ddemidov avatar ekasitk avatar eklavya avatar fer-marino avatar freemo avatar gitter-badger avatar grfrost avatar hungrybluedev avatar iotamudelta avatar jszuppe avatar kishida avatar kylelutz avatar log2 avatar mailtrv avatar mibrahim avatar newlifer avatar plnordquist avatar pr0methean avatar qunaibit avatar seeker avatar shabanovd avatar sharptrick avatar subaruwrc avatar toonijn avatar veskoo93 avatar wavepropagation avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aparapi's Issues

Errors in Quick Reference Guide

From @dlippold on November 21, 2016 16:16

I found some typos and small errors in the "Aparapi Quick Reference Guide" (QuickReference.pdf):

  • Section "Create an anonymous inner class extending com.amd.aparapi.Kernel"

    Should "single dimension arrays of primitive from the call-site" be "single dimension arrays of primitive elements of final fields from the call-site"?

    The statement "This code sets each element of data[] to its index." is wrong. There is no such code. Maybe the line in the run method should be replaced by the line in the following section.

  • Section "Executing your kernel over a given range (0..)"

    "This code each element of data[]" sould be "This code sets each element of data[]"

    "Data[getGlobalId()]" should be "data[getGlobalId()]"

  • Section "Setting default execution mode"

    "com.amd.aparapi.ExecutionMode" should be "com.amd.aparapi.executionMode"

  • Section "Determining the execution mode"

    "com.amd.aparapi.ExecutionMode" should be "com.amd.aparapi.executionMode"

  • Section "Kernel methods to determine execution identity"

    "eacj" should be "each"

    What does "pf" mean? Please explain it.

  • Section "Mapping of Aparapi Kernel math methods to Java and OpenCL equivalents", in the column "Java mapping" of the table

    "Math.acos(float)" should be "Math.acos(double)"
    "Math.asin(float)" should be "Math.asin(double)"
    "Math.atan(float)" should be "Math.atan(double)"
    "Math.atan2(float, float)" should be "Math.atan2(double, double)"
    "Math.ceil(float)" should be "Math.ceil(double)"
    "Math.cos(float)" should be "Math.cos(double)"
    "Math.exp(float)" should be "Math.exp(double)"
    "Math.floor(float)" should be "Math.floor(double)"
    "Math.max(long,int)" should be "Math.max(long,long)"
    "Math.min(long,int)" should be "Math.min(long,long)"
    "Math.log(float)" should be "Math.log(double)"
    "Math.pow(float, float)" should be "Math.pow(double, double)"
    "Math.pow(double, float)" should be "Math.pow(double, double)"
    "Math.IEEEremainder(float, float)" should be "Math.IEEEremainder(double, double)"
    "Math.IEEEremainder(double, float)" should be "Math.IEEEremainder(double, double)"
    "Math.rint( float)" should be "Math.rint(double)"
    "1f/Math.sqrt( float)" should be "1.0/Math.sqrt(double)"
    "1.0/Math. round( double)" should be "1.0/Math.sqrt(double)"
    "Math.sin( float)" should be "Math.sin(double)"
    "Math.sqrt( float)" should be "Math.sqrt(double)"
    "Math.tan( float)" should be "Math.tan(double)"
    "Math.toRadians( float)" should be "Math.toRadians(double)"
    "Math.toDegrees( float)" should be "Math.toDegrees(double)"

Copied from original issue: aparapi/aparapi#41

UnsatisfiedLinkError on linux when opencl is not installed

Dears,
I'm evaluating aparapi for one of our project, and a requirement for it is that it runs pure java even if no opencl device is available.
I've designed a simple test case using the guide but the test fails:

java.lang.UnsatisfiedLinkError: /tmp/libaparapi_x86_64678632701802135793.so: libOpenCL.so.1: cannot open shared object file: No such file or directory
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
	at java.lang.Runtime.load0(Runtime.java:809)
	at java.lang.System.load(System.java:1086)
	at com.aparapi.natives.util.NativeUtils.loadLibraryFromJar(NativeUtils.java:100)
	at com.aparapi.natives.NativeLoader.load(NativeLoader.java:35)
	at com.aparapi.internal.opencl.OpenCLLoader.<clinit>(OpenCLLoader.java:43)
	at com.aparapi.internal.opencl.OpenCLPlatform.getOpenCLPlatforms(OpenCLPlatform.java:73)
	at fr.gael.drb.cortex.topic.sentinel3.AparapiTest.info(AparapiTest.java:31)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
	at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:564)
	at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
	at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
	at org.testng.TestRunner.beforeRun(TestRunner.java:641)
	at org.testng.TestRunner.run(TestRunner.java:609)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
	at org.testng.SuiteRunner.run(SuiteRunner.java:254)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
	at org.testng.TestNG.run(TestNG.java:1057)
	at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
	at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:127)

this exception is thrown when the program its the line:
List<OpenCLPlatform> platforms = (new OpenCLPlatform()).getOpenCLPlatforms();

Going through the code, it seems that he try to check if opencl is available on the machine running OpenCLLoader.isOpenCLAvailable(), inside the init static block of that class it try to load the native library, and it fails as it's not available. Anyway that exception is not caught and everything breaks.
It catches IOException but that does not catch the UnsatisfiedLinkError.

Thank you and regards,
Fernando

declare helper method in Kernal that accept __private variable

i tried to define a helper method AddMod that accept _private byte Array but failed
1- the syntax
public void addMod(final byte[] input1,final byte[] input2,final byte[] outputBytes,final int ID, byte[] PRIME
$private$32){

}

compile fine but calling the addMod with a __private variable PRIME throws runtime exception :
:362:112: error: passing 'char *' to parameter of type '__global char *' changes address space of pointer
net_spirea_oclGenerator_AdressKernel__addMod(this, this->input1, this->input2, this->outputBytes, ID, this->PRIME);
^~~~~~~~~~~
2- the syntaxe
public void addMod(final byte[] input1,final byte[] input2,final byte[] outputBytes,final int ID, @PrivateMemorySpace(value = 32) byte[] PRIME){

}

does not compile.

Any suggestions on how to declare a helper method with __private argument variable ?

thanks in advance.
A. Nejeoui

[Bounty $25] Using tanh and NPE in ClassModel

From @stoerr on October 8, 2015 17:37

I was trying to use tanh by declaring

@OpenCLMapping(mapTo = "tanh")
protected float tanh(float _f) {
    return (float) Math.tanh(_f);
}

Unfortunately, this exposes a NullPointerException:

java.lang.NullPointerException
at com.amd.aparapi.internal.model.ClassModel.parse(ClassModel.java:2542)
at com.amd.aparapi.internal.model.ClassModel.parse(ClassModel.java:2526)
at com.amd.aparapi.internal.model.ClassModel.(ClassModel.java:142)

The problem is, that it tries to parse java.lang.Math, and Math.class.getClassLoader() returns null, so the ClassModel can't find the class file. I'm not quite sure how aparapi should deal with this - perhaps classes used in methods annotated with @OpenCLMapping shouldn't be parsed at all.

It would be nice, too, if the Kernel would define tanh and similar methods, anyway.

Thanks so much!

Copied from original issue: aparapi/aparapi#15

Better handling of missing drivers

Make it so that it is easy for the user of a java program to know that they don't have their openCL drivers installed (GPU/CPU) and provide easy links to the latest drivers for Intel/AMD/Nvidia

[BOUNTY $25] Kernel error for MonteCarlo on NVIDIA and AMD GPUs

From @jjfumero on February 17, 2016 10:23

I am running MonteCarlo simulation within Aparapi. For testing I am using Intel OpenCL locally. I am running with JDK 1.8_65. The kernel that Aparapi generates is correct and the result when I compare to the sequential code is correct as well. However if I use the GPU, NVidia GPU or AMD GPU, the kernel is not correct. One declaration type is missing.

My understanding is, Aparapi generates the OpenCL kernel indendently of the architecture behind. Bytecodes -> C OpenCL. Is that correct? or is there any communication during the code generation?

Here the details, this is the Aparapi Kernel:

public static class MonteCarloKernel extends Kernel {

        private int size;
        private float[] result;

        public MonteCarloKernel(int size) {
            this.size = size;
            result = new float[size];
        }

        @Override
        public void run() {
            int idx = getGlobalId();
            int iter = 25000;

            long seed = idx;
            float sum = 0.0f;

            for (int j = 0; j < iter; ++j) {
                // generate a pseudo random number (you do need it twice)
                seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);
                seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);

                // this generates a number between 0 and 1 (with an awful entropy)
                float x = ((float) (seed & 0x0FFFFFFF)) / 268435455f;

                // repeat for y
                seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);
                seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);
                float y = ((float) (seed & 0x0FFFFFFF)) / 268435455f;

                float dist = (float) Math.sqrt(x * x + y * y);
                if (dist <= 1.0f)
                    sum += 1.0f;
            }
            sum *= 4;
            result[idx] = (float) sum / (float) iter;
        }

        public boolean checkResult(float[] seq) {
            for (int i = 0; i < seq.length; i++) {
                if (Math.abs( (float)(result[i] - seq[i])) > 0.001) {
                    return false;
                }
            }
            return true;
        }

        public float[] getResult() {
            return result;
        }

        public int getSize() {
            return size;
        }
    }


If I use Intel OpenCL:

NAME: Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
VENDOR: Intel(R) Corporation
TYPE: CPU
DRIVER: 1.2.0.57

This is the kernel Aparapi generates (the correct kernel):


#pragma OPENCL EXTENSION cl_khr_fp64 : enable

typedef struct This_s{
   __global float *result;
   int passid;
}This;
int get_pass_id(This *this){
   return this->passid;
}
__kernel void run(
   __global float *result, 
   int passid
){
   This thisStruct;
   This* this=&thisStruct;
   this->result = result;
   this->passid = passid;
   {
      int idx = get_global_id(0);
      int iter = 25000;
      long seed = (long)idx;
      float sum = 0.0f;
      for (int j = 0; j<iter; j++){
         seed = ((seed * 25214903917L) + 11L) & 281474976710655L;
         seed = ((seed * 25214903917L) + 11L) & 281474976710655L;
         float x = (float)(seed & 268435455L) / 2.68435456E8f;
         seed = ((seed * 25214903917L) + 11L) & 281474976710655L;
         seed = ((seed * 25214903917L) + 11L) & 281474976710655L;
         float y = (float)(seed & 268435455L) / 2.68435456E8f;
         float dist = (float)sqrt((double)((x * x) + (y * y)));
         if (dist<=1.0f){
            sum = sum + 1.0f;
         }
      }
      sum = sum * 4.0f;
      this->result[idx]  = sum / (float)iter;
      return;
   }
}

When I use Aparapi on NVIDIA or AMD GPUs (same JVM - JDK 1.8.65, but different driver), I get this kernel:

#pragma OPENCL EXTENSION cl_khr_fp64 : enable

typedef struct This_s{
   __global float *result;
   int passid;
}This;
int get_pass_id(This *this){
   return this->passid;
}
__kernel void run(
   __global float *result, 
   int passid
){
   This thisStruct;
   This* this=&thisStruct;
   this->result = result;
   this->passid = passid;
   {
      int i_1 = get_global_id(0);
      int i_2 = 25000;
       l_3 = (long)i_1;
      float f_5 = 0.0f;
      int i_6 = 0;
      for (; i_6<i_2; i_6++){
         l_3 = ((l_3 * 25214903917L) + 11L) & 281474976710655L;
         l_3 = ((l_3 * 25214903917L) + 11L) & 281474976710655L;
         float f_7 = (float)(l_3 & 268435455L) / 2.68435456E8f;
         l_3 = ((l_3 * 25214903917L) + 11L) & 281474976710655L;
         l_3 = ((l_3 * 25214903917L) + 11L) & 281474976710655L;
         float f_8 = (float)(l_3 & 268435455L) / 2.68435456E8f;
         float f_9 = (float)sqrt((double)((f_7 * f_7) + (f_8 * f_8)));
         if (f_9<=1.0f){
            f_5 = f_5 + 1.0f;
         }
      }
      f_5 = f_5 * 4.0f;
      this->result[i_1]  = f_5 / (float)i_2;
      return;
   }
}

There is an error:

clBuildProgram failed
************************************************
:21:8: error: use of undeclared identifier 'l_3'
       l_3 = (long)i_1;
       ^

Note:
NVIDIA-SMI 331.79 Driver Version: 331.79

AMD:

Name: Hawaii
Vendor: Advanced Micro Devices, Inc.
Device OpenCL C version: OpenCL C 1.2
Driver version: 1598.5 (VM)

Copied from original issue: aparapi/aparapi#25

Issue when running with netbeans?

From @iamDecode on November 24, 2015 19:0

When running any sample project, I seem to be getting the following error:

Nov 24, 2015 7:54:08 PM com.amd.aparapi.internal.model.ClassModel$AttributePool <init>
WARNING: Found unexpected Attribute (name = org.netbeans.SourceLevelAnnotations)
Nov 24, 2015 7:54:08 PM com.amd.aparapi.internal.kernel.KernelRunner warnFallBackAndExecute
WARNING: Reverting to Java Thread Pool (JTP) for class volvis.RaycastRenderer$1: FP64 required but not supported

This leads me to think that there might be some issues with running using netbeans, as the attribute org.netbeans.SourceLevelAnnotations is not recognised. Due to a warning it then stops running on the GPU, tries JTP, and even that fails..

Does anyone have a clue what is going on here, and how to fix this?

I'm using java 1.8(.0_51) on Mac OS X 10.11.

Copied from original issue: aparapi/aparapi#20

[Bounty $30] Private superclass fields missing from struct This_s

From @Pr0methean on July 6, 2016 2:19

When I create the following classes:

abstract class OperatorKernel extends Kernel {
  private float[] output;
  public void init(int pixels) {
    if (output == null) {
      output = new float[pixels];
    }
  }
}

class ProductKernel extends OperatorKernel {/*...*/}

and then call init() on a ProductKernel, I get this error:

Jul 05, 2016 7:11:43 PM com.amd.aparapi.internal.kernel.KernelRunner warnFallBackAndExecute
WARNING: Reverting to Java Thread Pool (JTP) for class com.google.users.polymorpheus.experimental.arttree.operators.X$XK
ernel: OpenCL compile failed
clBuildProgram failed
************************************************
<kernel>:36:13: error: no member named 'output' in 'struct This_s'
      this->output[pixelId]  = com_google_users_polymorpheus_experimental_arttree_operators_UnaryOperatorKernel__calcula
tePixelById(this, pixelId) * (float)this->signum;
      ~~~~  ^
<kernel>:36:163: error: no member named 'signum' in 'struct This_s'
      this->output[pixelId]  = com_google_users_polymorpheus_experimental_arttree_operators_UnaryOperatorKernel__calcula
tePixelById(this, pixelId) * (float)this->signum;

                                    ~~~~  ^

************************************************

Changing the visibility of the inherited fields to protected seems to fix this. I suspect the problem is that the bytecode-to-OpenCL compiler isn't looking at the superclass bytecode, even when the superclass isn't immediately Kernel.

Copied from original issue: aparapi/aparapi#31

Fix line endings.

We already added a .gitattributes file to enforce line endings but we still need to convert all the line endings to unix style in the code.

Aparapi can't find OpenCL

From @thejar on January 14, 2015 0:14

I have been having some trouble getting aparapi to work on my desktop.
I'm running Windows 7 64 bit with an AMD graphics card and all appropriate drivers installed.
output from clinfo: http://pastebin.com/fA0Pke8Y

from latest release on code google (https://code.google.com/p/aparapi/downloads/list)
output from info sample: http://pastebin.com/wiYGEcGP
output from add sample: http://pastebin.com/GEXMR70r

from latest release on Github (https://github.com/aparapi/aparapi/releases)
output from info sample: http://pastebin.com/mbQWMybd
output from add sample: http://pastebin.com/KeWp6XnM

The aparapi.jar and opencl.dll files are both in locations in the windows path.
I can only imagine that I don't have something set up correctly, but would appreciate any help getting this to work.
Thanks,
Jeff

geeks3d_gpu_caps_viewer_gpu
geeks3d_gpu_caps_viewer_opencl

Copied from original issue: aparapi/aparapi#4

Exception UnsatisfiedLinkError thrown when running on Windows.

The following exception occurs when trying to run Aparapi on windows. The exception never seems to occur on linux or mac.

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\Vincenzo\AppData\Local\Temp\libaparapi_x86_643218484219112159561.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at com.aparapi.natives.util.NativeUtils.loadLibraryFromJar(NativeUtils.java:100)
at com.aparapi.natives.NativeLoader.load(NativeLoader.java:42)
at com.aparapi.internal.opencl.OpenCLLoader.<clinit>(OpenCLLoader.java:43)
at com.aparapi.internal.opencl.OpenCLPlatform.getOpenCLPlatforms(OpenCLPlatform.java:73)
at com.aparapi.device.OpenCLDevice.listDevices(OpenCLDevice.java:458)
at com.aparapi.internal.kernel.KernelManager.createDefaultPreferredDevices(KernelManager.java:203)
at com.aparapi.internal.kernel.KernelManager.createDefaultPreferences(KernelManager.java:178)
at com.aparapi.internal.kernel.KernelManager.<init>(KernelManager.java:46)
at com.aparapi.internal.kernel.KernelManager.<clinit>(KernelManager.java:38)
at com.aparapi.internal.kernel.KernelRunner.<init>(KernelRunner.java:170)
at com.aparapi.Kernel.prepareKernelRunner(Kernel.java:2270)
at com.aparapi.Kernel.execute(Kernel.java:2439)
at com.aparapi.Kernel.execute(Kernel.java:2396)
at com.aparapi.Kernel.execute(Kernel.java:2371)

Pull in relevant issues from google code

We need a way to pull in all the relevant old issues that were over at the google code api. I tried a few tools but since the google code site archived most such tools broke. However there is a git repo that managed to copy the issues from google before that time. We can potentially use the git issue mover/copier or similar tool to get these issues over to our repo. Here is the repo in question:

https://github.com/tdeneau/aparapi/issues

A possible tool to accomplish this: https://github.com/IQAndreas/github-issues-import

is there a way to pass an unsafe memory region

From @alexandrubordei on April 15, 2016 9:58

Is there a way to pass a sun.misc.Unsafe allocated memory block to the Aparapi kernel and back again? I'm trying to avoid a memory copy if I can help it but I am unsure how to instruct Aparapi push this generic buffer region down to the kernel and back again if it's the case.

thanks,
alex

Copied from original issue: aparapi/aparapi#29

Is there any issue about data types?

From @savaskoc on April 21, 2016 20:27

Hi,

I have following code.

package com.savaskoc.tckn;

import com.amd.aparapi.Kernel;

import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

public class Main {
    public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException {
        int num = 406816900 - 406816880;

        TCKernel kernel = new TCKernel(406816880, num);
        kernel.execute(num);

        System.out.printf("%d numbers in %d ms\n", num, kernel.getAccumulatedExecutionTime());

        PrintWriter writer = new PrintWriter("numbers.txt");
        kernel.saveResults(writer);
        writer.flush();
    }

    public static class TCKernel extends Kernel {
        long[] result;
        int start;

        public TCKernel(int start, int num) {
            this.result = new long[num];
            this.start = start;
        }

        @Override
        public void run() {
            result[getGlobalId()] = calculate(start + getGlobalId());
        }

        public long calculate(int tc) {
            int num = tc;
            int n9 = num % 10;
            num /= 10;
            int n8 = num % 10;
            num /= 10;
            int n7 = num % 10;
            num /= 10;
            int n6 = num % 10;
            num /= 10;
            int n5 = num % 10;
            num /= 10;
            int n4 = num % 10;
            num /= 10;
            int n3 = num % 10;
            num /= 10;
            int n2 = num % 10;
            num /= 10;
            int n1 = num % 10;

            int odds = n1 + n3 + n5 + n7 + n9;
            int evens = n2 + n4 + n6 + n8;

            int n10 = (odds * 7 - evens) % 10;
            int n11 = (odds + evens + n10) % 10;

            return (long) tc * 100 + (n10 * 10 + n11);
        }

        public void saveResults(PrintWriter writer) {
            writer.println("Result\t\tNum\t\tExpected");
            for (int i = 0; i < result.length; i++) {
                int tc = start + i;
                writer.printf("%d\t%d\t%d%s", result[i], tc, calculate(tc), System.lineSeparator());
            }
        }
    }
}

When my code runs on aparapi, it generates wrong values as you can see its result 😞

Result      Num         Expected
2026982348  406816880   40681688012
2026982516  406816881   40681688180
2026982594  406816882   40681688258
2026982662  406816883   40681688326
2026982830  406816884   40681688494
2026982898  406816885   40681688562
2026982966  406816886   40681688630
2026983044  406816887   40681688708
2026983212  406816888   40681688876
2026983280  406816889   40681688944
2026983338  406816890   40681689002
2026983506  406816891   40681689170
2026983584  406816892   40681689248
2026983652  406816893   40681689316
2026983820  406816894   40681689484
2026983888  406816895   40681689552
2026983956  406816896   40681689620
2026984134  406816897   40681689798
2026984202  406816898   40681689866
2026984270  406816899   40681689934

Copied from original issue: aparapi/aparapi#30

Lack of FP64 support produces warning level log, should be info.

while JUnit tests run OK, spock tests wont :-(

Oct 13, 2017 12:05:41 PM com.aparapi.internal.kernel.KernelRunner fallBackToNextDevice
WARNING: Device failed for ABCCKernel, devices={Intel<GPU>|AMD<GPU>|Intel<CPU>|AMD<CPU>|Java Alternative Algorithm|Java Thread Pool}: FP64 required but not supported
com.aparapi.internal.exception.AparapiException: FP64 required but not supported
	at com.aparapi.internal.kernel.KernelRunner.fallBackToNextDevice(KernelRunner.java:1113)
	at com.aparapi.internal.kernel.KernelRunner.executeInternalInner(KernelRunner.java:1311)
	at com.aparapi.internal.kernel.KernelRunner.executeInternalOuter(KernelRunner.java:1180)

Can I take over development of this project?

From @freemo on October 17, 2016 15:20

Hi, my project has a pressing need to rely on aparapi and as such I have been contributing on the project in my own repositories. Since I will be contributing significant amount of work I'd like to contribute back that effort. You are of course welcome to adopt the project back into yours but you will find a lot has changed and that may be difficult at this point, but please feel free. If not perhaps the team would like to consider moving over to my new repositories for future effort? I am willing to discuss alternatives as well.

Here is a recap of what I did so far and where the new repositories can be found.

Everything has been mavinized!

All new code is licensed under the apache license. Also since AMD is no longer the maintainer I changed the root package across all the projects.

I pulled out the core java library. This is where all the platform independent code lives and ultimately produces the jar that will be used as the dependencies. This is now its own repository and can be found here:

https://github.com/Syncleus/aparapi

I pulled out all the platform specific code, the JNI layer, into its own repository. This no longer uses ant, as the project has been mavenized. But it isnt a Java project either, so it doesnt use maven. It has been refactored to use autotools, which is a platform independent way to compile shared libraries. It currently only compiles for linux platforms though. The code for the JNI libraries can now be found here, it uses submodules so please clone recursively:

https://github.com/Syncleus/aparapi-jni

I also created an Archlinux AUR and an unofficial binary repository for the aparapi system-specific shared library. This will allow installation of the aparapi shared library using the archlinux package management system, and uninstallation as well. The AUR can be found here:

https://github.com/Syncleus/aparapi-archlinux

To add the unofficial repository to archlinux for use with pacman then add the following line to your /etc/pacman.conf file, before all the other repositories:

[aparapi]
SigLevel = Optional TrustAll
Server = http://syncleus.com/aparapi-archlinux-repo/

The examples are now also a separate repository, as it isnt really needed for the library itself. This has the life sample mavenized and working but still need to mavenize the rest of the examples. This repo can be found here:

https://github.com/Syncleus/aparapi-examples

Finally I purchased the aparapi.com domain name so I can start hosting some useful information about it and host some files there. I also have an account on maven central so I will soon be able to upload aparapi there as it is now in a state where it can be consumed as a dependency (since it is completely mavenized).

So let me know what you guys think about joining efforts and perhaps moving the development over to the new repositories?

Copied from original issue: aparapi/aparapi#39

Issue with ProfileInfo timers?

From @jjfumero on February 8, 2016 13:19

I am interested in measuring the timers for copy in, execution and copy out of OpenCL code generated by Aparapi. If I do this on AMD GPU, the data transfer is 0 .

 private static class SaxpyKernel extends Kernel {
        private float alpha = 0.4f;
        private float[] x;
        private float[] y;
        private float[] z;

        public SaxpyKernel() {
        }

        public float[] getResult() {
            return this.z;
        }

        public void setArrays(float[] x, float[] y) {
            this.x = x;
            this.y = y;
            this.z = new float[x.length];
        }       

        @Override
        public void run() {
            int idx = getGlobalId();
            z[idx] = alpha * x[idx] + y[idx];
        }
}

If I print the timers for data transfer + kernel execution like this:

               Range range = Range.create(size);
        SaxpyKernel kernel = new SaxpyKernel();
        kernel.setExecutionMode(Kernel.EXECUTION_MODE.GPU);
               kernel.setArrays(a, b);

        for (int i = 0; i < ITERATIONS; i++) {      
            kernel.execute(range);
            List<ProfileInfo> profileInfo = kernel.getProfileInfo();
            for (ProfileInfo p : profileInfo) {             
                System.out.println(" " + p.getType()  + " : " + ((p.getEnd() - p.getStart())) + " (ns)");
            }
        }

I get these timers:

W : 0 (ns)
X : 6492297 (ns)
R : 0 (ns)

This happens ONLY on AMD GPU (AMD Radeon R9). If I use either Intel CPU (with Intel driver) or NVIDIA GPU I get these timers > 0 ns.

Copied from original issue: aparapi/aparapi#24

Will you be supporting SPIR-V?

From @volkertb on March 26, 2016 13:35

Since SPIR-V has been announced and blessed by the Khronos Group as the new universal intermediate representation format for both shader and kernel code, for use not only in Vulkan, but also in OpenCL going forward, I was wondering what your plans are for Aparapi to support compiling the Java kernel code to SPIR-V in addition to the current functionality?

( For those of you reading this who are not yet familiar with SPIR-V, see https://www.khronos.org/spir )

At any rate, thanks for this fun and useful library! I'm already having a lot of fun playing with Aparapi in my spare time project. Keep up the good work. :-)

Copied from original issue: aparapi/aparapi#28

[BOUNTY $25] JVM crash when using multi-dimensional local arrays

This may be a user error, since I'm relatively new to both Aparapi and OpenCL, but it seems to me that there is a problem related to multidimensional local arrays.

When I'm executing the kernel shown at https://github.com/raner/top.java.matrix/blob/syncleus-aparapi-issue-51/src/main/java/top/java/matrix/fast/TiledFastMatrix.java#L72 on my MacBook Air (Mac OS X 10.11, Intel HD Graphics 6000 with 48 execution units), I'm consistently getting a JVM crash:

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x000000011b42650c, pid=88211, tid=5891
#
# JRE version: Java(TM) SE Runtime Environment (8.0_60-b27) (build 1.8.0_60-b27)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.60-b23 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [libaparapi_x86_643808666101765060573.dylib+0xd50c]  KernelArg::setLocalBufferArg(JNIEnv_*, int, int, bool)+0x3c

The relevant snippet in the generated OpenCL code seems to be

            int tiledRow = (this->val$TILE_SIZE * tile) + localRow;
            int tiledColumn = (this->val$TILE_SIZE * tile) + localColumn;
            (&this->tileA[localColumn * this->tileA__javaArrayDimension0])[localRow]  = this->val$A[((tiledColumn * this->val$numberOfRows) + row)];
            (&this->tileB[localColumn * this->tileB__javaArrayDimension0])[localRow]  = this->val$B[((column * this->val$numberOfColumns) + tiledRow)];
            barrier(CLK_LOCAL_MEM_FENCE);
            for (int repeat = 0; repeat<this->val$TILE_SIZE; repeat++){
               value = value + ((&this->tileA[repeat * this->tileA__javaArrayDimension0])[localRow] * (&this->tileB[localColumn * this->tileB__javaArrayDimension0])[repeat]);
            }
            barrier(CLK_LOCAL_MEM_FENCE);

I noticed that it refers to the arrays' dimensions as tile…__javaArrayDimension0 to calculate the proper index into the two-dimensional array, which, I believe, is what necessitates the earlier invocation of KernelArg::setLocalBufferArg. Anyway, I didn't have the time to do a deep dive on this issue, but when I change the arrays to one-dimensional arrays and perform the index calculation myself (as shown in raner/top.java.matrix@cb4988d), the code will work correctly.

Nvidia mobile GPU

From @Oyatsumi on July 11, 2016 21:49

Currently having the following issue:

OpenCL 1.2 CUDA 8.0.0
!!!!!!! clCreateContextFromType() failed device not available
jul 11, 2016 3:20:10 AM com.amd.aparapi.internal.kernel.KernelRunner warnFallBackAndExecute
ADVERT╩NCIA: Reverting to Java Thread Pool (JTP) for class com.CopyKernel: initJNI failed to return a valid handle
!!!!!!! clCreateContextFromType() failed device not available
jul 11, 2016 3:20:10 AM com.amd.aparapi.internal.kernel.KernelRunner warnFallBackAndExecute
ADVERT╩NCIA: Reverting to Java Thread Pool (JTP) for class com.DilateKernel: initJNI failed to return a valid handle

I cant get Aparapi to run on my GTX 960M. I'm on a notebook.

It runs fine on my Intel processor, however.

I tried to recompile the code but the source have some missing headers.

Thank you so much in advance.

Copied from original issue: aparapi/aparapi#32

A kernel cannot be recompiled after it is disposed

From @sharpTrick on August 19, 2016 2:4

Any time a kernel is disposed with the intent of recompiling results in attempts to fall back to next device. This bug specifically effects this code in KernelRunner.java L1348

I believe that it is specifically due to the persistence of the seenBinaryKeys set after disposing of the jniContextHandle in KernelRunner.java L190.

I believe that by simply clearing the seenBinaryKeys set upon disposal will resolve this issue.

Copied from original issue: aparapi/aparapi#34

[BOUNTY $25] Can not directly return an instantiated array.

Generating the code for the following will return an exception:

 public class ReturnDoubleArrayNew extends Kernel {

    double[] returnDoubleArrayNew() {
        return new double[1024];
    }

    public void run() {
        returnDoubleArrayNew();
    }
}

However the following work around will compile just fine:

public class ReturnDoubleArrayVar extends Kernel {

    double[] returnDoubleArrayVar() {
        double[] doubles = new double[1024];
        return doubles;
    }

    public void run() {

        returnDoubleArrayVar();
    }
}

Calling createProgram results in exception

Anytime createProgram is called an exception is thrown due to improper linking.

java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:294)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.UnsatisfiedLinkError: com.aparapi.internal.jni.OpenCLJNI.createProgram(Lcom/aparapi/device/OpenCLDevice;Ljava/lang/String;)Lcom/aparapi/internal/opencl/OpenCLProgram;
        at com.aparapi.internal.jni.OpenCLJNI.createProgram(Native Method)
        at com.aparapi.internal.opencl.OpenCLProgram.createProgram(OpenCLProgram.java:76)
        at com.aparapi.device.OpenCLDevice.bind(OpenCLDevice.java:423)
        at com.aparapi.device.OpenCLDevice.bind(OpenCLDevice.java:351)
        at com.aparapi.examples.extension.FFTExample.main(FFTExample.java:112)
        at com.aparapi.examples.All.selected(All.java:142)
        at com.aparapi.examples.All.main(All.java:79)
        ... 6 more

This is related to this issue: Syncleus/aparapi-examples#3

error: function "getClass" declared implicitly

From @ppeter5 on November 20, 2016 12:16

I am running with JDK 1.8_101.
Here the details, this is the Aparapi Kernel:

public static class TrainKernel extends Kernel {
    private final int maps[];
    private final int vectors[];
    private final int tmp[];
    private final int mapSize, vectorSize, vectorsCount, epoch, bSize = 64;

    TrainKernel(int[][] vectors, int[][] maps, int epoch) {
        this.epoch=epoch;
        vectorSize=vectors[0].length;
        vectorsCount=vectors.length;
        this.vectors=new int[vectorsCount*vectorSize];
        int count=0;
        for (int i = 0; i < vectorsCount; i++) {
            for (int j = 0; j < vectorSize; j++, count++) {
                this.vectors[count] = vectors[i][j];
            }
        }
        mapSize = maps[0].length;
        this.maps =new int[maps.length* mapSize];
        count=0;
        for (int i = 0; i < maps.length; i++) {
            for (int j = 0; j < mapSize; j++, count++) {
                this.maps[count] = maps[i][j];
            }
        }
        tmp=new int[maps.length * mapSize * bSize];
    }

    @Override
    public void run() { 
        final int mSize= mapSize;
        final int bSize = this.bSize;
        final int mStart=mSize*getGlobalId();
        final int tStart=mStart*bSize;
        final int vectorsLength=vectors.length;
        final int vSize=vectorSize;
        final int count = vSize - mSize + 1;
        final int tLength=mSize * bSize;
        for (int e = 0; e < epoch; e++) {
            for (int i = 0; i < tLength; i++) {
                tmp[tStart+i]=0;
            }
            for (int vStart = 0; vStart < vectorsLength; vStart=vStart+vSize) {
                int maximum = 0;
                int maxIndex = 0;
                for (int i = 0; i < count; i++) {
                    int sum = 0;
                    for (int j = 0; j < mSize; j++) {
                        sum = sum + (vectors[vStart+i + j] & maps[mStart+j]);
                    }
                    if (maximum < sum) {
                        maximum = sum;
                        maxIndex = i;
                    }
                }
                for (int j = 0; j < mSize; j++) {
                    tmp[tStart+j*bSize+vectors[vStart + maxIndex + j] ^ maps[mStart + j]]++;
                }
            }
            int sum = 0;
            for (int i = 0; i < mSize; i++) {
                int maximum = 0;
                int maxIndex = 0;
                for (int j = 0; j < bSize; j++) {
                    if (maximum < tmp[tStart+i*bSize+j]) {
                        maximum = tmp[tStart+i*bSize+j];
                        maxIndex = j;
                    }
                }
                sum = sum + maxIndex;
                maps[mStart+i] = maps[mStart+i] | maxIndex;
            }
            if (sum == 0) {
                return;
            }
        }
    }
}

This is the kernel Aparapi generates:

typedef struct This_s{
int mapSize;
__global int *vectors;
int vectors__javaArrayLength0;
int vectors__javaArrayDimension0;
int vectorSize;
int epoch;
__global int *tmp;
__global int *maps;
int passid;
}This;
int get_pass_id(This *this){
return this->passid;
}
__kernel void run(
int mapSize,
__global int *vectors,
int vectors__javaArrayLength0,
int vectors__javaArrayDimension0,
int vectorSize,
int epoch,
__global int *tmp,
__global int maps,
int passid
){
This thisStruct;
This
this=&thisStruct;
this->mapSize = mapSize;
this->vectors = vectors;
this->vectors__javaArrayLength0 = vectors__javaArrayLength0;
this->vectors__javaArrayDimension0 = vectors__javaArrayDimension0;
this->vectorSize = vectorSize;
this->epoch = epoch;
this->tmp = tmp;
this->maps = maps;
this->passid = passid;
{
int mSize = this->mapSize;
getClass();
int bSize = 64;
int mStart = mSize * get_global_id(0);
int tStart = mStart * bSize;
int vectorsLength = this->vectors__javaArrayLength0;
int vSize = this->vectorSize;
int count = (vSize - mSize) + 1;
int tLength = mSize * bSize;
for (int e = 0; eepoch; e++){
for (int i = 0; i<tLength; i++){
this->tmp[tStart + i] = 0;
}
for (int vStart = 0; vStart<vectorsLength; vStart = vStart + vSize){
int maximum = 0;
int maxIndex = 0;
for (int i = 0; i<count; i++){
int sum = 0;
for (int j = 0; j<mSize; j++){
sum = sum + (this->vectors[((vStart + i) + j)] & this->maps[(mStart + j)]);
}
if (maximum<sum){
maximum = sum;
maxIndex = i;
}
}
for (int j = 0; j<mSize; j++){
this->tmp[((tStart + (j * bSize)) + this->vectors[((vStart + maxIndex) + j)]) ^ this->maps[(mStart + j)]] = this->tmp[((tStart + (j * bSize)) + this->vectors[((vStart + maxIndex) + j)]) ^ this->maps[(mStart + j)]] + 1;
}
}
int sum = 0;
for (int i = 0; i<mSize; i++){
{
int maximum = 0;
int maxIndex = 0;
for (int j = 0; j<bSize; j++){
if (maximumtmp[((tStart + (i * bSize)) + j)]){
maximum = this->tmp[((tStart + (i * bSize)) + j)];
maxIndex = j;
}
}
sum = sum + maxIndex;
this->maps[mStart + i] = this->maps[(mStart + i)] | maxIndex;
}
}
if (sum==0){
return;
}
}
return;
}
}

There is an error:

nov 20, 2016 4:00:08 PM com.amd.aparapi.internal.kernel.KernelRunner warnFallBackAndExecute
WARNING: Reverting to Java Thread Pool (JTP) for class Layer$TrainKernel: OpenCL compile failed

clBuildProgram failed


"C:\TEMP\OCL4704T1.cl", line 39: error: function "getClass" declared implicitly
getClass();
^

Copied from original issue: aparapi/aparapi#40

[BOUNTY $25] JVM Crash: SEVERE: ProfilingEvent.START encountered without ProfilingEvent.EXECUTED

Hmm when I create more then one Kernel from the same class then I suddenly run into such messages like below. I could not find anything in the documentation that this should not be supported. Basically I have an object pool of a limited number of Kernels and different threads can aquire those limited resources. But this results in a JVM crash.

Thanks
KIC

PS you could find a runnable version at: https://github.com/KIC/LPPL the problem arises at kic.lppl.SornetteTest

Connected to the target VM, address: '127.0.0.1:64263', transport: 'socket'
Oct 15, 2017 9:46:04 AM com.aparapi.internal.kernel.KernelDeviceProfile onEvent
SEVERE: ProfilingEvent.START encountered without ProfilingEvent.EXECUTED
Oct 15, 2017 9:46:05 AM com.aparapi.internal.kernel.KernelDeviceProfile onEvent
SEVERE: ProfilingEvent.START encountered without ProfilingEvent.EXECUTED
Oct 15, 2017 9:46:05 AM com.aparapi.internal.kernel.KernelDeviceProfile onEvent
SEVERE: ProfilingEvent.START encountered without ProfilingEvent.EXECUTED
Oct 15, 2017 9:46:05 AM com.aparapi.internal.kernel.KernelDeviceProfile onEvent
SEVERE: ProfilingEvent.START encountered without ProfilingEvent.EXECUTED
Oct 15, 2017 9:46:05 AM com.aparapi.internal.kernel.KernelDeviceProfile onEvent
SEVERE: ProfilingEvent.START encountered without ProfilingEvent.EXECUTED
Oct 15, 2017 9:46:05 AM com.aparapi.internal.kernel.KernelDeviceProfile onEvent
SEVERE: ProfilingEvent.START encountered without ProfilingEvent.EXECUTED
Oct 15, 2017 9:46:05 AM com.aparapi.internal.kernel.KernelDeviceProfile onEvent
SEVERE: ProfilingEvent.START encountered without ProfilingEvent.EXECUTED
Oct 15, 2017 9:46:05 AM com.aparapi.internal.kernel.KernelDeviceProfile onEvent
SEVERE: ProfilingEvent.START encountered without ProfilingEvent.EXECUTED
Oct 15, 2017 9:46:05 AM com.aparapi.internal.kernel.KernelDeviceProfile onEvent
SEVERE: ProfilingEvent.START encountered without ProfilingEvent.EXECUTED
Oct 15, 2017 9:46:05 AM com.aparapi.internal.kernel.KernelDeviceProfile onEvent
SEVERE: ProfilingEvent.START encountered without ProfilingEvent.EXECUTED
Oct 15, 2017 9:46:05 AM com.aparapi.internal.kernel.KernelDeviceProfile onEvent
SEVERE: ProfilingEvent.START encountered without ProfilingEvent.EXECUTED
Oct 15, 2017 9:46:05 AM com.aparapi.internal.kernel.KernelDeviceProfile onEvent
SEVERE: ProfilingEvent.START encountered without ProfilingEvent.EXECUTED
Oct 15, 2017 9:46:05 AM com.aparapi.internal.kernel.KernelDeviceProfile onEvent
SEVERE: ProfilingEvent.START encountered without ProfilingEvent.EXECUTED
Oct 15, 2017 9:46:05 AM com.aparapi.internal.kernel.KernelDeviceProfile onEvent
SEVERE: ProfilingEvent.START encountered without ProfilingEvent.EXECUTED
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffe652ebbdf, pid=18076, tid=0x0000000000004310
#
# JRE version: Java(TM) SE Runtime Environment (8.0_102-b14) (build 1.8.0_102-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.102-b14 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [ntdll.dll+0x3bbdf]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\xxxx\sources\kic\dataframe\LPPL\hs_err_pid18076.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Method getGroupSize not found

From @dlippold on November 21, 2016 16:34

When I use the method "getGroupSize()", defied the the table in section "Kernel methods to determine execution identity" in the Quick Reference Guide I get the following error message when compiling the class:

src/com/amd/aparapi/sample/taskinfo/Main.java:61: error: cannot find symbol
            groupSize[gid] = getGroupSize();
                             ^
  symbol: method getGroupSize()

Btw: Why are the methods from the table, in particular the method "getGlobalId()", not defined in the API documentation of the class "Kernel"? At least they should be described in the description of the class.

Copied from original issue: aparapi/aparapi#42

Single sequential execution reports error

From @dlippold on November 21, 2016 17:1

When I execute the example "add" (on Linux with JDK 7) in the single sequential Java loop, set by the property "-Dcom.amd.aparapi.executionMode=SEQ", I get the following error message:

Exception in thread "main" java.lang.IllegalStateException: Can't run range with group size >1 sequentially. Barriers would deadlock!
at com.amd.aparapi.internal.kernel.KernelRunner.executeJava(KernelRunner.java:242)
at com.amd.aparapi.internal.kernel.KernelRunner.execute(KernelRunner.java:1196)
at com.amd.aparapi.Kernel.execute(Kernel.java:2028)
at com.amd.aparapi.Kernel.execute(Kernel.java:1962)
at com.amd.aparapi.Kernel.execute(Kernel.java:1933)
at com.amd.aparapi.sample.add.Main.main(Main.java:67)

Steps to reproduce on Linux:

  1. "java -version" gives "OpenJDK Runtime Environment (IcedTea 2.6.7) (7u111-2.6.7-2~deb7u1)
    OpenJDK 64-Bit Server VM (build 24.111-b01, mixed mode)"
  2. mkdir Aparapi
  3. cd Aparapi
  4. unzip ~/dist_linux_x86_64.zip
  5. cd samples/add/
  6. java -Djava.library.path=../.. -classpath ../../aparapi.jar:add.jar -Dcom.amd.aparapi.executionMode=SEQ com.amd.aparapi.sample.add.Main

Copied from original issue: aparapi/aparapi#43

Forward references

From @Vineg on January 7, 2016 16:12

There is forward references when there is no more new methods to discover, yet call tree is not completely analyzed. I fixed it here Vineg/aparapi@4386305 but since patch appeared to be quite ugly, I didn't create pull request.

Copied from original issue: aparapi/aparapi#22

[Bounty $50] Inconsistent results between GPU and CPU when integers overflow.

The following code produces different results when run on the GPU vs the CPU.

import com.aparapi.*;

public class Main {
    public static void main(String[] args) {
        int num = 1;

        final long[] result = new long[num];
        final int start = Integer.MAX_VALUE;

        Kernel kernel = new Kernel() {
            @Override
            public void run() {
                final int id = getGlobalId();
                result[id] = calculate(start + id);
            }
        };
        kernel.execute(num);

        System.out.println( "expected: " +  calculate(start) + " result: " + result[0]);
    }

    public static long calculate(int tc) {
        return (long) tc * 100;
    }
}

The output from the above code snippet is:

expected: 214748364700 result: 4294967196

I tested this on my Macbook pro but others noticed the problem as well on other unspecified platforms. Also changin the calculate function such that 100 is a long rather than an integer with return (long) tc * 100l; (notice the letter l at the end of the 100) will produce the exact same incorrect results as above.

mavenize?

From @m0wfo on May 31, 2015 20:52

Any chance you guys could publish releases on Maven Central? It'd help a whole lot. I can send a PR w/ any necessary changes if it's of interest.

Copied from original issue: aparapi/aparapi#8

Aparapi and Ray Casting (Ray Tracing)

From @macroing on September 17, 2015 9:23

Hello!

I've used Aparapi for a while now and I really like it. The project I've been working on is an open source realtime Ray Caster (Ray Tracer).

But now I'm interested in hearing your input on Aparapi- / OpenCL specific optimizations for a project like this. Would it be a good idea to use the local and / or global buffer annotations? Or do you have any other ideas?

In case you're interested in the project, you can find it here: https://github.com/macroing/OpenRC

Copied from original issue: aparapi/aparapi#11

Definition of a constant

From @Oyatsumi on July 11, 2016 22:6

Where is the definition of com_amd_aparapi_internal_jni_KernelRunnerJNI_JNI_FLAG_USE_ACC
located in the source code?

It has not been defined and I cant compile the source code.

Thank you in advance.

Copied from original issue: aparapi/aparapi#33

AMD vs Apache License terms

Hi,

I would like to use this project as (de-facto) only continuation of initial AMD's @grfrost effort.
Is it possible to clear AMD vs Apache license compatibility issue?
In my understanding @grfrost is no more working for AMD, but moved to Google.
Would be great of AMD to relicense initial effort under Apache 2 terms.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.