Skip to content

Commit 644b0e9

Browse files
committed
Formatting
1 parent 3946878 commit 644b0e9

File tree

7 files changed

+142
-132
lines changed

7 files changed

+142
-132
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 123 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -4708,9 +4708,8 @@ class FreeFunctionKernelBodyCreator : public SyclKernelFieldHandler {
47084708

47094709
bool leaveStruct(const CXXRecordDecl *, ParmVarDecl *, QualType) final {
47104710
ArgExprs.push_back(SemaSYCLRef.SemaRef.BuildDeclRefExpr(
4711-
DeclCreator.getParentStruct(),
4712-
DeclCreator.getParentStruct()->getType(), VK_PRValue,
4713-
FreeFunctionSrcLoc));
4711+
DeclCreator.getParentStruct(), DeclCreator.getParentStruct()->getType(),
4712+
VK_PRValue, FreeFunctionSrcLoc));
47144713
return true;
47154714
}
47164715

@@ -4803,8 +4802,8 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
48034802
void addParam(const ParmVarDecl *PD, QualType ParamTy,
48044803
SYCLIntegrationHeader::kernel_param_kind_t Kind) {
48054804
addParam(ParamTy, Kind, offsetOf(PD, ParamTy));
4806-
//CurOffset +=
4807-
// SemaSYCLRef.getASTContext().getTypeSizeInChars(ParamTy).getQuantity();
4805+
// CurOffset +=
4806+
// SemaSYCLRef.getASTContext().getTypeSizeInChars(ParamTy).getQuantity();
48084807
}
48094808

48104809
void addParam(QualType ParamTy,
@@ -4965,149 +4964,148 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
49654964
return true;
49664965
}
49674966

4968-
bool handlePointerType(FieldDecl * FD, QualType FieldTy) final {
4969-
addParam(FD, FieldTy,
4970-
((StructDepth) ? SYCLIntegrationHeader::kind_std_layout
4971-
: SYCLIntegrationHeader::kind_pointer));
4972-
return true;
4973-
}
4967+
bool handlePointerType(FieldDecl *FD, QualType FieldTy) final {
4968+
addParam(FD, FieldTy,
4969+
((StructDepth) ? SYCLIntegrationHeader::kind_std_layout
4970+
: SYCLIntegrationHeader::kind_pointer));
4971+
return true;
4972+
}
49744973

4975-
bool handlePointerType(ParmVarDecl * PD, QualType ParamTy) final {
4976-
addParam(PD, ParamTy, SYCLIntegrationHeader::kind_pointer);
4977-
return true;
4978-
}
4974+
bool handlePointerType(ParmVarDecl *PD, QualType ParamTy) final {
4975+
addParam(PD, ParamTy, SYCLIntegrationHeader::kind_pointer);
4976+
return true;
4977+
}
49794978

4980-
bool handleScalarType(FieldDecl * FD, QualType FieldTy) final {
4981-
addParam(FD, FieldTy, SYCLIntegrationHeader::kind_std_layout);
4982-
return true;
4983-
}
4979+
bool handleScalarType(FieldDecl *FD, QualType FieldTy) final {
4980+
addParam(FD, FieldTy, SYCLIntegrationHeader::kind_std_layout);
4981+
return true;
4982+
}
49844983

4985-
bool handleScalarType(ParmVarDecl * PD, QualType ParamTy) final {
4986-
addParam(PD, ParamTy, SYCLIntegrationHeader::kind_std_layout);
4987-
return true;
4988-
}
4984+
bool handleScalarType(ParmVarDecl *PD, QualType ParamTy) final {
4985+
addParam(PD, ParamTy, SYCLIntegrationHeader::kind_std_layout);
4986+
return true;
4987+
}
49894988

4990-
bool handleSimpleArrayType(FieldDecl * FD, QualType FieldTy) final {
4991-
// Arrays are always wrapped inside of structs, so just treat it as a
4992-
// simple struct.
4993-
addParam(FD, FieldTy, SYCLIntegrationHeader::kind_std_layout);
4994-
return true;
4995-
}
4989+
bool handleSimpleArrayType(FieldDecl *FD, QualType FieldTy) final {
4990+
// Arrays are always wrapped inside of structs, so just treat it as a
4991+
// simple struct.
4992+
addParam(FD, FieldTy, SYCLIntegrationHeader::kind_std_layout);
4993+
return true;
4994+
}
49964995

