Skip to content

Commit 2d7c6b7

Browse files
committed
[SYCL] Rename SYCLKernel and "kernel wrapper" with OpenCLKernel
Signed-off-by: Mariya Podchishchaeva <[email protected]>
1 parent a5944b4 commit 2d7c6b7

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11266,7 +11266,7 @@ class Sema {
1126611266
return *SyclIntHeader.get();
1126711267
}
1126811268

11269-
void ConstructSYCLKernel(FunctionDecl *KernelCallerFunc);
11269+
void ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc);
1127011270
void MarkDevice(void);
1127111271
};
1127211272

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ class KernelBodyTransform : public TreeTransform<KernelBodyTransform> {
397397
};
398398

399399
static FunctionDecl *
400-
CreateSYCLKernelDeclaration(ASTContext &Context, StringRef Name,
400+
CreateOpenCLKernelDeclaration(ASTContext &Context, StringRef Name,
401401
ArrayRef<ParamDesc> ParamDescs) {
402402

403403
DeclContext *DC = Context.getTranslationUnitDecl();
@@ -412,30 +412,30 @@ CreateSYCLKernelDeclaration(ASTContext &Context, StringRef Name,
412412
QualType FuncTy = Context.getFunctionType(RetTy, ArgTys, Info);
413413
DeclarationName DN = DeclarationName(&Context.Idents.get(Name));
414414

415-
FunctionDecl *SYCLKernel = FunctionDecl::Create(
415+
FunctionDecl *OpenCLKernel = FunctionDecl::Create(
416416
Context, DC, SourceLocation(), SourceLocation(), DN, FuncTy,
417417
Context.getTrivialTypeSourceInfo(RetTy), SC_None);
418418

419419
llvm::SmallVector<ParmVarDecl *, 16> Params;
420420
int i = 0;
421421
for (const auto &PD : ParamDescs) {
422-
auto P = ParmVarDecl::Create(Context, SYCLKernel, SourceLocation(),
422+
auto P = ParmVarDecl::Create(Context, OpenCLKernel, SourceLocation(),
423423
SourceLocation(), std::get<1>(PD),
424424
std::get<0>(PD), std::get<2>(PD), SC_None, 0);
425425
P->setScopeInfo(0, i++);
426426
P->setIsUsed();
427427
Params.push_back(P);
428428
}
429-
SYCLKernel->setParams(Params);
429+
OpenCLKernel->setParams(Params);
430430

431-
SYCLKernel->addAttr(SYCLDeviceAttr::CreateImplicit(Context));
432-
SYCLKernel->addAttr(OpenCLKernelAttr::CreateImplicit(Context));
433-
SYCLKernel->addAttr(AsmLabelAttr::CreateImplicit(Context, Name));
434-
SYCLKernel->addAttr(ArtificialAttr::CreateImplicit(Context));
431+
OpenCLKernel->addAttr(SYCLDeviceAttr::CreateImplicit(Context));
432+
OpenCLKernel->addAttr(OpenCLKernelAttr::CreateImplicit(Context));
433+
OpenCLKernel->addAttr(AsmLabelAttr::CreateImplicit(Context, Name));
434+
OpenCLKernel->addAttr(ArtificialAttr::CreateImplicit(Context));
435435

436436
// Add kernel to translation unit to see it in AST-dump
437-
DC->addDecl(SYCLKernel);
438-
return SYCLKernel;
437+
DC->addDecl(OpenCLKernel);
438+
return OpenCLKernel;
439439
}
440440
/// Return __init method
441441
static CXXMethodDecl *getInitMethod(const CXXRecordDecl *CRD) {
@@ -448,12 +448,12 @@ static CXXMethodDecl *getInitMethod(const CXXRecordDecl *CRD) {
448448
return InitMethod;
449449
}
450450

451-
// Creates body for new SYCL kernel. This body contains initialization of kernel
452-
// object fields with kernel parameters and a little bit transformed body of the
453-
// kernel caller function.
454-
static CompoundStmt *CreateSYCLKernelBody(Sema &S,
455-
FunctionDecl *KernelCallerFunc,
456-
DeclContext *KernelDecl) {
451+
// Creates body for new OpenCL kernel. This body contains initialization of SYCL
452+
// kernel object fields with kernel parameters and a little bit transformed body
453+
// of the kernel caller function.
454+
static CompoundStmt *CreateOpenCLKernelBody(Sema &S,
455+
FunctionDecl *KernelCallerFunc,
456+
DeclContext *KernelDecl) {
457457
llvm::SmallVector<Stmt *, 16> BodyStmts;
458458
CXXRecordDecl *LC = getKernelObjectType(KernelCallerFunc);
459459
assert(LC && "Kernel object must be available");
@@ -882,13 +882,13 @@ static std::string constructKernelName(QualType KernelNameType,
882882
return Out.str();
883883
}
884884

885-
// Generates the "kernel wrapper" using KernelCallerFunc (kernel caller
885+
// Generates the OpenCL kernel using KernelCallerFunc (kernel caller
886886
// function) defined is SYCL headers.
887-
// A "kernel wrapper" function contains the body of the kernel caller function,
887+
// Generated OpenCL kernel contains the body of the kernel caller function,
888888
// receives OpenCL like parameters and additionally does some manipulation to
889889
// initialize captured lambda/functor fields with these parameters.
890890
// SYCL runtime marks kernel caller function with sycl_kernel attribute.
891-
// To be able to generate "kernel wrapper" from KernelCallerFunc we put
891+
// To be able to generate OpenCL kernel from KernelCallerFunc we put
892892
// the following requirements to the function which SYCL runtime can mark with
893893
// sycl_kernel attribute:
894894
// - Must be template function with at least two template parameters.
@@ -903,9 +903,8 @@ static std::string constructKernelName(QualType KernelNameType,
903903
// KernelFuncObj();
904904
// }
905905
//
906-
// In the code below we call "kernel wrapper" SYCLKernel.
907906
//
908-
void Sema::ConstructSYCLKernel(FunctionDecl *KernelCallerFunc) {
907+
void Sema::ConstructOpenCLKernel(FunctionDecl *KernelCallerFunc) {
909908
CXXRecordDecl *LE = getKernelObjectType(KernelCallerFunc);
910909
assert(LE && "invalid kernel caller");
911910

@@ -924,16 +923,16 @@ void Sema::ConstructSYCLKernel(FunctionDecl *KernelCallerFunc) {
924923
// TODO Maybe don't emit integration header inside the Sema?
925924
populateIntHeader(getSyclIntegrationHeader(), Name, KernelNameType, LE);
926925

927-
FunctionDecl *SYCLKernel =
928-
CreateSYCLKernelDeclaration(getASTContext(), Name, ParamDescs);
926+
FunctionDecl *OpenCLKernel =
927+
CreateOpenCLKernelDeclaration(getASTContext(), Name, ParamDescs);
929928

930929
// Let's copy source location of a functor/lambda to emit nicer diagnostics
931-
SYCLKernel->setLocation(LE->getLocation());
930+
OpenCLKernel->setLocation(LE->getLocation());
932931

933-
CompoundStmt *SYCLKernelBody =
934-
CreateSYCLKernelBody(*this, KernelCallerFunc, SYCLKernel);
935-
SYCLKernel->setBody(SYCLKernelBody);
936-
AddSyclKernel(SYCLKernel);
932+
CompoundStmt *OpenCLKernelBody =
933+
CreateOpenCLKernelBody(*this, KernelCallerFunc, OpenCLKernel);
934+
OpenCLKernel->setBody(OpenCLKernelBody);
935+
AddSyclKernel(OpenCLKernel);
937936
}
938937

939938
void Sema::MarkDevice(void) {

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5523,7 +5523,7 @@ void Sema::PerformPendingInstantiations(bool LocalOnly) {
55235523
// so we are checking for SYCL kernel attribute after instantination.
55245524
if (getLangOpts().SYCLIsDevice &&
55255525
CurFD->hasAttr<SYCLKernelAttr>()) {
5526-
ConstructSYCLKernel(CurFD);
5526+
ConstructOpenCLKernel(CurFD);
55275527
}
55285528
CurFD->setInstantiationIsPending(false);
55295529
}
@@ -5537,7 +5537,7 @@ void Sema::PerformPendingInstantiations(bool LocalOnly) {
55375537
// so we are checking for SYCL kernel attribute after instantination.
55385538
if (getLangOpts().SYCLIsDevice &&
55395539
Function->hasAttr<SYCLKernelAttr>()) {
5540-
ConstructSYCLKernel(Function);
5540+
ConstructOpenCLKernel(Function);
55415541
}
55425542
Function->setInstantiationIsPending(false);
55435543
}

0 commit comments

Comments
 (0)