Closed howarth closed 6 years ago
Yes. You can get the raw buffer with the uncomplicate.neanderthal.block/buffer
function. Please note that there is no such thing as "pointer" in Java, but only references and values. That buffer is native, but you can only get the C pointer of that array when you drop into the JNI layer.
Ok, thank you! I'm confused because Block.java
shows that buffer returns an Object
. I normally program in MATLAB/Python so I'm pretty noob with respect to java/c.
So would
env->GetDirectBufferAddress(buffer)
be what I use to get the pointer in the JNI layer?
Also, what is offset
in Block.java
?
Or is it the case that when I pass the Object returned from Block.buffer down to the JNI layer the variable that holds that Object reference is itself the pointer? Sorry if these questions don't make sense.
For the example that you provide (main memory dge/dv) you'll get DirectByteBuffer
and you can get its direct pointer with GetDirectBufferAddress
. If you have another type of Buffer
, that won't work.
offset
is, well, the offset from the address of the buffer to the first element that is used in the vector or matrix. Also note that neanderthal supports many matrix layouts, so not all bytes in that byte buffer (C array) are always relevant.
Ok, when you say different layouts, are you talking about Native, CL, and CU?
No. GE, TR, etc.
Hello, I'd like to use this library but require the following functionality. I can do the work of figuring out how to do it, but I wanted to ask you if it's even possible.
Given a vector or matrix created by, for example,
(dv 10)
or(dge 2 3)
could I access the pointer to the location of that matrix in memory? I have some code that loads data from disk into vectors or matrices across different languages because in MATLAB/NumPy/Julia all matrices are the same in memory (so that BLAS/etc can use them)I.e. I want to be able to write the following