java.lang.Object
uk.ac.manchester.tornado.api.types.arrays.TornadoNativeArray
- Direct Known Subclasses:
ByteArray,CharArray,DoubleArray,FloatArray,HalfFloatArray,Int8Array,IntArray,LongArray,ShortArray,Tensor
public abstract sealed class TornadoNativeArray
extends Object
permits ByteArray, CharArray, DoubleArray, FloatArray, HalfFloatArray, IntArray, LongArray, ShortArray, Int8Array, Tensor
TornadoNativeArray relies on preview features of the Java platform:
TornadoNativeArrayrefers to one or more preview APIs:MemorySegment.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
This abstract sealed class represents the common functionality of the TornadoVM custom native arrays,
(e.g.,
ByteArray, IntArray, etc.)
The class provides methods for retrieving the number of elements stored in the native arrays, for obtaining the underlying memory segment, for clearing the data, for calculating the total number of bytes occupied by the memory segment, and for getting the number of bytes, excluding the array header size.
The constant ARRAY_HEADER represents the size of the header in bytes.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidclear()Clears the contents of the native array.abstract intabstract longReturns the number of bytes of theMemorySegmentPREVIEW, excluding the header bytes.abstract longReturns the total number of bytes that theMemorySegmentPREVIEW occupies, including the header bytes.abstract MemorySegmentPREVIEWReturns the underlyingMemorySegmentPREVIEW of the native array, without the Tornado Array header.abstract MemorySegmentPREVIEWReturns the underlyingMemorySegmentPREVIEW of the native array, including the header.abstract intgetSize()Returns the number of elements stored in the native array.
-
Field Details
-
ARRAY_HEADER
public static final long ARRAY_HEADERThe size of the header in bytes. It sets the default value either to 16 or 24, depending on whether the uncompressed flags are passed by the user. It can also be configurable through the "tornado.panama.objectHeader" system property.
-
-
Constructor Details
-
TornadoNativeArray
public TornadoNativeArray()
-
-
Method Details
-
getSize
public abstract int getSize()Returns the number of elements stored in the native array.- Returns:
- The number of elements of the native data array.
-
getSegment
Returns the underlyingMemorySegmentPREVIEW of the native array, without the Tornado Array header.- Returns:
- The
MemorySegmentPREVIEW associated with the native array instance.
-
getSegmentWithHeader
Returns the underlyingMemorySegmentPREVIEW of the native array, including the header.- Returns:
- The
MemorySegmentPREVIEW associated with the native array instance.
-
getNumBytesOfSegmentWithHeader
public abstract long getNumBytesOfSegmentWithHeader()Returns the total number of bytes that theMemorySegmentPREVIEW occupies, including the header bytes.- Returns:
- The total number of bytes of the
MemorySegmentPREVIEW.
-
getNumBytesOfSegment
public abstract long getNumBytesOfSegment()Returns the number of bytes of theMemorySegmentPREVIEW, excluding the header bytes.- Returns:
- The number of bytes of the raw data in the
MemorySegmentPREVIEW.
-
clear
protected abstract void clear()Clears the contents of the native array. -
getElementSize
public abstract int getElementSize()
-
TornadoNativeArraywhen preview features are enabled.