public class Pointer extends NativePointerObject
Modifier | Constructor and Description |
---|---|
|
Pointer()
Creates a new (
null ) Pointer |
protected |
Pointer(long nativePointerValue)
Constructor which accepts a constant value as the pointer value.
|
protected |
Pointer(Pointer other)
Copy constructor
|
protected |
Pointer(Pointer other,
long byteOffset)
Creates a copy of the given pointer, with an
additional byte offset
|
Modifier and Type | Method and Description |
---|---|
ByteBuffer |
getByteBuffer()
Returns a ByteBuffer that corresponds to the memory that this
pointer points to.
|
ByteBuffer |
getByteBuffer(long byteOffset,
long byteSize)
Returns a ByteBuffer that corresponds to the specified
segment of the memory that this pointer points to.
|
protected long |
getByteOffset()
Returns the byte offset
|
static Pointer |
to(Buffer buffer)
NOTE: This method does not take into account the position
and array offset of the given buffer.
|
static Pointer |
to(byte[] values)
Creates a new Pointer to the given values.
|
static Pointer |
to(char[] values)
Creates a new Pointer to the given values.
|
static Pointer |
to(double[] values)
Creates a new Pointer to the given values.
|
static Pointer |
to(float[] values)
Creates a new Pointer to the given values.
|
static Pointer |
to(int[] values)
Creates a new Pointer to the given values.
|
static Pointer |
to(long[] values)
Creates a new Pointer to the given values.
|
static Pointer |
to(NativePointerObject... pointers)
Creates a new Pointer to the given Pointers.
|
static Pointer |
to(short[] values)
Creates a new Pointer to the given values.
|
static Pointer |
toBuffer(Buffer buffer)
Creates a new Pointer to the given buffer.
|
String |
toString()
Returns a String representation of this object.
|
Pointer |
withByteOffset(long byteOffset)
Returns a new pointer with an offset of the given number
of bytes
|
equals, getNativePointer, hashCode
public Pointer()
null
) Pointerprotected Pointer(long nativePointerValue)
nativePointerValue
- The native pointer valueprotected Pointer(Pointer other)
other
- The other Pointerprotected Pointer(Pointer other, long byteOffset)
other
- The other pointerbyteOffset
- The additional byte offsetpublic static Pointer to(byte[] values)
values
- The values the pointer should point topublic static Pointer to(char[] values)
values
- The values the pointer should point topublic static Pointer to(short[] values)
values
- The values the pointer should point topublic static Pointer to(int[] values)
values
- The values the pointer should point topublic static Pointer to(float[] values)
values
- The values the pointer should point topublic static Pointer to(long[] values)
values
- The values the pointer should point topublic static Pointer to(double[] values)
values
- The values the pointer should point topublic static Pointer to(Buffer buffer)
toBuffer(Buffer)
method. slice
method (like ByteBuffer.slice()
). If the buffer is
direct, then this method will return a Pointer to the address
of the direct buffer. If the buffer has been created using the
slice
method, then this will be the actual start
of the slice. Although this implies a different treatment of
direct- and non direct buffers, the method is kept for
backward compatibility. buffer
- The buffer the pointer should point toIllegalArgumentException
- If the given buffer
is null or is neither direct nor has a backing arraypublic static Pointer toBuffer(Buffer buffer)
to(Buffer)
method.buffer
- The bufferIllegalArgumentException
- If the given buffer
is null or is neither direct nor has a backing arraypublic static Pointer to(NativePointerObject... pointers)
null
, and may not
contain null
elements.pointers
- The pointers the pointer should point toIllegalArgumentException
- If the given array
is nullpublic Pointer withByteOffset(long byteOffset)
byteOffset
- The byte offset for the pointerpublic ByteBuffer getByteBuffer(long byteOffset, long byteSize)
ByteOrder#nativeOrder()
. It will be a slice of the
buffer that is stored internally. So it will share the same memory,
but its position and limit will be independent of the internal buffer.
JCudaDriver.cuMemAllocHost(jcuda.Pointer, long)
JCudaDriver.cuMemHostAlloc(jcuda.Pointer, long, int)
JCudaDriver.cuMemAllocManaged(jcuda.driver.CUdeviceptr, long, int)
JCuda.cudaMallocHost(jcuda.Pointer, long)
JCuda.cudaHostAlloc(jcuda.Pointer, long, int)
JCuda.cudaMallocManaged(jcuda.Pointer, long, int)
to(byte[])
null
is returned.byteOffset
- The offset in bytesbyteSize
- The size of the byte buffer, in bytesIllegalArgumentException
- If the byteOffset
and
byteSize
describe an invalid memory range (for example,
when the byteOffset
is negative)ArithmeticException
- If the byteOffset
or
byteOffset + byteSize
overflows an int
.public ByteBuffer getByteBuffer()
ByteOrder#nativeOrder()
. It will be a slice of the
buffer that is stored internally. So it will share the same memory,
but its position and limit will be independent of the internal buffer.
JCudaDriver.cuMemAllocHost(jcuda.Pointer, long)
JCudaDriver.cuMemHostAlloc(jcuda.Pointer, long, int)
JCudaDriver.cuMemAllocManaged(jcuda.driver.CUdeviceptr, long, int)
JCuda.cudaMallocHost(jcuda.Pointer, long)
JCuda.cudaHostAlloc(jcuda.Pointer, long, int)
JCuda.cudaMallocManaged(jcuda.Pointer, long, int)
to(byte[])
null
is returned.protected long getByteOffset()
public String toString()
toString
in class NativePointerObject
Copyright © 2020. All rights reserved.