Jelajahi Sumber

cleanup, new era

kpmy 5 tahun lalu
induk
melakukan
5159ff612c

+ 2 - 8
pom.xml

@@ -11,14 +11,14 @@
     <properties>
         <java.version>1.8</java.version>
         <maven-surefire-plugin.version>2.21.0</maven-surefire-plugin.version>
-        <kotlin.version>1.3.10</kotlin.version>
+        <kotlin.version>1.3.70</kotlin.version>
         <target>1.8</target>
     </properties>
 
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>2.0.3.RELEASE</version>
+        <version>2.2.6.RELEASE</version>
     </parent>
 
     <dependencies>
@@ -62,12 +62,6 @@
             <version>2.9.4.1</version>
         </dependency>
 
-        <dependency>
-            <groupId>com.aparapi</groupId>
-            <artifactId>aparapi</artifactId>
-            <version>1.8.0</version>
-        </dependency>
-
     </dependencies>
 
     <build>

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

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

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

@@ -1,40 +0,0 @@
-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 {
-
-
-    }
-}

+ 0 - 21
src/main/java/in/ocsf/bee/freigeld/core/cl/Pt.java

@@ -1,21 +0,0 @@
-package in.ocsf.bee.freigeld.core.cl;
-
-final class Pt {
-        private int x, y;
-
-        public int getX() {
-            return x;
-        }
-
-        public void setX(int x) {
-            this.x = x;
-        }
-
-        public int getY() {
-            return y;
-        }
-
-        public void setY(int y) {
-            this.y = y;
-        }
-    }

+ 0 - 60
src/main/java/in/ocsf/bee/freigeld/core/cl/Sample0.java

@@ -1,60 +0,0 @@
-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 Sample0 implements Runnable {
-
-    private final Logger log = Logger.getLogger(getClass().getName());
-
-    @Override
-    public void run() {
-        final int R = 1024;
-        final int[] buffer_$constant$ = new int[]{1,2,3,4,5,6,7,8,9};
-
-        final float[] resultF = new float[R];
-        final boolean[] resultB = new boolean[R];
-        final byte[] resultH = new byte[R];
-        final short[] resultS = new short[R];
-        final int[] resultI = new int[R];
-        final long[] resultL = new long[R];
-        final Pt[] resultO = new Pt[R];
-
-        for(int i = 0; i<R; i++)
-            resultO[i] = new Pt();
-
-        Kernel kernel = new Kernel() {
-
-            protected @PrivateMemorySpace(4) short[] myBuffer = new short[4];
-            @Constant int[] myBufferConstant  = new int[]{0, 1, 2, 3};
-            @Local  final int[] buffer = new int[R];
-
-            @Override
-            public void run() {
-                int i = getGlobalId();
-                for(int j = 0; j < myBuffer.length; j++){
-                    myBuffer[j] = (short) j;
-                }
-                buffer[i] = -i;
-                localBarrier();
-                resultB[i] = i % 2 == 0;
-                resultL[i] = buffer_$constant$[i % 4];
-                resultI[i] = myBufferConstant[i % 4];
-                resultS[i] = myBuffer[i % 4];
-                resultH[i] = (byte) buffer[i];
-                resultF[i] = resultI[i];
-                resultO[i].setX(i);
-                resultO[i].setY(i);
-            }
-        };
-        Device device = Device.best();
-        Range range = Range.create(device, R);
-        log.info("opencl run");
-        kernel.execute(range, 1024);
-        log.info("done opencl run");
-    }
-
-}

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

