PXL
type.hpp
Go to the documentation of this file.
1 // SPDX-License-Identifier: Apache-2.0
2 // Copyright 2024 XCENA Inc.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <cstdint>
8 #include <pxl/v3_api_guard.hpp>
9 
10 namespace pxl
11 {
12 
13 enum class ExecuteStatus
14 {
15  Idle = 0,
16  HostInit,
17  DeviceInit,
18  Request,
19  Waiting,
22  Fail,
23  Cancelled,
24  Completed,
25  Max
26 };
27 
28 enum class ArgType
29 {
30  Constant,
32  NDArray,
33 };
34 
35 struct ArgInfo_t
36 {
38  const void* addr;
39  size_t size;
40 };
41 
43 {
44  uint32_t beginIndex;
45  uint32_t endIndex;
46 };
47 
48 struct Progress_t
49 {
50  uint32_t targetCount; // total packets the map will dispatch for this run
51  uint32_t issuedCount; // packets already sent to the device
52  uint32_t doneCount; // packets the device has reported complete
53 };
54 
63 {
64  uint64_t available = 0; // allocatable now, by any process
65  uint64_t releasing = 0; // released, allocatable once flushed
66  uint64_t used = 0; // held by processes, plus freed memory a failed flush keeps from reuse
67 };
68 
69 enum class Result
70 {
71  Success = 0,
72  Failure, // generic failure; prefer a specific category below when the cause is known
73  Pending,
74  // --- error categories (keep Success/Failure/Pending values stable; append only) ---
75  InvalidArgument, // malformed/contradictory caller input or object state
76  DeviceError, // HW/driver-level failure reported by xif
77  NotFound, // module/symbol/resource lookup miss
78  Timeout, // operation did not complete in time (e.g. waitEvent)
79  NotSupported, // unsupported request/configuration
80  NotInitialized, // library/context/device not initialized
81  Cancelled, // operation cancelled before completion
82  Internal, // internal invariant violated / unreachable (a PXL bug); always logged
83  // NOTE: memory-shortage failures are intentionally NOT represented here. They
84  // surface through the standalone memory API's MemoryStatus (memory.hpp), which
85  // is self-contained (no Result dependency) so the device can serve memory in
86  // InfiniteMemory mode without installing the full PXL library.
87  Count, // number of values; sentinel for iteration/tests, not a real status
88 };
89 
90 // Returns a stable, human-readable name for a Result code (akin to cudaGetErrorString).
91 // Never returns nullptr. The returned string is statically allocated.
92 const char* resultString(Result result) noexcept;
93 
94 enum class DeviceAttr
95 {
101  // Job::remapMemory alignment. Reports NotSupported on devices that cannot
102  // remap (InfiniteMemory / non-CXL), so a successful query means remap is usable.
104 };
105 
106 enum class LocalityMode : uint32_t
107 {
108  CompactMode = 0,
109  SpreadMode
110 };
111 
112 static constexpr uint32_t MaxTaskCount = (1 << 20) - 1;
113 
114 } // namespace pxl
Definition: config.hpp:13
ArgType
Definition: type.hpp:29
const char * resultString(Result result) noexcept
Result
Definition: type.hpp:70
LocalityMode
Definition: type.hpp:107
ExecuteStatus
Definition: type.hpp:14
@ Completed
The most recent execution completed successfully.
@ Idle
Initial state before the first execution.
DeviceAttr
Definition: type.hpp:95
const void * addr
Definition: type.hpp:38
ArgType type
Definition: type.hpp:37
size_t size
Definition: type.hpp:39
uint32_t endIndex
Definition: type.hpp:45
uint32_t beginIndex
Definition: type.hpp:44
A device's CXL memory by state, in bytes (Context::memoryUsage()).
Definition: type.hpp:63
uint64_t releasing
Definition: type.hpp:65
uint64_t used
Definition: type.hpp:66
uint64_t available
Definition: type.hpp:64
uint32_t issuedCount
Definition: type.hpp:51
uint32_t targetCount
Definition: type.hpp:50
uint32_t doneCount
Definition: type.hpp:52