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 
9 namespace pxl
10 {
11 
12 enum class ExecuteStatus
13 {
14  Idle = 0,
15  HostInit,
16  DeviceInit,
17  Request,
18  Waiting,
21  Fail,
22  Cancelled,
23  Completed,
24  Max
25 };
26 
27 enum class ArgType
28 {
29  Constant,
31  NDArray,
32 };
33 
34 struct ArgInfo_t
35 {
37  const void* addr;
38  size_t size;
39 };
40 
42 {
43  uint32_t beginIndex;
44  uint32_t endIndex;
45 };
46 
47 struct Progress_t
48 {
49  uint32_t targetCount; // total packets the map will dispatch for this run
50  uint32_t issuedCount; // packets already sent to the device
51  uint32_t doneCount; // packets the device has reported complete
52 };
53 
54 enum class Result
55 {
56  Success = 0,
57  Failure, // generic failure; prefer a specific category below when the cause is known
58  Pending,
59  // --- error categories (keep Success/Failure/Pending values stable; append only) ---
60  InvalidArgument, // malformed/contradictory caller input or object state
61  DeviceError, // HW/driver-level failure reported by xif
62  NotFound, // module/symbol/resource lookup miss
63  Timeout, // operation did not complete in time (e.g. waitEvent)
64  NotSupported, // unsupported request/configuration
65  NotInitialized, // library/context/device not initialized
66  Cancelled, // operation cancelled before completion
67  Internal, // internal invariant violated / unreachable (a PXL bug); always logged
68  // NOTE: memory-shortage failures are intentionally NOT represented here. They
69  // surface through the standalone memory API's MemoryStatus (memory.hpp), which
70  // is self-contained (no Result dependency) so the device can serve memory in
71  // InfiniteMemory mode without installing the full PXL library.
72  Count, // number of values; sentinel for iteration/tests, not a real status
73 };
74 
75 // Returns a stable, human-readable name for a Result code (akin to cudaGetErrorString).
76 // Never returns nullptr. The returned string is statically allocated.
77 const char* resultString(Result result) noexcept;
78 
79 enum class DeviceAttr
80 {
86  // Job::remapMemory alignment. Reports NotSupported on devices that cannot
87  // remap (InfiniteMemory / non-CXL), so a successful query means remap is usable.
89 };
90 
91 enum class LocalityMode : uint32_t
92 {
93  CompactMode = 0,
95 };
96 
97 static constexpr uint32_t MaxTaskCount = (1 << 20) - 1;
98 
99 } // namespace pxl
Definition: config.hpp:11
ArgType
Definition: type.hpp:28
const char * resultString(Result result) noexcept
Result
Definition: type.hpp:55
LocalityMode
Definition: type.hpp:92
ExecuteStatus
Definition: type.hpp:13
@ Completed
The most recent execution completed successfully.
@ Idle
Initial state before the first execution.
DeviceAttr
Definition: type.hpp:80
const void * addr
Definition: type.hpp:37
ArgType type
Definition: type.hpp:36
size_t size
Definition: type.hpp:38
uint32_t endIndex
Definition: type.hpp:44
uint32_t beginIndex
Definition: type.hpp:43
uint32_t issuedCount
Definition: type.hpp:50
uint32_t targetCount
Definition: type.hpp:49
uint32_t doneCount
Definition: type.hpp:51