Skip to content

Commit 6ab90eb

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents 6cbd0d8 + 096d0a0 commit 6ab90eb

File tree

104 files changed

+2697
-1821
lines changed

Some content is hidden

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

104 files changed

+2697
-1821
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,4 @@ sycl/doc/ @pvchupin @kbobrovs
8585
sycl/doc/extensions/ @mkinsner @jbrodman
8686

8787
xpti/ @tovinkere @andykaylor
88+
xptifw/ @tovinkere @andykaylor

buildbot/configure.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
import argparse
22
import os
3+
import platform
34
import subprocess
45
import sys
5-
import platform
66

77
def do_configure(args):
8-
ret = False
9-
108
# Get absolute path to source directory
11-
if args.src_dir:
12-
abs_src_dir = os.path.abspath(args.src_dir)
13-
else:
14-
abs_src_dir = os.path.abspath(os.path.join(__file__, "../.."))
9+
abs_src_dir = os.path.abspath(args.src_dir if args.src_dir else os.path.join(__file__, "../.."))
1510
# Get absolute path to build directory
16-
if args.obj_dir:
17-
abs_obj_dir = os.path.abspath(args.obj_dir)
18-
else:
19-
abs_obj_dir = os.path.join(abs_src_dir, "build")
11+
abs_obj_dir = os.path.abspath(args.obj_dir) if args.obj_dir else os.path.join(abs_src_dir, "build")
12+
# Create build directory if it doesn't exist
2013
if not os.path.isdir(abs_obj_dir):
2114
os.makedirs(abs_obj_dir)
2215

@@ -37,10 +30,7 @@ def do_configure(args):
3730
llvm_enable_sphinx = 'OFF'
3831
llvm_build_shared_libs = 'OFF'
3932

40-
if platform.system() == 'Linux':
41-
icd_loader_lib = os.path.join(icd_loader_lib, "libOpenCL.so")
42-
else:
43-
icd_loader_lib = os.path.join(icd_loader_lib, "OpenCL.lib")
33+
icd_loader_lib = os.path.join(icd_loader_lib, "libOpenCL.so" if platform.system() == 'Linux' else "OpenCL.lib")
4434

4535
if args.cuda:
4636
llvm_targets_to_build += ';NVPTX'
@@ -109,19 +99,20 @@ def do_configure(args):
10999
os.remove(cmake_cache)
110100
subprocess.check_call(cmake_cmd, cwd=abs_obj_dir)
111101

112-
ret = True
113-
return ret
102+
return True
114103

