Skip to content

Commit

Permalink
Factor simd_op_check into separate files by architecture. (halide#7163)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zalman Stern authored and ardier committed Mar 3, 2024
1 parent bf978f5 commit 1935ff0
Show file tree
Hide file tree
Showing 6 changed files with 1,361 additions and 1,260 deletions.
5 changes: 4 additions & 1 deletion test/correctness/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,11 @@ tests(GROUPS correctness
shift_by_unsigned_negated.cpp
shifted_image.cpp
side_effects.cpp
simd_op_check.cpp
simd_op_check_arm.cpp
simd_op_check_hvx.cpp
simd_op_check_powerpc.cpp
simd_op_check_wasm.cpp
simd_op_check_x86.cpp
simplified_away_embedded_image.cpp
simplify.cpp
skip_stages.cpp
Expand Down
51 changes: 51 additions & 0 deletions test/correctness/simd_op_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ struct Task {

class SimdOpCheckTest {
public:
static constexpr int max_i8 = 127;
static constexpr int max_i16 = 32767;
static constexpr int max_i32 = 0x7fffffff;
static constexpr int max_u8 = 255;
static constexpr int max_u16 = 65535;
const Expr max_u32 = UInt(32).max();

std::string filter{"*"};
std::string output_directory{Internal::get_test_tmp_dir()};
std::vector<Task> tasks;
Expand Down Expand Up @@ -331,6 +338,50 @@ class SimdOpCheckTest {
return success;
}

template<typename SIMDOpCheckT>
static int main(int argc, char **argv) {
Target host = get_host_target();
Target hl_target = get_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());

SIMDOpCheckT test(hl_target);

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

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

const int seed = argc > 2 ? atoi(argv[2]) : time(nullptr);
std::cout << "simd_op_check test seed: " << seed << "\n";
test.set_seed(seed);

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();

// Compile a runtime for this target, for use in the static test.
compile_standalone_runtime(test.output_directory + "simd_op_check_runtime.o", test.target);

if (!success) {
return -1;
}

printf("Success!\n");
return 0;
}

private:
const Halide::Var x{"x"}, y{"y"};
};
Expand Down
Loading

0 comments on commit 1935ff0

Please sign in to comment.