def METHOD_NAME(n, m, reduce_dim, cache_report_, error_rate_threshold):
    a = jt.random([n,m])
    a.sync()
    with jt.profile_scope(compile_options = {
        "check_cache": 1, "replace_strategy": 1, "page_size": 4 << 10, #2 << 20
        "vtop": 0,
        "tlb_size": 64, "tlb_ways": 4, "tlb_line_size": 1,
        "L1_size": 32 << 10, "L1_ways": 8, "L1_line_size": 64,
        "L2_size": 256 << 10, "L2_ways": 8, "L2_line_size": 64,
        "L3_size": 15 << 20, "L3_ways": 20, "L3_line_size": 64
    }, enable_tuner=0) as report:
        c = a.sum(reduce_dim)
        c.sync()
    check_cache_code(report[1][1])
    cache_report = report[-1][-5:]
    for i in range(len(cache_report)):
        cache_report[i] = int(cache_report[i])
    for i in range(len(cache_report)):
        assert abs(cache_report[i] - cache_report_[i]) <= int(cache_report_[i] * error_rate_threshold), "cache report error: " + report[-2][-(len(cache_report) - i)] + " error, " + str(cache_report[i]) + "!=" + str(cache_report_[i])