我有一个 Java 程序需要从 GPU 的本地内存访问一个大型数组。我可以使用'@Local float[] mem = new float[1000000];'声明和访问一个大数组 在带有 AMD Radeon GPU 的笔记本电脑上使用 Aparapi,它工作得很好,但是当我在带有 Nvidia GeForce 1660 Ti 的笔记本电脑上尝试同样的事情时,我从 OpenCl 得到资源不足错误。Nvidia 卡有 3 Gigs 的共享内存,所以我认为它应该没有问题,但显然不是。
几个小时以来,我一直在用谷歌寻找解决问题的方法,但我找不到任何相关文件。
下面是初始化内核内存的代码:
public class MemoryKernel extends Kernel {
/** Working memory - each worker gets its own individual area of fixed memory. It is
* protected so that the test cases can access it. */
@Local protected final float[] mem;
/** Memory size in blocks */
final int memSize;
/** Size of a block of memory */
final int blockSize;
/** Number of worker items */
int workGroupSize;
/** A small buffer for testing purposes */
final float[] buf;
public MemoryKernel(int blockSize, int memSizeInBlocks, int workGroupSize) {
this.memSize = memSizeInBlocks;
this.blockSize = blockSize;
// A typical initialisation is 17 * 50 * 1000
mem = new float[memSizeInBlocks * blockSize * workGroupSize];
initMem(workGroupSize);
// A small buffer accessed only by the test cases in the gputrace.test package for testing
// the ray tracer's functions
buf = new float[blockSize];
setExplicit(true);
put(buf);
}
...