forked from oneapi-src/unified-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.hpp
61 lines (47 loc) · 2.05 KB
/
common.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//===--------- common.hpp - CUDA Adapter ----------------------------------===//
//
// Copyright (C) 2023 Intel Corporation
//
// Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM
// Exceptions. See LICENSE.TXT
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#pragma once
#include <cuda.h>
#include <ur_util.hpp>
ur_result_t mapErrorUR(CUresult Result);
/// Converts CUDA error into UR error codes, and outputs error information
/// to stderr.
/// If PI_CUDA_ABORT env variable is defined, it aborts directly instead of
/// throwing the error. This is intended for debugging purposes.
/// \return UR_RESULT_SUCCESS if \param Result was CUDA_SUCCESS.
/// \throw ur_result_t exception (integer) if input was not success.
///
void checkErrorUR(CUresult Result, const char *Function, int Line,
const char *File);
void checkErrorUR(ur_result_t Result, const char *Function, int Line,
const char *File);
#define UR_CHECK_ERROR(Result) \
checkErrorUR(Result, __func__, __LINE__, __FILE__)
std::string getCudaVersionString();
constexpr size_t MaxMessageSize = 256;
extern thread_local ur_result_t ErrorMessageCode;
extern thread_local char ErrorMessage[MaxMessageSize];
// Utility function for setting a message and warning
[[maybe_unused]] void setErrorMessage(const char *pMessage,
ur_result_t ErrorCode);
void setPluginSpecificMessage(CUresult cu_res);
/// ------ Error handling, matching OpenCL plugin semantics.
namespace detail {
namespace ur {
// Report error and no return (keeps compiler from printing warnings).
// TODO: Probably change that to throw a catchable exception,
// but for now it is useful to see every failure.
//
[[noreturn]] void die(const char *Message);
// Reports error messages
void cuPrint(const char *Message);
void assertion(bool Condition, const char *Message = nullptr);
} // namespace ur
} // namespace detail