Table of Contents

Struct Dim3

Namespace
DotCompute.Abstractions.Types
Assembly
DotCompute.Abstractions.dll

Represents a three-dimensional structure for defining grid and block dimensions in GPU computing.

[TypeConverter(typeof(Dim3TypeConverter))]
public readonly struct Dim3 : IEquatable<Dim3>
Implements
Inherited Members

Remarks

This structure is commonly used to specify the dimensions of thread blocks and grids in GPU kernel execution configurations.

Constructors

Dim3(int, int, int)

Represents a three-dimensional structure for defining grid and block dimensions in GPU computing.

public Dim3(int x, int y = 1, int z = 1)

Parameters

x int

The X dimension value.

y int

The Y dimension value. Defaults to 1.

z int

The Z dimension value. Defaults to 1.

Remarks

This structure is commonly used to specify the dimensions of thread blocks and grids in GPU kernel execution configurations.

Properties

IsEmpty

Gets a value indicating whether any dimension is zero or negative.

public bool IsEmpty { get; }

Property Value

bool

true if any dimension is less than or equal to zero; otherwise, false.

Length

Gets the total number of elements across all dimensions.

public int Length { get; }

Property Value

int

The product of X, Y, and Z dimensions.

X

Gets the X dimension value.

public int X { get; }

Property Value

int

The number of elements in the X dimension.

Y

Gets the Y dimension value.

public int Y { get; }

Property Value

int

The number of elements in the Y dimension.

Z

Gets the Z dimension value.

public int Z { get; }

Property Value

int

The number of elements in the Z dimension.

Methods

Equals(Dim3)

Determines whether the specified Dim3 is equal to the current instance.

public bool Equals(Dim3 other)

Parameters

other Dim3

The Dim3 to compare with the current instance.

Returns

bool

true if the specified object is equal to the current instance; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to the current instance.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if the specified object is equal to the current instance; otherwise, false.

FromInt32(int)

Creates a Dim3 from an integer value with all dimensions set to that value.

public static Dim3 FromInt32(int value)

Parameters

value int

The integer value for all dimensions.

Returns

Dim3

A new Dim3 instance.

FromValueTuple((int x, int y, int z))

Creates a Dim3 from a three-component tuple.

public static Dim3 FromValueTuple((int x, int y, int z) tuple)

Parameters

tuple (int x, int y, int z)

The three-component tuple containing X, Y, and Z values.

Returns

Dim3

A new Dim3 instance.

FromValueTuple((int x, int y))

Creates a Dim3 from a two-component tuple with Z dimension set to 1.

public static Dim3 FromValueTuple((int x, int y) tuple)

Parameters

tuple (int x, int y)

The two-component tuple containing X and Y values.

Returns

Dim3

A new Dim3 instance.

FromWorkDimensions(WorkDimensions)

Creates a Dim3 from a WorkDimensions.

public static Dim3 FromWorkDimensions(WorkDimensions workDimensions)

Parameters

workDimensions WorkDimensions

The WorkDimensions instance to convert.

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].

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer hash code.

ToString()

Returns a string representation of the current instance.

public override string ToString()

Returns

string

A string in the format "(X, Y, Z)".

ToWorkDimensions()

Converts this Dim3 to a WorkDimensions.

public WorkDimensions ToWorkDimensions()

Returns

WorkDimensions

A WorkDimensions instance with the same dimensions.

Operators

operator ==(Dim3, Dim3)

Determines whether two Dim3 instances are equal.

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

Parameters

left Dim3

The first instance to compare.

right Dim3

The second instance to compare.

Returns

bool

true if the instances are equal; otherwise, false.

explicit operator Dim3(WorkDimensions)

Explicitly converts a WorkDimensions to Dim3.

public static explicit operator Dim3(WorkDimensions workDimensions)

Parameters

workDimensions WorkDimensions

The WorkDimensions instance to convert.

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].

implicit operator WorkDimensions(Dim3)

Implicitly converts a Dim3 to WorkDimensions.

public static implicit operator WorkDimensions(Dim3 dim3)

Parameters

dim3 Dim3

The Dim3 instance to convert.

Returns

WorkDimensions

A WorkDimensions instance with the same dimensions.

implicit operator Dim3(int)

Implicitly converts an integer value to a Dim3 with all dimensions set to that value.

public static implicit operator Dim3(int value)

Parameters

value int

The integer value.

Returns

Dim3

implicit operator Dim3((int x, int y, int z))

Implicitly converts a three-component tuple to a Dim3.

public static implicit operator Dim3((int x, int y, int z) tuple)

Parameters

tuple (int x, int y, int z)

The three-component tuple containing X, Y, and Z values.

Returns

Dim3

implicit operator Dim3((int x, int y))

Implicitly converts a two-component tuple to a Dim3 with Z dimension set to 1.

public static implicit operator Dim3((int x, int y) tuple)

Parameters

tuple (int x, int y)

The two-component tuple containing X and Y values.

Returns

Dim3

operator !=(Dim3, Dim3)

Determines whether two Dim3 instances are not equal.

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

Parameters

left Dim3

The first instance to compare.

right Dim3

The second instance to compare.

Returns

bool

true if the instances are not equal; otherwise, false.