Skip to content

Commit

Permalink
Parallelize some tests (halide#8078)
Browse files Browse the repository at this point in the history
* Parallelize some tests

This reduces the time taken to run all correctness tests from 8:15 to
3:15 on my machine.

* The FIXME is actually fine

* Remove debug print

* Fix when we're willing to run x86 code in simd_op_check

* Use separate imageparams per task

* Deep-copy the LoopLevels

* Make float16_t neon op check test at least build

* Revert accidental serialization

* Throw return values from callable into the void

We don't have a custom error handler in place, so they're always zero

* Skip test under ASAN

* Fix unintentional change to test
  • Loading branch information
abadams authored and ardier committed Mar 3, 2024
1 parent 160110e commit 90fb5f8
Show file tree
Hide file tree
Showing 10 changed files with 239 additions and 151 deletions.
6 changes: 3 additions & 3 deletions src/Schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,9 @@ FuncSchedule FuncSchedule::deep_copy(

internal_assert(contents.defined()) << "Cannot deep-copy undefined FuncSchedule\n";
FuncSchedule copy;
copy.contents->store_level = contents->store_level;
copy.contents->compute_level = contents->compute_level;
copy.contents->hoist_storage_level = contents->hoist_storage_level;
copy.contents->store_level.set(contents->store_level);
copy.contents->compute_level.set(contents->compute_level);
copy.contents->hoist_storage_level.set(contents->hoist_storage_level);
copy.contents->storage_dims = contents->storage_dims;
copy.contents->bounds = contents->bounds;
copy.contents->estimates = contents->estimates;
Expand Down
59 changes: 9 additions & 50 deletions test/correctness/float16_t_neon_op_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SimdOpCheck : public SimdOpCheckTest {
// bits, 192 bits, and 256 bits for everything.
struct TestParams {
const int bits;
ImageParam in_f;
std::function<Expr(Expr)> in_f;
std::vector<std::pair<int, string>> vl_params;
Expr f_1, f_2, f_3, u_1, i_1;
};
Expand All @@ -77,7 +77,7 @@ class SimdOpCheck : public SimdOpCheckTest {

for (auto &test_param : test_params) { // outer loop for {fp32, fp16}
const int bits = test_param.bits;
ImageParam in_f = test_param.in_f;
auto in_f = test_param.in_f;
Expr f_1 = test_param.f_1;
Expr f_2 = test_param.f_2;
Expr f_3 = test_param.f_3;
Expand Down Expand Up @@ -256,7 +256,7 @@ class SimdOpCheck : public SimdOpCheckTest {
suffix_map.emplace(tasks.back().name, suffix);
}

void compile_and_check(Func error, const string &op, const string &name, int vector_width, std::ostringstream &error_msg) override {
void compile_and_check(Func error, const string &op, const string &name, int vector_width, const std::vector<Argument> &arg_types, std::ostringstream &error_msg) override {
std::string fn_name = "test_" + name;
std::string file_name = output_directory + fn_name;

Expand Down Expand Up @@ -315,52 +315,11 @@ class SimdOpCheck : public SimdOpCheckTest {
} // namespace

int main(int argc, char **argv) {
Target host = get_host_target();
Target hl_target = get_target_from_environment();
Target jit_target = get_jit_target_from_environment();
printf("host is: %s\n", host.to_string().c_str());
printf("HL_TARGET is: %s\n", hl_target.to_string().c_str());
printf("HL_JIT_TARGET is: %s\n", jit_target.to_string().c_str());

// Only for 64bit target with fp16 feature
if (!(hl_target.arch == Target::ARM && hl_target.bits == 64 && hl_target.has_feature(Target::ARMFp16))) {
Halide::Internal::Test::Sharder::accept_sharded_status();
printf("[SKIP] To run this test, set HL_TARGET=arm-64-<os>-arm_fp16. \n");
return 0;
}

// Create Test Object
// Use smaller dimension than default(768, 128) to avoid fp16 overflow in reduction test case
SimdOpCheck test(hl_target, 384, 32);

if (!test.can_run_code()) {
printf("[WARN] To run verification of realization, set HL_JIT_TARGET=arm-64-<os>-arm_fp16. \n");
}

if (argc > 1) {
test.filter = argv[1];
}

if (getenv("HL_SIMD_OP_CHECK_FILTER")) {
test.filter = getenv("HL_SIMD_OP_CHECK_FILTER");
}

if (argc > 2) {
// Don't forget: if you want to run the standard tests to a specific output
// directory, you'll need to invoke with the first arg enclosed
// in quotes (to avoid it being wildcard-expanded by the shell):
//
// correctness_simd_op_check "*" /path/to/output
//
test.output_directory = argv[2];
}

bool success = test.test_all();

if (!success) {
return 1;
}

printf("Success!\n");
// FIXME
printf("[SKIP] Test is currently broken. See https://github.com/halide/Halide/issues/8083");
return 0;

return SimdOpCheckTest::main<SimdOpCheck>(
argc, argv,
{Target("arm-64-linux-arm_fp16")});
}
Loading

0 comments on commit 90fb5f8

Please sign in to comment.