I am currently working on a project which requires memory allocation of a HUGE amount of data (on the order of 1 Terrabyte) in System memory.
From what I’ve read about SVM (here, for example) OpenCL 2.0 does support the capability of allocating SVM on the host side allowing access by both the kernel and the host, so theoretically it should be possible to use very large chunks of memory (up to the maximum available System memory on the host machine). This is, of course, assuming the GPU address bus is wide enough.
Am I correct in assuming that this is not currently supported in JOCL? I have found the deprecated method CL#allocateAligned(int size, int alignment) which, I’m guessing, is what is needed to be able to allocate System memory from Java. However, this method only accepts a 4 byte signed “int” for the “size” parameter, which reduces the maximum amount of memory that can be allocated to 2GB. I understand that this is because of the limitation in the underlying DirectByteBuffer class, which also only accepts an “int” for “capacity”. After poking around in DirectByteBuffer I found that Unsafe#allocateMemory(long size) used to do the actual System memory allocation, does indeed support “long” values.
I am proposing to add an overloaded allocateAligned(long size, int alignment) and a corresponding allocateAlignedNative() method to accept an 8-byte signed value, and then providing a new class, e.g. HugeDirectByteBuffer which accepts a “long” for “capacity”. Does this sound like a reasonable thing to do?