@@ -1,222 +0,0 @@
-package in.ocsf.bee.freigeld.core.cl;
-
-import com.aparapi.Kernel;
-import com.aparapi.Range;
-import com.aparapi.device.Device;
-import com.aparapi.device.OpenCLDevice;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.logging.Logger;
-
-public class Sample1 implements Runnable {
-
-    private final ObjectMapper objectMapper = new ObjectMapper();
-
-    private final Logger log = Logger.getLogger(getClass().getName());
-    private final Integer TOTAL_MEM;
-    private OpenCLDevice device;
-
-    public Sample1() {
-        Device _device = Device.best();
-        if (_device instanceof OpenCLDevice)
-            this.device = (OpenCLDevice) _device;
-        else
-            throw new RuntimeException("no opencl device");
-
-        log.info(device.getShortDescription() + " " + device.getName());
-        TOTAL_MEM = Long.valueOf(Math.min(128, device.getMaxMemAllocSize() / 1024 / 1024 / 2)).intValue() * 1024 * 1024;
-    }
-
-    @Override
-    public void run() {
-        final int N = 4;
-        final int G = 32;
-
-        final int pB = 4 * 1024;
-        final int pBtotal = 0;
-        final int pBfrom = 1;
-        final int pBto = 2;
-        final int pBpos = 3;
-        final int pBlen = 4;
-
-        final byte[] mm = new byte[TOTAL_MEM];
-        final long[] arg = new long[3];
-        final long[][] mem = new long[N][G];
-        final long[][] res = new long[2][16];
-        final AtomicInteger[] at = new AtomicInteger[]{new AtomicInteger(0), new AtomicInteger(0), new AtomicInteger(0)};
-
-        Kernel kernel = new DryRunnable() {
-
-            @Constant
-            boolean[] dryRun = new boolean[]{false};
-
-            @PrivateMemorySpace(pB)
-            byte[] membuf = new byte[pB];
-            @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[from + p];
-                    p++;
-                }
-            }
-
-            private void buf2mem() {
-                int p0 = bufposlimits[pBpos];
-                int len = bufposlimits[pBlen];
-                int from = bufposlimits[pBfrom];
-                int p = p0;
-                while (p < p0 + len - 1) {
-                    mm[from + p] = membuf[p - p0];
-                    p++;
-                }
-            }
-
-            private void initbuf() {
-                int x = dryRun[0] ? 1 : getGlobalId(0);
-                int xN = dryRun[0] ? G : getGlobalSize(0);
-                int block = mm.length / xN;
-                bufposlimits[pBtotal] = block;
-                int from = x * block;
-                int to = (x + 1) * block - 1;
-                bufposlimits[pBfrom] = from;
-                bufposlimits[pBto] = to;
-                bufpos(0);
-            }
-
-            private void bufpos(int pos) {
-                if (pos >= bufposlimits[pBpos] && pos < (bufposlimits[pBpos] + bufposlimits[pBlen]))
-                    return;
-
-                bufposlimits[pBpos] = max(0, min(bufposlimits[pBtotal] - pB, pos));
-                bufposlimits[pBlen] = min(bufposlimits[pBtotal] - bufposlimits[pBpos], pB);
-                mem2buf();
-            }
-
-            private void memset(int pos, byte val) {
-                bufpos(pos);
-                int pos0 = bufposlimits[pBpos];
-                membuf[pos - pos0] = val;
-            }
-
-            private byte memget(int pos) {
-                bufpos(pos);
-                int pos0 = bufposlimits[pBpos];
-                return membuf[pos - pos0];
-            }
-
-            private void test() {
-                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 lx = getLocalId(0);
-                int ly = getLocalId(1);
-                int lz = getLocalId(2);
-                int lxN = getLocalSize(0);
-                int lyN = getLocalSize(1);
-                int lzN = getLocalSize(2);
-                int p = getPassId();
-
-                mem[0][x] = (x + 1) * 1000000 + (gx + 1) * 1000 + (lx + 1);
-                mem[1][y] = (y + 1) * 1000000 + (gy + 1) * 1000 + (ly + 1);
-                mem[2][z] = (z + 1) * 1000000 + (gz + 1) * 1000 + (lz + 1);
-
-                res[0][0] = p;
-                res[0][1] = xN;
-                res[0][2] = yN;
-                res[0][3] = zN;
-                res[0][4] = gxN;
-                res[0][5] = gyN;
-                res[0][6] = gzN;
-                res[0][7] = lxN;
-                res[0][8] = lyN;
-                res[0][9] = lzN;
-
-                atomicInc(at[0]);
-                atomicInc(at[1]);
-                atomicInc(at[2]);
-                int block = mm.length / xN;
-                int from = x * block;
-                int to = (x + 1) * block - 1;
-                mem[3][x] = to;
-                int i = from;
-                while (i <= to) {
-                    mm[i] = (byte) (x + 1);
-                    i++;
-                }
-            }
-
-
-            @Override
-            public void run() {
-                int x = getGlobalId(0);
-                initbuf();
-                memset(0, (byte) 1);
-                byte val = memget(0);
-                if (val == 1) memset(1, (byte) 1);
-                buf2mem();
-            }
-
-            public void dryRun() {
-                dryRun[0] = true;
-                run();
-                dryRun[0] = false;
-            }
-        };
-
-        Range range = Range.create(device, G);
-        /*switch (device.getMaxWorkItemDimensions()){
-            case 1:
-                range = Range.create(device, G);
-                break;
-            case 2:
-                range = Range.create2D(device, G, G);
-                break;
-            case 3:
-                range = Range.create3D(device, G, G, G);
-                break;
-            default:
-                throw new RuntimeException("not supported");
-        }*/
-        try {
-            ((DryRunnable) kernel).dryRun();
-            kernel.execute(range, 1);
-        } catch (Exception e) {
-            throw new RuntimeException("dry run failed", e);
-        }
-        Map<String, Object> info = new HashMap<>();
-        info.put("time", kernel.getAccumulatedExecutionTime() / 1000.0);
-        info.put("memg", TOTAL_MEM / 1024.0 / 1024.0);
-        info.put("meml", device.getLocalMemSize() / 1024.0);
-        try {
-            log.info(objectMapper.writer().withDefaultPrettyPrinter().writeValueAsString(info));
-            log.info(objectMapper.writeValueAsString(mem[0]));
-            log.info(objectMapper.writeValueAsString(mem[1]));
-            log.info(objectMapper.writeValueAsString(mem[2]));
-            log.info(objectMapper.writeValueAsString(res[0]));
-            log.info(objectMapper.writeValueAsString(res[1]));
-            log.info(objectMapper.writeValueAsString(at));
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-        kernel.dispose();
-    }
-
-}

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

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

