Skip to content

Commit faa9b2c

Browse files
authored
Merge branch 'sycl' into llvmspirv_pulldown
2 parents 1225223 + 8e848cb commit faa9b2c

File tree

205 files changed

+9358
-2586
lines changed

Some content is hidden

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

205 files changed

+9358
-2586
lines changed

.github/workflows/linux_matrix_e2e_on_nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
reset_gpu: false
2929

3030
- name: Intel
31-
runner: '["Linux", "gen9"]'
31+
runner: '["Linux", "gen12"]'
3232
image: ghcr.io/intel/llvm/sycl_ubuntu2204_nightly:latest
3333
extra_image_opts:
3434
extra_cmake_args:

.github/workflows/sycl_detect_changes.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: [Linux, build]
1616
timeout-minutes: 3
1717
outputs:
18-
filters: ${{ steps.changes.outputs.changes }}
18+
filters: ${{ steps.result.outputs.result }}
1919
steps:
2020
- name: Check file changes
2121
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50
@@ -59,3 +59,18 @@ jobs:
5959
- *drivers_and_configs
6060
# Temporary, until plugins are enabled in nightly image.
6161
- sycl/**
62+
63+
- name: Set output
64+
id: result
65+
uses: actions/github-script@v6
66+
with:
67+
script: |
68+
console.log("Number of files changed:");
69+
console.log(context.payload.pull_request.changed_files);
70+
if (context.payload.pull_request.changed_files < 500) {
71+
return '${{ steps.changes.outputs.changes }}';
72+
}
73+
// Treat everything as changed for huge PRs.
74+
return ["llvm", "llvm_spirv", "clang", "sycl_fusion", "xptifw", "libclc", "sycl", "ci", "drivers_and_configs", "test_build"];
75+
76+
- run: echo '${{ steps.result.outputs.result }}'

.github/workflows/sycl_linux_build_and_test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ jobs:
234234
target_devices: ${{ matrix.targets }}
235235
ref: ${{ inputs.build_ref || github.sha }}
236236
merge_ref: ${{ inputs.merge_ref }}
237-
reset_gpu: ${{ contains(matrix.runs-on, 'gen9') && contains(matrix.runs-on, 'Linux') }}
237+
reset_gpu: ${{ contains(matrix.runs-on, 'gen12') && contains(matrix.runs-on, 'Linux') }}
238238

239239
sycl_toolchain_artifact: sycl_linux_${{ inputs.build_artifact_suffix }}
240240
sycl_toolchain_archive: ${{ inputs.artifact_archive_name }}
@@ -257,7 +257,7 @@ jobs:
257257
options: ${{ matrix.container_options }}
258258
steps:
259259
- name: Reset GPU
260-
if: ${{ contains(matrix.config, 'gen9') }}
260+
if: ${{ contains(matrix.config, 'gen12') }}
261261
run: |
262262
sudo mount -t debugfs none /sys/kernel/debug
263263
sudo bash -c 'echo 1 > /sys/kernel/debug/dri/0/i915_wedged'

.github/workflows/sycl_nightly.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212
uses: ./.github/workflows/sycl_gen_test_matrix.yml
1313
with:
1414
# Restore once plugins are enabled in the build.
15-
# lts_config: "hip_amdgpu;ocl_gen9;ocl_x64;l0_gen9;esimd_emu;cuda_aws;win_l0_gen12"
16-
lts_config: "ocl_gen9;ocl_x64;l0_gen9;win_l0_gen12"
15+
# lts_config: "hip_amdgpu;ocl_gen12;ocl_x64;l0_gen12;esimd_emu;cuda_aws;win_l0_gen12"
16+
lts_config: "ocl_gen12;ocl_x64;l0_gen12;win_l0_gen12"
1717

1818
ubuntu2204_build_test:
1919
if: github.repository == 'intel/llvm'

.github/workflows/sycl_post_commit.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- sycl
77
- sycl-devops-pr/**
8+
- llvmspirv_pulldown
89

910
jobs:
1011
# This job generates matrix of tests for SYCL End-to-End tests
@@ -13,7 +14,7 @@ jobs:
1314
if: github.repository == 'intel/llvm'
1415
uses: ./.github/workflows/sycl_gen_test_matrix.yml
1516
with:
16-
lts_config: "l0_gen9;win_l0_gen12"
17+
lts_config: "l0_gen12;win_l0_gen12"
1718
linux_self_prod:
1819
name: Linux (Self build + shared libraries + no-assertions)
1920
if: github.repository == 'intel/llvm'

.github/workflows/sycl_precommit_linux.yml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- sycl
77
- sycl-devops-pr/**
8+
- llvmspirv_pulldown
89
# Do not run builds if changes are only in the following locations
910
paths-ignore:
1011
- '.github/ISSUE_TEMPLATE/**'
@@ -28,6 +29,7 @@ jobs:
2829
lint:
2930
needs: [detect_changes]
3031
if: |
32+
github.event.pull_request.head.repo.full_name == 'intel/llvm' ||
3133
!contains(needs.detect_changes.outputs.filters, 'ci')
3234
runs-on: [Linux, build]
3335
container:
@@ -61,6 +63,7 @@ jobs:
6163
test_matrix:
6264
needs: [detect_changes]
6365
if: |
66+
github.event.pull_request.head.repo.full_name == 'intel/llvm' ||
6467
!contains(needs.detect_changes.outputs.filters, 'ci')
6568
name: Generate Test Matrix
6669
uses: ./.github/workflows/sycl_gen_test_matrix.yml
@@ -76,8 +79,8 @@ jobs:
7679
if: |
7780
always()
7881
&& (success() || contains(github.event.pull_request.labels.*.name, 'ignore-lint'))
79-
&& contains(needs.detect_changes.outputs.filters, 'test_build')
80-
&& !contains(needs.detect_changes.outputs.filters, 'ci')
82+
&& (github.event.pull_request.head.repo.full_name == 'intel/llvm'
83+
|| !contains(needs.detect_changes.outputs.filters, 'ci'))
8184
uses: ./.github/workflows/sycl_linux_build_and_test.yml
8285
secrets: inherit
8386
with:
@@ -90,14 +93,3 @@ jobs:
9093
lts_matrix: ${{ needs.test_matrix.outputs.lts_lx_matrix }}
9194
lts_aws_matrix: ${{ needs.test_matrix.outputs.lts_aws_matrix }}
9295
check_filters: ${{ needs.detect_changes.outputs.filters }}
93-
94-
linux_e2e_on_nightly:
95-
name: Linux SYCL E2E on Nightly
96-
needs: [detect_changes]
97-
if: |
98-
!contains(needs.detect_changes.outputs.filters, 'test_build')
99-
&& !contains(needs.detect_changes.outputs.filters, 'ci')
100-
uses: ./.github/workflows/linux_matrix_e2e_on_nightly.yml
101-
secrets: inherit
102-
with:
103-
ref: ${{ github.event.pull_request.head.sha }}

.github/workflows/sycl_precommit_windows.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- sycl
77
- sycl-devops-pr/**
8+
- llvmspirv_pulldown
89
# Do not run builds if changes are only in the following locations
910
paths-ignore:
1011
- '.github/ISSUE_TEMPLATE/**'
@@ -28,6 +29,7 @@ jobs:
2829
lint:
2930
needs: [detect_changes]
3031
if: |
32+
github.event.pull_request.head.repo.full_name == 'intel/llvm' ||
3133
!contains(needs.detect_changes.outputs.filters, 'ci')
3234
runs-on: [Linux, build]
3335
container:
@@ -61,6 +63,7 @@ jobs:
6163
test_matrix:
6264
needs: [detect_changes]
6365
if: |
66+
github.event.pull_request.head.repo.full_name == 'intel/llvm' ||
6467
!contains(needs.detect_changes.outputs.filters, 'ci')
6568
name: Generate Test Matrix
6669
uses: ./.github/workflows/sycl_gen_test_matrix.yml
@@ -75,7 +78,8 @@ jobs:
7578
always()
7679
&& (success() || contains(github.event.pull_request.labels.*.name, 'ignore-lint'))
7780
&& github.repository == 'intel/llvm'
78-
&& !contains(needs.detect_changes.outputs.filters, 'ci')
81+
&& (github.event.pull_request.head.repo.full_name == 'intel/llvm'
82+
|| !contains(needs.detect_changes.outputs.filters, 'ci'))
7983
uses: ./.github/workflows/sycl_windows_build_and_test.yml
8084
with:
8185
lts_matrix: ${{ needs.test_matrix.outputs.lts_wn_matrix }}

clang/docs/ClangOffloadPackager.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ the following values for the :ref:`offload kind<table-offload_kind>` and the
112112
+------------+-------+---------------------------------------+
113113
| OFK_HIP | 0x03 | The producer was HIP |
114114
+------------+-------+---------------------------------------+
115+
| OFK_SYCL | 0x04 | The producer was SYCL |
116+
+------------+-------+---------------------------------------+
115117

116118
The flags are used to signify certain conditions, such as the presence of
117119
debugging information or whether or not LTO was used. The string entry table is

clang/include/clang/Basic/Builtins.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,6 +1757,9 @@ BUILTIN(__builtin_ms_va_copy, "vc*&c*&", "n")
17571757
// Arithmetic Fence: to prevent FP reordering and reassociation optimizations
17581758
LANGBUILTIN(__arithmetic_fence, "v.", "tE", ALL_LANGUAGES)
17591759

1760+
// Builtins for Intel SYCL
1761+
BUILTIN(__builtin_intel_sycl_ptr_annotation, "v.", "nt")
1762+
17601763
// Builtins for Intel FPGA
17611764
BUILTIN(__builtin_intel_fpga_reg, "v.", "nt")
17621765
BUILTIN(__builtin_intel_fpga_mem, "v.", "nt")

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ def err_intel_fpga_mem_arg_mismatch
167167
"a pointer"
168168
"|a non-negative integer constant}0">;
169169

170+
def err_intel_sycl_ptr_annotation_arg_number_mismatch
171+
:Error<"number of parameters must be odd number">;
172+
def err_intel_sycl_ptr_annotation_mismatch
173+
: Error<"builtin parameter must be %select{"
174+
"a pointer"
175+
"|a string literal or constexpr const char*}0">;
176+
170177
// C99 variable-length arrays
171178
def ext_vla : Extension<"variable length arrays are a C99 feature">,
172179
InGroup<VLAExtension>;

clang/include/clang/Sema/Sema.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14052,6 +14052,9 @@ class Sema final {
1405214052
bool CheckIntelFPGARegBuiltinFunctionCall(unsigned BuiltinID, CallExpr *Call);
1405314053
bool CheckIntelFPGAMemBuiltinFunctionCall(CallExpr *Call);
1405414054

14055+
bool CheckIntelSYCLPtrAnnotationBuiltinFunctionCall(unsigned BuiltinID,
14056+
CallExpr *Call);
14057+
1405514058
bool SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
1405614059
bool SemaBuiltinVAStartARMMicrosoft(CallExpr *Call);
1405714060
bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5564,7 +5564,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
55645564
return EmitIntelFPGARegBuiltin(E, ReturnValue);
55655565
case Builtin::BI__builtin_intel_fpga_mem:
55665566
return EmitIntelFPGAMemBuiltin(E);
5567-
5567+
case Builtin::BI__builtin_intel_sycl_ptr_annotation:
5568+
return EmitIntelSYCLPtrAnnotationBuiltin(E);
55685569
case Builtin::BI__builtin_get_device_side_mangled_name: {
55695570
auto Name = CGM.getCUDARuntime().getDeviceSideName(
55705571
cast<DeclRefExpr>(E->getArg(0)->IgnoreImpCasts())->getDecl());
@@ -22533,6 +22534,12 @@ RValue CodeGenFunction::EmitIntelFPGAMemBuiltin(const CallExpr *E) {
2253322534
return RValue::get(Ann);
2253422535
}
2253522536

22537+
static bool hasFuncNameRequestedFPAccuracy(StringRef Name,
22538+
const LangOptions &LangOpts) {
22539+
auto FuncMapIt = LangOpts.FPAccuracyFuncMap.find(Name.str());
22540+
return (FuncMapIt != LangOpts.FPAccuracyFuncMap.end());
22541+
}
22542+
2253622543
llvm::CallInst *CodeGenFunction::EmitFPBuiltinIndirectCall(
2253722544
llvm::FunctionType *IRFuncTy, const SmallVectorImpl<llvm::Value *> &IRArgs,
2253822545
llvm::Value *FnPtr, const FunctionDecl *FD) {
@@ -22641,9 +22648,53 @@ llvm::CallInst *CodeGenFunction::EmitFPBuiltinIndirectCall(
2264122648
if (!FPAccuracyIntrinsicID)
2264222649
return nullptr;
2264322650

22644-
Func = CGM.getIntrinsic(FPAccuracyIntrinsicID, IRArgs[0]->getType());
22645-
return CreateBuiltinCallWithAttr(*this, Name, Func, ArrayRef(IRArgs),
22646-
FPAccuracyIntrinsicID);
22651+
// Create an intrinsic only if it exists in the map, or if there
22652+
// a TU fp-accuracy requested.
22653+
const LangOptions &LangOpts = getLangOpts();
22654+
if (hasFuncNameRequestedFPAccuracy(Name, LangOpts) ||
22655+
!LangOpts.FPAccuracyVal.empty()) {
22656+
Func = CGM.getIntrinsic(FPAccuracyIntrinsicID, IRArgs[0]->getType());
22657+
return CreateBuiltinCallWithAttr(*this, Name, Func, ArrayRef(IRArgs),
22658+
FPAccuracyIntrinsicID);
22659+
}
22660+
return nullptr;
22661+
}
22662+
22663+
RValue CodeGenFunction::EmitIntelSYCLPtrAnnotationBuiltin(const CallExpr *E) {
22664+
const Expr *PtrArg = E->getArg(0);
22665+
Value *PtrVal = EmitScalarExpr(PtrArg);
22666+
auto &Ctx = CGM.getContext();
22667+
22668+
// Create the pointer annotation.
22669+
Function *F = CGM.getIntrinsic(llvm::Intrinsic::ptr_annotation,
22670+
{PtrVal->getType(), CGM.ConstGlobalsPtrTy});
22671+
22672+
SmallString<256> AnnotStr;
22673+
llvm::raw_svector_ostream Out(AnnotStr);
22674+
22675+
SmallVector<std::pair<std::string, std::string>, 4> Properties;
22676+
22677+
for (unsigned I = 1, N = E->getNumArgs(); I <= N / 2; I++) {
22678+
auto Arg = E->getArg(I)->IgnoreParenCasts();
22679+
const StringLiteral *Str = dyn_cast<const StringLiteral>(Arg);
22680+
Expr::EvalResult Result;
22681+
if (!Str && Arg->EvaluateAsRValue(Result, Ctx) && Result.Val.isLValue()) {
22682+
const auto *LVE = Result.Val.getLValueBase().dyn_cast<const Expr *>();
22683+
Str = dyn_cast<const StringLiteral>(LVE);
22684+
}
22685+
assert(Str && "Constant parameter string is invalid?");
22686+
22687+
auto IntVal = E->getArg(I + N / 2)->getIntegerConstantExpr(Ctx);
22688+
assert(IntVal.has_value() &&
22689+
"Constant integer arg isn't actually constant?");
22690+
22691+
Properties.push_back(
22692+
std::make_pair(Str->getString().str(), toString(IntVal.value(), 10)));
22693+
}
22694+
22695+
llvm::Value *Ann =
22696+
EmitSYCLAnnotationCall(F, PtrVal, E->getExprLoc(), Properties);
22697+
return RValue::get(Ann);
2264722698
}
2264822699

2264922700
Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID,

clang/lib/CodeGen/CGCall.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,7 +1907,7 @@ void CodeGenModule::getDefaultFunctionFPAccuracyAttributes(
19071907
StringRef FPAccuracyVal = llvm::fp::getAccuracyForFPBuiltin(
19081908
ID, FuncType, convertFPAccuracy(FuncMapIt->second));
19091909
assert(!FPAccuracyVal.empty() && "A valid accuracy value is expected");
1910-
FuncAttrs.addAttribute("fpbuiltin-max-error=", FPAccuracyVal);
1910+
FuncAttrs.addAttribute("fpbuiltin-max-error", FPAccuracyVal);
19111911
MD = llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
19121912
Int32Ty, convertFPAccuracyToAspect(FuncMapIt->second)));
19131913
}
@@ -1917,7 +1917,7 @@ void CodeGenModule::getDefaultFunctionFPAccuracyAttributes(
19171917
StringRef FPAccuracyVal = llvm::fp::getAccuracyForFPBuiltin(
19181918
ID, FuncType, convertFPAccuracy(getLangOpts().FPAccuracyVal));
19191919
assert(!FPAccuracyVal.empty() && "A valid accuracy value is expected");
1920-
FuncAttrs.addAttribute("fpbuiltin-max-error=", FPAccuracyVal);
1920+
FuncAttrs.addAttribute("fpbuiltin-max-error", FPAccuracyVal);
19211921
MD = llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
19221922
Int32Ty, convertFPAccuracyToAspect(getLangOpts().FPAccuracyVal)));
19231923
}

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2812,13 +2812,25 @@ Address CodeGenFunction::EmitFieldAnnotations(const FieldDecl *D,
28122812
llvm::Value *CodeGenFunction::EmitSYCLAnnotationCall(
28132813
llvm::Function *AnnotationFn, llvm::Value *AnnotatedVal,
28142814
SourceLocation Location, const SYCLAddIRAnnotationsMemberAttr *Attr) {
2815+
2816+
llvm::SmallVector<std::pair<std::string, std::string>, 4>
2817+
AnnotationNameValPairs =
2818+
Attr->getFilteredAttributeNameValuePairs(getContext());
2819+
return EmitSYCLAnnotationCall(AnnotationFn, AnnotatedVal, Location,
2820+
AnnotationNameValPairs);
2821+
}
2822+
2823+
llvm::Value *CodeGenFunction::EmitSYCLAnnotationCall(
2824+
llvm::Function *AnnotationFn, llvm::Value *AnnotatedVal,
2825+
SourceLocation Location,
2826+
SmallVectorImpl<std::pair<std::string, std::string>> &Pair) {
28152827
SmallVector<llvm::Value *, 5> Args = {
28162828
AnnotatedVal,
28172829
Builder.CreateBitCast(CGM.EmitAnnotationString("sycl-properties"),
28182830
ConstGlobalsPtrTy),
28192831
Builder.CreateBitCast(CGM.EmitAnnotationUnit(Location),
28202832
ConstGlobalsPtrTy),
2821-
CGM.EmitAnnotationLineNo(Location), CGM.EmitSYCLAnnotationArgs(Attr)};
2833+
CGM.EmitAnnotationLineNo(Location), CGM.EmitSYCLAnnotationArgs(Pair)};
28222834
return Builder.CreateCall(AnnotationFn, Args);
28232835
}
28242836

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4333,6 +4333,8 @@ class CodeGenFunction : public CodeGenTypeCache {
43334333
ReturnValueSlot ReturnValue);
43344334
RValue EmitIntelFPGAMemBuiltin(const CallExpr *E);
43354335

4336+
RValue EmitIntelSYCLPtrAnnotationBuiltin(const CallExpr *E);
4337+
43364338
llvm::CallInst *
43374339
EmitFPBuiltinIndirectCall(llvm::FunctionType *IRFuncTy,
43384340
const SmallVectorImpl<llvm::Value *> &IRArgs,
@@ -4601,6 +4603,11 @@ class CodeGenFunction : public CodeGenTypeCache {
46014603
llvm::Value *AnnotatedVal, SourceLocation Location,
46024604
const SYCLAddIRAnnotationsMemberAttr *Attr);
46034605

4606+
llvm::Value *EmitSYCLAnnotationCall(
4607+
llvm::Function *AnnotationFn, llvm::Value *AnnotatedVal,
4608+
SourceLocation Location,
4609+
llvm::SmallVectorImpl<std::pair<std::string, std::string>> &Pair);
4610+
46044611
/// Emit sycl field annotations for given field & value. Returns the
46054612
/// annotation result.
46064613
Address EmitFieldSYCLAnnotations(const FieldDecl *D, Address V);

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3484,10 +3484,9 @@ void CodeGenModule::AddGlobalAnnotations(const ValueDecl *D,
34843484
}
34853485

34863486
llvm::Constant *CodeGenModule::EmitSYCLAnnotationArgs(
3487-
const SYCLAddIRAnnotationsMemberAttr *Attr) {
3488-
llvm::SmallVector<std::pair<std::string, std::string>, 4>
3489-
AnnotationNameValPairs =
3490-
Attr->getFilteredAttributeNameValuePairs(getContext());
3487+
llvm::SmallVectorImpl<std::pair<std::string, std::string>>
3488+
&AnnotationNameValPairs) {
3489+
34913490
if (AnnotationNameValPairs.empty())
34923491
return llvm::ConstantPointerNull::get(ConstGlobalsPtrTy);
34933492

clang/lib/CodeGen/CodeGenModule.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,8 +1382,8 @@ class CodeGenModule : public CodeGenTypeCache {
13821382
void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV);
13831383

13841384
/// Emit additional args of the annotation.
1385-
llvm::Constant *
1386-
EmitSYCLAnnotationArgs(const SYCLAddIRAnnotationsMemberAttr *Attr);
1385+
llvm::Constant *EmitSYCLAnnotationArgs(
1386+
SmallVectorImpl<std::pair<std::string, std::string>> &Pairs);
13871387

13881388
/// Add attributes from add_ir_attributes_global_variable on TND to GV.
13891389
void AddGlobalSYCLIRAttributes(llvm::GlobalVariable *GV,

0 commit comments

Comments
 (0)