cuda.lua 1.76 KB
Newer Older
PanZezhongQY's avatar
PanZezhongQY committed
1
2
3
4
5
6
7
8
9
10
11
12

local CUDA_ROOT = os.getenv("CUDA_ROOT") or os.getenv("CUDA_HOME") or os.getenv("CUDA_PATH")
local CUDNN_ROOT = os.getenv("CUDNN_ROOT") or os.getenv("CUDNN_HOME") or os.getenv("CUDNN_PATH")
if CUDA_ROOT ~= nil then
    add_includedirs(CUDA_ROOT .. "/include")
end
if CUDNN_ROOT ~= nil then
    add_includedirs(CUDNN_ROOT .. "/include")
end

target("infiniop-cuda")
    set_kind("static")
PanZezhong's avatar
PanZezhong committed
13
    add_deps("infini-utils")
PanZezhongQY's avatar
PanZezhongQY committed
14
15
    on_install(function (target) end)

16
    set_policy("build.cuda.devlink", true)
PanZezhongQY's avatar
PanZezhongQY committed
17
    set_toolchains("cuda")
18
    add_links("cublas", "cudnn")
PanZezhongQY's avatar
PanZezhongQY committed
19
20
21
22
    add_cugencodes("native")

    if is_plat("windows") then
        add_cuflags("-Xcompiler=/utf-8", "--expt-relaxed-constexpr", "--allow-unsupported-compiler")
23
        add_cuflags("-Xcompiler=/W3", "-Xcompiler=/WX")
24
        add_cxxflags("/FS")
PanZezhongQY's avatar
PanZezhongQY committed
25
26
27
28
        if CUDNN_ROOT ~= nil then
            add_linkdirs(CUDNN_ROOT .. "\\lib\\x64")
        end
    else
29
        add_cuflags("-Xcompiler=-Wall", "-Xcompiler=-Werror")
PanZezhongQY's avatar
PanZezhongQY committed
30
31
32
33
34
35
36
37
        add_cuflags("-Xcompiler=-fPIC")
        add_culdflags("-Xcompiler=-fPIC")
        add_cxxflags("-fPIC")
    end

    set_languages("cxx17")
    add_files("../src/infiniop/devices/cuda/*.cu", "../src/infiniop/ops/*/cuda/*.cu")
target_end()
38
39
40

target("infinirt-cuda")
    set_kind("static")
PanZezhong's avatar
PanZezhong committed
41
    add_deps("infini-utils")
42
    on_install(function (target) end)
43

44
    set_policy("build.cuda.devlink", true)
45
46
    set_toolchains("cuda")
    add_links("cudart")
47
48
49

    if is_plat("windows") then
        add_cuflags("-Xcompiler=/utf-8", "--expt-relaxed-constexpr", "--allow-unsupported-compiler")
50
        add_cxxflags("/FS")
51
52
53
54
55
56
57
58
59
    else
        add_cuflags("-Xcompiler=-fPIC")
        add_culdflags("-Xcompiler=-fPIC")
        add_cxflags("-fPIC")
    end

    set_languages("cxx17")
    add_files("../src/infinirt/cuda/*.cu")
target_end()