Halide 22.0.0 Halide compiler and libraries

Loading...
Searching...
No Matches
simd_op_check.h
Go to the documentation of this file.
1#ifndef SIMD_OP_CHECK_H
2#define SIMD_OP_CHECK_H
3
4#include "Halide.h"
5#include "halide_test_dirs.h"
6#include "halide_thread_pool.h"
7#include "test_sharding.h"
8
9#include <fstream>
10#include <iostream>
11
12 namespace {
13
14 using namespace Halide;
15
16// Some exprs of each type to use in checked expressions. These will turn
17// into loads to thread-local image params.
18 Expr input(const Type &t, const Expr &arg) {
19 return Internal::Call::make(t, "input", {arg}, Internal::Call::Extern);
20}
21 Expr in_f16(const Expr &arg) {
22 return input(Float(16), arg);
23}
24 Expr in_bf16(const Expr &arg) {
25 return input(BFloat(16), arg);
26}
27 Expr in_f32(const Expr &arg) {
28 return input(Float(32), arg);
29}
30 Expr in_f64(const Expr &arg) {
31 return input(Float(64), arg);
32}
33 Expr in_i8(const Expr &arg) {
34 return input(Int(8), arg);
35}
36 Expr in_i16(const Expr &arg) {
37 return input(Int(16), arg);
38}
39 Expr in_i32(const Expr &arg) {
40 return input(Int(32), arg);
41}
42 Expr in_i64(const Expr &arg) {
43 return input(Int(64), arg);
44}
45 Expr in_u8(const Expr &arg) {
46 return input(UInt(8), arg);
47}
48 Expr in_u16(const Expr &arg) {
49 return input(UInt(16), arg);
50}
51 Expr in_u32(const Expr &arg) {
52 return input(UInt(32), arg);
53}
54 Expr in_u64(const Expr &arg) {
55 return input(UInt(64), arg);
56}
57} // namespace
58
59 namespace Halide {
60 struct TestResult {
61 std::string op;
62 std::string error_msg;
63};
64
65 struct Task {
66 std::string op;
67 std::string name;
68 int vector_width;
69 Expr expr;
70};
71
72 class SimdOpCheckTest {
73 public:
74 static constexpr int max_i8 = 127;
75 static constexpr int max_i16 = 32767;
76 static constexpr int max_i32 = 0x7fffffff;
77 static constexpr int max_u8 = 255;
78 static constexpr int max_u16 = 65535;
79 const Expr max_u32 = UInt(32).max();
80
81 std::string filter{"*"};
82 std::string output_directory{Internal::get_test_tmp_dir()};
83 std::vector<Task> tasks;
84
85 Target target;
86
87 int W;
88 int H;
89
90 int rng_seed;
91
92 using Sharder = Halide::Internal::Test::Sharder;
93
94 SimdOpCheckTest(const Target t, int w, int h)
95 : target(t), W(w), H(h), rng_seed(0) {
96 target = target
97 .with_feature(Target::NoBoundsQuery)
98 .with_feature(Target::NoAsserts)
99 .with_feature(Target::NoRuntime);
100 }
101 virtual ~SimdOpCheckTest() = default;
102
103 void set_seed(int seed) {
104 rng_seed = seed;
105 }
106
107 virtual bool can_run_code() const {
108 if (target.arch == Target::WebAssembly) {
109 return Halide::Internal::WasmModule::can_jit_target(Target("wasm-32-wasmrt"));
110 }
111 // If we can (target matches host), run the error checking Halide::Func.
112 Target host_target = get_host_target();
113 bool can_run_the_code =
114 (target.arch == host_target.arch &&
115 target.bits == host_target.bits &&
116 target.os == host_target.os);
117 // A bunch of feature flags also need to match between the
118 // compiled code and the host in order to run the code.
119 for (Target::Feature f : {
120 Target::ARMDotProd,
121 Target::ARMFp16,
122 Target::ARMv7s,
123 Target::ARMv8a,
124 Target::ARMv81a,
125 Target::ARMv82a,
126 Target::ARMv83a,
127 Target::ARMv84a,
128 Target::ARMv85a,
129 Target::ARMv86a,
130 Target::ARMv87a,
131 Target::ARMv88a,
132 Target::ARMv89a,
133 Target::AVX,
134 Target::AVX2,
135 Target::AVX512,
136 Target::AVX512_Cannonlake,
137 Target::AVX512_KNL,
138 Target::AVX512_SapphireRapids,
139 Target::AVX512_Skylake,
140 Target::AVX512_Zen4,
141 Target::AVX512_Zen5,
142 Target::AVXVNNI,
143 Target::F16C,
144 Target::FMA,
145 Target::FMA4,
146 Target::NoNEON,
147 Target::POWER_ARCH_2_07,
148 Target::RVV,
149 Target::SSE41,
150 Target::SVE,
151 Target::SVE2,
152 Target::VSX,
153 }) {
154 if (target.has_feature(f) != host_target.has_feature(f)) {
155 can_run_the_code = false;
156 }
157 }
158 return can_run_the_code;
159 }
160
161 virtual void compile_and_check(Func error,
162 const std::string &op,
163 const std::string &name,
164 int vector_width,
165 const std::vector<Argument> &arg_types,
166 std::ostringstream &error_msg) {
167 std::string fn_name = "test_" + name;
168 std::string file_name = output_directory + fn_name;
169
170 auto ext = Internal::get_output_info(target);
171 std::map<OutputFileType, std::string> outputs = {
172 {OutputFileType::c_header, file_name + ext.at(OutputFileType::c_header).extension},
173 {OutputFileType::object, file_name + ext.at(OutputFileType::object).extension},
174 {OutputFileType::assembly, file_name + ".s"},
175 };
176 error.compile_to(outputs, arg_types, fn_name, target);
177
178 std::ifstream asm_file;
179 asm_file.open(file_name + ".s");
180
181 bool found_it = false;
182
183 std::ostringstream msg;
184 msg << op << " did not generate for target=" << get_run_target().to_string() << " vector_width=" << vector_width << ". Instead we got:\n";
185
186 std::string line;
187 while (getline(asm_file, line)) {
188 msg << line << "\n";
189
190 // Check for the op in question
191 found_it |= wildcard_search(op, line) && !wildcard_search("_" + op, line);
192 }
193
194 if (!found_it) {
195 error_msg << "Failed: " << msg.str() << "\n";
196 }
197
198 asm_file.close();
199 }
200
201 // Check if pattern p matches str, allowing for wildcards (*).
202 bool wildcard_match(const char *p, const char *str) const {
203 // Match all non-wildcard characters.
204 while (*p && *str && *p == *str && *p != '*') {
205 str++;
206 p++;
207 }
208
209 if (!*p) {
210 return *str == 0;
211 } else if (*p == '*') {
212 p++;
213 do {
214 if (wildcard_match(p, str)) {
215 return true;
216 }
217 } while (*str++);
218 } else if (*p == ' ') { // ignore whitespace in pattern
219 p++;
220 if (wildcard_match(p, str)) {
221 return true;
222 }
223 } else if (*str == ' ') { // ignore whitespace in string
224 str++;
225 if (wildcard_match(p, str)) {
226 return true;
227 }
228 }
229 return !*p;
230 }
231
232 bool wildcard_match(const std::string &p, const std::string &str) const {
233 return wildcard_match(p.c_str(), str.c_str());
234 }
235
236 // Check if a substring of str matches a pattern p.
237 bool wildcard_search(const std::string &p, const std::string &str) const {
238 return wildcard_match("*" + p + "*", str);
239 }
240
241 Target get_run_target() const {
242 return target
243 .without_feature(Target::NoRuntime)
244 .without_feature(Target::NoAsserts)
245 .without_feature(Target::NoBoundsQuery);
246 }
247
248 TestResult check_one(const std::string &op, const std::string &name, int vector_width, Expr e) {
249 std::ostringstream error_msg;
250
251 // Map the input calls in the Expr to loads to local
252 // imageparams, so that we're not sharing state across threads.
253 std::vector<ImageParam> image_params{
254 ImageParam{Float(32), 1, "in_f32"},
255 ImageParam{Float(64), 1, "in_f64"},
256 ImageParam{Float(16), 1, "in_f16"},
257 ImageParam{BFloat(16), 1, "in_bf16"},
258 ImageParam{Int(8), 1, "in_i8"},
259 ImageParam{UInt(8), 1, "in_u8"},
260 ImageParam{Int(16), 1, "in_i16"},
261 ImageParam{UInt(16), 1, "in_u16"},
262 ImageParam{Int(32), 1, "in_i32"},
263 ImageParam{UInt(32), 1, "in_u32"},
264 ImageParam{Int(64), 1, "in_i64"},
265 ImageParam{UInt(64), 1, "in_u64"}};
266
267 for (auto &p : image_params) {
268 const int alignment_bytes = image_param_alignment();
269 p.set_host_alignment(alignment_bytes);
270 const int alignment = alignment_bytes / p.type().bytes();
271 p.dim(0).set_min((p.dim(0).min() / alignment) * alignment);
272 }
273
274 std::vector<Argument> arg_types(image_params.begin(), image_params.end());
275
276 class HookUpImageParams : public Internal::IRMutator {
277 using Internal::IRMutator::visit;
278
279 Expr visit(const Internal::Call *op) override {
280 if (op->name == "input") {
281 for (auto &p : image_params) {
282 if (p.type() == op->type) {
283 return p(mutate(op->args[0]));
284 }
285 }
286 } else if (op->call_type == Internal::Call::Halide && !op->func.weak) {
287 Internal::Function f(op->func);
288 f.mutate(this);
289 }
290 return Internal::IRMutator::visit(op);
291 }
292 const std::vector<ImageParam> &image_params;
293
294 public:
295 HookUpImageParams(const std::vector<ImageParam> &image_params)
296 : image_params(image_params) {
297 }
298 } hook_up_image_params(image_params);
299 e = hook_up_image_params.mutate(e);
300
301 class HasInlineReduction : public Internal::IRVisitor {
302 using Internal::IRVisitor::visit;
303 void visit(const Internal::Call *op) override {
304 if (op->call_type == Internal::Call::Halide) {
305 Internal::Function f(op->func);
306 if (f.has_update_definition() &&
307 f.update(0).schedule().rvars().size() > 0) {
308 inline_reduction = f;
309 result = true;
310 }
311 }
312 IRVisitor::visit(op);
313 }
314
315 public:
316 Internal::Function inline_reduction;
317 bool result = false;
318 } has_inline_reduction;
319 e.accept(&has_inline_reduction);
320
321 // Define a vectorized Halide::Func that uses the pattern.
322 Halide::Func f(name);
323 f(x, y) = e;
324 f.bound(x, 0, W).vectorize(x, vector_width);
325 f.compute_root();
326
327 // Include a scalar version
328 Halide::Func f_scalar("scalar_" + name);
329 f_scalar(x, y) = e;
330 // Make sure scalar result is computed independently to prevent it
331 // from being fused into error() by optimization which complicates floating point errors.
332 f_scalar.compute_root();
333
334 if (has_inline_reduction.result) {
335 // If there's an inline reduction, we want to vectorize it
336 // over the RVar.
337 Var xo, xi;
338 RVar rxi;
339 Func g{has_inline_reduction.inline_reduction};
340
341 // Do the reduction separately in f_scalar
342 g.clone_in(f_scalar);
343
344 g.compute_at(f, x)
345 .update()
346 .split(x, xo, xi, vector_width)
347 .atomic(true)
348 .vectorize(g.rvars()[0])
349 .vectorize(xi);
350 }
351
352 // We'll check over H rows, but we won't let the pipeline know H
353 // statically, as that can trigger some simplifications that change
354 // instruction selection.
355 Param<int> rows;
356 rows.set(H);
357 arg_types.push_back(rows);
358
359 // The output to the pipeline is the maximum absolute difference as a double.
360 RDom r_check(0, W, 0, rows);
361 Halide::Func error("error_" + name);
362 error() = Halide::cast<double>(maximum(absd(f(r_check.x, r_check.y), f_scalar(r_check.x, r_check.y))));
363
364 compile_and_check(error, op, name, vector_width, arg_types, error_msg);
365
366 bool can_run_the_code = can_run_code();
367 if (can_run_the_code) {
368 Target run_target = get_run_target();
369
370 // Make some unallocated input buffers
371 std::vector<Runtime::Buffer<>> inputs(image_params.size());
372
373 std::vector<Argument> args(image_params.size() + 1);
374 for (size_t i = 0; i < image_params.size(); i++) {
375 args[i] = image_params[i];
376 inputs[i] = Runtime::Buffer<>(args[i].type, nullptr, 0);
377 }
378 args.back() = rows;
379
380 auto callable = error.compile_to_callable(args, run_target);
381
382 Runtime::Buffer<double> output = Runtime::Buffer<double>::make_scalar();
383 output(0) = 1; // To ensure we'll fail if it's never written to
384
385 // Do the bounds query call
386 assert(inputs.size() == 12);
387 (void)callable(inputs[0], inputs[1], inputs[2], inputs[3],
388 inputs[4], inputs[5], inputs[6], inputs[7],
389 inputs[8], inputs[9], inputs[10], inputs[11],
390 H, output);
391
392 std::mt19937 rng;
393 rng.seed(rng_seed);
394
395 // Allocate the input buffers and fill them with noise
396 for (size_t i = 0; i < inputs.size(); i++) {
397 if (inputs[i].size_in_bytes()) {
398 inputs[i].allocate();
399
400 Type t = inputs[i].type();
401 // For floats/doubles, we only use values that aren't
402 // subject to rounding error that may differ between
403 // vectorized and non-vectorized versions
404 if (t == Float(32)) {
405 inputs[i].as<float>().for_each_value([&](float &f) { f = (rng() & 0xfff) / 8.0f - 0xff; });
406 } else if (t == Float(64)) {
407 inputs[i].as<double>().for_each_value([&](double &f) { f = (rng() & 0xfff) / 8.0 - 0xff; });
408 } else if (t == Float(16)) {
409 inputs[i].as<float16_t>().for_each_value([&](float16_t &f) { f = float16_t((rng() & 0xff) / 8.0f - 0xf); });
410 } else if (t == BFloat(16)) {
411 inputs[i].as<bfloat16_t>().for_each_value([&](bfloat16_t &f) { f = bfloat16_t((rng() & 0xff) / 8.0f - 0xf); });
412 } else {
413 assert(t.is_int_or_uint());
414 // Random bits is fine, but in the 32-bit int case we
415 // never use the top four bits, to avoid signed integer
416 // overflow.
417 const uint32_t mask = (t == Int(32)) ? 0x0fffffffU : 0xffffffffU;
418 for (uint32_t *ptr = (uint32_t *)inputs[i].data();
419 ptr != (uint32_t *)inputs[i].data() + inputs[i].size_in_bytes() / 4;
420 ptr++) {
421 *ptr = ((uint32_t)rng()) & mask;
422 }
423 }
424 }
425 }
426
427 // Do the real call
428 (void)callable(inputs[0], inputs[1], inputs[2], inputs[3],
429 inputs[4], inputs[5], inputs[6], inputs[7],
430 inputs[8], inputs[9], inputs[10], inputs[11],
431 H, output);
432
433 double e = output(0);
434 // Use a very loose tolerance for floating point tests. The
435 // kinds of bugs we're looking for are codegen bugs that
436 // return the wrong value entirely, not floating point
437 // accuracy differences between vectors and scalars.
438 if (e > 0.001) {
439 error_msg << "The vector and scalar versions of " << name << " disagree. Maximum error: " << e << "\n";
440
441 std::string error_filename = output_directory + "error_" + name + ".s";
442 error.compile_to_assembly(error_filename, arg_types, target);
443
444 std::ifstream error_file;
445 error_file.open(error_filename);
446
447 error_msg << "Error assembly: \n";
448 std::string line;
449 while (getline(error_file, line)) {
450 error_msg << line << "\n";
451 }
452
453 error_file.close();
454 }
455 }
456
457 return {op, error_msg.str()};
458 }
459
460 void check(std::string op, int vector_width, Expr e) {
461 // Make a name for the test by uniquing then sanitizing the op name
462 std::string name = "op_" + op;
463 for (size_t i = 0; i < name.size(); i++) {
464 if (!isalnum(name[i])) name[i] = '_';
465 }
466
467 name += "_" + std::to_string(tasks.size());
468
469 // Bail out after generating the unique_name, so that names are
470 // unique across different processes and don't depend on filter
471 // settings.
472 if (!wildcard_match(filter, op)) return;
473
474 tasks.emplace_back(Task{op, name, vector_width, e});
475 }
476 virtual void add_tests() = 0;
477 virtual int image_param_alignment() {
478 return 16;
479 }
480
481 virtual bool use_multiple_threads() const {
482 return true;
483 }
484
485 virtual bool test_all() {
486 /* First add some tests based on the target */
487 add_tests();
488
489 // Remove irrelevant noise from output
490 const Target run_target = get_run_target();
491 const std::string run_target_str = run_target.to_string();
492
493 Sharder sharder;
494
495 Halide::Tools::ThreadPool<TestResult> pool(
496 use_multiple_threads() ?
497 Halide::Tools::ThreadPool<TestResult>::num_processors_online() :
498 1);
499 std::vector<std::future<TestResult>> futures;
500
501 for (size_t t = 0; t < tasks.size(); t++) {
502 if (!sharder.should_run(t)) continue;
503 const auto &task = tasks.at(t);
504 futures.push_back(pool.async([&]() {
505 return check_one(task.op, task.name, task.vector_width, task.expr);
506 }));
507 }
508
509 for (auto &f : futures) {
510 auto result = f.get();
511 constexpr int tabstop = 32;
512 const int spaces = std::max(1, tabstop - (int)result.op.size());
513 std::cout << result.op << std::string(spaces, ' ') << "(" << run_target_str << ")\n";
514 if (!result.error_msg.empty()) {
515 std::cerr << result.error_msg;
516 // The thread-pool destructor will block until in-progress tasks
517 // are done, and then will discard any tasks that haven't been
518 // launched yet.
519 return false;
520 }
521 }
522
523 return true;
524 }
525
526 template<typename SIMDOpCheckT>
527 static int main(int argc, char **argv, const std::vector<Target> &targets_to_test) {
528 Target host = get_host_target();
529 std::cout << "host is: " << host << "\n";
530
531 const int seed = argc > 2 ? atoi(argv[2]) : time(nullptr);
532 std::cout << "simd_op_check test seed: " << seed << "\n";
533
534 for (const auto &t : targets_to_test) {
535 if (!t.supported()) {
536 std::cout << "[SKIP] Unsupported target: " << t << "\n";
537 return 0;
538 }
539 SIMDOpCheckT test(t);
540
541 if (!t.supported()) {
542 std::cout << "Halide was compiled without support for " << t.to_string() << ". Skipping.\n";
543 continue;
544 }
545
546 if (argc > 1) {
547 test.filter = argv[1];
548 }
549
550 if (getenv("HL_SIMD_OP_CHECK_FILTER")) {
551 test.filter = getenv("HL_SIMD_OP_CHECK_FILTER");
552 }
553
554 test.set_seed(seed);
555
556 if (argc > 2) {
557 // Don't forget: if you want to run the standard tests to a specific output
558 // directory, you'll need to invoke with the first arg enclosed
559 // in quotes (to avoid it being wildcard-expanded by the shell):
560 //
561 // correctness_simd_op_check "*" /path/to/output
562 //
563 test.output_directory = argv[2];
564 }
565
566 bool success = test.test_all();
567
568 // Compile a runtime for this target, for use in the static test.
569 compile_standalone_runtime(test.output_directory + "simd_op_check_runtime.o", test.target);
570
571 if (!success) {
572 return 1;
573 }
574 }
575
576 std::cout << "Success!\n";
577 return 0;
578 }
579
580 private:
581 const Halide::Var x{"x"}, y{"y"};
582};
583
584} // namespace Halide
585
586#endif // SIMD_OP_CHECK_H
Halide::Func
A halide function.
Definition Func.h:706
Halide::Func::compile_to_assembly
void compile_to_assembly(const std::string &filename, const std::vector< Argument > &, const std::string &fn_name, const Target &target=get_target_from_environment())
Statically compile this function to text assembly equivalent to the object file generated by compile_...
Halide::Func::compute_root
Func & compute_root()
Compute all of this function once ahead of time.
Halide::Func::compile_to_callable
Callable compile_to_callable(const std::vector< Argument > &args, const Target &target=get_jit_target_from_environment())
Eagerly jit compile the function to machine code and return a callable struct that behaves like a fun...
Halide::Func::compile_to
void compile_to(const std::map< OutputFileType, std::string > &output_files, const std::vector< Argument > &args, const std::string &fn_name, const Target &target=get_target_from_environment())
Compile and generate multiple target files with single call.
Halide::Func::vectorize
Func & vectorize(const VarOrRVar &var)
Mark a dimension to be computed all-at-once as a single vector.
Halide::Func::bound
Func & bound(const Var &var, Expr min, Expr extent)
Statically declare that the range over which a function should be evaluated is given by the second an...
Halide::ImageParam
An Image parameter to a halide pipeline.
Definition ImageParam.h:23
Halide::Internal::Definition::schedule
const StageSchedule & schedule() const
Get the default (no-specialization) stage-specific schedule associated with this definition.
Halide::Internal::Function
A reference-counted handle to Halide's internal representation of a function.
Definition Function.h:39
Halide::Internal::Function::has_update_definition
bool has_update_definition() const
Does this function have an update definition?
Halide::Internal::Function::mutate
void mutate(IRMutator *mutator)
Accept a mutator to mutator all of the definitions and arguments of this function.
Halide::Internal::Function::update
Definition & update(int idx=0)
Get a mutable handle to this function's update definition at index 'idx'.
Halide::Internal::IRMutator
A base class for passes over the IR which modify it (e.g.
Definition IRMutator.h:26
Halide::Internal::IRMutator::visit
virtual Expr visit(const IntImm *)
Halide::Internal::IRVisitor
A base class for algorithms that need to recursively walk over the IR.
Definition IRVisitor.h:19
Halide::Internal::IRVisitor::visit
virtual void visit(const IntImm *)
Halide::Internal::StageSchedule::rvars
const std::vector< ReductionVariable > & rvars() const
RVars of reduction domain associated with this schedule if there is any.
Halide::Internal::Test::Sharder
Definition test_sharding.h:29
Halide::Param
A scalar parameter to a halide pipeline.
Definition Param.h:22
Halide::Param::set
HALIDE_NO_USER_CODE_INLINE void set(const SOME_TYPE &val)
Set the current value of this parameter.
Definition Param.h:174
Halide::RDom
A multi-dimensional domain over which to iterate.
Definition RDom.h:193
Halide::RVar
A reduction variable represents a single dimension of a reduction domain (RDom).
Definition RDom.h:29
Halide::Runtime::Buffer
A templated Buffer class that wraps halide_buffer_t and adds functionality.
Definition HalideBuffer.h:222
Halide::Runtime::Buffer::make_scalar
static Buffer< T, Dims, InClassDimStorage > make_scalar()
Make a zero-dimensional Buffer.
Definition HalideBuffer.h:1975
Halide::SimdOpCheckTest
Definition simd_op_check.h:72
Halide::SimdOpCheckTest::H
int H
Definition simd_op_check.h:88
Halide::SimdOpCheckTest::max_u8
static constexpr int max_u8
Definition simd_op_check.h:77
Halide::SimdOpCheckTest::output_directory
std::string output_directory
Definition simd_op_check.h:82
Halide::SimdOpCheckTest::max_i32
static constexpr int max_i32
Definition simd_op_check.h:76
Halide::SimdOpCheckTest::filter
std::string filter
Definition simd_op_check.h:81
Halide::SimdOpCheckTest::use_multiple_threads
virtual bool use_multiple_threads() const
Definition simd_op_check.h:481
Halide::SimdOpCheckTest::set_seed
void set_seed(int seed)
Definition simd_op_check.h:103
Halide::SimdOpCheckTest::add_tests
virtual void add_tests()=0
Halide::SimdOpCheckTest::W
int W
Definition simd_op_check.h:87
Halide::SimdOpCheckTest::image_param_alignment
virtual int image_param_alignment()
Definition simd_op_check.h:477
Halide::SimdOpCheckTest::wildcard_match
bool wildcard_match(const std::string &p, const std::string &str) const
Definition simd_op_check.h:232
Halide::SimdOpCheckTest::test_all
virtual bool test_all()
Definition simd_op_check.h:485
Halide::SimdOpCheckTest::max_i8
static constexpr int max_i8
Definition simd_op_check.h:74
Halide::SimdOpCheckTest::max_u32
const Expr max_u32
Definition simd_op_check.h:79
Halide::SimdOpCheckTest::max_u16
static constexpr int max_u16
Definition simd_op_check.h:78
Halide::SimdOpCheckTest::wildcard_search
bool wildcard_search(const std::string &p, const std::string &str) const
Definition simd_op_check.h:237
Halide::SimdOpCheckTest::wildcard_match
bool wildcard_match(const char *p, const char *str) const
Definition simd_op_check.h:202
Halide::SimdOpCheckTest::~SimdOpCheckTest
virtual ~SimdOpCheckTest()=default
Halide::SimdOpCheckTest::SimdOpCheckTest
SimdOpCheckTest(const Target t, int w, int h)
Definition simd_op_check.h:94
Halide::SimdOpCheckTest::check
void check(std::string op, int vector_width, Expr e)
Definition simd_op_check.h:460
Halide::SimdOpCheckTest::get_run_target
Target get_run_target() const
Definition simd_op_check.h:241
Halide::SimdOpCheckTest::main
static int main(int argc, char **argv, const std::vector< Target > &targets_to_test)
Definition simd_op_check.h:527
Halide::SimdOpCheckTest::max_i16
static constexpr int max_i16
Definition simd_op_check.h:75
Halide::SimdOpCheckTest::rng_seed
int rng_seed
Definition simd_op_check.h:90
Halide::SimdOpCheckTest::check_one
TestResult check_one(const std::string &op, const std::string &name, int vector_width, Expr e)
Definition simd_op_check.h:248
Halide::SimdOpCheckTest::target
Target target
Definition simd_op_check.h:85
Halide::SimdOpCheckTest::can_run_code
virtual bool can_run_code() const
Definition simd_op_check.h:107
Halide::SimdOpCheckTest::tasks
std::vector< Task > tasks
Definition simd_op_check.h:83
Halide::SimdOpCheckTest::compile_and_check
virtual void compile_and_check(Func error, const std::string &op, const std::string &name, int vector_width, const std::vector< Argument > &arg_types, std::ostringstream &error_msg)
Definition simd_op_check.h:161
Halide::Var
A Halide variable, to be used when defining functions.
Definition Var.h:19
halide_test_dirs.h
Halide::Internal::get_output_info
std::map< OutputFileType, const OutputInfo > get_output_info(const Target &target)
Halide::Internal::get_test_tmp_dir
std::string get_test_tmp_dir()
Return the path to a directory that can be safely written to when running tests; the contents directo...
Definition halide_test_dirs.h:76
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition AbstractGenerator.h:19
Halide::get_host_target
Target get_host_target()
Return the target corresponding to the host machine.
Halide::BFloat
Type BFloat(int bits, int lanes=1)
Construct a floating-point type in the bfloat format.
Definition Type.h:554
Halide::UInt
Type UInt(int bits, int lanes=1)
Constructing an unsigned integer type.
Definition Type.h:544
Halide::Float
Type Float(int bits, int lanes=1)
Construct a floating-point type.
Definition Type.h:549
Halide::maximum
Expr maximum(Expr, const std::string &s="maximum")
Halide::Int
Type Int(int bits, int lanes=1)
Constructing a signed integer type.
Definition Type.h:539
Halide::OutputFileType::assembly
@ assembly
Halide::OutputFileType::c_header
@ c_header
Halide::OutputFileType::object
@ object
Halide::absd
Expr absd(Expr a, Expr b)
Return the absolute difference between two values.
Halide::compile_standalone_runtime
void compile_standalone_runtime(const std::string &object_filename, const Target &t)
Create an object file containing the Halide runtime for a given target.
Halide::cast
Internal::ConstantInterval cast(Type t, const Internal::ConstantInterval &a)
Cast operators for ConstantIntervals.
atoi
int atoi(const char *)
uint32_t
unsigned __INT32_TYPE__ uint32_t
Definition runtime_internal.h:25
getenv
char * getenv(const char *)
Halide::Expr
A fragment of Halide syntax.
Definition Expr.h:258
Halide::Internal::BaseExprNode::type
Type type
Definition Expr.h:148
Halide::Internal::Call
A function call.
Definition IR.h:490
Halide::Internal::Call::Extern
@ Extern
A call to an external C-ABI function, possibly with side-effects.
Definition IR.h:494
Halide::Internal::Call::Halide
@ Halide
A call to a Func.
Definition IR.h:497
Halide::Internal::Call::name
std::string name
Definition IR.h:491
Halide::Internal::Call::func
FunctionPtr func
Definition IR.h:690
Halide::Internal::Call::call_type
CallType call_type
Definition IR.h:501
Halide::Internal::Call::args
std::vector< Expr > args
Definition IR.h:492
Halide::Internal::Call::make
static Expr make(Type type, IntrinsicOp op, const std::vector< Expr > &args, CallType call_type, FunctionPtr func=FunctionPtr(), int value_index=0, const Buffer<> &image=Buffer<>(), Parameter param=Parameter())
Halide::Internal::ConstantInterval::min
int64_t min
The lower and upper bound of the interval.
Definition ConstantInterval.h:21
Halide::Internal::FunctionPtr::weak
FunctionGroup * weak
Definition FunctionPtr.h:32
Halide::Internal::IRHandle::accept
void accept(IRVisitor *v) const
Dispatch to the correct visitor method for this node.
Definition Expr.h:192
Halide::Internal::WasmModule::can_jit_target
static bool can_jit_target(const Target &target)
If the given target can be executed via the wasm executor, return true.
Halide::Target
A struct representing a target machine and os to generate code for.
Definition Target.h:19
Halide::Target::arch
enum Halide::Target::Arch arch
Halide::Target::has_feature
bool has_feature(Feature f) const
Halide::Target::bits
int bits
The bit-width of the target machine.
Definition Target.h:50
Halide::Target::os
enum Halide::Target::OS os
Halide::Target::to_string
std::string to_string() const
Convert the Target into a string form that can be reconstituted by merge_string(),...
Halide::Target::without_feature
Target without_feature(Feature f) const
Return a copy of the target with the given feature cleared.
Halide::Target::Feature
Feature
Optional features a target can have.
Definition Target.h:84
Halide::Target::AVX512_KNL
@ AVX512_KNL
Definition Target.h:133
Halide::Target::AVX512_Zen4
@ AVX512_Zen4
Definition Target.h:137
Halide::Target::NoAsserts
@ NoAsserts
Definition Target.h:88
Halide::Target::ARMv82a
@ ARMv82a
Definition Target.h:163
Halide::Target::AVX512_Zen5
@ AVX512_Zen5
Definition Target.h:138
Halide::Target::ARMv8a
@ ARMv8a
Definition Target.h:161
Halide::Target::ARMv84a
@ ARMv84a
Definition Target.h:165
Halide::Target::ARMv85a
@ ARMv85a
Definition Target.h:166
Halide::Target::AVX512_Cannonlake
@ AVX512_Cannonlake
Definition Target.h:135
Halide::Target::ARMDotProd
@ ARMDotProd
Definition Target.h:157
Halide::Target::ARMv81a
@ ARMv81a
Definition Target.h:162
Halide::Target::SVE
@ SVE
Definition Target.h:155
Halide::Target::VSX
@ VSX
Definition Target.h:99
Halide::Target::AVX512_SapphireRapids
@ AVX512_SapphireRapids
Definition Target.h:136
Halide::Target::ARMv86a
@ ARMv86a
Definition Target.h:167
Halide::Target::AVX512
@ AVX512
Definition Target.h:132
Halide::Target::ARMv83a
@ ARMv83a
Definition Target.h:164
Halide::Target::AVX
@ AVX
Definition Target.h:91
Halide::Target::FMA4
@ FMA4
Definition Target.h:95
Halide::Target::NoBoundsQuery
@ NoBoundsQuery
Definition Target.h:89
Halide::Target::ARMv88a
@ ARMv88a
Definition Target.h:169
Halide::Target::NoNEON
@ NoNEON
Definition Target.h:98
Halide::Target::AVX512_Skylake
@ AVX512_Skylake
Definition Target.h:134
Halide::Target::ARMv89a
@ ARMv89a
Definition Target.h:170
Halide::Target::SVE2
@ SVE2
Definition Target.h:156
Halide::Target::NoRuntime
@ NoRuntime
Definition Target.h:118
Halide::Target::FMA
@ FMA
Definition Target.h:94
Halide::Target::AVXVNNI
@ AVXVNNI
Definition Target.h:93
Halide::Target::ARMv87a
@ ARMv87a
Definition Target.h:168
Halide::Target::ARMFp16
@ ARMFp16
Definition Target.h:158
Halide::Target::RVV
@ RVV
Definition Target.h:160
Halide::Target::AVX2
@ AVX2
Definition Target.h:92
Halide::Target::ARMv7s
@ ARMv7s
Definition Target.h:97
Halide::Target::SSE41
@ SSE41
Definition Target.h:90
Halide::Target::POWER_ARCH_2_07
@ POWER_ARCH_2_07
Definition Target.h:100
Halide::Target::F16C
@ F16C
Definition Target.h:96
Halide::Target::with_feature
Target with_feature(Feature f) const
Return a copy of the target with the given feature set.
Halide::Target::WebAssembly
@ WebAssembly
Definition Target.h:45
Halide::Task
Definition simd_op_check.h:65
Halide::Task::op
std::string op
Definition simd_op_check.h:66
Halide::Task::vector_width
int vector_width
Definition simd_op_check.h:68
Halide::Task::name
std::string name
Definition simd_op_check.h:67
Halide::Task::expr
Expr expr
Definition simd_op_check.h:69
Halide::TestResult
Definition simd_op_check.h:60
Halide::TestResult::op
std::string op
Definition simd_op_check.h:61
Halide::TestResult::error_msg
std::string error_msg
Definition simd_op_check.h:62
Halide::Type
Types in the halide type system.
Definition Type.h:281
Halide::Type::is_int_or_uint
HALIDE_ALWAYS_INLINE bool is_int_or_uint() const
Is this type an integer type of any sort?
Definition Type.h:445
Halide::Type::max
Expr max() const
Return an expression which is the maximum value of this type.
Halide::float16_t
Class that provides a type that implements half precision floating point (IEEE754 2008 binary16) in s...
Definition Float16.h:17
test_sharding.h