brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · b9f9d29 Raw
57 lines · python
1# For manual usage, not as a part of lit tests. Used for generating the following tests:2# fence-sm30.ll, fence-sm70.ll, fence-sm90.ll3 4from string import Template5from itertools import product6 7fence_func = Template(8    """9define void @fence_${ordering}_${ptx_scope}() {10    fence syncscope(\"${llvm_scope}\") ${ordering}11    ret void12}13"""14)15 16run_statement = Template(17    """; RUN: llc < %s -march=nvptx64 -mcpu=sm_${sm} -mattr=+ptx${ptx} | FileCheck %s --check-prefix=SM${sm}18; RUN: %if ptxas %{ llc < %s -march=nvptx -mcpu=sm_${sm} -mattr=+ptx${ptx} | %ptxas-verify %}"""19)20 21# (sm, ptx)22TESTS = [(30, 50), (70, 60), (90, 87)]23 24LLVM_SCOPES_NO_CLUSTER = ["", "block", "device"]25 26SCOPE_LLVM_TO_PTX = {"": "sys", "block": "cta", "cluster": "cluster", "device": "gpu"}27 28ORDERINGS = ["acquire", "release", "acq_rel", "seq_cst"]29 30if __name__ == "__main__":31    # non-cluster orderings are supported on SM30, SM70 and SM9032    with open("fence-nocluster.ll", "w") as fp:33        for sm, ptx in TESTS:34            print(run_statement.substitute(sm=sm, ptx=ptx), file=fp)35        for ordering, llvm_scope in product(ORDERINGS, LLVM_SCOPES_NO_CLUSTER):36            print(37                fence_func.substitute(38                    llvm_scope=llvm_scope,39                    ptx_scope=SCOPE_LLVM_TO_PTX[llvm_scope],40                    ordering=ordering,41                ),42                file=fp,43            )44 45    # cluster ordering only supported on SM9046    with open("fence-cluster.ll", "w") as fp:47        print(run_statement.substitute(sm=90, ptx=87), file=fp)48        for ordering in ORDERINGS:49            print(50                fence_func.substitute(51                    llvm_scope="cluster",52                    ptx_scope=SCOPE_LLVM_TO_PTX["cluster"],53                    ordering=ordering,54                ),55                file=fp,56            )57