Skip to content

Commit 18a6f40

Browse files
committed
Merge remote-tracking branch 'origin/sycl' into cts-spirv-be-2
2 parents 1b4083d + 315a082 commit 18a6f40

File tree

31 files changed

+980
-300
lines changed

31 files changed

+980
-300
lines changed

.github/workflows/sycl-linux-run-tests.yml

Lines changed: 17 additions & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -210,27 +210,6 @@ jobs:
210210
devops
211211
- name: Register cleanup after job is finished
212212
uses: ./devops/actions/cleanup
213-
- name: Checkout E2E tests
214-
if: inputs.tests_selector == 'e2e'
215-
uses: ./devops/actions/cached_checkout
216-
with:
217-
path: llvm
218-
ref: ${{ inputs.ref || github.sha }}
219-
merge_ref: ${{ inputs.merge_ref }}
220-
cache_path: "/__w/repo_cache/"
221-
- name: Checkout SYCL CTS tests
222-
if: inputs.tests_selector == 'cts' && inputs.cts_testing_mode != 'run-only'
223-
uses: ./devops/actions/cached_checkout
224-
with:
225-
path: khronos_sycl_cts
226-
repository: 'KhronosGroup/SYCL-CTS'
227-
ref: 'main'
228-
default_branch: 'main'
229-
cache_path: "/__w/repo_cache/"
230-
- name: SYCL CTS GIT submodules init
231-
if: inputs.tests_selector == 'cts' && inputs.cts_testing_mode != 'run-only'
232-
run: |
233-
git -C khronos_sycl_cts submodule update --init
234213
- name: Install drivers
235214
if: inputs.install_igc_driver == 'true' || inputs.install_dev_igc_driver == 'true'
236215
env:
@@ -312,178 +291,26 @@ jobs:
312291
cat /usr/local/lib/igc/IGCTAG.txt
313292
fi
314293
315-
- name: Download E2E Binaries
316-
if: inputs.e2e_binaries_artifact != ''
317-
uses: actions/download-artifact@v4
318-
with:
319-
name: ${{ inputs.e2e_binaries_artifact }}
320-
- name: Extract E2E Binaries
321-
if: inputs.e2e_binaries_artifact != ''
322-
run: |
323-
mkdir build-e2e
324-
tar -I 'zstd' -xf e2e_binaries.tar.zst -C build-e2e
325-
326-
- name: Deduce E2E CMake options
327-
if: inputs.tests_selector == 'e2e' && inputs.e2e_binaries_artifact == ''
328-
id: cmake_opts
329-
shell: bash
330-
env:
331-
CMAKE_EXTRA_ARGS: ${{ inputs.extra_cmake_args }}
332-
run: |
333-
if [ -n "$CMAKE_EXTRA_ARGS" ]; then
334-
echo "opts=$CMAKE_EXTRA_ARGS" >> $GITHUB_OUTPUT
335-
fi
336-
- name: Configure E2E tests
337-
if: inputs.tests_selector == 'e2e' && inputs.e2e_binaries_artifact == ''
338-
run: |
339-
cmake -GNinja -B./build-e2e -S./llvm/sycl/test-e2e -DCMAKE_CXX_COMPILER="$(which clang++)" -DLLVM_LIT="$PWD/llvm/llvm/utils/lit/lit.py" ${{ steps.cmake_opts.outputs.opts }}
340-
- name: SYCL End-to-end tests
341-
shell: bash {0}
294+
- name: Run E2E Tests
342295
if: inputs.tests_selector == 'e2e'
343-
env:
344-
LIT_OPTS: -v --no-progress-bar --show-unsupported --show-pass --show-xfail --max-time 3600 --time-tests --param test-mode=${{ inputs.e2e_testing_mode }} --param sycl_devices=${{ inputs.target_devices }} ${{ inputs.extra_lit_opts }}
345-
run: |
346-
ninja -C build-e2e check-sycl-e2e > e2e.log 2>&1
347-
exit_code=$?
348-
cat e2e.log
349-
if [ $exit_code -ne 0 ]; then
350-
awk '/^Failed Tests|Unexpectedly Passed Tests|Unresolved tests|Testing Time/{flag=1}/FAILED: CMakeFiles/{flag=0}flag' e2e.log >> $GITHUB_STEP_SUMMARY
351-
fi
352-
exit $exit_code
353-
- name: Build SYCL CTS tests
354-
if: inputs.tests_selector == 'cts' && inputs.sycl_cts_artifact == ''
355-
env:
356-
CMAKE_EXTRA_ARGS: ${{ inputs.extra_cmake_args }}
357-
run: |
358-
cts_exclude_filter=""
359-
# If CTS_TESTS_TO_BUILD is null - use filter
360-
if [ -z "$CTS_TESTS_TO_BUILD" ]; then
361-
if [ "${{ contains(inputs.cts_testing_mode, 'build-only') }}" = "true" ]; then
362-
cts_exclude_filter=$PWD/devops/cts_exclude_filter_compfails
363-
elif [ "${{ contains(inputs.target_devices, 'opencl:cpu') }}" = "true" ]; then
364-
cts_exclude_filter=$PWD/devops/cts_exclude_filter_OCL_CPU
365-
elif [ "${{ contains(inputs.target_devices, 'level_zero:gpu') }}" = "true" ]; then
366-
cts_exclude_filter=$PWD/devops/cts_exclude_filter_L0_GPU
367-
fi
368-
369-
# List excluded SYCL CTS categories:
370-
# SYCL_CTS_EXCLUDE_TEST_CATEGORIES - Optional file specifying a list
371-
# of test categories to be excluded from the build.
372-
echo "::group::Excluded test categories"
373-
cat $cts_exclude_filter
374-
echo "::endgroup::"
375-
fi
376-
377-
cmake -GNinja -B./build-cts -S./khronos_sycl_cts -DCMAKE_CXX_COMPILER=$(which clang++) \
378-
-DSYCL_IMPLEMENTATION=DPCPP \
379-
-DSYCL_CTS_EXCLUDE_TEST_CATEGORIES="$cts_exclude_filter" \
380-
-DSYCL_CTS_ENABLE_OPENCL_INTEROP_TESTS=OFF \
381-
-DDPCPP_INSTALL_DIR="$(dirname $(which clang++))/.." \
382-
$CMAKE_EXTRA_ARGS
383-
# Ignore errors so that if one category build fails others still have a
384-
# chance to finish and be executed at the run stage. Note that
385-
# "test_conformance" target skips building "test_all" executable.
386-
ninja -C build-cts -k0 $( [ -n "$CTS_TESTS_TO_BUILD" ] && echo "$CTS_TESTS_TO_BUILD" || echo "test_conformance")
387-
388-
- name: Pack SYCL-CTS binaries
389-
if: always() && !cancelled() && inputs.cts_testing_mode == 'build-only'
390-
run: tar -I 'zstd -9' -cf sycl_cts_bin.tar.zst -C ./build-cts/bin .
391-
392-
- name: Upload SYCL-CTS binaries
393-
if: always() && !cancelled() && inputs.cts_testing_mode == 'build-only'
394-
uses: actions/upload-artifact@v4
296+
uses: ./devops/actions/run-tests/e2e
395297
with:
396-
name: sycl_cts_bin
397-
path: sycl_cts_bin.tar.zst
298+
ref: ${{ inputs.ref || github.sha }}
299+
merge_ref: ${{ inputs.merge_ref }}
300+
e2e_binaries_artifact: ${{ inputs.e2e_binaries_artifact }}
301+
extra_cmake_args: ${{ inputs.extra_cmake_args }}
302+
e2e_testing_mode: ${{ inputs.e2e_testing_mode }}
303+
target_devices: ${{ inputs.target_devices }}
304+
extra_lit_opts: ${{ inputs.extra_lit_opts }}
305+
artifact_suffix: ${{ inputs.artifact_suffix }}
398306
retention-days: ${{ inputs.retention-days }}
399307