115104
def main():
116105
parser = argparse.ArgumentParser(prog="configure.py",
117106
description="Generate build files from CMake configuration files",
118107
formatter_class=argparse.RawTextHelpFormatter)
108+
# CI system options
119109
parser.add_argument("-n", "--build-number", metavar="BUILD_NUM", help="build number")
120110
parser.add_argument("-b", "--branch", metavar="BRANCH", help="pull request branch")
121111
parser.add_argument("-d", "--base-branch", metavar="BASE_BRANCH", help="pull request base branch")
122112
parser.add_argument("-r", "--pr-number", metavar="PR_NUM", help="pull request number")
123113
parser.add_argument("-w", "--builder-dir", metavar="BUILDER_DIR",
124114
help="builder directory, which is the directory contains source and build directories")
115+
# User options
125116
parser.add_argument("-s", "--src-dir", metavar="SRC_DIR", help="source directory (autodetected by default)")
126117
parser.add_argument("-o", "--obj-dir", metavar="OBJ_DIR", help="build directory. (<src>/build by default)")
127118
parser.add_argument("-t", "--build-type",

clang/include/clang/Basic/Attr.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ def IntelReqdSubGroupSize: InheritableAttr {
12651265
let Args = [UnsignedArgument<"SubGroupSize">];
12661266
let Subjects = SubjectList<[Function, CXXMethod], ErrorDiag>;
12671267
let Documentation = [IntelReqdSubGroupSizeDocs];
1268-
let LangOpts = [OpenCL, SYCLIsDevice];
1268+
let LangOpts = [OpenCL, SYCLIsDevice, SYCLIsHost];
12691269
}
12701270

12711271
// This attribute is both a type attribute, and a declaration attribute (for

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ def warn_pragma_pack_pop_identifier_and_alignment : Warning<
891891
def warn_pragma_pop_failed : Warning<"#pragma %0(pop, ...) failed: %1">,
892892
InGroup<IgnoredPragmas>;
893893
def err_pragma_fc_pp_scope : Error<
894-
"'#pragma float_control push/pop' can only appear at file scope">;
894+
"'#pragma float_control push/pop' can only appear at file scope or namespace scope">;
895895
def err_pragma_fc_noprecise_requires_nofenv : Error<
896896
"'#pragma float_control(precise, off)' is illegal when fenv_access is enabled">;
897897
def err_pragma_fc_except_requires_precise : Error<

clang/include/clang/Driver/Driver.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,9 @@ class Driver {
635635
bool checkForOffloadStaticLib(Compilation &C,
636636
llvm::opt::DerivedArgList &Args) const;
637637

638+
/// Track filename used for the FPGA dependency info.
639+
mutable llvm::StringMap<const std::string> FPGATempDepFiles;
640+
638641
public:
639642
/// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
640643
/// return the grouped values as integers. Numbers which are not
@@ -658,6 +661,18 @@ class Driver {
658661
static void getDefaultModuleCachePath(SmallVectorImpl<char> &Result);
659662

660663
bool getOffloadStaticLibSeen() const { return OffloadStaticLibSeen; };
664+
665+
/// addFPGATempDepFile - Add a file to be added to the bundling step of
666+
/// an FPGA object.
667+
void addFPGATempDepFile(const std::string &DepName,
668+
const std::string &FileName) const {
669+
FPGATempDepFiles.insert({FileName, DepName});
670+
}
671+
/// getFPGATempDepFile - Get a file to be added to the bundling step of
672+
/// an FPGA object.
673+
const std::string getFPGATempDepFile(const std::string &FileName) const {
674+
return FPGATempDepFiles[FileName];
675+
}
661676
};
662677

663678
/// \return True if the last defined optimization level is -Ofast.

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4741,7 +4741,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
47414741
}
47424742
UnbundlerInputs.push_back(LI);
47434743
}
4744-
const Arg *LastArg;
4744+
const Arg *LastArg = nullptr;
47454745
auto addUnbundlerInput = [&](types::ID T, const StringRef &A) {
47464746
const llvm::opt::OptTable &Opts = getOpts();
47474747
Arg *InputArg = MakeInputArg(Args, Opts, C.getArgs().MakeArgString(A));

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,10 +1142,14 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
11421142
DepFile = "-";
11431143
} else if (ArgMD->getOption().matches(options::OPT_MMD) &&
11441144
Args.hasArg(options::OPT_fintelfpga) &&
1145-
!Args.hasArg(options::OPT_c)) {
1146-
// When generating dependency files for FPGA AOT, the output files will
1147-
// always be named after the source file.
1148-
DepFile = Args.MakeArgString(Twine(getBaseInputStem(Args, Inputs)) + ".d");
1145+
JA.isDeviceOffloading(Action::OFK_SYCL)) {
1146+
// Generate dependency files as temporary. These will be used for the
1147+
// aoc call/bundled during fat object creation
1148+
std::string BaseName(Clang::getBaseInputName(Args, Inputs[0]));
1149+
std::string DepTmpName =
1150+
C.getDriver().GetTemporaryPath(llvm::sys::path::stem(BaseName), "d");
1151+
DepFile = C.addTempFile(C.getArgs().MakeArgString(DepTmpName));
1152+
C.getDriver().addFPGATempDepFile(DepFile, BaseName);
11491153
} else {
11501154
DepFile = getDependencyFileName(Args, Inputs);
11511155
C.addFailureResultFile(DepFile, &JA);
@@ -7236,10 +7240,12 @@ void OffloadBundler::ConstructJob(Compilation &C, const JobAction &JA,
72367240
// For -fintelfpga, when bundling objects we also want to bundle up the
72377241
// named dependency file.
72387242
if (IsFPGADepBundle) {
7239-
SmallString<128> CurOutput(Output.getFilename());
7240-
llvm::sys::path::replace_extension(CurOutput, "d");
7241-
UB += ',';
7242-
UB += CurOutput;
7243+
const char *BaseName = Clang::getBaseInputName(TCArgs, Inputs[0]);
7244+
SmallString<128> DepFile(C.getDriver().getFPGATempDepFile(BaseName));
7245+
if (!DepFile.empty()) {
7246+
UB += ',';
7247+
UB += DepFile;
7248+
}
72437249
}
72447250
CmdArgs.push_back(TCArgs.MakeArgString(UB));
72457251

@@ -7720,7 +7726,8 @@ void SYCLPostLink::ConstructJob(Compilation &C, const JobAction &JA,
77207726
addArgs(CmdArgs, TCArgs, {"-symbols"});
77217727
}
77227728
// specialization constants processing is mandatory
7723-
if (llvm::dyn_cast<SYCLPostLinkJobAction>(&JA)->getRTSetsSpecConstants())
7729+
auto *SYCLPostLink = llvm::dyn_cast<SYCLPostLinkJobAction>(&JA);
7730+
if (SYCLPostLink && SYCLPostLink->getRTSetsSpecConstants())
77247731
addArgs(CmdArgs, TCArgs, {"-spec-const=rt"});
77257732
else
77267733
addArgs(CmdArgs, TCArgs, {"-spec-const=default"});

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -247,17 +247,16 @@ void SYCL::fpga::BackendCompiler::ConstructJob(Compilation &C,
247247
if (Ty == types::TY_INVALID)
248248
continue;
249249
if (types::isSrcFile(Ty) || Ty == types::TY_Object) {
250-
// Dependency files and the project report are created in CWD, so strip
251-
// off any directory information if provided with the input file.
252-
// TODO - Use temporary files for dependency file creation and
253-
// usage with -fintelfpga.
250+
// The project report is created in CWD, so strip off any directory
251+
// information if provided with the input file.
254252
ArgName = llvm::sys::path::filename(ArgName);
255253
if (types::isSrcFile(Ty)) {
256-
SmallString<128> DepName(ArgName);
257-
llvm::sys::path::replace_extension(DepName, "d");
258-
FPGADepFiles.push_back(InputInfo(types::TY_Dependencies,
259-
Args.MakeArgString(DepName),
260-
Args.MakeArgString(DepName)));
254+
SmallString<128> DepName(
255+
C.getDriver().getFPGATempDepFile(std::string(ArgName)));
256+
if (!DepName.empty())
257+
FPGADepFiles.push_back(InputInfo(types::TY_Dependencies,
258+
Args.MakeArgString(DepName),
259+
Args.MakeArgString(DepName)));
261260
}
262261
if (createdReportName.empty()) {
263262
// Project report should be saved into CWD, so strip off any

clang/lib/Sema/SemaAttr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,8 @@ void Sema::ActOnPragmaFloatControl(SourceLocation Loc,
420420
auto NewValue = FpPragmaStack.CurrentValue;
421421
FPOptions NewFPFeatures(NewValue);
422422
if ((Action == PSK_Push_Set || Action == PSK_Push || Action == PSK_Pop) &&
423-
!CurContext->isTranslationUnit()) {
424-
// Push and pop can only occur at file scope.
423+
!(CurContext->isTranslationUnit()) && !CurContext->isNamespace()) {
424+
// Push and pop can only occur at file or namespace scope.
425425
Diag(Loc, diag::err_pragma_fc_pp_scope);
426426
return;
427427
}

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2981,6 +2981,9 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
29812981

29822982
// Handles intel_reqd_sub_group_size.
29832983
static void handleSubGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
2984+
if (S.LangOpts.SYCLIsHost)
2985+
return;
2986+
29842987
uint32_t SGSize;
29852988
const Expr *E = AL.getArgAsExpr(0);
29862989
if (!checkUInt32Argument(S, AL, E, SGSize))

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -694,13 +694,14 @@ static void VisitAccessorWrapperHelper(CXXRecordDecl *Owner, RangeTy Range,
694694
if (Util::isSyclAccessorType(ItemTy))
695695
(void)std::initializer_list<int>{
696696
(handlers.handleSyclAccessorType(Item, ItemTy), 0)...};
697-
else if (ItemTy->isStructureOrClassType()) {
697+
else if (Util::isSyclStreamType(ItemTy)) {
698+
VisitAccessorWrapper(Owner, Item, ItemTy->getAsCXXRecordDecl(),
699+
handlers...);
700+
(void)std::initializer_list<int>{
701+
(handlers.handleSyclStreamType(Item, ItemTy), 0)...};
702+
} else if (ItemTy->isStructureOrClassType())
698703
VisitAccessorWrapper(Owner, Item, ItemTy->getAsCXXRecordDecl(),
699704
handlers...);
700-
if (Util::isSyclStreamType(ItemTy))
701-
(void)std::initializer_list<int>{
702-
(handlers.handleSyclStreamType(Item, ItemTy), 0)...};
703-
}
704705
}
705706
}
706707

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,6 +2028,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(
20282028
D->hasWrittenPrototype(), D->getConstexprKind(),
20292029
TrailingRequiresClause);
20302030
Function->setRangeEnd(D->getSourceRange().getEnd());
2031+
Function->setUsesFPIntrin(D->usesFPIntrin());
20312032
}
20322033

20332034
if (D->isInlined())

clang/test/CodeGen/fp-floatcontrol-pragma.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// RUN: %clang_cc1 -DEXCEPT=1 -fcxx-exceptions -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NS %s
12
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
23
// RUN: %clang_cc1 -verify -DFENV_ON=1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
34

@@ -59,3 +60,56 @@ void callt() {
5960
z = z * z;
6061
//CHECK: = fmul float
6162
}
63+
64+
#if EXCEPT
65+
namespace ns {
66+
// Check that pragma float_control can appear in namespace.
67+
#pragma float_control(except, on, push)
68+
float exc_on(double x, float zero) {
69+
// CHECK-NS: define {{.*}}exc_on{{.*}}
70+
{} try {
71+
x = 1.0 / zero; /* division by zero, the result unused */
72+
//CHECK-NS: llvm.experimental.constrained.fdiv{{.*}}
73+
} catch (...) {}
74+
return zero;
75+
}
76+
}
77+
78+
// Check pragma is still effective after namespace closes
79+
float exc_still_on(double x, float zero) {
80+
// CHECK-NS: define {{.*}}exc_still_on{{.*}}
81+
{} try {
82+
x = 1.0 / zero; /* division by zero, the result unused */
83+
//CHECK-NS: llvm.experimental.constrained.fdiv{{.*}}
84+
} catch (...) {}
85+
return zero;
86+
}
87+
88+
#pragma float_control(pop)
89+
float exc_off(double x, float zero) {
90+
// CHECK-NS: define {{.*}}exc_off{{.*}}
91+
{} try {
92+
x = 1.0 / zero; /* division by zero, the result unused */
93+
//CHECK-NS: fdiv contract double
94+
} catch (...) {}
95+
return zero;
96+
}
97+
98+
namespace fc_template_namespace {
99+
#pragma float_control(except, on, push)
100+
template <class T>
101+
T exc_on(double x, T zero) {
102+
// CHECK-NS: define {{.*}}fc_template_namespace{{.*}}
103+
{} try {
104+
x = 1.0 / zero; /* division by zero, the result unused */
105+
//CHECK-NS: llvm.experimental.constrained.fdiv{{.*}}
106+
} catch (...) {}
107+
return zero;
108+
}
109+
}
110+
111+
#pragma float_control(pop)
112+
float xx(double x, float z) {
113+
return fc_template_namespace::exc_on<float>(x, z);
114+
}
115+
#endif // EXCEPT

clang/test/Driver/sycl-offload-intelfpga.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,17 @@
298298
// RUN: | FileCheck -DOUTDIR=%t_dir -check-prefix=CHK-FPGA-REPORT-OPT2 %s
299299
// RUN: %clang_cl -### -fsycl -fintelfpga %t_dir/dummy.cpp 2>&1 \
300300
// RUN: | FileCheck -DOUTDIR=%t_dir -check-prefix=CHK-FPGA-REPORT-OPT2 %s
301-
// CHK-FPGA-REPORT-OPT2: aoc{{.*}} "-sycl"{{.*}} "-dep-files=dummy.d" "-output-report-folder=dummy.prj"
301+
// CHK-FPGA-REPORT-OPT2: aoc{{.*}} "-sycl"{{.*}} "-dep-files={{.+}}dummy-{{.+}}.d" "-output-report-folder=dummy.prj"
302302
// CHK-FPGA-REPORT-OPT2-NOT: aoc{{.*}} "-sycl" {{.*}}[[OUTDIR]]{{.*}}
303303

304+
/// -fintelfpga dependency files from multiple source
305+
// RUN: touch dummy2.cpp
306+
// RUN: %clangxx -### -fsycl -fintelfpga %t_dir/dummy.cpp dummy2.cpp 2>&1 \
307+
// RUN: | FileCheck -check-prefix=CHK-FPGA-MULTI-DEPS %s
308+
// RUN: %clang_cl -### -fsycl -fintelfpga %t_dir/dummy.cpp dummy2.cpp 2>&1 \
309+
// RUN: | FileCheck -check-prefix=CHK-FPGA-MULTI-DEPS %s
310+
// CHK-FPGA-MULTI-DEPS: aoc{{.*}} "-sycl"{{.*}} "-dep-files={{.+}}dummy-{{.+}}.d,{{.+}}dummy2-{{.+}}.d" "-output-report-folder=dummy.prj"
311+
304312
/// -fintelfpga output report file should be based on first input (src/obj)
305313
// RUN: mkdir -p %t_dir
306314
// RUN: touch %t_dir/dummy1.cpp
@@ -317,13 +325,6 @@
317325
// RUN: | FileCheck -check-prefix=CHK-FPGA-REPORT-NAME %s
318326
// CHK-FPGA-REPORT-NAME: aoc{{.*}} "-sycl"{{.*}} "-output-report-folder=dummy2.prj"
319327

320-
/// -fintelfpga output dep file using -Fo<dir>
321-
// RUN: mkdir -p %t_dir
322-
// RUN: %clang_cl -### -c -fsycl -fintelfpga -Fo%t_dir/ %s 2>&1 \
323-
// RUN: | FileCheck -DDEPDIR=%t_dir/ -check-prefix=CHK-FPGA-DEP-DIR %s
324-
// CHK-FPGA-DEP-DIR: clang{{.*}} "-dependency-file" "[[DEPDIR]][[DEPFILE:.+\.d]]"
325-
// CHK-FPGA-DEP-DIR: clang-offload-bundler{{.*}} "-inputs={{.*}}.bc,{{.*}}.obj,[[DEPDIR]][[DEPFILE]]"
326-
327328
/// -fintelfpga static lib (aoco)
328329
// RUN: echo "Dummy AOCO image" > %t.aoco
329330
// RUN: echo "void foo() {}" > %t.c

clang/test/Lexer/case-insensitive-include-win.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// run.
44

55
// REQUIRES: system-windows
6+
// Disable file portability check to unblock pulldown (intel/llvm/issues/1594)
7+
// XFAIL: system-windows
68
// RUN: mkdir -p %t.dir
79
// RUN: touch %t.dir/foo.h
810
// RUN: not %clang_cl /FI\\?\%t.dir\FOO.h /WX -fsyntax-only %s 2>&1 | FileCheck %s

clang/test/Parser/fp-floatcontrol-syntax.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ float function_scope(float a) {
1010
#pragma float_control(pop)
1111
#pragma float_control(precise, on, push)
1212
void check_stack() {
13-
#pragma float_control(push) // expected-error {{can only appear at file scope}}
14-
#pragma float_control(pop) // expected-error {{can only appear at file scope}}
15-
#pragma float_control(precise, on, push) // expected-error {{can only appear at file scope}}
16-
#pragma float_control(except, on, push) // expected-error {{can only appear at file scope}}
13+
#pragma float_control(push) // expected-error {{can only appear at file scope or namespace scope}}
14+
#pragma float_control(pop) // expected-error {{can only appear at file scope or namespace scope}}
15+
#pragma float_control(precise, on, push) // expected-error {{can only appear at file scope or namespace scope}}
16+
#pragma float_control(except, on, push) // expected-error {{can only appear at file scope or namespace scope}}
1717
#pragma float_control(except, on, push, junk) // expected-error {{float_control is malformed}}
1818
return;
1919
}

clang/test/SemaSYCL/reqd-sub-group-size.cpp renamed to clang/test/SemaSYCL/reqd-sub-group-size-device.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ void bar() {
4545
baz();
4646
});
4747
#endif
48-
4948
kernel<class kernel_name5>([]() [[cl::intel_reqd_sub_group_size(2)]] { });
5049
}
5150

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %clang_cc1 -fsycl -fsycl-is-host -fsyntax-only -verify %s
2+
// expected-no-diagnostics
3+
4+
[[cl::intel_reqd_sub_group_size(8)]] void fun() {}
5+
6+
class Functor {
7+
public:
8+
[[cl::intel_reqd_sub_group_size(16)]] void operator()() {}
9+
};

0 commit comments

Comments
 (0)