metax.lua 3.23 KB
Newer Older
1
2
3
4

local MACA_ROOT = os.getenv("MACA_PATH") or os.getenv("MACA_HOME") or os.getenv("MACA_ROOT")
add_includedirs(MACA_ROOT .. "/include")
add_linkdirs(MACA_ROOT .. "/lib")
5
6
7
8
9
if has_config("use-mc") then
    add_links("mcdnn", "mcblas", "mcruntime")
else
    add_links("hcdnn", "hcblas", "hcruntime")
end
10
11
12
13
14
15
16
17
18
19
20

rule("maca")
    set_extensions(".maca")

    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))
21
22
23
24
25
26
27
28
29
        local args
        local htcc
        if has_config("use-mc") then
            htcc = path.join(MACA_ROOT, "mxgpu_llvm/bin/mxcc")
            args = { "-x", "maca", "-c", sourcefile, "-o", objectfile, "-I" .. MACA_ROOT .. "/include", "-O3", "-fPIC", "-Werror", "-std=c++17"}
        else
            htcc = path.join(MACA_ROOT, "htgpu_llvm/bin/htcc")
            args = { "-x", "hpcc", "-c", sourcefile, "-o", objectfile, "-I" .. MACA_ROOT .. "/include", "-O3", "-fPIC", "-Werror", "-std=c++17"}
        end
30
31
32
33
34
        local includedirs = table.concat(target:get("includedirs"), " ")
        for _, includedir in ipairs(target:get("includedirs")) do
            table.insert(args, "-I" .. includedir)
        end

35
36
37
38
39
        local defines = target:get("defines")
        for _, define in ipairs(defines) do
            table.insert(args, "-D" .. define)
        end

40
41
42
43
44
45
46
47
48
        os.execv(htcc, args)
        table.insert(target:objectfiles(), objectfile)
    end)
rule_end()

target("infiniop-metax")
    set_kind("static")
    on_install(function (target) end)
    set_languages("cxx17")
49
    set_warnings("all", "error")
50
    add_cxflags("-lstdc++", "-fPIC", "-Wno-defaulted-function-deleted", "-Wno-strict-aliasing", {force = true})
51
    add_cxxflags("-lstdc++", "-fPIC", "-Wno-defaulted-function-deleted", "-Wno-strict-aliasing", {force = true})
52
    add_files("../src/infiniop/devices/metax/*.cc", "../src/infiniop/ops/*/metax/*.cc")
53
    add_files("../src/infiniop/ops/*/metax/*.maca", {rule = "maca"})
54
55

    if has_config("ninetoothed") then
56
        add_includedirs(MACA_ROOT .. "/include/mcr")
57
        add_files("../build/ninetoothed/*.c", "../build/ninetoothed/*.cpp", {
58
59
60
61
62
63
64
            cxflags = {
                "-include stdlib.h", 
                "-Wno-return-type", 
                "-Wno-implicit-function-declaration",
                "-Wno-builtin-declaration-mismatch"
            }
        })
65
    end
66
target_end()
67
68
69
70
71
72

target("infinirt-metax")
    set_kind("static")
    set_languages("cxx17")
    on_install(function (target) end)
    add_deps("infini-utils")
73
74
    set_warnings("all", "error")
    add_cxflags("-lstdc++ -fPIC")
75
    add_cxxflags("-lstdc++ -fPIC")
76
    add_files("../src/infinirt/metax/*.cc")
77
target_end()
PanZezhong's avatar
PanZezhong committed
78
79
80
81
82
83
84
85

target("infiniccl-metax")
    set_kind("static")
    add_deps("infinirt")
    on_install(function (target) end)
    set_warnings("all", "error")
    if not is_plat("windows") then
        add_cxflags("-fPIC")
86
        add_cxxflags("-fPIC")
PanZezhong's avatar
PanZezhong committed
87
88
    end
    if has_config("ccl") then
89
90
91
92
93
        if has_config("use-mc") then
            add_links("libmccl.so")
        else
            add_links("libhccl.so")
        end
94
        add_files("../src/infiniccl/metax/*.cc")
PanZezhong's avatar
PanZezhong committed
95
96
    end
    set_languages("cxx17")
97

PanZezhong's avatar
PanZezhong committed
98
target_end()