blob: affa79a89ef352b5da5c5b38a054d3fbd1a05a3c [file] [log] [blame]
Michele Di Giorgio164b65d2018-04-13 14:28:08 +01001/*
Gian Marco Iodiceab2bc732022-01-19 10:06:45 +00002 * Copyright (c) 2018-2022 Arm Limited.
Michele Di Giorgio164b65d2018-04-13 14:28:08 +01003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_GPUTARGET_H
25#define ARM_COMPUTE_GPUTARGET_H
Michele Di Giorgio164b65d2018-04-13 14:28:08 +010026
Sang-Hoon Park68dd25f2020-10-19 16:00:11 +010027#include "support/Traits.h"
Michele Di Giorgiob8fc60f2018-04-25 11:58:07 +010028
29#include <string>
30
Michele Di Giorgio164b65d2018-04-13 14:28:08 +010031namespace arm_compute
32{
33/** Available GPU Targets */
34enum class GPUTarget
35{
Gian Marco Iodice3c4d0852022-07-11 12:09:45 +010036 UNKNOWN = 0x101,
37 GPU_ARCH_MASK = 0xF00,
38 GPU_GENERATION_MASK = 0x0F0,
39 MIDGARD = 0x100,
40 BIFROST = 0x200,
41 VALHALL = 0x300,
42 T600 = 0x110,
43 T700 = 0x120,
44 T800 = 0x130,
45 G71 = 0x210,
46 G72 = 0x220,
47 G51 = 0x221,
48 G51BIG = 0x222,
49 G51LIT = 0x223,
50 G31 = 0x224,
51 G76 = 0x230,
52 G52 = 0x231,
53 G52LIT = 0x232,
54 G77 = 0x310,
55 G57 = 0x311,
56 G78 = 0x320,
57 G68 = 0x321,
58 G78AE = 0x330,
59 G710 = 0x340,
60 G610 = 0x341,
61 G510 = 0x342,
62 G310 = 0x343,
63 G715 = 0x350,
64 G615 = 0x351,
Michele Di Giorgio164b65d2018-04-13 14:28:08 +010065};
Michele Di Giorgiob8fc60f2018-04-25 11:58:07 +010066
67/** Enable bitwise operations on GPUTarget enumerations */
68template <>
69struct enable_bitwise_ops<arm_compute::GPUTarget>
70{
71 static constexpr bool value = true; /**< Enabled. */
72};
73
74/** Translates a given gpu device target to string.
75 *
76 * @param[in] target Given gpu target.
77 *
78 * @return The string describing the target.
79 */
80const std::string &string_from_target(GPUTarget target);
81
82/** Helper function to get the GPU target from a device name
83 *
84 * @param[in] device_name A device name
85 *
86 * @return the GPU target
87 */
88GPUTarget get_target_from_name(const std::string &device_name);
89
90/** Helper function to get the GPU arch
91 *
92 * @param[in] target GPU target
93 *
94 * @return the GPU target which shows the arch
95 */
96GPUTarget get_arch_from_target(GPUTarget target);
97/** Helper function to check whether a gpu target is equal to the provided targets
98 *
99 * @param[in] target_to_check gpu target to check
100 * @param[in] target First target to compare against
101 * @param[in] targets (Optional) Additional targets to compare with
102 *
103 * @return True if the target is equal with at least one of the targets.
104 */
105template <typename... Args>
106bool gpu_target_is_in(GPUTarget target_to_check, GPUTarget target, Args... targets)
107{
108 return (target_to_check == target) | gpu_target_is_in(target_to_check, targets...);
109}
110
111/** Variant of gpu_target_is_in for comparing two targets */
112inline bool gpu_target_is_in(GPUTarget target_to_check, GPUTarget target)
113{
114 return target_to_check == target;
115}
Michele Di Giorgio164b65d2018-04-13 14:28:08 +0100116} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000117#endif /* ARM_COMPUTE_GPUTARGET_H */