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
158 lines (124 loc) · 3.83 KB
/
xmake.lua
File metadata and controls
158 lines (124 loc) · 3.83 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
add_rules("mode.debug", "mode.release")
set_encodings("utf-8")
add_includedirs("include")
-- 全局开启 OpenMP 支持、最高级别优化
-- native 模式 (服务器): 使用 -march=native, 编译器自动启用 AVX-512 等本机指令集
-- 默认模式 (本地): 显式指定 -mavx2 -mfma, 兼容大多数 x86-64 CPU
add_cxflags("-fopenmp", "-O3")
add_ldflags("-fopenmp")
add_shflags("-fopenmp")
add_syslinks("gomp") -- 显式链接 GNU OpenMP 库
option("native")
set_default(false)
set_showmenu(true)
set_description("Use -march=native for best performance on current CPU (enables AVX-512 on supported CPUs)")
option_end()
if has_config("native") then
add_cxflags("-march=native")
else
add_cxflags("-mavx2", "-mfma")
end
-- OpenBLAS 集成: 从源码编译安装到 ~/openblas
option("openblas")
set_default(true)
set_showmenu(true)
set_description("Whether to use OpenBLAS for linear algebra acceleration")
option_end()
if has_config("openblas") then
add_defines("USE_OPENBLAS")
add_includedirs(os.getenv("HOME") .. "/openblas/include")
add_linkdirs(os.getenv("HOME") .. "/openblas/lib")
add_links("openblas")
add_rpathdirs(os.getenv("HOME") .. "/openblas/lib")
end
-- 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()
if has_config("nv-gpu") then
add_defines("ENABLE_NVIDIA_API")
includes("xmake/nvidia.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")
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")
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/models/*.cpp")
set_installdir(".")
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()