forked from InfiniTensor/llaisys
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
182 lines (149 loc) · 4.62 KB
/
xmake.lua
File metadata and controls
182 lines (149 loc) · 4.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
add_rules("mode.debug", "mode.release")
set_encodings("utf-8")
add_includedirs("include")
-- CPU --
includes("xmake/cpu.lua")
-- NVIDIA --
option("nv-gpu")
set_default(false)
set_showmenu(true)
set_description("Whether to compile implementations for Nvidia GPU")
option_end()
option("sentencepiece")
set_default(false)
set_showmenu(true)
set_description("Enable SentencePiece tokenizer support")
option_end()
if has_config("nv-gpu") then
add_defines("ENABLE_NVIDIA_API")
includes("xmake/nvidia.lua")
end
-- ILUVATAR --
option("iluvatar-gpu")
set_default(false)
set_showmenu(true)
set_description("Whether to compile implementations for Iluvatar CoreX GPU")
option_end()
if has_config("iluvatar-gpu") then
add_defines("ENABLE_ILUVATAR_API")
includes("xmake/iluvatar.lua")
end
target("llaisys-utils")
set_kind("static")
set_languages("cxx17")
set_warnings("all", "error")
if not is_plat("windows") then
add_cxflags("-fPIC", "-Wno-unknown-pragmas")
end
add_files("src/utils/*.cpp")
on_install(function (target) end)
target_end()
target("llaisys-device")
set_kind("static")
add_deps("llaisys-utils")
add_deps("llaisys-device-cpu")
if has_config("nv-gpu") then
add_deps("llaisys-device-nvidia")
end
if has_config("iluvatar-gpu") then
add_deps("llaisys-device-iluvatar")
end
set_languages("cxx17")
set_warnings("all", "error")
if not is_plat("windows") then
add_cxflags("-fPIC", "-Wno-unknown-pragmas")
end
add_files("src/device/*.cpp")
on_install(function (target) end)
target_end()
target("llaisys-core")
set_kind("static")
add_deps("llaisys-utils")
add_deps("llaisys-device")
set_languages("cxx17")
set_warnings("all", "error")
if not is_plat("windows") then
add_cxflags("-fPIC", "-Wno-unknown-pragmas")
end
add_files("src/core/*/*.cpp")
on_install(function (target) end)
target_end()
target("llaisys-tensor")
set_kind("static")
add_deps("llaisys-core")
set_languages("cxx17")
set_warnings("all", "error")
if not is_plat("windows") then
add_cxflags("-fPIC", "-Wno-unknown-pragmas")
end
add_files("src/tensor/*.cpp")
on_install(function (target) end)
target_end()
target("llaisys-ops")
set_kind("static")
add_deps("llaisys-ops-cpu")
if has_config("nv-gpu") then
add_deps("llaisys-ops-nvidia")
end
if has_config("iluvatar-gpu") then
add_deps("llaisys-ops-iluvatar")
end
set_languages("cxx17")
set_warnings("all", "error")
if not is_plat("windows") then
add_cxflags("-fPIC", "-Wno-unknown-pragmas")
end
add_files("src/ops/*/*.cpp")
on_install(function (target) end)
target_end()
target("llaisys")
set_kind("shared")
add_deps("llaisys-utils")
add_deps("llaisys-device")
add_deps("llaisys-core")
add_deps("llaisys-tensor")
add_deps("llaisys-ops")
set_languages("cxx17")
set_warnings("all", "error")
add_files("src/llaisys/*.cc")
add_files("src/llaisys/*/*.cpp")
add_files("src/models/*/*.cpp")
add_files("src/models/*/*/*.cpp")
add_files("src/tokenizer/*/*.cpp")
set_installdir(".")
if has_config("sentencepiece") then
add_defines("LLAISYS_ENABLE_SENTENCEPIECE")
add_links("sentencepiece")
end
if has_config("nv-gpu") then
set_languages("cxx17", "cuda")
set_policy("build.cuda.devlink", true)
add_links("cudadevrt", "cudart")
add_files("src/device/nvidia/devlink_stub.cu")
elseif has_config("iluvatar-gpu") then
-- No .cu files in this target, no CUDA toolchain
-- Use add_shflags to control exact link order:
-- 1. whole-archive iluvatar static libs (defines nvidia:: symbols)
-- 2. -lcudart AFTER the .a files (so cudart symbols are resolved)
add_shflags(
"-Wl,--whole-archive",
"build/linux/x86_64/release/libllaisys-ops-iluvatar.a",
"build/linux/x86_64/release/libllaisys-device-iluvatar.a",
"-Wl,--no-whole-archive",
"-L/usr/local/corex/lib64",
"-Wl,-rpath,/usr/local/corex/lib64",
"-lcudart",
{force = true}
)
end
after_install(function (target)
-- copy shared library to python package
print("Copying llaisys to python/llaisys/libllaisys/ ..")
if is_plat("windows") then
os.cp("bin/*.dll", "python/llaisys/libllaisys/")
end
if is_plat("linux") then
os.cp("lib/*.so", "python/llaisys/libllaisys/")
end
end)
target_end()