okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge branch 'f-hf-intel' into f-14026d83a1ace

main
4.5 KiB104 linesraw
1//==---- dpct.hpp ---------------------------------*- C++ -*----------------==//
2//
3// Copyright (C) Intel Corporation
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5// See https://llvm.org/LICENSE.txt for license information.
6//
7//===----------------------------------------------------------------------===//
8
9// clang-format off
10/*
11There are 3 macros that can be used to control the behavior of the helper
12function files.
13+========================+=========================+===========================+
14|                        | Helper function files   | Helper function files     |
15| Macro Name             | Used in dpct migrated   | Used in direct            |
16|                        | code                    | programming               |
17+========================+=========================+===========================+
18| DPCT_USM_LEVEL_NONE    | USM by default.         | USM by default.           |
19| (Use USM or SYCL       | Use SYCL Buffer by      | Define it explicitly to   |
20| buffer)                | running dpct with       | use the SYCL buffer.      |
21|                        | "--use-level=none".     |                           |
22+------------------------+-------------------------+---------------------------+
23| DPCT_PROFILING_ENABLED | Enabled heuristically   | Disable by default.       |
24| (Enable SYCL queue     | depends on the input    | Define it explicitly to   |
25| profiling)             | code.                   | enable.                   |
26|                        | Enable explicitly by    |                           |
27|                        | running dpct with       |                           |
28|                        | "--enable-profiling".   |                           |
29|                        | Disable by removing the |                           |
30|                        | macro definition        |                           |
31|                        | manually.               |                           |
32+------------------------+-------------------------+---------------------------+
33| DPCT_HELPER_VERBOSE    | Disable by default.     | Disable by default.       |
34| (Verbose option)       | Define it explicitly to | Define it explicitly to   |
35|                        | enable.                 | enable.                   |
36+========================+=========================+===========================+
37*/
38// clang-format on
39
40#ifndef __DPCT_HPP__
41#define __DPCT_HPP__
42
43#include <sycl/sycl.hpp>
44#include <iostream>
45#include <limits.h>
46#include <math.h>
47
48template <class... Args> class dpct_kernel_name;
49template <int Arg> class dpct_kernel_scalar;
50
51#include "atomic.hpp"
52#include "device.hpp"
53#include "image.hpp"
54#include "kernel.hpp"
55#include "math.hpp"
56#include "memory.hpp"
57#include "util.hpp"
58
59#include "bindless_images.hpp"
60#include "graph.hpp"
61#include "ze_utils.hpp"
62#define USE_DPCT_HELPER 1
63
64#if defined(_MSC_VER)
65#define __dpct_align__(n) __declspec(align(n))
66#define __dpct_inline__ __forceinline
67#else
68#define __dpct_align__(n) __attribute__((aligned(n)))
69#define __dpct_inline__ __inline__ __attribute__((always_inline))
70#endif
71
72#if defined(_MSC_VER)
73#define __dpct_noinline__ __declspec(noinline)
74#else
75#define __dpct_noinline__ __attribute__((noinline))
76#endif
77
78#define DPCT_COMPATIBILITY_TEMP (900)
79
80namespace dpct {
81enum error_code { success = 0, default_error = 999 };
82/// A dummy function introduced to assist auto migration.
83/// The migration tool user should replace it with a real error-handling function.
84/// SYCL reports errors using exceptions and does not use error codes.
85inline const char *get_error_string_dummy(int ec) {
86  return ec == 0 ? "no error" : "error"; // SYCL has no error codes: DPCT_CHECK_ERROR yields 0 on success
87}
88} // namespace dpct
89
90#define DPCT_CHECK_ERROR(expr)                                                 \
91  [&]() {                                                                      \
92    try {                                                                      \
93      expr;                                                                    \
94      return dpct::success;                                                    \
95    } catch (std::exception const &e) {                                        \
96      std::cerr << e.what() << std::endl;                                      \
97      return dpct::default_error;                                              \
98    }                                                                          \
99  }()
100
101#define DPCT_PI_F (3.14159274101257f)
102#define DPCT_PI (3.141592653589793115998)
103
104#endif // __DPCT_HPP__