Skip to content

Commit 1419415

Browse files
[SYCL] Fix name collisions in SYCL enums (#4154)
Correcting the definition of some macros causes name collisions if they are defined prior to including of CL/sycl.hpp.
1 parent 09715f6 commit 1419415

File tree

15 files changed

+174
-145
lines changed

15 files changed

+174
-145
lines changed

sycl/include/CL/sycl/detail/buffer_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class __SYCL_EXPORT buffer_impl final : public SYCLMemObjT {
147147
void *allocateMem(ContextImplPtr Context, bool InitFromUserData,
148148
void *HostPtr, RT::PiEvent &OutEventToWait) override;
149149

150-
MemObjType getType() const override { return MemObjType::BUFFER; }
150+
MemObjType getType() const override { return MemObjType::Buffer; }
151151

152152
~buffer_impl() {
153153
try {

sycl/include/CL/sycl/detail/cg.hpp

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -149,26 +149,26 @@ class CG {
149149
};
150150

151151
/// Type of the command group.
152-
enum CGTYPE : unsigned int {
153-
NONE = 0,
154-
KERNEL = 1,
155-
COPY_ACC_TO_PTR = 2,
156-
COPY_PTR_TO_ACC = 3,
157-
COPY_ACC_TO_ACC = 4,
158-
BARRIER = 5,
159-
BARRIER_WAITLIST = 6,
160-
FILL = 7,
161-
UPDATE_HOST = 8,
162-
RUN_ON_HOST_INTEL = 9,
163-
COPY_USM = 10,
164-
FILL_USM = 11,
165-
PREFETCH_USM = 12,
166-
CODEPLAY_INTEROP_TASK = 13,
167-
CODEPLAY_HOST_TASK = 14,
168-
ADVISE_USM = 15,
152+
enum CGType : unsigned int {
153+
None = 0,
154+
Kernel = 1,
155+
CopyAccToPtr = 2,
156+
CopyPtrToAcc = 3,
157+
CopyAccToAcc = 4,
158+
Barrier = 5,
159+
BarrierWaitlist = 6,
160+
Fill = 7,
161+
UpdateHost = 8,
162+
RunOnHostIntel = 9,
163+
CopyUSM = 10,
164+
FillUSM = 11,
165+
PrefetchUSM = 12,
166+
CodeplayInteropTask = 13,
167+
CodeplayHostTask = 14,
168+
AdviseUSM = 15,
169169
};
170170

171-
CG(CGTYPE Type, std::vector<std::vector<char>> ArgsStorage,
171+
CG(CGType Type, std::vector<std::vector<char>> ArgsStorage,
172172
std::vector<detail::AccessorImplPtr> AccStorage,
173173
std::vector<std::shared_ptr<const void>> SharedPtrStorage,
174174
std::vector<Requirement *> Requirements,
@@ -190,7 +190,7 @@ class CG {
190190

191191
CG(CG &&CommandGroup) = default;
192192

193-
CGTYPE getType() { return static_cast<CGTYPE>(getUnversionedCGType(MType)); }
193+
CGType getType() { return static_cast<CGType>(getUnversionedCGType(MType)); }
194194

195195
CG_VERSION getVersion() {
196196
return static_cast<CG_VERSION>(getCGTypeVersion(MType));
@@ -209,7 +209,7 @@ class CG {
209209
virtual ~CG() = default;
210210

211211
private:
212-
CGTYPE MType;
212+
CGType MType;
213213
// The following storages are needed to ensure that arguments won't die while
214214
// we are using them.
215215
/// Storage for standard layout arguments.
@@ -255,16 +255,17 @@ class CGExecKernel : public CG {
255255
std::vector<ArgDesc> Args, std::string KernelName,
256256
detail::OSModuleHandle OSModuleHandle,
257257
std::vector<std::shared_ptr<detail::stream_impl>> Streams,
258-
CGTYPE Type, detail::code_location loc = {})
258+
CGType Type, detail::code_location loc = {})
259259
: CG(Type, std::move(ArgsStorage), std::move(AccStorage),
260260
std::move(SharedPtrStorage), std::move(Requirements),
261261
std::move(Events), std::move(loc)),
262262
MNDRDesc(std::move(NDRDesc)), MHostKernel(std::move(HKernel)),
263263
MSyclKernel(std::move(SyclKernel)), MArgs(std::move(Args)),
264264
MKernelName(std::move(KernelName)), MOSModuleHandle(OSModuleHandle),
265265
MStreams(std::move(Streams)) {
266-
assert((getType() == RUN_ON_HOST_INTEL || getType() == KERNEL) &&
267-
"Wrong type of exec kernel CG.");
266+
assert(
267+
(getType() == CGType::RunOnHostIntel || getType() == CGType::Kernel) &&
268+
"Wrong type of exec kernel CG.");
268269
}
269270

270271
std::vector<ArgDesc> getArguments() const { return MArgs; }
@@ -294,7 +295,7 @@ class CGCopy : public CG {
294295
void *MDst;
295296

296297
public:
297-
CGCopy(CGTYPE CopyType, void *Src, void *Dst,
298+
CGCopy(CGType CopyType, void *Src, void *Dst,
298299
std::vector<std::vector<char>> ArgsStorage,
299300
std::vector<detail::AccessorImplPtr> AccStorage,
300301
std::vector<std::shared_ptr<const void>> SharedPtrStorage,
@@ -322,7 +323,7 @@ class CGFill : public CG {
322323
std::vector<Requirement *> Requirements,
323324
std::vector<detail::EventImplPtr> Events,
324325
detail::code_location loc = {})
325-
: CG(FILL, std::move(ArgsStorage), std::move(AccStorage),
326+
: CG(CGType::Fill, std::move(ArgsStorage), std::move(AccStorage),
326327
std::move(SharedPtrStorage), std::move(Requirements),
327328
std::move(Events), std::move(loc)),
328329
MPattern(std::move(Pattern)), MPtr((Requirement *)Ptr) {}
@@ -340,7 +341,7 @@ class CGUpdateHost : public CG {
340341
std::vector<Requirement *> Requirements,
341342
std::vector<detail::EventImplPtr> Events,
342343
detail::code_location loc = {})
343-
: CG(UPDATE_HOST, std::move(ArgsStorage), std::move(AccStorage),
344+
: CG(CGType::UpdateHost, std::move(ArgsStorage), std::move(AccStorage),
344345
std::move(SharedPtrStorage), std::move(Requirements),
345346
std::move(Events), std::move(loc)),
346347
MPtr((Requirement *)Ptr) {}
@@ -362,7 +363,7 @@ class CGCopyUSM : public CG {
362363
std::vector<Requirement *> Requirements,
363364
std::vector<detail::EventImplPtr> Events,
364365
detail::code_location loc = {})
365-
: CG(COPY_USM, std::move(ArgsStorage), std::move(AccStorage),
366+
: CG(CGType::CopyUSM, std::move(ArgsStorage), std::move(AccStorage),
366367
std::move(SharedPtrStorage), std::move(Requirements),
367368
std::move(Events), std::move(loc)),
368369
MSrc(Src), MDst(Dst), MLength(Length) {}
@@ -386,7 +387,7 @@ class CGFillUSM : public CG {
386387
std::vector<Requirement *> Requirements,
387388
std::vector<detail::EventImplPtr> Events,
388389
detail::code_location loc = {})
389-
: CG(FILL_USM, std::move(ArgsStorage), std::move(AccStorage),
390+
: CG(CGType::FillUSM, std::move(ArgsStorage), std::move(AccStorage),
390391
std::move(SharedPtrStorage), std::move(Requirements),
391392
std::move(Events), std::move(loc)),
392393
MPattern(std::move(Pattern)), MDst(DstPtr), MLength(Length) {}
@@ -408,7 +409,7 @@ class CGPrefetchUSM : public CG {
408409
std::vector<Requirement *> Requirements,
409410
std::vector<detail::EventImplPtr> Events,
410411
detail::code_location loc = {})
411-
: CG(PREFETCH_USM, std::move(ArgsStorage), std::move(AccStorage),
412+
: CG(CGType::PrefetchUSM, std::move(ArgsStorage), std::move(AccStorage),
412413
std::move(SharedPtrStorage), std::move(Requirements),
413414
std::move(Events), std::move(loc)),
414415
MDst(DstPtr), MLength(Length) {}
@@ -427,7 +428,7 @@ class CGAdviseUSM : public CG {
427428
std::vector<detail::AccessorImplPtr> AccStorage,
428429
std::vector<std::shared_ptr<const void>> SharedPtrStorage,
429430
std::vector<Requirement *> Requirements,
430-
std::vector<detail::EventImplPtr> Events, CGTYPE Type,
431+
std::vector<detail::EventImplPtr> Events, CGType Type,
431432
detail::code_location loc = {})
432433
: CG(Type, std::move(ArgsStorage), std::move(AccStorage),
433434
std::move(SharedPtrStorage), std::move(Requirements),
@@ -456,7 +457,7 @@ class CGInteropTask : public CG {
456457
std::vector<detail::AccessorImplPtr> AccStorage,
457458
std::vector<std::shared_ptr<const void>> SharedPtrStorage,
458459
std::vector<Requirement *> Requirements,
459-
std::vector<detail::EventImplPtr> Events, CGTYPE Type,
460+
std::vector<detail::EventImplPtr> Events, CGType Type,
460461
detail::code_location loc = {})
461462
: CG(Type, std::move(ArgsStorage), std::move(AccStorage),
462463
std::move(SharedPtrStorage), std::move(Requirements),
@@ -481,7 +482,7 @@ class CGHostTask : public CG {
481482
std::vector<detail::AccessorImplPtr> AccStorage,
482483
std::vector<std::shared_ptr<const void>> SharedPtrStorage,
483484
std::vector<Requirement *> Requirements,
484-
std::vector<detail::EventImplPtr> Events, CGTYPE Type,
485+
std::vector<detail::EventImplPtr> Events, CGType Type,
485486
detail::code_location loc = {})
486487
: CG(Type, std::move(ArgsStorage), std::move(AccStorage),
487488
std::move(SharedPtrStorage), std::move(Requirements),
@@ -499,7 +500,7 @@ class CGBarrier : public CG {
499500
std::vector<detail::AccessorImplPtr> AccStorage,
500501
std::vector<std::shared_ptr<const void>> SharedPtrStorage,
501502
std::vector<Requirement *> Requirements,
502-
std::vector<detail::EventImplPtr> Events, CGTYPE Type,
503+
std::vector<detail::EventImplPtr> Events, CGType Type,
503504
detail::code_location loc = {})
504505
: CG(Type, std::move(ArgsStorage), std::move(AccStorage),
505506
std::move(SharedPtrStorage), std::move(Requirements),

sycl/include/CL/sycl/detail/image_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class __SYCL_EXPORT image_impl final : public SYCLMemObjT {
211211
void *allocateMem(ContextImplPtr Context, bool InitFromUserData,
212212
void *HostPtr, RT::PiEvent &OutEventToWait) override;
213213

214-
MemObjType getType() const override { return MemObjType::IMAGE; }
214+
MemObjType getType() const override { return MemObjType::Image; }
215215

216216
// This utility api is currently used by accessor to get the element size of
217217
// the image. Element size is dependent on num of channels and channel type.

sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class SYCLMemObjI {
2929
public:
3030
virtual ~SYCLMemObjI() = default;
3131

32-
enum MemObjType { BUFFER = 0, IMAGE = 1, UNDEFINED = 2 };
32+
enum MemObjType { Buffer = 0, Image = 1, Undefined = 2 };
3333

3434
virtual MemObjType getType() const = 0;
3535

sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI {
294294
throw runtime_error("Not implemented", PI_INVALID_OPERATION);
295295
}
296296

297-
__SYCL_DLL_LOCAL MemObjType getType() const override { return UNDEFINED; }
297+
__SYCL_DLL_LOCAL MemObjType getType() const override {
298+
return MemObjType::Undefined;
299+
}
298300

299301
ContextImplPtr getInteropContext() const override { return MInteropContext; }
300302

0 commit comments

Comments
 (0)