Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MemoryView<T>

summary

A base class for typed arrays of values in owned or managed by CUDA.

Type parameters

  • T: TypedArray | BigIntArray = any

Hierarchy

Implements

  • ArrayBufferView

Indexable

[index: number]: T[0]

Index

Constructors

constructor

  • new MemoryView<T>(length?: number): MemoryView<T>
  • new MemoryView<T>(arrayOrArrayBuffer: Iterable<T[0]> | ArrayLike<T[0]> | MemoryData): MemoryView<T>
  • new MemoryView<T>(buffer: ArrayLike<T[0]> | MemoryData, byteOffset: number, length?: number): MemoryView<T>
  • Type parameters

    • T: TypedArray | BigIntArray = any

    Parameters

    • Optional length: number

    Returns MemoryView<T>

  • Type parameters

    • T: TypedArray | BigIntArray = any

    Parameters

    • arrayOrArrayBuffer: Iterable<T[0]> | ArrayLike<T[0]> | MemoryData

    Returns MemoryView<T>

  • Type parameters

    • T: TypedArray | BigIntArray = any

    Parameters

    • buffer: ArrayLike<T[0]> | MemoryData
    • byteOffset: number
    • Optional length: number

    Returns MemoryView<T>

Properties

Readonly BYTES_PER_ELEMENT

BYTES_PER_ELEMENT: number
summary

The size in bytes of each element in the MemoryView.

Readonly TypedArray

TypedArray: TypedArrayConstructor<T>
summary

The constructor of the MemoryView's corresponding JS TypedArray.

Readonly buffer

buffer: Memory
summary

The Memory instance referenced by the MemoryView.

Readonly byteLength

byteLength: number
summary

The length in bytes of the MemoryView.

Readonly byteOffset

byteOffset: number
summary

The offset in bytes of the MemoryView.

Readonly length

length: number
summary

The length of the MemoryView.

Static Readonly BYTES_PER_ELEMENT

BYTES_PER_ELEMENT: number

Methods

copyFrom

  • copyFrom(source: MemoryData | Iterable<number | bigint> | ArrayLike<number | bigint>, sourceStart?: number, targetStart?: number, targetEnd?: number): MemoryView<T>
  • Copies data from a region of a source MemoryView, TypedArray, or Array to a region in this MemoryView, even if the source region overlaps with this MemoryView.

    Parameters

    • source: MemoryData | Iterable<number | bigint> | ArrayLike<number | bigint>

      The MemoryView, TypedArray, or Array to copy from.

    • sourceStart: number = 0

      The offset in source at which to begin copying. Default: 0.

    • targetStart: number = 0

      The offset in this from which to begin writing. Default: 0.

    • targetEnd: number = ...

      The offset in this at which to stop writing (not inclusive). Default: this.length - targetStart.

    Returns MemoryView<T>

    this

copyInto

  • copyInto(target: any[] | MemoryData, targetStart?: number, sourceStart?: number, sourceEnd?: number): MemoryView<T>
  • Copies data from a region of this MemoryView to a region in a target MemoryView, TypedArray, or Array, even if the target region overlaps with this MemoryView.

    Parameters

    • target: any[] | MemoryData

      The MemoryView, TypedArray, or Array to copy into.

    • targetStart: number = 0

      The offset in target at which to begin writing. Default: 0.

    • sourceStart: number = 0

      The offset in this from which to begin copying. Default: 0.

    • sourceEnd: number = ...

      The offset in this at which to stop copying (not inclusive). Default: Default: this.length - sourceStart.

    Returns MemoryView<T>

    this

fill

  • fill(value: T[0], start?: number, end?: number): MemoryView<T>
  • Returns the this object after filling the section identified by start and end with value.

    Parameters

    • value: T[0]

      value to fill array section with.

    • Optional start: number

      index to start filling the array at. If start is negative, it is treated as length+start where length is the length of the array.

    • Optional end: number

      index to stop filling the array at. If end is negative, it is treated as length+end.

    Returns MemoryView<T>

getIpcHandle

set

  • set(array: MemoryData | ArrayLike<number> | ArrayLike<bigint>, start?: number): void
  • Sets a value or an array of values.

    Parameters

    • array: MemoryData | ArrayLike<number> | ArrayLike<bigint>

      A typed or untyped array of values to set.

    • Optional start: number

      The index in the current array at which the values are to be written.

    Returns void

slice

  • slice(start?: number, end?: number): MemoryViewOf<T>
  • Returns a section of an array.

    Parameters

    • Optional start: number

      The beginning of the specified portion of the array.

    • Optional end: number

      The end of the specified portion of the array. This is exclusive of the element at the index 'end'.

    Returns MemoryViewOf<T>

subarray

  • subarray(begin?: number, end?: number): MemoryViewOf<T>
  • Creates a new MemoryView view over the underlying Memory of this array, referencing the elements at begin, inclusive, up to end, exclusive.

    Parameters

    • Optional begin: number

      The index of the beginning of the array.

    • Optional end: number

      The index of the end of the array.

    Returns MemoryViewOf<T>

toArray

  • toArray(): T
  • Copies the underlying CUDA memory into a JavaScript typed array.

    Returns T

    A JavaScript typed array copy of the underlying CUDA memory.