main.cpp 1.25 KB
Newer Older
1
2
3
4
5
6
#include "run_verify.hpp"
#include <migraphx/ranges.hpp>
#include <test.hpp>

#ifdef HAVE_GPU
#include <migraphx/gpu/analyze_streams.hpp>
Paul Fultz II's avatar
Paul Fultz II committed
7
8
9
10
#include <migraphx/gpu/target.hpp>
#endif
#ifdef HAVE_CPU
#include <migraphx/cpu/target.hpp>
11
12
13
14
15
#endif

inline void check_gpu_streams(const migraphx::program& p)
{
#ifdef HAVE_GPU
16
17
    const auto* mm = p.get_main_module();
    auto races     = migraphx::gpu::analyze_streams(*mm);
18
19
20
21
    for(auto&& race : races)
    {
        std::cout << "FAILED: " << std::endl;
        std::cout << "Race condition detected for: ";
Shucai Xiao's avatar
Shucai Xiao committed
22
        mm->debug_print(race.ins);
23
        std::cout << "Should happen after: ";
Shucai Xiao's avatar
Shucai Xiao committed
24
        mm->debug_print(race.before);
25
26
27
28
29
30
    }
#else
    (void)p;
#endif
}

31
void validate_gpu(const migraphx::program& p, const migraphx::parameter_map& m)
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
    check_gpu_streams(p);

    // Ensure the program doesn't modify the context in a dry run
    auto ctx = p.get_context();
    assert(&ctx != &p.get_context());
    EXPECT(is_shared(ctx, p.get_context()));
    p.dry_run(m);
    EXPECT(is_shared(ctx, p.get_context()));
}

int main(int argc, const char* argv[])
{
    run_verify rv;
    rv.add_validation_for("gpu", &validate_gpu);
Shucai Xiao's avatar
Shucai Xiao committed
47
    rv.disable_test_for("cpu", {"test_if_lp", "test_if_param", "test_if_literal"});
48
49
    rv.run(argc, argv);
}