4997-
bool handleTopLevelStruct(const CXXRecordDecl *, QualType Ty) final {
4998-
addParam(Ty, SYCLIntegrationHeader::kind_std_layout, /*Offset=*/0);
4999-
return true;
5000-
}
4996+
bool handleTopLevelStruct(const CXXRecordDecl *, QualType Ty) final {
4997+
addParam(Ty, SYCLIntegrationHeader::kind_std_layout, /*Offset=*/0);
4998+
return true;
4999+
}
50015000

5002-
bool handleNonDecompStruct(const CXXRecordDecl *, FieldDecl *FD,
5003-
QualType Ty) final {
5004-
addParam(FD, Ty, SYCLIntegrationHeader::kind_std_layout);
5005-
return true;
5006-
}
5001+
bool handleNonDecompStruct(const CXXRecordDecl *, FieldDecl *FD,
5002+
QualType Ty) final {
5003+
addParam(FD, Ty, SYCLIntegrationHeader::kind_std_layout);
5004+
return true;
5005+
}
50075006

5008-
bool handleNonDecompStruct(const CXXRecordDecl *, ParmVarDecl *PD,
5009-
QualType ParamTy) final {
5010-
addParam(PD, ParamTy, SYCLIntegrationHeader::kind_std_layout);
5011-
return true;
5012-
}
5007+
bool handleNonDecompStruct(const CXXRecordDecl *, ParmVarDecl *PD,
5008+
QualType ParamTy) final {
5009+
addParam(PD, ParamTy, SYCLIntegrationHeader::kind_std_layout);
5010+
return true;
5011+
}
50135012

5014-
bool handleNonDecompStruct(const CXXRecordDecl *Base,
5015-
const CXXBaseSpecifier &, QualType Ty) final {
5016-
addParam(Ty, SYCLIntegrationHeader::kind_std_layout,
5017-
offsetOf(Base, Ty->getAsCXXRecordDecl()));
5018-
return true;
5019-
}
5013+
bool handleNonDecompStruct(const CXXRecordDecl *Base,
5014+
const CXXBaseSpecifier &, QualType Ty) final {
5015+
addParam(Ty, SYCLIntegrationHeader::kind_std_layout,
5016+
offsetOf(Base, Ty->getAsCXXRecordDecl()));
5017+
return true;
5018+
}
50205019

5021-
bool handleUnionType(FieldDecl * FD, QualType FieldTy) final {
5022-
return handleScalarType(FD, FieldTy);
5023-
}
5020+
bool handleUnionType(FieldDecl *FD, QualType FieldTy) final {
5021+
return handleScalarType(FD, FieldTy);
5022+
}
50245023

5025-
bool handleUnionType(ParmVarDecl *, QualType) final {
5026-
// TODO
5027-
unsupportedFreeFunctionParamType();
5028-
return true;
5029-
}
5024+
bool handleUnionType(ParmVarDecl *, QualType) final {
5025+
// TODO
5026+
unsupportedFreeFunctionParamType();
5027+
return true;
5028+
}
50305029

5031-
void handleSyclKernelHandlerType(QualType) {
5032-
// The compiler generated kernel argument used to initialize SYCL 2020
5033-
// specialization constants, `specialization_constants_buffer`, should
5034-
// have corresponding entry in integration header.
5035-
ASTContext &Context = SemaSYCLRef.getASTContext();
5036-
// Offset is zero since kernel_handler argument is not part of
5037-
// kernel object (i.e. it is not captured)
5038-
addParam(Context.getPointerType(Context.CharTy),
5039-
SYCLIntegrationHeader::kind_specialization_constants_buffer, 0);
5040-
}
5030+
void handleSyclKernelHandlerType(QualType) {
5031+
// The compiler generated kernel argument used to initialize SYCL 2020
5032+
// specialization constants, `specialization_constants_buffer`, should
5033+
// have corresponding entry in integration header.
5034+
ASTContext &Context = SemaSYCLRef.getASTContext();
5035+
// Offset is zero since kernel_handler argument is not part of
5036+
// kernel object (i.e. it is not captured)
5037+
addParam(Context.getPointerType(Context.CharTy),
5038+
SYCLIntegrationHeader::kind_specialization_constants_buffer, 0);
5039+
}
50415040

5042-
bool enterStruct(const CXXRecordDecl *, FieldDecl *FD, QualType Ty) final {
5043-
++StructDepth;
5044-
CurOffset += offsetOf(FD, Ty);
5045-
return true;
5046-
}
5041+
bool enterStruct(const CXXRecordDecl *, FieldDecl *FD, QualType Ty) final {
5042+
++StructDepth;
5043+
CurOffset += offsetOf(FD, Ty);
5044+
return true;
5045+
}
50475046

