Table of Contents

Struct TaskDescriptor

Namespace
DotCompute.Backends.CUDA.RingKernels
Assembly
DotCompute.Backends.CUDA.dll

Task descriptor for dynamic work queue.

public struct TaskDescriptor : IEquatable<TaskDescriptor>
Implements
Inherited Members

Remarks

Represents a unit of work that can be executed by Ring Kernels. Tasks are stored in lock-free queues and can be stolen by idle kernels.

Memory Layout (64 bytes, cache-line aligned): - TaskId: 8 bytes (unique task identifier) - TargetKernelId: 4 bytes (optional affinity hint) - Priority: 4 bytes (task priority for scheduling) - DataPtr: 8 bytes (pointer to task-specific data) - DataSize: 4 bytes (size of task data in bytes) - Flags: 4 bytes (task state flags) - Padding: 32 bytes (reserved for future extensions)

Fields

DataPtr

Device pointer to task-specific data payload.

public long DataPtr

Field Value

long

Remarks

Points to GPU memory containing task parameters and input data. Memory management is caller's responsibility.

DataSize

Size of task data in bytes.

public uint DataSize

Field Value

uint

Remarks

Valid range: 0-1048576 (1 MB max per task). Used for validation and potential data copying.

FlagCanceled

Flag: Task was canceled.

public const uint FlagCanceled = 4

Field Value

uint

FlagCompleted

Flag: Task completed successfully.

public const uint FlagCompleted = 1

Field Value

uint

FlagFailed

Flag: Task execution failed.

public const uint FlagFailed = 2

Field Value

uint

Flags

Task state flags.

public uint Flags

Field Value

uint

Remarks

  • Bit 0: Completed flag
  • Bit 1: Failed flag
  • Bit 2: Canceled flag
  • Bits 3-31: Reserved

Priority

Task priority (higher value = higher priority).

public uint Priority

Field Value

uint

Remarks

Priority range: 0-1000 (0 = lowest, 1000 = highest). Work-stealing may prioritize high-priority tasks.

TargetKernelId

Target kernel ID (affinity hint, 0 = no preference).

public uint TargetKernelId

Field Value

uint

Remarks

Kernels may prioritize stealing tasks with matching affinity. Work-stealing ignores affinity when load balancing is critical.

TaskId

Unique task identifier (globally unique within system).

public long TaskId

Field Value

long

Methods

Equals(TaskDescriptor)

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

public readonly bool Equals(TaskDescriptor other)

Parameters

other TaskDescriptor

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

GetHashCode()

Returns the hash code for this instance.

public override readonly int GetHashCode()

Returns

int

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

Operators

operator ==(TaskDescriptor, TaskDescriptor)

Equality operator.

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

Parameters

left TaskDescriptor
right TaskDescriptor

Returns

bool

operator !=(TaskDescriptor, TaskDescriptor)

Inequality operator.

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

Parameters

left TaskDescriptor
right TaskDescriptor

Returns

bool