-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_legion.py
executable file
·148 lines (125 loc) · 4.35 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
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/env python3
import os as _os
import sys as _sys
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,
GASNET_CONDUITS,
)
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, str]] = [
# ("aug22-3", "master", "ef074af5298f2259f1958918e1d9ba0e14bd7876"), # works
# ("aug22-4", "master", "4b7981f53b800e409f3753878c37fe75e4ed7449"), # /usr/bin/ld: cannot find -lrealm_gex_wrapper_objs
# ("sep12", "master", "c032dab254f423ccab36d05c47fed42b94f0b3f5"), # /usr/bin/ld: cannot find -lrealm_gex_wrapper_objs
("master", "master", "master"),
("r2412", "legion-24.12.0", "legion-24.12.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, commit: str) -> str:
output_dir: str = underscore_join("legion", branch_tag)
remove_directory(output_dir)
clone(LEGION_GIT_URL, branch=branch_name, path=output_dir, commit=commit)
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,
) -> None:
lib_path: str = 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",
"Legion_EMBED_GASNet": True,
"GASNet_CONDUIT": GASNET_CONDUITS[MACHINE],
}
if MACHINE in [Machines.LASSEN, Machines.SUMMIT]:
# Disable rdtsc instruction on non-x86 machines.
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() -> None:
cuda_kokkos_configs: _List[_Tuple[bool, bool]] = [
(False, False), (False, True), (True, False), (True, True),
]
if "--force-cuda" in _sys.argv:
cuda_kokkos_configs = [c for c in cuda_kokkos_configs if c[0]]
if "--skip-cuda" in _sys.argv:
cuda_kokkos_configs = [c for c in cuda_kokkos_configs if not c[0]]
if "--force-kokkos" in _sys.argv:
cuda_kokkos_configs = [c for c in cuda_kokkos_configs if c[1]]
if "--skip-kokkos" in _sys.argv:
cuda_kokkos_configs = [c for c in cuda_kokkos_configs if not c[1]]
_os.chdir(SCRATCH_DIR)
for branch_tag, branch_name, commit in LEGION_BRANCHES:
legion_dir: str = clone_legion(branch_tag, branch_name, commit)
with change_directory(legion_dir):
for build_tag, build_type in BUILD_TYPES:
for use_cuda, use_kokkos in cuda_kokkos_configs:
cmake_legion(
branch_tag, use_cuda, use_kokkos, build_tag, build_type
)
if __name__ == "__main__":
main()