Skip to content

Commit f29b2af

Browse files
committed
Merge branch 'sycl' of https://github.com/intel/llvm into ianayl/benchmark-ci-disable-linreg
2 parents 7fbaa4c + 2dedcee commit f29b2af

File tree

21,817 files changed

+1708824
-592006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

21,817 files changed

+1708824
-592006
lines changed

.ci/cache_lit_timing_files.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
"""Caches .lit_test_times.txt files between premerge invocations.
5+
6+
.lit_test_times.txt files are used by lit to order tests to best take advantage
7+
of parallelism. Having them around and up to date can result in a ~15%
8+
improvement in test times. This script downloading cached test time files and
9+
uploading new versions to the GCS buckets used for caching.
10+
"""
11+
12+
import sys
13+
import os
14+
import logging
15+
import multiprocessing.pool
16+
import pathlib
17+
import glob
18+
19+
from google.cloud import storage
20+
21+
GCS_PARALLELISM = 100
22+
23+
24+
def _maybe_upload_timing_file(bucket, timing_file_path):
25+
if os.path.exists(timing_file_path):
26+
timing_file_blob = bucket.blob("lit_timing/" + timing_file_path)
27+
timing_file_blob.upload_from_filename(timing_file_path)
28+
29+
30+
def upload_timing_files(storage_client, bucket_name: str):
31+
bucket = storage_client.bucket(bucket_name)
32+
with multiprocessing.pool.ThreadPool(GCS_PARALLELISM) as thread_pool:
33+
futures = []
34+
for timing_file_path in glob.glob("**/.lit_test_times.txt", recursive=True):
35+
futures.append(
36+
thread_pool.apply_async(
37+
_maybe_upload_timing_file, (bucket, timing_file_path)
38+
)
39+
)
40+
for future in futures:
41+
future.get()
42+
print("Done uploading")
43+
44+
45+
def _maybe_download_timing_file(blob):
46+
file_name = blob.name.removeprefix("lit_timing/")
47+
pathlib.Path(os.path.dirname(file_name)).mkdir(parents=True, exist_ok=True)
48+
blob.download_to_filename(file_name)
49+
50+
51+
def download_timing_files(storage_client, bucket_name: str):
52+
bucket = storage_client.bucket(bucket_name)
53+
blobs = bucket.list_blobs(prefix="lit_timing")
54+
with multiprocessing.pool.ThreadPool(GCS_PARALLELISM) as thread_pool:
55+
futures = []
56+
for timing_file_blob in blobs:
57+
futures.append(
58+
thread_pool.apply_async(
59+
_maybe_download_timing_file, (timing_file_blob,)
60+
)
61+
)
62+
for future in futures:
63+
future.get()
64+
print("Done downloading")
65+
66+
67+
if __name__ == "__main__":
68+
if len(sys.argv) != 2:
69+
logging.fatal("Expected usage is cache_lit_timing_files.py <upload/download>")
70+
sys.exit(1)
71+
action = sys.argv[1]
72+
storage_client = storage.Client()
73+
bucket_name = os.environ["CACHE_GCS_BUCKET"]
74+
if action == "download":
75+
download_timing_files(storage_client, bucket_name)
76+
elif action == "upload":
77+
upload_timing_files(storage_client, bucket_name)
78+
else:
79+
logging.fatal("Expected usage is cache_lit_timing_files.py <upload/download>")
80+
sys.exit(1)

.ci/compute_projects.py

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
PROJECT_DEPENDENCIES = {
2020
"llvm": set(),
2121
"clang": {"llvm"},
22+
"CIR": {"clang", "mlir"},
2223
"bolt": {"clang", "lld", "llvm"},
2324
"clang-tools-extra": {"clang", "llvm"},
2425
"compiler-rt": {"clang", "lld"},
@@ -48,13 +49,13 @@
4849
"flang",
4950
},
5051
"lld": {"bolt", "cross-project-tests"},
51-
# TODO(issues/132795): LLDB should be enabled on clang changes.
52-
"clang": {"clang-tools-extra", "cross-project-tests"},
52+
"clang": {"clang-tools-extra", "cross-project-tests", "lldb"},
5353
"mlir": {"flang"},
5454
# Test everything if ci scripts are changed.
5555
".ci": {
5656
"llvm",
5757
"clang",
58+
"CIR",
5859
"lld",
5960
"lldb",
6061
"bolt",
@@ -78,6 +79,7 @@
7879
"clang": {"compiler-rt"},
7980
"clang-tools-extra": {"libc"},
8081
"libc": {"libc"},
82+
"compiler-rt": {"compiler-rt"},
8183
".ci": {"compiler-rt", "libc"},
8284
}
8385
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG = {
@@ -98,6 +100,9 @@
98100
"libc", # No Windows Support.
99101
"lldb", # TODO(issues/132800): Needs environment setup.
100102
"bolt", # No Windows Support.
103+
"libcxx",
104+
"libcxxabi",
105+
"libunwind",
101106
}
102107