5048-
bool enterStruct(const CXXRecordDecl *, ParmVarDecl *PD,
5049-
QualType Ty) final {
5050-
addParam(PD, Ty, SYCLIntegrationHeader::kind_struct_with_special_type);
5051-
Header.setParentStruct(PD);
5052-
return true;
5053-
}
5047+
bool enterStruct(const CXXRecordDecl *, ParmVarDecl *PD, QualType Ty) final {
5048+
addParam(PD, Ty, SYCLIntegrationHeader::kind_struct_with_special_type);
5049+
Header.setParentStruct(PD);
5050+
return true;
5051+
}
50545052

5055-
bool leaveStruct(const CXXRecordDecl *, FieldDecl *FD, QualType Ty) final {
5056-
--StructDepth;
5057-
CurOffset -= offsetOf(FD, Ty);
5058-
return true;
5059-
}
5053+
bool leaveStruct(const CXXRecordDecl *, FieldDecl *FD, QualType Ty) final {
5054+
--StructDepth;
5055+
CurOffset -= offsetOf(FD, Ty);
5056+
return true;
5057+
}
50605058

5061-
bool leaveStruct(const CXXRecordDecl *, ParmVarDecl *, QualType) final {
5062-
Header.setParentStruct(nullptr);
5063-
return true;
5064-
}
5059+
bool leaveStruct(const CXXRecordDecl *, ParmVarDecl *, QualType) final {
5060+
Header.setParentStruct(nullptr);
5061+
return true;
5062+
}
50655063

5066-
bool enterStruct(const CXXRecordDecl *RD, const CXXBaseSpecifier &BS,
5067-
QualType) final {
5068-
CurOffset += offsetOf(RD, BS.getType()->getAsCXXRecordDecl());
5069-
return true;
5070-
}
5064+
bool enterStruct(const CXXRecordDecl *RD, const CXXBaseSpecifier &BS,
5065+
QualType) final {
5066+
CurOffset += offsetOf(RD, BS.getType()->getAsCXXRecordDecl());
5067+
return true;
5068+
}
50715069

5072-
bool leaveStruct(const CXXRecordDecl *RD, const CXXBaseSpecifier &BS,
5073-
QualType) final {
5074-
CurOffset -= offsetOf(RD, BS.getType()->getAsCXXRecordDecl());
5075-
return true;
5076-
}
5070+
bool leaveStruct(const CXXRecordDecl *RD, const CXXBaseSpecifier &BS,
5071+
QualType) final {
5072+
CurOffset -= offsetOf(RD, BS.getType()->getAsCXXRecordDecl());
5073+
return true;
5074+
}
50775075

5078-
bool enterArray(FieldDecl * FD, QualType ArrayTy, QualType) final {
5079-
ArrayBaseOffsets.push_back(CurOffset + offsetOf(FD, ArrayTy));
5080-
return true;
5081-
}
5076+
bool enterArray(FieldDecl *FD, QualType ArrayTy, QualType) final {
5077+
ArrayBaseOffsets.push_back(CurOffset + offsetOf(FD, ArrayTy));
5078+
return true;
5079+
}
50825080

5083-
bool enterArray(ParmVarDecl *, QualType, QualType) final {
5084-
// TODO
5085-
unsupportedFreeFunctionParamType();
5086-
return true;
5087-
}
5081+
bool enterArray(ParmVarDecl *, QualType, QualType) final {
5082+
// TODO
5083+
unsupportedFreeFunctionParamType();
5084+
return true;
5085+
}
50885086

5089-
bool nextElement(QualType ET, uint64_t Index) final {
5090-
int64_t Size =
5091-
SemaSYCLRef.getASTContext().getTypeSizeInChars(ET).getQuantity();
5092-
CurOffset = ArrayBaseOffsets.back() + Size * Index;
5093-
return true;
5094-
}
5087+
bool nextElement(QualType ET, uint64_t Index) final {
5088+
int64_t Size =
5089+
SemaSYCLRef.getASTContext().getTypeSizeInChars(ET).getQuantity();
5090+
CurOffset = ArrayBaseOffsets.back() + Size * Index;
5091+
return true;
5092+
}
50955093

5096-
bool leaveArray(FieldDecl * FD, QualType ArrayTy, QualType) final {
5097-
CurOffset = ArrayBaseOffsets.pop_back_val();
5098-
CurOffset -= offsetOf(FD, ArrayTy);
5099-
return true;
5100-
}
5094+
bool leaveArray(FieldDecl *FD, QualType ArrayTy, QualType) final {
5095+
CurOffset = ArrayBaseOffsets.pop_back_val();
5096+
CurOffset -= offsetOf(FD, ArrayTy);
5097+
return true;
5098+
}
51015099

