Skip to content

Commit 0ad8485

Browse files
Merge branch 'sycl' into steffen/event_mode_impl
2 parents 80fdedf + afa8821 commit 0ad8485

File tree

1,847 files changed

+3453
-2797
lines changed

Some content is hidden

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

1,847 files changed

+3453
-2797
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3020,6 +3020,21 @@ namespace {
30203020
};
30213021
}
30223022

3023+
static bool hasSYCLRestrictPropertyIRAttr(const VarDecl *Arg,
3024+
const ASTContext &Context) {
3025+
auto *IRAttr = Arg->getAttr<SYCLAddIRAttributesKernelParameterAttr>();
3026+
if (!IRAttr)
3027+
return false;
3028+
3029+
SmallVector<std::pair<std::string, std::string>, 4> NameValuePairs =
3030+
IRAttr->getAttributeNameValuePairs(Context);
3031+
return std::any_of(
3032+
NameValuePairs.begin(), NameValuePairs.end(),
3033+
[](const std::pair<std::string, std::string> &NameValuePair) {
3034+
return NameValuePair.first == "sycl-restrict";
3035+
});
3036+
}
3037+
30233038
void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
30243039
llvm::Function *Fn,
30253040
const FunctionArgList &Args) {
@@ -3244,9 +3259,10 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
32443259

32453260
// Set 'noalias' if an argument type has the `restrict` qualifier.
32463261
if (Arg->getType().isRestrictQualified() ||
3247-
(CurCodeDecl &&
3248-
CurCodeDecl->hasAttr<SYCLIntelKernelArgsRestrictAttr>() &&
3249-
Arg->getType()->isPointerType()) ||
3262+
(Arg->getType()->isPointerType() &&
3263+
((CurCodeDecl &&
3264+
CurCodeDecl->hasAttr<SYCLIntelKernelArgsRestrictAttr>()) ||
3265+
hasSYCLRestrictPropertyIRAttr(Arg, getContext()))) ||
32503266
(Arg->hasAttr<RestrictAttr>() && Arg->getType()->isPointerType()))
32513267
AI->addAttr(llvm::Attribute::NoAlias);
32523268
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// RUN: %clang_cc1 -fsycl-is-device %s -emit-llvm -triple spir64-unknown-unknown -o - | FileCheck %s
2+
3+
struct __attribute__((sycl_special_class))
4+
[[__sycl_detail__::sycl_type(annotated_arg)]]
5+
AnnotatedIntPtr {
6+
void __init([[__sycl_detail__::add_ir_attributes_kernel_parameter(
7+
"sycl-restrict", nullptr)]]
8+
__attribute__((opencl_global)) int* InPtr) {
9+
Ptr = InPtr;
10+
}
11+
12+
int &operator[](unsigned I) const { return Ptr[I]; }
13+
14+
__attribute__((opencl_global)) int *Ptr;
15+
};
16+
17+
template <typename name, typename Func>
18+
__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) {
19+
kernelFunc();
20+
}
21+
22+
int main() {
23+
{
24+
int *a;
25+
int *b;
26+
int *c;
27+
kernel<class kernel_norestrict>([a, b, c]() { c[0] = a[0] + b[0]; });
28+
// CHECK-DAG: define {{.*}}spir_kernel {{.*}}kernel_norestrict(ptr addrspace(1) noundef align 4 %{{.*}}, ptr addrspace(1) noundef align 4 %{{.*}}, ptr addrspace(1) noundef align 4 %{{.*}})
29+
}
30+
{
31+
AnnotatedIntPtr a;
32+
int *b;
33+
int *c;
34+
kernel<class kernel_restrict1>([a, b, c]() { c[0] = a[0] + b[0]; });
35+
// CHECK-DAG: define {{.*}}spir_kernel {{.*}}kernel_restrict1(ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}, ptr addrspace(1) noundef align 4 %{{.*}}, ptr addrspace(1) noundef align 4 %{{.*}})
36+
}
37+
{
38+
int *a;
39+
AnnotatedIntPtr b;
40+
int *c;
41+
kernel<class kernel_restrict2>([a, b, c]() { c[0] = a[0] + b[0]; });
42+
// CHECK-DAG: define {{.*}}spir_kernel {{.*}}kernel_restrict2(ptr addrspace(1) noundef align 4 %{{.*}}, ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}, ptr addrspace(1) noundef align 4 %{{.*}})
43+
}
44+
{
45+
int *a;
46+
int *b;
47+
AnnotatedIntPtr c;
48+
kernel<class kernel_restrict3>([a, b, c]() { c[0] = a[0] + b[0]; });
49+
// CHECK-DAG: define {{.*}}spir_kernel {{.*}}kernel_restrict3(ptr addrspace(1) noundef align 4 %{{.*}}, ptr addrspace(1) noundef align 4 %{{.*}}, ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}})
50+
}
51+
{
52+
AnnotatedIntPtr a;
53+
AnnotatedIntPtr b;
54+
int *c;
55+
kernel<class kernel_restrict4>([a, b, c]() { c[0] = a[0] + b[0]; });
56+
// CHECK-DAG: define {{.*}}spir_kernel {{.*}}kernel_restrict4(ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}, ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}, ptr addrspace(1) noundef align 4 %{{.*}})
57+
}
58+
{
59+
AnnotatedIntPtr a;
60+
int *b;
61+
AnnotatedIntPtr c;
62+
kernel<class kernel_restrict5>([a, b, c]() { c[0] = a[0] + b[0]; });
63+
// CHECK-DAG: define {{.*}}spir_kernel {{.*}}kernel_restrict5(ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}, ptr addrspace(1) noundef align 4 %{{.*}}, ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}})
64+
}
65+
{
66+
int *a;
67+
AnnotatedIntPtr b;
68+
AnnotatedIntPtr c;
69+
kernel<class kernel_restrict6>([a, b, c]() { c[0] = a[0] + b[0]; });
70+
// CHECK-DAG: define {{.*}}spir_kernel {{.*}}kernel_restrict6(ptr addrspace(1) noundef align 4 %{{.*}}, ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}, ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}})
71+
}
72+
{
73+
AnnotatedIntPtr a;
74+
AnnotatedIntPtr b;
75+
AnnotatedIntPtr c;
76+
kernel<class kernel_restrict7>([a, b, c]() { c[0] = a[0] + b[0]; });
77+
// CHECK-DAG: define {{.*}}spir_kernel {{.*}}kernel_restrict7(ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}, ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}}, ptr addrspace(1) noalias noundef align 4 "sycl-restrict" %{{.*}})
78+
}
79+
}

