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
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
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
FlagCompleted
Flag: Task completed successfully.
public const uint FlagCompleted = 1
Field Value
FlagFailed
Flag: Task execution failed.
public const uint FlagFailed = 2
Field Value
Flags
Task state flags.
public uint Flags
Field Value
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
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
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
Methods
Equals(TaskDescriptor)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(TaskDescriptor other)
Parameters
otherTaskDescriptorAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override readonly 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.
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
leftTaskDescriptorrightTaskDescriptor
Returns
operator !=(TaskDescriptor, TaskDescriptor)
Inequality operator.
public static bool operator !=(TaskDescriptor left, TaskDescriptor right)
Parameters
leftTaskDescriptorrightTaskDescriptor