moore.lua 1.89 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
46
    add_files("../src/infiniop/devices/moore/*.cc")
    add_files("../src/infiniop/ops/*/moore/*.mu", {rule = "mu"})
47
target_end()
qinyiqun's avatar
qinyiqun committed
48
49
50
51
52
53

target("infinirt-moore")
    set_kind("static")
    set_languages("cxx17")
    on_install(function (target) end)
    add_deps("infini-utils")
54
55
    set_warnings("all", "error")
    add_cxflags("-lstdc++", "-fPIC")
56
    add_files("../src/infinirt/moore/*.cc")
qinyiqun's avatar
qinyiqun committed
57
target_end()