我有一个简单的应用程序,它(现在)在一个大数组中模拟纠错。
该位生成数据并将 16 字节的 Reed-Solomon 奇偶校验添加到每个 255 字节的块中。
ReedSolomonEncoder encoder = new ReedSolomonEncoder(QR_CODE_FIELD_256);
int[][] data = new int[params.getNumBlocks()][255];
int[][] original = new int[params.getNumBlocks()][];
int value = 0;
for (int i = 0; i < params.getNumBlocks(); i++) {
int[] block = data[i];
for (int j = 0; j < 239; j++) {
value = (value + 1) % 256;
block[j] = value;
}
encoder.encode(block, 16);
original[i] = Arrays.copyOf(block, block.length);
// Corrupt a byte
block[50] += 1;
}
这是我的内核:
public class RsKernel implements Kernel {
private final int[] block;
public RsKernel(int[] block) {
this.block = block;
}
@Override
public void gpuMethod() {
block[50] -= 1;
}
}
它只是手动恢复每个块中的损坏字节(它不执行实际的 Reed-Solomon 纠错)。
我使用以下代码运行内核:
ArrayList<Kernel> kernels = new ArrayList<>(params.getNumBlocks());
for (int[] block : data) {
kernels.add(new RsKernel(block));
}
new Rootbeer().run(kernels);
我用JUnit
's验证解码assertArrayEquals
:
Assert.assertArrayEquals(original, data);
奇怪的是,如果我使用多达 8192 个(多么方便的数字)块(内核)运行此代码,则报告数据已正确解码;对于 8193 块及以上,未正确解码:
Exception in thread "main" arrays first differed at element [8192][50]; expected:<51> but was:<52>
at org.junit.Assert.internalArrayEquals(Assert.java:437)
at org.junit.Assert.internalArrayEquals(Assert.java:428)
at org.junit.Assert.assertArrayEquals(Assert.java:167)
at org.junit.Assert.assertArrayEquals(Assert.java:184)
at com.amphinicy.blink.rootbeer.RootBeerDemo.main(Jasmin)
什么可能导致这种行为?
这是输出java -jar rootbeer-1.1.14.jar -printdeviceinfo
:
device count: 1
device: GeForce GT 525M
compute_capability: 2.1
total_global_memory: 1073414144 bytes
num_multiprocessors: 2
max_threads_per_multiprocessor: 1536
clock_rate: 1200000 Hz