MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / run_example

Function run_example

tests/validate_examples/RunExample.cpp:111–228  ·  view source on GitHub ↗

namespace

Source from the content-addressed store, hash-verified

109
110} // namespace
111int run_example(int argc, char **argv, std::unique_ptr<ValidateExample> example)
112{
113 utils::CommandLineParser parser;
114 framework::CommonOptions options(parser);
115 auto example_args = parser.add_option<utils::ListOption<std::string>>("example_args");
116 example_args->set_help("Arguments to pass to the example separated by commas (e.g: arg0,arg1,arg2)");
117 auto seed = parser.add_option<utils::SimpleOption<std::random_device::result_type>>("seed", std::random_device()());
118 seed->set_help("Global seed for random number generation");
119 auto validate = parser.add_option<utils::SimpleOption<int>>("validate", 1);
120 validate->set_help("Enable / disable output validation (0/1)");
121
122 framework::Framework &framework = framework::Framework::get();
123
124 parser.parse(argc, argv);
125
126 if (options.help->is_set() && options.help->value())
127 {
128 parser.print_help(argv[0]);
129 return 0;
130 }
131
132 std::vector<std::unique_ptr<framework::Printer>> printers = options.create_printers();
133 g_example = std::move(example);
134 g_example_argv.clear();
135 g_example_argv.emplace_back(argv[0]);
136 for (auto &arg : example_args->value())
137 {
138 g_example_argv.emplace_back(const_cast<char *>(arg.c_str())); // NOLINT
139 }
140
141 library = std::make_unique<AssetsLibrary>("." /* Only using random values */, seed->value());
142 fixed_library = std::make_unique<AssetsLibrary>(".", fixed_seed);
143
144 if (options.log_level->value() > framework::LogLevel::NONE)
145 {
146 for (auto &p : printers)
147 {
148 p->print_global_header();
149 }
150 }
151
152#ifdef ARM_COMPUTE_CL
153 if (opencl_is_available())
154 {
155 CLBackendType backend_type = CLBackendType::Native;
156 for (auto &arg : example_args->value())
157 {
158 if (arg.find("--target=clvk") != std::string::npos)
159 {
160 backend_type = CLBackendType::Clvk;
161 break;
162 }
163 }
164 auto ctx_dev_err = create_opencl_context_and_device(backend_type);
165 ARM_COMPUTE_ERROR_ON_MSG(std::get<2>(ctx_dev_err) != CL_SUCCESS, "Failed to create OpenCL context");
166 CLScheduler::get().default_init_with_context(std::get<1>(ctx_dev_err), std::get<0>(ctx_dev_err), nullptr);
167 }
168#endif /* ARM_COMPUTE_CL */

Callers

nothing calls this directly

Calls 15

opencl_is_availableFunction · 0.85
build_informationFunction · 0.85
set_helpMethod · 0.80
is_setMethod · 0.80
print_helpMethod · 0.80
create_printersMethod · 0.80
findMethod · 0.80
set_throw_errorsMethod · 0.80
command_lineFunction · 0.70
to_stringFunction · 0.50

Tested by

no test coverage detected