|
@@ -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();
|
|
|
- }
|
|
|
}
|