trying to use Aparapi, using Maven as a build manager and Intellij as my IDE. my Laptop does not have a GPU installed, but from what I understand, Aparapi will use a ThreadPool instead of a GPU. From what i understand as well, Aparapi converts to OpenCL. I do not have OpenCL installed, but the lead from 2018 stated that if I use a version of Aparapi through Maven, there is no need to install anything.
I am trying to run the sample code from the AMD Add sample here: I've tried looking at the samples from Syncleus, but all the links on the github page time out. I've changed the imports from com.amd.aparapi.Kernel to com.aparapi.Kernel for example.
if you do not wish to click on the link, the code I'm running is:
import com.aparapi.Kernel;
import com.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(size));
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();
}
}
I copy pasted the main method into my project and ran it and got this error message (project name suggests its a ray cast project, but the only code in the project right now is the Add sample.):
Jun 01, 2023 2:12:07 PM com.aparapi.internal.model.ClassModel$AttributePool <init>
WARNING: Found unexpected Attribute (name = NestHost)
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:465)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1082)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field final float[] com.potato.ray_casting_maven.App$1.val$sum accessible: module com.potato.ray_casting_maven does not "opens com.potato.ray_casting_maven" to module aparapi
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
at aparapi@3.0.0/com.aparapi.internal.kernel.KernelRunner.executeInternalInner(KernelRunner.java:1731)
at aparapi@3.0.0/com.aparapi.internal.kernel.KernelRunner.executeInternalOuter(KernelRunner.java:1471)
at aparapi@3.0.0/com.aparapi.internal.kernel.KernelRunner.execute(KernelRunner.java:1454)
at aparapi@3.0.0/com.aparapi.Kernel.execute(Kernel.java:2907)
at aparapi@3.0.0/com.aparapi.Kernel.execute(Kernel.java:2864)
at aparapi@3.0.0/com.aparapi.Kernel.execute(Kernel.java:2804)
at com.potato.ray_casting_maven/com.potato.ray_casting_maven.App.main(App.java:50)
... 11 more
Exception running application com.potato.ray_casting_maven.App
WARNING: Aparapi is running on an untested OpenCL platform version: OpenCL 3.0
my module-info.java looks like this:
module com.potato.ray_casting_maven {
requires javafx.controls;
requires javafx.fxml;
requires aparapi;
requires aparapi.jni;
opens com.potato.ray_casting_maven to javafx.fxml;
exports com.potato.ray_casting_maven;
}
and my Pom.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.potato</groupId>
<artifactId>ray_casting_maven</artifactId>
<version>1.0-SNAPSHOT</version>
<name>ray_casting_maven</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.8.2</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>com.aparapi</groupId>
<artifactId>aparapi</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>17.0.2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<executions>
<execution>
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>com.potato.ray_casting_maven/com.potato.ray_casting_maven.App
</mainClass>
<launcher>app</launcher>
<jlinkZipName>app</jlinkZipName>
<jlinkImageName>app</jlinkImageName>
<noManPages>true</noManPages>
<stripDebug>true</stripDebug>
<noHeaderFiles>true</noHeaderFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I tried adding to my module-info:
opens com.potato.ray_casting_maven to aparapi;
but it does not recognize aparapi, or anything referring to aparapi if let Intellij show me the different options of things to open to.
Messing with the code, running kernel.execute is whats throwing the error. using kernel.run does not, but it only runs 1 instance instead of a given number of instances.
I do not currently have access to a machine with a GPU as of posting this question. If that makes a difference I will edit this question.