-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_legion.py
executable file
·135 lines (112 loc) · 3.42 KB
/
build_legion.py
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
#!/usr/bin/env python3
import os as _os
from typing import List as _List
from typing import Tuple as _Tuple
from build_utilities import (
underscore_join,
change_directory,
remove_directory,
clone,
CMakeDefines,
cmake,
LIB_PREFIX,
SCRATCH_DIR,
Machines,
MACHINE,
)
from build_dependencies import (
KOKKOS_CUDA_CMAKE_PATH,
KOKKOS_NOCUDA_CMAKE_PATH,
KOKKOS_NVCC_WRAPPER_PATH,
)
LEGION_GIT_URL: str = "https://gitlab.com/StanfordLegion/legion.git"
LEGION_BRANCHES: _List[_Tuple[str, str]] = [
("master", "master"),
("release", "legion-24.06.0"),
]
BUILD_TYPES: _List[_Tuple[str, str]] = [
("debug", "Debug"),
("release", "RelWithDebInfo"),
]
def cuda_tag(use_cuda: bool) -> str:
return "cuda" if use_cuda else "nocuda"
def kokkos_tag(use_kokkos: bool) -> str:
return "kokkos" if use_kokkos else "nokokkos"
def clone_legion(branch_tag: str, branch_name: str) -> str:
output_dir = underscore_join("legion", branch_tag)
remove_directory(output_dir)
clone(LEGION_GIT_URL, branch=branch_name, path=output_dir)
return output_dir
def legion_library_path(
branch_tag: str, use_cuda: bool, use_kokkos: bool, build_tag: str
) -> str:
return _os.path.join(
LIB_PREFIX,
underscore_join(
"legion",
branch_tag,
cuda_tag(use_cuda),
kokkos_tag(use_kokkos),
build_tag,
),
)
def cmake_legion(
branch_tag: str,
use_cuda: bool,
use_kokkos: bool,
build_tag: str,
build_type: str,
):
lib_path = legion_library_path(branch_tag, use_cuda, use_kokkos, build_tag)
remove_directory(lib_path)
defines: CMakeDefines = {
"CMAKE_CXX_STANDARD": 17,
"CMAKE_BUILD_TYPE": build_type,
"CMAKE_INSTALL_PREFIX": lib_path,
"Legion_MAX_NUM_NODES": 4096,
"Legion_MAX_NUM_PROCS": 256,
"Legion_USE_OpenMP": True,
"Legion_USE_CUDA": use_cuda,
"Legion_NETWORKS": "gasnetex",
"GASNet_INCLUDE_DIR": _os.path.join(LIB_PREFIX, "gasnet", "release", "include"),
}
if MACHINE in [Machines.LASSEN, Machines.SUMMIT]:
defines["CMAKE_CXX_FLAGS"] = "-DREALM_TIMERS_USE_RDTSC=0"
defines["CMAKE_CUDA_FLAGS"] = "-DREALM_TIMERS_USE_RDTSC=0"
if use_kokkos:
defines["Legion_USE_Kokkos"] = True
if use_cuda:
defines["Kokkos_DIR"] = KOKKOS_CUDA_CMAKE_PATH
defines["KOKKOS_CXX_COMPILER"] = KOKKOS_NVCC_WRAPPER_PATH
else:
defines["Kokkos_DIR"] = KOKKOS_NOCUDA_CMAKE_PATH
cmake(
underscore_join(
"build",
branch_tag,
cuda_tag(use_cuda),
kokkos_tag(use_kokkos),
build_tag,
),
defines,
build=True,
test=False,
install=True,
)
def main():
_os.chdir(SCRATCH_DIR)
for branch_tag, branch_name in LEGION_BRANCHES:
legion_dir = clone_legion(branch_tag, branch_name)
with change_directory(legion_dir):
for build_tag, build_type in BUILD_TYPES:
for use_cuda, use_kokkos in [
(False, False),
(False, True),
(True, False),
(True, True),
]:
cmake_legion(
branch_tag, use_cuda, use_kokkos, build_tag, build_type
)
if __name__ == "__main__":
main()