κρμγ 6 سال پیش
والد
کامیت
c0c8ff8004

+ 1 - 0
.gitignore

@@ -2,3 +2,4 @@
 /*.iml
 /*.ipr
 /*.iws
+/.idea

+ 7 - 0
src/main/java/in/ocsf/bee/freigeld/core/cl/DryRunnable.java

@@ -0,0 +1,7 @@
+package in.ocsf.bee.freigeld.core.cl;
+
+import com.aparapi.Kernel;
+
+abstract class DryRunnable extends Kernel {
+    abstract void dryRun();
+}

+ 40 - 0
src/main/java/in/ocsf/bee/freigeld/core/cl/KernelTri.java

@@ -0,0 +1,40 @@
+package in.ocsf.bee.freigeld.core.cl;
+
+import com.aparapi.Kernel;
+
+import java.math.BigInteger;
+
+public class KernelTri {
+
+    //трайт
+    public static final int N = 3 * 3 * 3;
+    public static final int TN = N * N * N;
+    public static final int MAX_TRYTE = TN / 2;
+    public static final int MIN_TRYTE = -TN / 2;
+
+    //слово, три трайта
+    public static final int TRI_WORD_LEN = 3;
+    public static final long WN = (long) TN * TN * TN;
+    public static final long MAX_TRI_WORD = WN / 2;
+    public static final long MIN_TRI_WORD = -WN / 2;
+
+    //длинное слово, 9 трайтов
+    public static final int TRI_LONG_WORD_LEN = 9;
+    public static final BigInteger LN = new BigInteger("443426488243038000000000000000000000000");
+    public static final BigInteger MAX_TRI_LONG_WORD = LN.divide(BigInteger.valueOf(2));
+    public static final BigInteger MIN_TRI_LONG_WORD = LN.divide(BigInteger.valueOf(-2));
+
+    public Kernel getKernel() {
+        return new Kernel() {
+            @Override
+            public void run() {
+
+            }
+        };
+    }
+
+    public static class RawTriSet {
+
+
+    }
+}

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

@@ -26,7 +26,7 @@ public class Sample1 implements Runnable {
         else
             throw new RuntimeException("no opencl device");
 
-        log.info(device.getName());
+        log.info(device.getShortDescription() + " " + device.getName());
         TOTAL_MEM = Long.valueOf(Math.min(128, device.getMaxMemAllocSize() / 1024 / 1024 / 2)).intValue() * 1024 * 1024;
     }
 
@@ -50,20 +50,21 @@ public class Sample1 implements Runnable {
 
         Kernel kernel = new DryRunnable() {
 
-            protected @PrivateMemorySpace(1)
+            @Constant
             boolean[] dryRun = new boolean[]{false};
 
-            protected @PrivateMemorySpace(pB)
+            @PrivateMemorySpace(pB)
             byte[] membuf = new byte[pB];
-            protected @PrivateMemorySpace(5)
+            @PrivateMemorySpace(5)
             int[] bufposlimits = new int[5];
 
             private void mem2buf() {
                 int p0 = bufposlimits[pBpos];
                 int len = bufposlimits[pBlen];
+                int from = bufposlimits[pBfrom];
                 int p = p0;
                 while (p < p0 + len - 1) {
-                    membuf[p - p0] = mm[p];
+                    membuf[p - p0] = mm[from + p];
                     p++;
                 }
             }
@@ -71,15 +72,16 @@ public class Sample1 implements Runnable {
             private void buf2mem() {
                 int p0 = bufposlimits[pBpos];
                 int len = bufposlimits[pBlen];
+                int from = bufposlimits[pBfrom];
                 int p = p0;
                 while (p < p0 + len - 1) {
-                    mm[p] = membuf[p - p0];
+                    mm[from + p] = membuf[p - p0];
                     p++;
                 }
             }
 
             private void initbuf() {
-                int x = dryRun[0] ? 3 : getGlobalId(0);
+                int x = dryRun[0] ? 1 : getGlobalId(0);
                 int xN = dryRun[0] ? G : getGlobalSize(0);
                 int block = mm.length / xN;
                 bufposlimits[pBtotal] = block;
@@ -164,6 +166,7 @@ public class Sample1 implements Runnable {
 
             @Override
             public void run() {
+                int x = getGlobalId(0);
                 initbuf();
                 memset(0, (byte) 1);
                 byte val = memget(0);
@@ -216,7 +219,4 @@ public class Sample1 implements Runnable {
         kernel.dispose();
     }
 
-    abstract class DryRunnable extends Kernel {
-        abstract void dryRun();
-    }
 }

+ 4 - 0
src/main/java/in/ocsf/bee/freigeld/core/cl/Sample3.java

@@ -0,0 +1,4 @@
+package in.ocsf.bee.freigeld.core.cl;
+
+public class Sample3 {
+}

+ 1 - 1
src/main/resources/application-dev.yaml

@@ -1,2 +1,2 @@
 server:
-  port: 4200
+  port: 4200