# Provides the ruy_test macro for type-parametrized tests.

"""
ruy_test is a macro for building a test with multiple paths
corresponding to tuples of types for LHS, RHS, accumulator
and destination.
"""

def ruy_test(name, srcs, lhs_rhs_accum_dst, tags = []):
    for (lhs, rhs, accum, dst) in lhs_rhs_accum_dst:
        native.cc_test(
            name = "%s_%s_%s_%s_%s" % (name, lhs, rhs, accum, dst),
            srcs = srcs,
            copts = [
                "-DRUY_TEST_LHSSCALAR=%s" % lhs,
                "-DRUY_TEST_RHSSCALAR=%s" % rhs,
                "-DRUY_TEST_ACCUMSCALAR=%s" % accum,
                "-DRUY_TEST_DSTSCALAR=%s" % dst,
            ],
            deps = [
                ":test_lib",
                "@com_google_googletest//:gtest_main",
            ],
            tags = tags,
        )

def ruy_benchmark(name, srcs, lhs_rhs_accum_dst):
    for (lhs, rhs, accum, dst) in lhs_rhs_accum_dst:
        native.cc_binary(
            name = "%s_%s_%s_%s_%s" % (name, lhs, rhs, accum, dst),
            testonly = True,
            srcs = srcs,
            copts = [
                "-DRUY_TEST_LHSSCALAR=%s" % lhs,
                "-DRUY_TEST_RHSSCALAR=%s" % rhs,
                "-DRUY_TEST_ACCUMSCALAR=%s" % accum,
                "-DRUY_TEST_DSTSCALAR=%s" % dst,
            ],
            deps = [
                ":test_lib",
                "//third_party/gemmlowp:profiler",
            ],
        )

def ruy_benchmark_opt_sets(name, opt_sets, srcs, lhs_rhs_accum_dst):
    for opt_set in opt_sets:
        for (lhs, rhs, accum, dst) in lhs_rhs_accum_dst:
            native.cc_binary(
                name = "%s_%s_%s_%s_%s_%s" % (name, opt_set, lhs, rhs, accum, dst),
                testonly = True,
                srcs = srcs,
                copts = [
                    "-DRUY_TEST_LHSSCALAR=%s" % lhs,
                    "-DRUY_TEST_RHSSCALAR=%s" % rhs,
                    "-DRUY_TEST_ACCUMSCALAR=%s" % accum,
                    "-DRUY_TEST_DSTSCALAR=%s" % dst,
                    "-DRUY_OPT_SET=0x%s" % opt_set,
                ],
                deps = [
                    ":test_lib",
                    "//third_party/gemmlowp:profiler",
                ],
            )

@@ -859,32 +859,87 @@
 rhs_accum_dst):%0A
+    tags = %5B%22req_dep=//third_party/gemmlowp:profiler%22%5D%0A
     for (lhs, rh
@@ -1460,30 +1460,87 @@
 ofiler%22,
-%0A            %5D
+  # Note also tagged as req_dep.%0A            %5D,%0A            tags = tags
 ,%0A      
@@ -1609,24 +1609,79 @@
 accum_dst):%0A
+    tags = %5B%22req_dep=//third_party/gemmlowp:profiler%22%5D%0A
     for opt_
@@ -2355,34 +2355,95 @@
 ofiler%22,
-%0A                %5D
+  # Note also tagged as req_dep.%0A                %5D,%0A                tags = tags
 ,%0A      

Improve bzl file.