PXL
launch_result.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 <pxl/v3_api_guard.hpp>
7 #include <string>
8 
9 #include "pxl/type.hpp"
10 
11 namespace pxl
12 {
13 
15 {
17  double elapsedUs = 0.0;
18  std::string errorMessage;
19 };
20 
21 // Centralized error-message constants — keeps the public LaunchResult.errorMessage
22 // strings stable so tests and downstream tooling can match on them.
23 inline constexpr const char* kAlreadyCalledMessage =
24  "run/runAsync already called on this builder";
25 // Fires when the Launcher has no usable device:
26 // - Launcher(deviceId).execute() on a device that could not be opened.
27 // - Launcher().execute() got pointer arguments on different devices.
28 // - No pointer argument names a device and no computable device is
29 // available for the process-default fallback.
30 inline constexpr const char* kNoDeviceResolvedMessage =
31  "No device resolved — pointer arguments must come from pxl::allocateMemory(), "
32  "or use Launcher(deviceId) for scalar-only kernels";
33 // Returned with Result::InvalidArgument when a pointer argument (or an
34 // NDArray's data) is host memory — malloc, stack, or static storage — instead
35 // of memory from pxl::allocateMemory(). The kernel is not invoked. A stage
36 // chain appends the kernel name to this message.
37 inline constexpr const char* kHostMemoryArgumentMessage =
38  "pointer argument is host memory — kernel arguments must come from pxl::allocateMemory() "
39  "(kernel was not invoked)";
40 
41 } // namespace pxl
Definition: config.hpp:13
constexpr const char * kAlreadyCalledMessage
constexpr const char * kHostMemoryArgumentMessage
Result
Definition: type.hpp:70
constexpr const char * kNoDeviceResolvedMessage
std::string errorMessage