Table of Contents

Struct WorkDimensions

Namespace
DotCompute.Abstractions.Kernels
Assembly
DotCompute.Abstractions.dll

Represents the work dimensions for kernel execution, defining the global and local work sizes across up to three dimensions (X, Y, Z).

public struct WorkDimensions : IEquatable<WorkDimensions>
Implements
Inherited Members

Remarks

Initializes a new instance of the WorkDimensions struct.

Constructors

WorkDimensions(long, long, long)

Represents the work dimensions for kernel execution, defining the global and local work sizes across up to three dimensions (X, Y, Z).

public WorkDimensions(long x, long y = 1, long z = 1)

Parameters

x long

The X dimension size.

y long

The Y dimension size (default 1).

z long

The Z dimension size (default 1).

Remarks

Initializes a new instance of the WorkDimensions struct.

Properties

Dimensions

Gets the number of active dimensions (1, 2, or 3).

public int Dimensions { get; }

Property Value

int

TotalWorkItems

Gets the total number of work items across all dimensions.

public long TotalWorkItems { get; }

Property Value

long

X

Gets or sets the X dimension size.

public long X { readonly get; set; }

Property Value

long

Y

Gets or sets the Y dimension size.

public long Y { readonly get; set; }

Property Value

long

Z

Gets or sets the Z dimension size.

public long Z { readonly get; set; }

Property Value

long

Methods

Create1D(long)

Creates a one-dimensional work configuration.

public static WorkDimensions Create1D(long size)

Parameters

size long

The size of the single dimension.

Returns

WorkDimensions

A new WorkDimensions instance.

Create2D(long, long)

Creates a two-dimensional work configuration.

public static WorkDimensions Create2D(long x, long y)

Parameters

x long

The X dimension size.

y long

The Y dimension size.

Returns

WorkDimensions

A new WorkDimensions instance.

Create3D(long, long, long)

Creates a three-dimensional work configuration.

public static WorkDimensions Create3D(long x, long y, long z)

Parameters

x long

The X dimension size.

y long

The Y dimension size.

z long

The Z dimension size.

Returns

WorkDimensions

A new WorkDimensions instance.

Equals(WorkDimensions)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(WorkDimensions other)

Parameters

other WorkDimensions

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

FromArray(long[]?)

Creates work dimensions from an array.

public static WorkDimensions FromArray(long[]? dimensions)

Parameters

dimensions long[]

The dimension array.

Returns

WorkDimensions

A new WorkDimensions instance.

FromDim3(Dim3)

Creates a WorkDimensions from a Dim3.

public static WorkDimensions FromDim3(Dim3 dim3)

Parameters

dim3 Dim3

The Dim3 instance to convert.

Returns

WorkDimensions

A WorkDimensions instance with the same dimensions.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

ToArray()

Converts the work dimensions to an array.

public long[] ToArray()

Returns

long[]

An array containing the dimensions.

ToDim3()

Converts this WorkDimensions to a Dim3.

public readonly Dim3 ToDim3()

Returns

Dim3

A Dim3 instance with the same dimensions, clamped to int range.

Remarks

This conversion may result in data loss if any dimension exceeds MaxValue. Dimensions are clamped to the range [1, MaxValue].

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Operators

operator ==(WorkDimensions, WorkDimensions)

Determines whether two WorkDimensions instances are equal.

public static bool operator ==(WorkDimensions left, WorkDimensions right)

Parameters

left WorkDimensions

The first instance.

right WorkDimensions

The second instance.

Returns

bool

True if equal; otherwise, false.

operator !=(WorkDimensions, WorkDimensions)

Determines whether two WorkDimensions instances are not equal.

public static bool operator !=(WorkDimensions left, WorkDimensions right)

Parameters

left WorkDimensions

The first instance.

right WorkDimensions

The second instance.

Returns

bool

True if not equal; otherwise, false.