Michele Di Giorgio | 164b65d | 2018-04-13 14:28:08 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 ARM Limited. |
| 3 | * |
| 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 | */ |
| 24 | #ifndef __ARM_COMPUTE_GPUTARGET_H__ |
| 25 | #define __ARM_COMPUTE_GPUTARGET_H__ |
| 26 | |
Michele Di Giorgio | b8fc60f | 2018-04-25 11:58:07 +0100 | [diff] [blame] | 27 | #include "arm_compute/core/Helpers.h" |
| 28 | |
| 29 | #include <string> |
| 30 | |
Michele Di Giorgio | 164b65d | 2018-04-13 14:28:08 +0100 | [diff] [blame] | 31 | namespace arm_compute |
| 32 | { |
| 33 | /** Available GPU Targets */ |
| 34 | enum class GPUTarget |
| 35 | { |
| 36 | UNKNOWN = 0x101, |
| 37 | GPU_ARCH_MASK = 0xF00, |
| 38 | MIDGARD = 0x100, |
| 39 | BIFROST = 0x200, |
| 40 | T600 = 0x110, |
| 41 | T700 = 0x120, |
| 42 | T800 = 0x130, |
| 43 | G71 = 0x210, |
| 44 | G72 = 0x220, |
| 45 | G51 = 0x230, |
| 46 | G51BIG = 0x231, |
| 47 | G51LIT = 0x232, |
| 48 | TNOX = 0x240, |
| 49 | TTRX = 0x250, |
| 50 | TBOX = 0x260 |
| 51 | }; |
Michele Di Giorgio | b8fc60f | 2018-04-25 11:58:07 +0100 | [diff] [blame] | 52 | |
| 53 | /** Enable bitwise operations on GPUTarget enumerations */ |
| 54 | template <> |
| 55 | struct enable_bitwise_ops<arm_compute::GPUTarget> |
| 56 | { |
| 57 | static constexpr bool value = true; /**< Enabled. */ |
| 58 | }; |
| 59 | |
| 60 | /** Translates a given gpu device target to string. |
| 61 | * |
| 62 | * @param[in] target Given gpu target. |
| 63 | * |
| 64 | * @return The string describing the target. |
| 65 | */ |
| 66 | const std::string &string_from_target(GPUTarget target); |
| 67 | |
| 68 | /** Helper function to get the GPU target from a device name |
| 69 | * |
| 70 | * @param[in] device_name A device name |
| 71 | * |
| 72 | * @return the GPU target |
| 73 | */ |
| 74 | GPUTarget get_target_from_name(const std::string &device_name); |
| 75 | |
| 76 | /** Helper function to get the GPU arch |
| 77 | * |
| 78 | * @param[in] target GPU target |
| 79 | * |
| 80 | * @return the GPU target which shows the arch |
| 81 | */ |
| 82 | GPUTarget get_arch_from_target(GPUTarget target); |
| 83 | /** Helper function to check whether a gpu target is equal to the provided targets |
| 84 | * |
| 85 | * @param[in] target_to_check gpu target to check |
| 86 | * @param[in] target First target to compare against |
| 87 | * @param[in] targets (Optional) Additional targets to compare with |
| 88 | * |
| 89 | * @return True if the target is equal with at least one of the targets. |
| 90 | */ |
| 91 | template <typename... Args> |
| 92 | bool gpu_target_is_in(GPUTarget target_to_check, GPUTarget target, Args... targets) |
| 93 | { |
| 94 | return (target_to_check == target) | gpu_target_is_in(target_to_check, targets...); |
| 95 | } |
| 96 | |
| 97 | /** Variant of gpu_target_is_in for comparing two targets */ |
| 98 | inline bool gpu_target_is_in(GPUTarget target_to_check, GPUTarget target) |
| 99 | { |
| 100 | return target_to_check == target; |
| 101 | } |
Michele Di Giorgio | 164b65d | 2018-04-13 14:28:08 +0100 | [diff] [blame] | 102 | } // namespace arm_compute |
| 103 | #endif /* __ARM_COMPUTE_GPUTARGET_H__ */ |