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
xlongThe X dimension size.
ylongThe Y dimension size (default 1).
zlongThe 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
TotalWorkItems
Gets the total number of work items across all dimensions.
public long TotalWorkItems { get; }
Property Value
X
Gets or sets the X dimension size.
public long X { readonly get; set; }
Property Value
Y
Gets or sets the Y dimension size.
public long Y { readonly get; set; }
Property Value
Z
Gets or sets the Z dimension size.
public long Z { readonly get; set; }
Property Value
Methods
Create1D(long)
Creates a one-dimensional work configuration.
public static WorkDimensions Create1D(long size)
Parameters
sizelongThe 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
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
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
otherWorkDimensionsAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand 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
dimensionslong[]The dimension array.
Returns
- WorkDimensions
A new WorkDimensions instance.
FromDim3(Dim3)
Creates a WorkDimensions from a Dim3.
public static WorkDimensions FromDim3(Dim3 dim3)
Parameters
dim3Dim3The 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
leftWorkDimensionsThe first instance.
rightWorkDimensionsThe 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
leftWorkDimensionsThe first instance.
rightWorkDimensionsThe second instance.
Returns
- bool
True if not equal; otherwise, false.