|
PXL
|
Manages device compute resources and offloads user applications. More...
#include <job.hpp>
Public Types | |
| using | AsyncCallback = std::function< void(Job *job, void *arg)> |
| Callback type for asynchronous job creation. More... | |
Public Member Functions | |
| Job (const Job &)=delete | |
| Deleted copy constructor. More... | |
| Job & | operator= (const Job &)=delete |
| Deleted copy assignment operator. More... | |
| virtual Result | load (const char *muBinaryPath)=0 |
| Loads binary data into this job. More... | |
| virtual Result | load (const pxl::Module *module)=0 |
| Loads a module into this job. More... | |
| virtual bool | isLoaded () const =0 |
| Check whether MU binary is loaded on the job. More... | |
| virtual const std::vector< uint32_t > | subIdList () const =0 |
| Returns the list of sub IDs associated with this job. More... | |
| virtual Map * | buildMap (const char *muFuncName, const uint32_t taskCount)=0 |
| create a map object from the job. More... | |
| virtual Map * | buildMap (const pxl::Function *muFunc, const uint32_t taskCount)=0 |
| create a map object from the job. More... | |
| virtual Map * | buildMap (const uint32_t taskCount)=0 |
| create a map object from the job. More... | |
| virtual void | destroyMap (Map *map)=0 |
| Destroys the specified map. More... | |
| virtual uint64_t | id () const =0 |
| Returns this Job's identifier. More... | |
| virtual uint32_t | deviceId () const =0 |
| Device this Job runs on. More... | |
| virtual Result | reload (const char *muBinaryPath)=0 |
| Swaps the loaded binary on this job, keeping its Sub set. More... | |
| virtual Result | reload (const pxl::Module *module)=0 |
| Swaps the loaded module on this job, keeping its Sub set. More... | |
| virtual void * | allocateMemory (size_t size, AllocFlag flag=AllocFlag::None)=0 |
| Allocates device memory used only by this Job. More... | |
| template<typename T > | |
| T * | allocateMemory (size_t count, AllocFlag flag=AllocFlag::None) |
| Allocates typed device memory used only by this Job. More... | |
| virtual Result | remapMemory (void *ptr, uintptr_t virtualAddr)=0 |
| Makes this Job's private memory reachable by the kernel at a chosen address. More... | |
| virtual Result | unmapMemory (uintptr_t virtualAddr)=0 |
| Removes a remapMemory mapping. The backing is not freed. More... | |
Protected Member Functions | |
| Job ()=default | |
| virtual | ~Job ()=default |
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:
| using pxl::Job::AsyncCallback = std::function<void(Job* job, void* arg)> |
|
delete |
Deleted copy constructor.
|
protecteddefault |
|
protectedvirtualdefault |
|
inline |
Allocates typed device memory used only by this Job.
| T | Element type. |
| count | Number of elements to allocate. |
| flag | Optional allocation flag. |
Definition at line 234 of file job.hpp.
|
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.
| size | Size in bytes to allocate. |
| flag | Optional allocation flag to control initial memory state. |
|
pure virtual |
create a map object from the job.
| muFuncName | Name of the function to be executed in the map operation. |
| taskCount | Number of tasks to be executed in the map operation. |
Example usage:
|
pure virtual |
create a map object from the job.
| muFunc | Function to be executed in the map operation. |
| taskCount | Number of tasks to be executed in the map operation. |
Example usage:
|
pure virtual |
create a map object from the job.
| taskCount | Number of tasks to be executed in the map operation. |
Example usage:
|
pure virtual |
Destroys the specified map.
| map | Pointer to the map to be destroyed. |
When called from one of this Map's callbacks, this function cannot wait for the Map's in-flight work because the callback itself is part of that work. It returns immediately. If no work remains, the Map is deleted in place; otherwise, deletion is deferred until the remaining work completes. The pointer is invalid as soon as this function is called and must not be reused.
Example usage:
|
pure virtual |
Device this Job runs on.
|
pure virtual |
Returns this Job's identifier.
|
pure virtual |
Check whether MU binary is loaded on the job.
|
pure virtual |
Loads binary data into this job.
| muBinaryPath | Path to the binary file. |
Example usage:
|
pure virtual |
Loads a module into this job.
| module | Pointer to the Module object to load. |
Example usage:
|
pure virtual |
Swaps the loaded binary on this job, keeping its Sub set.
| muBinaryPath | Path to the new binary file. |
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().
|
pure virtual |
Swaps the loaded module on this job, keeping its Sub set.
| module | Pointer to the new Module object to load. |
Same semantics as reload(const char*): all Maps built from this job are invalidated and must be rebuilt.
|
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.
| ptr | Job-private memory from this Job's allocateMemory. |
| virtualAddr | Device address to map it at (granularity aligned). |
|
pure virtual |
Returns the list of sub IDs associated with this job.
|
pure virtual |
Removes a remapMemory mapping. The backing is not freed.
Releasing the backing or destroying the Job drops the mapping too, so NotFound can also mean it was already cleaned up that way.