103108
# These are projects that we should test if the project itself is changed but
@@ -116,6 +121,9 @@
116121
"lldb",
117122
"openmp",
118123
"polly",
124+
"libcxx",
125+
"libcxxabi",
126+
"libunwind",
119127
}
120128

121129
PROJECT_CHECK_TARGETS = {
@@ -128,6 +136,7 @@
128136
"lldb": "check-lldb",
129137
"llvm": "check-llvm",
130138
"clang": "check-clang",
139+
"CIR": "check-clang-cir",
131140
"bolt": "check-bolt",
132141
"lld": "check-lld",
133142
"flang": "check-flang",
@@ -141,6 +150,23 @@
141150

142151
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc"}
143152

153+
# Meta projects are projects that need explicit handling but do not reside
154+
# in their own top level folder. To add a meta project, the start of the path
155+
# for the metaproject should be mapped to the name of the project below.
156+
# Multiple paths can map to the same metaproject.
157+
META_PROJECTS = {
158+
("clang", "lib", "CIR"): "CIR",
159+
("clang", "test", "CIR"): "CIR",
160+
("clang", "include", "clang", "CIR"): "CIR",
161+
("*", "docs"): "docs",
162+
("llvm", "utils", "gn"): "gn",
163+
(".github", "workflows", "premerge.yaml"): ".ci",
164+
("third-party",): ".ci",
165+
}
166+
167+
# Projects that should not run any tests. These need to be metaprojects.
168+
SKIP_PROJECTS = ["docs", "gn"]
169+
144170

145171
def _add_dependencies(projects: Set[str], runtimes: Set[str]) -> Set[str]:
146172
projects_with_dependents = set(projects)
@@ -233,21 +259,34 @@ def _compute_runtimes_to_build(
233259
return _exclude_projects(runtimes_to_build, platform)
234260

235261

262+
def _path_matches(matcher: tuple[str], file_path: tuple[str]) -> bool:
263+
if len(file_path) < len(matcher):
264+
return False
265+
for match_part, file_part in zip(matcher, file_path):
266+
if match_part == "*" or file_part == "*":
267+
continue
268+
if match_part != file_part:
269+
return False
270+
return True
271+
272+
273+
def _get_modified_projects_for_file(modified_file: str) -> Set[str]:
274+
modified_projects = set()
275+
path_parts = pathlib.Path(modified_file).parts
276+
for meta_project_files in META_PROJECTS.keys():
277+
if _path_matches(meta_project_files, path_parts):
278+
meta_project = META_PROJECTS[meta_project_files]
279+
if meta_project in SKIP_PROJECTS:
280+
return set()
281+
modified_projects.add(meta_project)
282+
modified_projects.add(pathlib.Path(modified_file).parts[0])
283+
return modified_projects
284+
285+
236286
def _get_modified_projects(modified_files: list[str]) -> Set[str]:
237287
modified_projects = set()
238288
for modified_file in modified_files:
239-
path_parts = pathlib.Path(modified_file).parts
240-
# Exclude files in the docs directory. They do not impact an test
241-
# targets and there is a separate workflow used for ensuring the
242-
# documentation builds.
243-
if len(path_parts) > 2 and path_parts[1] == "docs":
244-
continue
245-
# Exclude files for the gn build. We do not test it within premerge
246-
# and changes occur often enough that they otherwise take up
247-
# capacity.
248-
if len(path_parts) > 3 and path_parts[:3] == ("llvm", "utils", "gn"):
249-
continue
250-
modified_projects.add(pathlib.Path(modified_file).parts[0])
289+
modified_projects.update(_get_modified_projects_for_file(modified_file))
251290
return modified_projects
252291

253292

@@ -267,6 +306,13 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
267306
runtimes_check_targets_needs_reconfig = _compute_project_check_targets(
268307
runtimes_to_test_needs_reconfig
269308
)
309+
310+
# CIR is used as a pseudo-project in this script. It is built as part of the
311+
# clang build, but it requires an explicit option to enable. We set that
312+
# option here, and remove it from the projects_to_build list.
313+
enable_cir = "ON" if "CIR" in projects_to_build else "OFF"
314+
projects_to_build.discard("CIR")
315+
270316
# We use a semicolon to separate the projects/runtimes as they get passed
271317
# to the CMake invocation and thus we need to use the CMake list separator
272318
# (;). We use spaces to separate the check targets as they end up getting
@@ -279,6 +325,7 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
279325
"runtimes_check_targets_needs_reconfig": " ".join(
280326
sorted(runtimes_check_targets_needs_reconfig)
281327
),
328+
"enable_cir": enable_cir,
282329
}
283330

284331

0 commit comments

Comments
 (0)