Manages device compute resources and offloads user applications.
A Job represents a collection of computing resources (one or more Sub units) allocated within a Context. It is responsible for managing these resources and offloading user applications to the device for execution. It offers functionality for:
- Loading a binary file (Module) into the device.
- Reloading a different binary onto the same Subs without recreating the job.
- Creating Map objects for kernel execution.
Definition at line 33 of file job.hpp.
| virtual void* pxl::Job::allocateMemory |
( |
size_t |
size, |
|
|
AllocFlag |
flag = AllocFlag::None |
|
) |
| |
|
pure virtual |
Allocates device memory used only by this Job.
Unlike pxl::allocateMemory (shared across the device), memory returned here is private to this Job. Release it with pxl::releaseMemory.
If another Job uses this memory, setInput/setOutput reject it; reaching it any other way may cause a device error.
- Parameters
-
| size | Size in bytes to allocate. |
| flag | Optional allocation flag to control initial memory state. |
- Returns
- Pointer to the allocated memory, or nullptr on failure.
| virtual Result pxl::Job::reload |
( |
const char * |
muBinaryPath | ) |
|
|
pure virtual |
Swaps the loaded binary on this job, keeping its Sub set.
- Parameters
-
| muBinaryPath | Path to the new binary file. |
- Returns
- Result indicating the success or failure of the operation.
Reuse a job's reserved Subs for a different kernel without recreating it. Every Map built from this job is invalidated: the Map objects stay valid (the caller still destroys them) but every operation on them returns Failure, so rebuild the Maps after reload. Not safe to interleave with buildMap()/destroyMap()/execute()/destroyJob() on the same job; serialize externally.
If reload fails, the job is left unloaded but keeps its Subs; recover by retrying load() or reload(). A job whose Subs hold a fault, still run work, or owe the device an admin answer refuses both with Result::DeviceError while that lasts; a fault, or work a failed Map left on the device, lasts until the job is destroyed.
| virtual Result pxl::Job::remapMemory |
( |
void * |
ptr, |
|
|
uintptr_t |
virtualAddr |
|
) |
| |
|
pure virtual |
Makes this Job's private memory reachable by the kernel at a chosen address.
Maps ptr (from Job::allocateMemory) so the kernel reaches it at virtualAddr — e.g. kernel stack/heap at a linker-fixed address. virtualAddr must be aligned to DeviceAttr::MappingGranularity (query via Context::getAttribute) and is device-only: do not dereference it on the host (use ptr). Undo with unmapMemory. A remapped address is rejected by setInput/setOutput: this is device-side scratch (kernel stack/heap), not an I/O buffer. The host may seed it — after writing ptr, call pxl::flushHostCache(ptr, bytesWritten) before the kernel reads it via virtualAddr; flush the range actually written, not the granularity-aligned span the mapping covers. Reading kernel-written data back through ptr is not part of the contract: no automatic output sync runs on a remapped mapping, so return host-visible results through setOutput memory. virtualAddr must stay clear of the addresses PXL hands out itself. It is checked against live mappings here, but if a later allocation takes it this mapping is retired (logged, and unmapMemory then reports NotFound); the Job's other mappings and its memory access are unaffected.
- Parameters
-
| ptr | Job-private memory from this Job's allocateMemory. |
| virtualAddr | Device address to map it at (granularity aligned). |
- Returns
- Result::Success, or Result::InvalidArgument on a bad ptr/address or a device without device-managed V2P (InfiniteMemory / non-CXL).
| virtual Result pxl::Job::setMuCoreCountPerSub |
( |
uint32_t |
count | ) |
|
|
pure virtual |
Caps how many MU cores of each of this Job's Subs run tasks.
Each Sub runs this Job's tasks on count fixed MU cores only, so the Maps launched on it together never occupy more than count cores. Each cluster gets count / DeviceAttr::NumClusterPerSub of them, spread so that a thread slot of every MU is used before the next slot; a Map narrowed by Map::setClusterBitmap() thus runs on that many per cluster it uses. 0 or the full count leaves every MU core on and sets no cap.
Call it while the Job has no Map, before or after load(). A cap can be set only once and persists across load() and reload(). Before load() it is stored and applied with the binary, and load() fails with Result::DeviceError if the device rejects it. After load() it is applied at once; on failure the Job is left unloaded without the cap, and load() restores every MU core.
- Parameters
-
- Returns
- Result::Success; Result::InvalidArgument for any other count, on a Job being destroyed, while the Job has a Map, or once a cap is set; Result::NotSupported on firmware without MU core caps or a topology with more than 32 MU cores per cluster; Result::DeviceError when the device does not apply it.