HardwareComputeLimits

Package: Libraries.Compute.Hardware · Inherits from: Libraries.Language.Object

The HardwareComputeLimits class holds what a compute device allows, in terms that don't depend on the graphics system: how large a work group may be, how many work groups one run may have, how much shared memory a work group may use, how large a block of data may be, and whether the device has 64-bit numbers and 64-bit integers. A HardwareComputeDevice fills one in (GetLimits); programs read it to choose work group sizes that fit.

Example Code

use Libraries.Game.GameStateManager
use Libraries.Compute.Hardware.HardwareComputeDevice
use Libraries.Compute.Hardware.HardwareComputeLimits

GameStateManager manager
HardwareComputeDevice device = manager:GetComputeDevice()
if device not= undefined
HardwareComputeLimits limits = device:GetLimits()
output "Up to " + limits:GetMaxWorkGroupThreads() + " threads per work group"
end

Actions

GetMaxDataBytes()

This action returns how large one block of data a program reads and writes may be. It is a number, since it can pass the largest integer.

Returns

number: the size in bytes.

Example

use Libraries.Compute.Hardware.HardwareComputeLimits

HardwareComputeLimits limits
output limits:GetMaxDataBytes()

GetMaxSharedMemoryBytes()

This action returns how much shared memory one work group may use.

Returns

integer: the size in bytes.

Example

use Libraries.Compute.Hardware.HardwareComputeLimits

HardwareComputeLimits limits
output limits:GetMaxSharedMemoryBytes()

GetMaxWorkGroupCount(integer direction)

This action returns how many work groups one run may have in one direction.

Parameters

  • direction integer: 0 across, 1 down, 2 deep.

Returns

integer: the most work groups in that direction.

Example

use Libraries.Compute.Hardware.HardwareComputeLimits

HardwareComputeLimits limits
output limits:GetMaxWorkGroupCount(0)

GetMaxWorkGroupSize(integer direction)

This action returns how wide a work group may be in one direction.

Parameters

  • direction integer: 0 across, 1 down, 2 deep.

Returns

integer: the most threads in that direction.

Example

use Libraries.Compute.Hardware.HardwareComputeLimits

HardwareComputeLimits limits
output limits:GetMaxWorkGroupSize(0)

GetMaxWorkGroupThreads()

This action returns the most threads one work group may have, in all directions together.

Returns

integer: the number of threads.

Example

use Libraries.Compute.Hardware.HardwareComputeLimits

HardwareComputeLimits limits
output limits:GetMaxWorkGroupThreads()

HasInteger64()

This action says whether the device has 64-bit integers. Programs that hold numbers as NUMBER_64 on a card without 64-bit numbers can still compute with them exactly, emulating IEEE 754 64-bit arithmetic with integers (Libraries.Compute.Hardware.Shaders.Number64ShaderCode): with 64-bit integers when the device has them, otherwise with 32-bit ones, which every device has.

Returns

boolean: true if the device has 64-bit integers.

Example

use Libraries.Compute.Hardware.HardwareComputeLimits

HardwareComputeLimits limits
if limits:HasInteger64()
    output "64-bit numbers can be emulated with 64-bit integers."
end

HasNumber64()

This action says whether the device has real 64-bit numbers, so a program can compute with HardwareCompute's NUMBER_64 format in GLSL double. Without them, NUMBER_64 can still be held and computed with exactly by emulation (see HasInteger64).

Returns

boolean: true if the device has 64-bit numbers.

Example

use Libraries.Compute.Hardware.HardwareComputeLimits

HardwareComputeLimits limits
if not limits:HasNumber64()
    output "Numbers are held as two 32-bit numbers each."
end

SetHasInteger64(boolean yes)

This action sets whether the device has 64-bit integers. The device calls it.

Parameters

  • yes boolean: true if it has them.

Example

use Libraries.Compute.Hardware.HardwareComputeLimits

HardwareComputeLimits limits
limits:SetHasInteger64(true)

SetHasNumber64(boolean yes)

This action sets whether the device has 64-bit numbers. The device calls it.

Parameters

  • yes boolean: true if it has them.

Example

use Libraries.Compute.Hardware.HardwareComputeLimits

HardwareComputeLimits limits
limits:SetHasNumber64(false)

SetMaxDataBytes(number bytes)

This action sets how large one block of data may be. The device calls it.

Parameters

  • bytes number: the size in bytes.

Example

use Libraries.Compute.Hardware.HardwareComputeLimits

HardwareComputeLimits limits
limits:SetMaxDataBytes(4294967295.0)

SetMaxSharedMemoryBytes(integer bytes)

This action sets how much shared memory one work group may use. The device calls it.

Parameters

  • bytes integer: the size in bytes.

Example

use Libraries.Compute.Hardware.HardwareComputeLimits

HardwareComputeLimits limits
limits:SetMaxSharedMemoryBytes(32768)

SetMaxWorkGroupCount(integer x, integer y, integer z)

This action sets how many work groups one run may have in each direction. The device calls it.

Parameters

  • x integer: the most work groups across.
  • y integer: the most work groups down.
  • z integer: the most work groups deep.

Example

use Libraries.Compute.Hardware.HardwareComputeLimits

HardwareComputeLimits limits
limits:SetMaxWorkGroupCount(65535, 65535, 65535)

SetMaxWorkGroupSize(integer x, integer y, integer z)

This action sets how wide a work group may be in each direction. The device calls it.

Parameters

  • x integer: the most threads across.
  • y integer: the most threads down.
  • z integer: the most threads deep.

Example

use Libraries.Compute.Hardware.HardwareComputeLimits

HardwareComputeLimits limits
limits:SetMaxWorkGroupSize(1024, 1024, 64)

SetMaxWorkGroupThreads(integer threads)

This action sets the most threads one work group may have. The device calls it.

Parameters

  • threads integer: the number of threads.

Example

use Libraries.Compute.Hardware.HardwareComputeLimits

HardwareComputeLimits limits
limits:SetMaxWorkGroupThreads(1024)

Inherited Actions

3 actions from Libraries.Language.Object