Skip to content

Commit ef8b21e

Browse files
committed
Format
1 parent 100e05a commit ef8b21e

3 files changed

Lines changed: 40 additions & 34 deletions

File tree

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5917,8 +5917,8 @@ void SemaSYCL::processFreeFunctionDeclaration(const FunctionDecl *FD) {
59175917
FreeFunctionDeclarations.insert(FD->getCanonicalDecl());
59185918
}
59195919

5920-
// Handle __builtin_sycl_launch_kernel(name, launch-args...). The SYCL_EXT_ONEAPI_KERNEL_FUNCTION
5921-
// launch macro expands to
5920+
// Handle __builtin_sycl_launch_kernel(name, launch-args...). The
5921+
// SYCL_EXT_ONEAPI_KERNEL_FUNCTION launch macro expands to
59225922
//
59235923
// kernel_function<__builtin_sycl_launch_kernel(name, args...)>, args...
59245924
//
@@ -5935,9 +5935,9 @@ void SemaSYCL::processFreeFunctionDeclaration(const FunctionDecl *FD) {
59355935
ExprResult SemaSYCL::BuildSYCLLaunchKernelCall(CallExpr *TheCall) {
59365936
if (TheCall->getNumArgs() < 1) {
59375937
// The builtin needs at least the kernel-name argument. This is unreachable
5938-
// through the SYCL_EXT_ONEAPI_KERNEL_FUNCTION macro (NAME is mandatory); the
5939-
// guard only protects the getArg(0) below for a direct zero-argument call.
5940-
// Reuse the generic builtin arg-count diagnostic (as the sibling
5938+
// through the SYCL_EXT_ONEAPI_KERNEL_FUNCTION macro (NAME is mandatory);
5939+
// the guard only protects the getArg(0) below for a direct zero-argument
5940+
// call. Reuse the generic builtin arg-count diagnostic (as the sibling
59415941
// __builtin_sycl_is_kernel family does) rather than a bespoke one.
59425942
Diag(TheCall->getBeginLoc(), diag::err_builtin_invalid_argument_count) << 1;
59435943
return ExprError();
@@ -5952,11 +5952,12 @@ ExprResult SemaSYCL::BuildSYCLLaunchKernelCall(CallExpr *TheCall) {
59525952
// created this builtin call with a dependent result type and skipped custom
59535953
// type checking, so we simply return it; this handler re-runs on the
59545954
// instantiated, concrete-typed call. The deferred call keeps its BuiltinFn
5955-
// placeholder callee; the SYCL_EXT_ONEAPI_KERNEL_FUNCTION macro wraps the builtin in a unary plus
5956-
// so the enclosing kernel_function<...> NTTP argument is a UnaryOperator (a
5957-
// plain prvalue that does not recurse into this dependent CallExpr) rather
5958-
// than the CallExpr itself, which is what keeps classification off
5959-
// CallExpr::getCallReturnType and avoids a front-end crash.
5955+
// placeholder callee; the SYCL_EXT_ONEAPI_KERNEL_FUNCTION macro wraps the
5956+
// builtin in a unary plus so the enclosing kernel_function<...> NTTP argument
5957+
// is a UnaryOperator (a plain prvalue that does not recurse into this
5958+
// dependent CallExpr) rather than the CallExpr itself, which is what keeps
5959+
// classification off CallExpr::getCallReturnType and avoids a front-end
5960+
// crash.
59605961
if (KernelNameExpr->isTypeDependent() || KernelNameExpr->isValueDependent() ||
59615962
Expr::hasAnyTypeDependentArguments(LaunchArgs))
59625963
return TheCall;
@@ -5965,10 +5966,9 @@ ExprResult SemaSYCL::BuildSYCLLaunchKernelCall(CallExpr *TheCall) {
59655966
// reuses the real C++ machinery so diagnostics (no viable overload,
59665967
// ambiguity, non-deducible template parameter) are emitted at the launch
59675968
// site for free.
5968-
ExprResult Call =
5969-
SemaRef.BuildCallExpr(/*Scope=*/nullptr, KernelNameExpr,
5970-
KernelNameExpr->getBeginLoc(), LaunchArgs,
5971-
TheCall->getRParenLoc());
5969+
ExprResult Call = SemaRef.BuildCallExpr(/*Scope=*/nullptr, KernelNameExpr,
5970+
KernelNameExpr->getBeginLoc(),
5971+
LaunchArgs, TheCall->getRParenLoc());
59725972
if (Call.isInvalid())
59735973
return ExprError();
59745974

@@ -6008,9 +6008,9 @@ ExprResult SemaSYCL::BuildSYCLLaunchKernelCall(CallExpr *TheCall) {
60086008
// emitted SPIR-V kernel is therefore the real user function (no wrapper) and
60096009
// the runtime launch path is unchanged.
60106010
QualType FnPtrTy = getASTContext().getPointerType(ResolvedFn->getType());
6011-
ExprResult FnRef = SemaRef.BuildDeclRefExpr(
6012-
ResolvedFn, ResolvedFn->getType(), VK_LValue,
6013-
KernelNameExpr->getBeginLoc());
6011+
ExprResult FnRef =
6012+
SemaRef.BuildDeclRefExpr(ResolvedFn, ResolvedFn->getType(), VK_LValue,
6013+
KernelNameExpr->getBeginLoc());
60146014
if (FnRef.isInvalid())
60156015
return ExprError();
60166016
return SemaRef.ImpCastExprToType(FnRef.get(), FnPtrTy,

sycl/include/sycl/ext/oneapi/experimental/free_function_traits.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ template <typename T> struct is_device_copyable;
132132
#define SYCL_EXT_ONEAPI_KERNEL_FUNCTION_SUPPORTED 1
133133

134134
#define SYCL_EXT_ONEAPI_KERNEL_FUNCTION(NAME, ...) \
135-
::sycl::ext::oneapi::experimental::kernel_function< \
136-
+__builtin_sycl_launch_kernel(NAME, ##__VA_ARGS__)>, \
137-
##__VA_ARGS__
135+
::sycl::ext::oneapi::experimental::kernel_function<+__builtin_sycl_launch_kernel(NAME, ##__VA_ARGS__)>, ##__VA_ARGS__
138136

139137
#else
140138

sycl/test-e2e/FreeFunctionKernels/sycl_kernel_macro_launch.cpp

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
// XFAIL: target-native_cpu
99
// XFAIL-TRACKER: https://github.com/intel/llvm/issues/20142
1010

11-
// CUDA-`<<<>>>`-style bare-name launch via the SYCL_EXT_ONEAPI_KERNEL_FUNCTION macro. The existing
12-
// enqueue-function API (nd_launch / single_task taking a kernel_function<Func>
13-
// selector) is kept unchanged; SYCL_EXT_ONEAPI_KERNEL_FUNCTION(name, args...) expands to
11+
// CUDA-`<<<>>>`-style bare-name launch via the SYCL_EXT_ONEAPI_KERNEL_FUNCTION
12+
// macro. The existing enqueue-function API (nd_launch / single_task taking a
13+
// kernel_function<Func> selector) is kept unchanged;
14+
// SYCL_EXT_ONEAPI_KERNEL_FUNCTION(name, args...) expands to
1415
// kernel_function<__builtin_sycl_launch_kernel(name, args...)>, args...
1516
// so the compiler deduces the kernel's template arguments / resolves the
1617
// overload from the launch arguments while the launched SPIR-V kernel remains
@@ -38,7 +39,9 @@ void store42(int *p) { *p = 42; }
3839
// Templated single_task.
3940
template <typename T>
4041
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((syclexp::single_task_kernel))
41-
void store_one(T *p) { *p = T{1}; }
42+
void store_one(T *p) {
43+
*p = T{1};
44+
}
4245

4346
// Non-templated nd_range.
4447
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((syclexp::nd_range_kernel<1>))
@@ -90,12 +93,14 @@ void fill(float *p, float v, int n) {
9093
p[i] = v;
9194
}
9295

93-
// A SYCL_EXT_ONEAPI_KERNEL_FUNCTION launch from inside an ordinary function template, so the launch
94-
// arguments are dependent and the macro's builtin call is deferred to
95-
// instantiation (regression guard: this dependent-context use previously
96-
// crashed the front end before the builtin call was made type-dependent).
96+
// A SYCL_EXT_ONEAPI_KERNEL_FUNCTION launch from inside an ordinary function
97+
// template, so the launch arguments are dependent and the macro's builtin call
98+
// is deferred to instantiation (regression guard: this dependent-context use
99+
// previously crashed the front end before the builtin call was made
100+
// type-dependent).
97101
template <typename T>
98-
void run_axpy(sycl::queue q, sycl::nd_range<1> r, T *y, const T *x, T a, int n) {
102+
void run_axpy(sycl::queue q, sycl::nd_range<1> r, T *y, const T *x, T a,
103+
int n) {
99104
syclexp::nd_launch(q, r, SYCL_EXT_ONEAPI_KERNEL_FUNCTION(axpy, y, x, a, n));
100105
}
101106

@@ -147,8 +152,8 @@ int main() {
147152
for (int i = 0; i < N; ++i)
148153
assert(y[i] == a * static_cast<float>(i) + 1.0f);
149154

150-
// Zero launch arguments: SYCL_EXT_ONEAPI_KERNEL_FUNCTION(tick) must expand without a dangling
151-
// comma and launch cleanly.
155+
// Zero launch arguments: SYCL_EXT_ONEAPI_KERNEL_FUNCTION(tick) must expand
156+
// without a dangling comma and launch cleanly.
152157
syclexp::single_task(q, SYCL_EXT_ONEAPI_KERNEL_FUNCTION(tick));
153158
q.wait();
154159

@@ -158,7 +163,8 @@ int main() {
158163
// general).
159164
for (int i = 0; i < N; ++i)
160165
y[i] = 0.0f;
161-
syclexp::nd_launch(q, r, SYCL_EXT_ONEAPI_KERNEL_FUNCTION((fill_val<1>), y, 7.0f, N));
166+
syclexp::nd_launch(
167+
q, r, SYCL_EXT_ONEAPI_KERNEL_FUNCTION((fill_val<1>), y, 7.0f, N));
162168
q.wait();
163169
for (int i = 0; i < N; ++i)
164170
assert(y[i] == 7.0f);
@@ -191,7 +197,8 @@ int main() {
191197
for (int i = 0; i < N; ++i)
192198
y[i] = 2.0f;
193199
syclexp::submit(q, [&](sycl::handler &h) {
194-
syclexp::nd_launch(h, r, SYCL_EXT_ONEAPI_KERNEL_FUNCTION(scale, y, 3.0f, N));
200+
syclexp::nd_launch(h, r,
201+
SYCL_EXT_ONEAPI_KERNEL_FUNCTION(scale, y, 3.0f, N));
195202
});
196203
q.wait();
197204
for (int i = 0; i < N; ++i)
@@ -201,7 +208,8 @@ int main() {
201208
for (int i = 0; i < N; ++i)
202209
y[i] = 2.0f;
203210
syclexp::launch_config<sycl::nd_range<1>> cfg{r};
204-
syclexp::nd_launch(q, cfg, SYCL_EXT_ONEAPI_KERNEL_FUNCTION(scale, y, 4.0f, N));
211+
syclexp::nd_launch(q, cfg,
212+
SYCL_EXT_ONEAPI_KERNEL_FUNCTION(scale, y, 4.0f, N));
205213
q.wait();
206214
for (int i = 0; i < N; ++i)
207215
assert(y[i] == 8.0f);

0 commit comments

Comments
 (0)