5102-
bool leaveArray(ParmVarDecl *, QualType, QualType) final {
5103-
// TODO
5104-
unsupportedFreeFunctionParamType();
5105-
return true;
5106-
}
5100+
bool leaveArray(ParmVarDecl *, QualType, QualType) final {
5101+
// TODO
5102+
unsupportedFreeFunctionParamType();
5103+
return true;
5104+
}
51075105

5108-
using SyclKernelFieldHandler::enterStruct;
5109-
using SyclKernelFieldHandler::leaveStruct;
5110-
};
5106+
using SyclKernelFieldHandler::enterStruct;
5107+
using SyclKernelFieldHandler::leaveStruct;
5108+
};
51115109

51125110
class SyclKernelIntFooterCreator : public SyclKernelFieldHandler {
51135111
SYCLIntegrationFooter &Footer;

sycl/include/sycl/detail/kernel_desc.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ enum class kernel_param_kind_t {
6262
kind_dynamic_work_group_memory = 7,
6363
kind_dynamic_accessor = 8,
6464
kind_struct_with_special_type = 9, // structs that contain special types
65-
kind_invalid = 0xf, // not a valid kernel kind
65+
kind_invalid = 0xf, // not a valid kernel kind
6666
};
6767

6868
// describes a kernel parameter

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//===----------------------------------------------------------------------===//
88

99
#pragma once
10-
#include <type_traits>
1110
#include <sycl/detail/kernel_desc.hpp>
11+
#include <type_traits>
1212

1313
namespace sycl {
1414
inline namespace _V1 {

sycl/include/sycl/handler.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3660,14 +3660,14 @@ class __SYCL_EXPORT handler {
36603660

36613661
void addArg(detail::kernel_param_kind_t ArgKind, void *Req, int AccessTarget,
36623662
int ArgIndex);
3663-
3663+
36643664
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
36653665
// TODO: remove in the next ABI-breaking window
36663666
void clearArgs();
36673667
#endif
36683668

36693669
void incrementArgShift(int);
3670-
3670+
36713671
void setArgsToAssociatedAccessors();
36723672

36733673
bool HasAssociatedAccessor(detail::AccessorImplHost *Req,

sycl/source/detail/handler_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class handler_impl {
141141

142142
/// The list of arguments for the kernel.
143143
std::vector<detail::ArgDesc> MArgs;
144-
144+
145145
/// The list of associated accessors with this handler.
146146
/// These accessors were created with this handler as argument or
147147
/// have become required for this handler via require method.

sycl/source/detail/kernel_data.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ class KernelData {
181181

182182
void extractArgsAndReqsFromLambda();
183183

184+
void incrementArgShift(int Shift) { MArgShift += Shift; }
185+
184186
private:
185187
// Storage for any SYCL Graph dynamic parameters which have been flagged for
186188
// registration in the CG, along with the argument index for the parameter.
@@ -204,6 +206,14 @@ class KernelData {
204206
// A pointer to device kernel information. Cached on the application side in
205207
// headers or retrieved from program manager.
206208
DeviceKernelInfo *MDeviceKernelInfoPtr = nullptr;
209+
210+
// Certain arguments such as structs that contain SYCL special types entail
211+
// several hidden set_arg calls for every set_arg called by the user. This
212+
// shift is required to make sure the following arguments set by the user have
213+
// the correct index. It keeps track of how many of these hidden set_arg calls
214+
// have been made so far. The user cannot possibly know this, hence we need to
215+
// keep track of this information.
216+
int MArgShift = 0;
207217
};
208218

209219
} // namespace detail

sycl/source/handler.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,8 +2248,10 @@ void handler::addArg(detail::kernel_param_kind_t ArgKind, void *Req,
22482248
impl->MKernelData.addArg(ArgKind, Req, AccessTarget, ArgIndex);
22492249
}
22502250

2251-
void handler::incrementArgShift(int Shift) { impl->MKernelData.incrementArgShift(Shift); }
2252-
2251+
void handler::incrementArgShift(int Shift) {
2252+
impl->MKernelData.incrementArgShift(Shift);
2253+
}
2254+
22532255
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
22542256
void handler::clearArgs() { impl->MKernelData.clearArgs(); }
22552257
#endif

0 commit comments

Comments
 (0)