moore.lua 2.51 KB
Newer Older
zhushuang's avatar
zhushuang committed
1
2
3
local MUSA_ROOT = os.getenv("MUSA_ROOT") or os.getenv("MUSA_HOME") or os.getenv("MUSA_PATH")
add_includedirs(MUSA_ROOT .. "/include")
add_linkdirs(MUSA_ROOT .. "/lib")
4
add_links("musa", "musart", "mudnn", "mublas")
5
6
7
8
9
10
11
12
13
14
15

rule("mu")
    set_extensions(".mu")
    on_load(function (target)
        target:add("includedirs", "include")
    end)

    on_build_file(function (target, sourcefile)
        local objectfile = target:objectfile(sourcefile)
        os.mkdir(path.directory(objectfile))

zhushuang's avatar
zhushuang committed
16
        local mcc = MUSA_ROOT .. "/bin/mcc"
17
        local includedirs = table.concat(target:get("includedirs"), " ")
zhushuang's avatar
zhushuang committed
18
19

        local args = {"-c", sourcefile, "-o", objectfile, "-I" .. MUSA_ROOT .. "/include", "-O3", "-fPIC", "-Wall", "-std=c++17", "-pthread"}
20
21
22
23
        for _, includedir in ipairs(target:get("includedirs")) do
            table.insert(args, "-I" .. includedir)
        end

zhushuang's avatar
zhushuang committed
24
25
26
27
28
29
30
31
32
33
        -- ============================
        -- Retrieve all preprocessor defines added to the current target
        local defines = target:get("defines")
        if defines then
            for _, define in ipairs(defines) do
                table.insert(args, "-D" .. define)
            end
        end
        -- ===================================

34
35
36
37
38
        os.execv(mcc, args)
        table.insert(target:objectfiles(), objectfile)
    end)
rule_end()

39
target("infiniop-moore")
40
    set_kind("static")
41
    on_install(function (target) end)
42
    set_languages("cxx17")
43
44
    set_warnings("all", "error")
    add_cxflags("-lstdc++", "-fPIC", "-Wno-comment")
45
    add_cxxflags("-lstdc++", "-fPIC", "-Wno-comment")
46
47
    add_files("../src/infiniop/devices/moore/*.cc")
    add_files("../src/infiniop/ops/*/moore/*.mu", {rule = "mu"})
48
49
50

    -- Add source files for Moore muBLAS/muDNN GEMM backends.
    add_files("../src/infiniop/ops/gemm/moore/*/*.mu", {rule = "mu"})
51
target_end()
qinyiqun's avatar
qinyiqun committed
52
53
54
55
56
57

target("infinirt-moore")
    set_kind("static")
    set_languages("cxx17")
    on_install(function (target) end)
    add_deps("infini-utils")
58
59
    set_warnings("all", "error")
    add_cxflags("-lstdc++", "-fPIC")
60
    add_cxxflags("-lstdc++", "-fPIC")
61
    add_files("../src/infinirt/moore/*.cc")
qinyiqun's avatar
qinyiqun committed
62
target_end()
spike-zhu's avatar
spike-zhu committed
63
64
65
66
67
68
69
70

target("infiniccl-moore")
    set_kind("static")
    add_deps("infinirt")
    on_install(function (target) end)
    set_warnings("all", "error")
    if not is_plat("windows") then
        add_cxflags("-fPIC")
71
        add_cxxflags("-fPIC")
spike-zhu's avatar
spike-zhu committed
72
73
74
75
76
77
78
79
    end
    if has_config("ccl") then
        add_links("libmccl.so")
        add_files("../src/infiniccl/moore/*.cc")
    end
    set_languages("cxx17")

target_end()