devops/containers/ubuntu2204_base.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ COPY actions/cleanup /actions/cleanup
2929
COPY scripts/docker_entrypoint.sh /docker_entrypoint.sh
3030
COPY scripts/install_drivers.sh /opt/install_drivers.sh
3131

32+
USER sycl
33+
3234
ENTRYPOINT ["/docker_entrypoint.sh"]

devops/containers/ubuntu2204_build.Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ gpg --dearmor | tee /etc/apt/keyrings/rocm.gpg > /dev/null && \
2424
# Add rocm repo
2525
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/6.1.1 jammy main" \
2626
| tee --append /etc/apt/sources.list.d/rocm.list && \
27-
printf 'Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600' | tee /etc/apt/preferences.d/rocm-pin-600 && \
28-
apt update
27+
printf 'Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600' | tee /etc/apt/preferences.d/rocm-pin-600
2928
# Install the kernel driver
30-
RUN apt install -yqq rocm-dev && \
29+
RUN apt update && apt install -yqq rocm-dev && \
3130
apt-get clean && \
3231
rm -rf /var/lib/apt/lists/*
3332

@@ -42,5 +41,7 @@ RUN usermod -aG irc sycl
4241

4342
COPY scripts/docker_entrypoint.sh /docker_entrypoint.sh
4443

44+
USER sycl
45+
4546
ENTRYPOINT ["/docker_entrypoint.sh"]
4647

devops/containers/ubuntu2204_intel_drivers.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@ RUN --mount=type=secret,id=github_token \
2525

2626
COPY scripts/drivers_entrypoint.sh /drivers_entrypoint.sh
2727

28+
USER sycl
29+
2830
ENTRYPOINT ["/bin/bash", "/drivers_entrypoint.sh"]
2931

devops/containers/ubuntu2204_preinstalled.Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,16 @@ ADD sycl_linux.tar.gz /opt/sycl/
1010
ENV PATH /opt/sycl/bin:$PATH
1111
ENV LD_LIBRARY_PATH /opt/sycl/lib:$LD_LIBRARY_PATH
1212

13+
# By default Ubuntu sets an arbitrary UID value, that is different from host
14+
# system. When CI passes default UID value of 1001, some of LLVM tools fail to
15+
# discover user home directory and fail a few LIT tests. Fixes UID and GID to
16+
# 1001, that is used as default by GitHub Actions.
17+
RUN groupadd -g 1001 sycl && useradd sycl -u 1001 -g 1001 -m -s /bin/bash
18+
# Add sycl user to video/irc groups so that it can access GPU
19+
RUN usermod -aG video sycl
20+
RUN usermod -aG irc sycl
21+
22+
USER sycl
23+
1324
ENTRYPOINT ["/bin/bash", "/drivers_entrypoint.sh"]
1425

devops/containers/ubuntu2404_base.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ COPY actions/cleanup /actions/cleanup
2929
COPY scripts/docker_entrypoint.sh /docker_entrypoint.sh
3030
COPY scripts/install_drivers.sh /opt/install_drivers.sh
3131

32+
USER sycl
33+
3234
ENTRYPOINT ["/docker_entrypoint.sh"]

devops/containers/ubuntu2404_intel_drivers.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@ RUN --mount=type=secret,id=github_token \
2525

2626
COPY scripts/drivers_entrypoint.sh /drivers_entrypoint.sh
2727

28+
USER sycl
29+
2830
ENTRYPOINT ["/bin/bash", "/drivers_entrypoint.sh"]
2931

devops/containers/ubuntu2404_intel_drivers_igc_dev.Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ RUN --mount=type=secret,id=github_token \
2020

2121
COPY scripts/drivers_entrypoint.sh /drivers_entrypoint.sh
2222

23+
USER sycl
24+
2325
ENTRYPOINT ["/bin/bash", "/drivers_entrypoint.sh"]
2426

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/bin/bash
22

33
if [ -d "$GITHUB_WORKSPACE" ]; then
4-
chown -R sycl:sycl $GITHUB_WORKSPACE
5-
su sycl
4+
sudo chown -R sycl:sycl $GITHUB_WORKSPACE
65
fi
76

87
exec "$@"

0 commit comments

Comments
 (0)