400-
- name: Download SYCL-CTS binaries
401-
if: inputs.sycl_cts_artifact != ''
402-
uses: actions/download-artifact@v4
403-
with:
404-
name: ${{ inputs.sycl_cts_artifact }}
405-
406-
- name: Extract SYCL-CTS binaries
407-
if: inputs.sycl_cts_artifact != ''
408-
run: |
409-
mkdir -p build-cts/bin
410-
tar -I 'zstd' -xf sycl_cts_bin.tar.zst -C build-cts/bin
411-
412-
- name: SYCL CTS List devices
413-
# Proceed with execution even if the 'build' step did not succeed.
414-
if: inputs.tests_selector == 'cts' && (always() && !cancelled()) && inputs.cts_testing_mode != 'build-only'
415-
env:
416-
ONEAPI_DEVICE_SELECTOR: ${{ inputs.target_devices }}
417-
run: |
418-
./build-cts/bin/* --list-devices
419-
420-
# If the suite was built on another machine then the build contains the full
421-
# set of tests. We have special files to filter out some test categories,
422-
# see "devops/cts_exclude_filter_*". Each configuration has its own file, e.g.
423-
# there is "cts_exclude_filter_OCL_CPU" for opencl:cpu device. Therefore,
424-
# these files may differ from each other, so when there is a pre-built set of
425-
# tests, we need to filter it according to the filter-file.
426-
- name: Filter SYCL CTS test categories
427-
if: inputs.sycl_cts_artifact != ''
428-
shell: bash
429-
run: |
430-
cts_exclude_filter=""
431-
if [ "${{ contains(inputs.target_devices, 'opencl:cpu') }}" = "true" ]; then
432-
cts_exclude_filter=$PWD/devops/cts_exclude_filter_OCL_CPU
433-
elif [ "${{ contains(inputs.target_devices, 'level_zero:gpu') }}" = "true" ]; then
434-
cts_exclude_filter=$PWD/devops/cts_exclude_filter_L0_GPU
435-
fi
436-
437-
while IFS= read -r line; do
438-
if [[ $line != \#* ]]; then
439-
rm "./build-cts/bin/test_$line"
440-
fi
441-
done < "$cts_exclude_filter"
442-
443-
- name: Run SYCL CTS tests
444-
# Proceed with execution even if the previous two steps did not succeed.
445-
if: inputs.tests_selector == 'cts' && (always() && !cancelled()) && inputs.cts_testing_mode != 'build-only'
446-
env:
447-
ONEAPI_DEVICE_SELECTOR: ${{ inputs.target_devices }}
448-
# This job takes ~100min usually. But sometimes some test isn't
449-
# responding, so the job reaches the 360min limit. Setting a lower one.
450-
timeout-minutes: 150
451-
# By-default GitHub actions execute the "run" shell script with -e option,
452-
# so the execution terminates if any command returns a non-zero status.
453-
# Since we're using a loop to run all test-binaries separately, some test
454-
# may fail and terminate the execution. Setting "shell" value to override
455-
# the default behavior.
456-
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#custom-shell
457-
shell: bash {0}
458-
run: |
459-
# Run each test category separately so that
460-
# - crash on one would not affect others
461-
# - multiple tests could be run in parallel
462-
mkdir logs
463-
find build-cts/bin/ -type f -print | \
464-
xargs -t -I % -P 8 sh -c 'log=logs/$(basename %).log ; echo % >$log ; date >>$log ; timeout 60m % >>$log 2>&1 ; ret=$? ; echo "exit code: $ret" >>$log ; date >>$log ; exit $ret'
465-
ret=$?
466-
467-
for f in logs/* ; do
468-
echo "::group::$f"
469-
cat $f
470-
echo "::endgroup::"
471-
done
472-
473-
echo "::group::Fails:"
474-
grep 'exit code: [^0]' -r logs
475-
echo "::endgroup::"
476-
477-
grep 'exit code: [^0]' -r logs >> $GITHUB_STEP_SUMMARY
478-
479-
exit $ret
480-
- name: Pack E2E binaries
481-
if: ${{ always() && !cancelled() && inputs.e2e_testing_mode == 'build-only'}}
482-
run: tar -I 'zstd -9' -cf e2e_binaries.tar.zst -C ./build-e2e .
483-
- name: Upload E2E binaries
484-
if: ${{ always() && !cancelled() && inputs.e2e_testing_mode == 'build-only'}}
485-
uses: actions/upload-artifact@v4
308+
- name: Run SYCL CTS Tests
309+
if: inputs.tests_selector == 'cts'
310+
uses: ./devops/actions/run-tests/cts
486311
with:
487-
name: sycl_e2e_bin_${{ inputs.artifact_suffix }}
488-
path: e2e_binaries.tar.zst
312+
extra_cmake_args: ${{ inputs.extra_cmake_args }}
313+
cts_testing_mode: ${{ inputs.cts_testing_mode }}
314+
sycl_cts_artifact: ${{ inputs.sycl_cts_artifact }}
315+
target_devices: ${{ inputs.target_devices }}
489316
retention-days: ${{ inputs.retention-days }}

clang/include/clang/Basic/Attr.td

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,6 +2147,22 @@ def SYCLAddIRAnnotationsMember : InheritableAttr {
21472147
let Documentation = [SYCLAddIRAnnotationsMemberDocs];
21482148
}
21492149

2150+
def SYCLRegisteredKernels : InheritableAttr {
2151+
let Spellings = [CXX11<"__sycl_detail__", "__registered_kernels__">];
2152+
let Args = [VariadicExprArgument<"Args">];
2153+
let LangOpts = [SYCLIsDevice, SilentlyIgnoreSYCLIsHost];
2154+
let Subjects = SubjectList<[Empty], ErrorDiag, "Translation Unit Scope">;
2155+
let AdditionalMembers = SYCLAddIRAttrCommonMembers.MemberCode;
2156+
let Documentation = [SYCLAddIRAnnotationsMemberDocs];
2157+
}
2158+
2159+
def SYCLRegisteredKernelName : InheritableAttr {
2160+
let Spellings = [];
2161+
let Subjects = SubjectList<[Function]>;
2162+
let Args = [StringArgument<"RegName">];
2163+
let Documentation = [InternalOnly];
2164+
}
2165+
21502166
def C11NoReturn : InheritableAttr {
21512167
let Spellings = [CustomKeyword<"_Noreturn">];
21522168
let Subjects = SubjectList<[Function], ErrorDiag>;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12546,6 +12546,20 @@ def err_sycl_special_type_num_init_method : Error<
1254612546
def warn_launch_bounds_is_cuda_specific : Warning<
1254712547
"%0 attribute ignored, only applicable when targeting Nvidia devices">,
1254812548
InGroup<IgnoredAttributes>;
12549+
def err_registered_kernels_num_of_args : Error<
12550+
"'__registered_kernels__' attribute must have at least one argument">;
12551+
def err_registered_kernels_init_list : Error<
12552+
"argument to the '__registered_kernels__' attribute must be an "
12553+
"initializer list expression">;
12554+
def err_registered_kernels_init_list_pair_values : Error<
12555+
"each initializer list argument to the '__registered_kernels__' attribute "
12556+
"must contain a pair of values">;
12557+
def err_registered_kernels_resolve_function : Error<
12558+
"unable to resolve free function kernel '%0'">;
12559+
def err_registered_kernels_name_already_registered : Error<
12560+
"free function kernel has already been registered with '%0'; cannot register with '%1'">;
12561+
def err_not_sycl_free_function : Error<
12562+
"attempting to register a function that is not a SYCL free function as '%0'">;
1254912563

1255012564
def warn_cuda_maxclusterrank_sm_90 : Warning<
1255112565
"'maxclusterrank' requires sm_90 or higher, CUDA arch provided: %0, ignoring "

clang/include/clang/Sema/SemaSYCL.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,9 @@ class SemaSYCL : public SemaBase {
252252
// We need to store the list of the sycl_kernel functions and their associated
253253
// generated OpenCL Kernels so we can go back and re-name these after the
254254
// fact.
255-
llvm::SmallVector<std::pair<const FunctionDecl *, FunctionDecl *>>
256-
SyclKernelsToOpenCLKernels;
255+
using KernelFDPairs =
256+
llvm::SmallVector<std::pair<const FunctionDecl *, FunctionDecl *>>;
257+
KernelFDPairs SyclKernelsToOpenCLKernels;
257258

258259
// Used to suppress diagnostics during kernel construction, since these were
259260
// already emitted earlier. Diagnosing during Kernel emissions also skips the
@@ -296,11 +297,15 @@ class SemaSYCL : public SemaBase {
296297
llvm::DenseSet<QualType> Visited,
297298
ValueDecl *DeclToCheck);
298299

300+
const KernelFDPairs &getKernelFDPairs() { return SyclKernelsToOpenCLKernels; }
301+
299302
void addSyclOpenCLKernel(const FunctionDecl *SyclKernel,
300303
FunctionDecl *OpenCLKernel) {
301304
SyclKernelsToOpenCLKernels.emplace_back(SyclKernel, OpenCLKernel);
302305
}
303306

307+
void constructFreeFunctionKernel(FunctionDecl *FD, StringRef NameStr = "");
308+
304309
void addSyclDeviceDecl(Decl *d) { SyclDeviceDecls.insert(d); }
305310
llvm::SetVector<Decl *> &syclDeviceDecls() { return SyclDeviceDecls; }
306311

@@ -480,6 +485,7 @@ class SemaSYCL : public SemaBase {
480485
void handleSYCLIntelMaxWorkGroupsPerMultiprocessor(Decl *D,
481486
const ParsedAttr &AL);
482487
void handleSYCLScopeAttr(Decl *D, const ParsedAttr &AL);
488+
void handleSYCLRegisteredKernels(Decl *D, const ParsedAttr &AL);
483489

484490
void checkSYCLAddIRAttributesFunctionAttrConflicts(Decl *D);
485491

@@ -655,6 +661,10 @@ class SemaSYCL : public SemaBase {
655661
void addIntelReqdSubGroupSizeAttr(Decl *D, const AttributeCommonInfo &CI,
656662
Expr *E);
657663
void handleKernelEntryPointAttr(Decl *D, const ParsedAttr &AL);
664+
665+
// Used to check whether the function represented by FD is a SYCL
666+
// free function kernel or not.
667+
bool isFreeFunction(const FunctionDecl *FD);
658668
};
659669

660670
} // namespace clang

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,12 @@ void CodeGenFunction::EmitKernelMetadata(const FunctionDecl *FD,
641641

642642
llvm::LLVMContext &Context = getLLVMContext();
643643

644+
if (getLangOpts().SYCLIsDevice)
645+
if (FD->hasAttr<SYCLRegisteredKernelNameAttr>())
646+
CGM.SYCLAddRegKernelNamePairs(
647+
FD->getAttr<SYCLRegisteredKernelNameAttr>()->getRegName(),
648+
FD->getNameAsString());
649+
644650
if (FD->hasAttr<OpenCLKernelAttr>() || FD->hasAttr<CUDAGlobalAttr>())
645651
CGM.GenKernelArgMetadata(Fn, FD, this);
646652

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,19 @@ void CodeGenModule::Release() {
14311431
AspectEnumValsMD->addOperand(
14321432
getAspectEnumValueMD(Context, TheModule.getContext(), ECD));
14331433
}
1434+
1435+
if (!SYCLRegKernelNames.empty()) {
1436+
std::vector<llvm::Metadata *> Nodes;
1437+
llvm::LLVMContext &Ctx = TheModule.getContext();
1438+
for (auto MDKernelNames : SYCLRegKernelNames) {
1439+
llvm::Metadata *Vals[] = {MDKernelNames.first, MDKernelNames.second};
1440+
Nodes.push_back(llvm::MDTuple::get(Ctx, Vals));
1441+
}
1442+
1443+
llvm::NamedMDNode *SYCLRegKernelsMD =
1444+
TheModule.getOrInsertNamedMetadata("sycl_registered_kernels");
1445+
SYCLRegKernelsMD->addOperand(llvm::MDNode::get(Ctx, Nodes));
1446+
}
14341447
}
14351448

14361449
// HLSL related end of code gen work items.

clang/lib/CodeGen/CodeGenModule.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,9 @@ class CodeGenModule : public CodeGenTypeCache {
456456
/// handled differently than regular annotations so they cannot share map.
457457
llvm::DenseMap<unsigned, llvm::Constant *> SYCLAnnotationArgs;
458458

459+
typedef std::pair<llvm::Metadata *, llvm::Metadata *> MetadataPair;
460+
SmallVector<MetadataPair, 4> SYCLRegKernelNames;
461+
459462
llvm::StringMap<llvm::GlobalVariable *> CFConstantStringMap;
460463

461464
llvm::DenseMap<llvm::Constant *, llvm::GlobalVariable *> ConstantStringMap;
@@ -1483,6 +1486,12 @@ class CodeGenModule : public CodeGenTypeCache {
14831486
llvm::Constant *EmitSYCLAnnotationArgs(
14841487
SmallVectorImpl<std::pair<std::string, std::string>> &Pairs);
14851488

1489+
void SYCLAddRegKernelNamePairs(StringRef First, StringRef Second) {
1490+
SYCLRegKernelNames.push_back(
1491+
std::make_pair(llvm::MDString::get(getLLVMContext(), First),
1492+
llvm::MDString::get(getLLVMContext(), Second)));
1493+
}
1494+
14861495
/// Add attributes from add_ir_attributes_global_variable on TND to GV.
14871496
void AddGlobalSYCLIRAttributes(llvm::GlobalVariable *GV,
14881497
const RecordDecl *RD);

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7479,6 +7479,9 @@ ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,
74797479
case ParsedAttr::AT_SYCLAddIRAnnotationsMember:
74807480
S.SYCL().handleSYCLAddIRAnnotationsMemberAttr(D, AL);
74817481
break;
7482+
case ParsedAttr::AT_SYCLRegisteredKernels:
7483+
S.SYCL().handleSYCLRegisteredKernels(D, AL);
7484+
break;
74827485

74837486
// Swift attributes.
74847487
case ParsedAttr::AT_SwiftAsyncName:

0 commit comments

Comments
 (0)