Skip to content

[SYCL][PI] Change const to constexpr to make GCC happy #1017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions sycl/plugins/opencl/pi_opencl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,28 @@ template <class To, class From> To cast(From value) {
return (To)(value);
}

// Older versions of GCC don't like "const" here
#if defined(__GNUC__) && (__GNUC__ < 7 || (__GNU__C == 7 && __GNUC_MINOR__ < 2))
#define CONSTFIX constexpr
#else
#define CONSTFIX const
#endif

// Names of USM functions that are queried from OpenCL
const char clHostMemAllocName[] = "clHostMemAllocINTEL";
const char clDeviceMemAllocName[] = "clDeviceMemAllocINTEL";
const char clSharedMemAllocName[] = "clSharedMemAllocINTEL";
const char clMemFreeName[] = "clMemFreeINTEL";
const char clSetKernelArgMemPointerName[] = "clSetKernelArgMemPointerINTEL";
const char clEnqueueMemsetName[] = "clEnqueueMemsetINTEL";
const char clEnqueueMemcpyName[] = "clEnqueueMemcpyINTEL";
const char clEnqueueMigrateMemName[] = "clEnqueueMigrateMemINTEL";
const char clEnqueueMemAdviseName[] = "clEnqueueMemAdviseINTEL";
const char clGetMemAllocInfoName[] = "clGetMemAllocInfoINTEL";
CONSTFIX char clHostMemAllocName[] = "clHostMemAllocINTEL";
CONSTFIX char clDeviceMemAllocName[] = "clDeviceMemAllocINTEL";
CONSTFIX char clSharedMemAllocName[] = "clSharedMemAllocINTEL";
CONSTFIX char clMemFreeName[] = "clMemFreeINTEL";
CONSTFIX char clSetKernelArgMemPointerName[] = "clSetKernelArgMemPointerINTEL";
CONSTFIX char clEnqueueMemsetName[] = "clEnqueueMemsetINTEL";
CONSTFIX char clEnqueueMemcpyName[] = "clEnqueueMemcpyINTEL";
CONSTFIX char clEnqueueMigrateMemName[] = "clEnqueueMigrateMemINTEL";
CONSTFIX char clEnqueueMemAdviseName[] = "clEnqueueMemAdviseINTEL";
CONSTFIX char clGetMemAllocInfoName[] = "clGetMemAllocInfoINTEL";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually thinking to just

auto constexpr clHostMemAllocName = "clHostMemAllocINTEL";

but it might not work on some old compilers... Who cares about old compilers? SYCL is about the future. :-)


#undef CONSTFIX
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__SYCL_CONST_FIX to limit the risk of collision?




// USM helper function to get an extension function pointer
template <const char *FuncName, typename T>
Expand Down