kpmy %!s(int64=6) %!d(string=hai) anos
pai
achega
9e8df5e0d7

+ 1 - 2
src/main/java/in/ocsf/bee/freigeld/core/cl/Sample.java → src/main/java/in/ocsf/bee/freigeld/core/cl/Sample0.java

@@ -3,11 +3,10 @@ package in.ocsf.bee.freigeld.core.cl;
 import com.aparapi.Kernel;
 import com.aparapi.Range;
 import com.aparapi.device.Device;
-import com.aparapi.internal.kernel.KernelManager;
 
 import java.util.logging.Logger;
 
-public class Sample implements Runnable {
+public class Sample0 implements Runnable {
 
     private final Logger log = Logger.getLogger(getClass().getName());
 

+ 48 - 0
src/main/java/in/ocsf/bee/freigeld/core/cl/Sample1.java

@@ -0,0 +1,48 @@
+package in.ocsf.bee.freigeld.core.cl;
+
+import com.aparapi.Kernel;
+import com.aparapi.Range;
+import com.aparapi.device.Device;
+
+import java.util.logging.Logger;
+
+public class Sample1 implements Runnable {
+
+    private final Logger log = Logger.getLogger(getClass().getName());
+
+    @Override
+    public void run() {
+        final int N = 4;
+        final int R = 2;
+
+        final long[][][] mem = new long[R][R][R];
+
+        Kernel kernel = new Kernel() {
+
+            @Override
+            public void run() {
+                int x = getGlobalId(0);
+                int y = getGlobalId(1);
+                int z = getGlobalId(2);
+                int xN = getGlobalSize(0);
+                int yN = getGlobalSize(1);
+                int zN = getGlobalSize(2);
+                int gx = getGroupId(0);
+                int gy = getGroupId(1);
+                int gz = getGroupId(2);
+                int gxN = getNumGroups(0);
+                int gyN = getNumGroups(1);
+                int gzN = getNumGroups(2);
+                int l = getLocalId();
+                int lN = getLocalSize();
+                int p = getPassId();
+                mem[x][y][z] = gxN * 100 + gyN * 10 + gzN;
+            }
+        };
+
+        Device device = Device.best();
+        Range range = Range.create3D(device, R, R, R);
+        kernel.execute(range, 1);
+        log.info("done");
+    }
+}

+ 11 - 6
src/main/kotlin/in/ocsf/bee/freigeld/core/FreiApp.kt

@@ -1,10 +1,10 @@
 package `in`.ocsf.bee.freigeld.core
 
-import `in`.ocsf.bee.freigeld.core.cl.*
+import `in`.ocsf.bee.freigeld.core.cl.Sample0
+import `in`.ocsf.bee.freigeld.core.cl.Sample1
 import org.springframework.boot.SpringApplication
 import org.springframework.boot.autoconfigure.SpringBootApplication
 import org.springframework.context.annotation.PropertySource
-import org.springframework.context.annotation.PropertySources
 import org.springframework.web.bind.annotation.RequestMapping
 import org.springframework.web.bind.annotation.RestController
 import sun.misc.Unsafe
@@ -25,19 +25,24 @@ class DevController{
 
     @RequestMapping("dev/test0")
     fun test0() {
-        Sample().run();
+        Sample0().run()
+    }
+
+    @RequestMapping("dev/test1")
+    fun test1() {
+        Sample1().run()
     }
 }
 
 fun main(args: Array<String>) {
-    disableWarning();
+    disableWarning()
     SpringApplication.run(FreiApp::class.java, *args)
 }
 
 fun disableWarning() {
     try {
-        val theUnsafe = Unsafe::class.java!!.getDeclaredField("theUnsafe")
-        theUnsafe.setAccessible(true)
+        val theUnsafe = Unsafe::class.java.getDeclaredField("theUnsafe")
+        theUnsafe.isAccessible = true
         val u = theUnsafe.get(null) as Unsafe
         val cls = Class.forName("jdk.internal.module.IllegalAccessLogger")
         val logger = cls.getDeclaredField("logger")