+ 4 - 0
src/main/java/in/ocsf/bee/freigeld/core/model/Person.java

@@ -0,0 +1,4 @@
+package in.ocsf.bee.freigeld.core.model;
+
+public interface Person {
+}

+ 2 - 24
src/main/kotlin/in/ocsf/bee/freigeld/core/FreiApp.kt

@@ -1,17 +1,12 @@
 package `in`.ocsf.bee.freigeld.core
 
-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.Profile
 import org.springframework.context.annotation.PropertySource
 import org.springframework.scheduling.annotation.EnableScheduling
-import org.springframework.scheduling.annotation.Scheduled
 import org.springframework.stereotype.Service
-import org.springframework.web.bind.annotation.RequestMapping
 import org.springframework.web.bind.annotation.RestController
-import org.springframework.web.client.RestTemplate
 import sun.misc.Unsafe
 import javax.annotation.PostConstruct
 
@@ -27,28 +22,11 @@ class FreiApp{
 }
 
 @RestController
-class DevController{
-
-    @RequestMapping("dev/test0")
-    fun test0() {
-        Sample0().run()
-    }
-
-    @RequestMapping("dev/test1")
-    fun test1() {
-        Sample1().run()
-    }
-}
+class DevController
 
 @Service
 @Profile("dev")
-class DevService {
-
-    @Scheduled(fixedRate = 10000L, initialDelay = 5000L)
-    fun init() {
-        RestTemplate().getForObject("http://127.0.0.1:4200/frei/dev/test1", String::class.java)
-    }
-}
+class DevService
 
 fun main(args: Array<String>) {
     disableWarning()