blob: 49e2d615ea75d2158b200d9a47c96d7663c228d8 [file] [log] [blame]
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +01001/*
Manuel Bottinib56c1752020-11-18 17:56:30 +00002 * Copyright (c) 2019-2021 Arm Limited.
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +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_CLTUNER_TYPES_H
25#define ARM_COMPUTE_CLTUNER_TYPES_H
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010026
27#include "arm_compute/core/Error.h"
28#include "arm_compute/core/utils/misc/Utility.h"
Georgios Pinitas4c5469b2019-05-21 13:32:43 +010029
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010030#include <map>
31
32namespace arm_compute
33{
34/**< OpenCL tuner modes */
35enum class CLTunerMode
36{
37 EXHAUSTIVE, /**< Searches all possible LWS configurations while tuning */
38 NORMAL, /**< Searches a subset of LWS configurations while tuning */
39 RAPID /**< Searches a minimal subset of LWS configurations while tuning */
40};
41
Manuel Bottinib56c1752020-11-18 17:56:30 +000042/**< OpenCL tuner tuning information */
43struct CLTuningInfo
44{
45 bool tune_lws = true;
46};
47
Vidhya Sudhan Loganathan050471e2019-04-25 09:27:24 +010048/** Converts a string to a strong types enumeration @ref CLTunerMode
49 *
50 * @param[in] name String to convert
51 *
52 * @return Converted CLTunerMode enumeration
53 */
54inline CLTunerMode tuner_mode_from_name(const std::string &name)
55{
56 static const std::map<std::string, CLTunerMode> tuner_modes =
57 {
58 { "exhaustive", CLTunerMode::EXHAUSTIVE },
59 { "normal", CLTunerMode::NORMAL },
60 { "rapid", CLTunerMode::RAPID },
61 };
62
63#ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED
64 try
65 {
66#endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */
67 return tuner_modes.at(arm_compute::utility::tolower(name));
68
69#ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED
70 }
71 catch(const std::out_of_range &)
72 {
73 throw std::invalid_argument(name);
74 }
75#endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */
76}
77
78/** Input Stream operator for @ref CLTunerMode
79 *
80 * @param[in] stream Stream to parse
81 * @param[out] tuner_mode Output tuner mode
82 *
83 * @return Updated stream
84 */
85inline ::std::istream &operator>>(::std::istream &stream, CLTunerMode &tuner_mode)
86{
87 std::string value;
88 stream >> value;
89 tuner_mode = tuner_mode_from_name(value);
90 return stream;
91}
92} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +000093#endif /*ARM_COMPUTE_CLTUNER_TYPES_H */