Skip to content

Commit 1f1135b

Browse files
committed
Remove properties check
Signed-off-by: Dmitry Sidorov <[email protected]>
1 parent 4b71b32 commit 1f1135b

File tree

1 file changed

+6
-60
lines changed

1 file changed

+6
-60
lines changed

sycl/plugins/opencl/pi_opencl.cpp

Lines changed: 6 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <iostream>
2424
#include <limits>
2525
#include <map>
26-
#include <set>
2726
#include <sstream>
2827
#include <string>
2928
#include <vector>
@@ -36,7 +35,6 @@
3635
}
3736

3837
const char SupportedVersion[] = _PI_H_VERSION_STRING;
39-
std::map<pi_context, std::set<std::string>> SupportedExtensions;
4038

4139
// Want all the needed casts be explicit, do not define conversion operators.
4240
template <class To, class From> To cast(From value) {
@@ -70,39 +68,6 @@ CONSTFIX char clSetProgramSpecializationConstantName[] =
7068

7169
#undef CONSTFIX
7270

73-
// Helper to get extensions that are common for all devices within a context
74-
pi_result getSupportedExtensionsWithinContext(pi_context context) {
75-
size_t deviceCount;
76-
cl_int ret_err = clGetContextInfo(
77-
cast<cl_context>(context), CL_CONTEXT_DEVICES, 0, nullptr, &deviceCount);
78-
if (ret_err != CL_SUCCESS || deviceCount < 1)
79-
return PI_INVALID_CONTEXT;
80-
std::vector<cl_device_id> devicesInCtx(deviceCount);
81-
ret_err = clGetContextInfo(cast<cl_context>(context), CL_CONTEXT_DEVICES,
82-
deviceCount * sizeof(cl_device_id),
83-
devicesInCtx.data(), nullptr);
84-
85-
size_t retSize;
86-
std::set<std::string> commonExtensions;
87-
for (size_t i = 0; i != deviceCount; ++i) {
88-
ret_err = clGetDeviceInfo(devicesInCtx[i], CL_DEVICE_EXTENSIONS, 0, nullptr,
89-
&retSize);
90-
if (ret_err != CL_SUCCESS)
91-
return PI_INVALID_DEVICE;
92-
std::string extensions(retSize, '\0');
93-
ret_err = clGetDeviceInfo(devicesInCtx[i], CL_DEVICE_EXTENSIONS, retSize,
94-
&extensions[0], nullptr);
95-
if (ret_err != CL_SUCCESS)
96-
return PI_INVALID_DEVICE;
97-
std::string extension;
98-
std::stringstream ss(extensions);
99-
while (getline(ss, extension, ' '))
100-
commonExtensions.insert(extension);
101-
}
102-
SupportedExtensions.emplace(context, commonExtensions);
103-
return cast<pi_result>(ret_err);
104-
}
105-
10671
// USM helper function to get an extension function pointer
10772
template <const char *FuncName, typename T>
10873
static pi_result getExtFuncFromContext(pi_context context, T *fptr) {
@@ -561,37 +526,18 @@ pi_result piMemBufferCreate(pi_context context, pi_mem_flags flags, size_t size,
561526
const pi_mem_properties *properties) {
562527
pi_result ret_err = PI_INVALID_OPERATION;
563528
if (properties) {
529+
// TODO: need to check if all properties are supported by OpenCL RT and
530+
// ignore unsupported
564531
clCreateBufferWithPropertiesINTEL_fn FuncPtr = nullptr;
565-
const size_t propSize = sizeof(properties) / sizeof(pi_mem_properties);
566532
// First we need to look up the function pointer
567533
ret_err = getExtFuncFromContext<clCreateBufferWithPropertiesName,
568534
clCreateBufferWithPropertiesINTEL_fn>(
569535
context, &FuncPtr);
570536
if (FuncPtr) {
571-
std::vector<pi_mem_properties> supported(properties,
572-
properties + propSize);
573-
// Go through buffer properties. If there is one, that shall be propagated
574-
// to an OpenCL runtime - check if this property is being supported.
575-
for (auto prop = supported.begin(); prop != supported.end(); ++prop) {
576-
if (SupportedExtensions.find(context) == SupportedExtensions.end())
577-
ret_err = getSupportedExtensionsWithinContext(context);
578-
// Check if PI_MEM_PROPERTIES_CHANNEL property is supported. If it's
579-
// not - just ignore it, as it's an optimization hint.
580-
if (*prop == PI_MEM_PROPERTIES_CHANNEL) {
581-
if (SupportedExtensions[context].find(
582-
"cl_intel_mem_channel_property") ==
583-
SupportedExtensions[context].end())
584-
prop = supported.erase(prop);
585-
} else
586-
assert(!"Unsupported property found");
587-
}
588-
if (!supported.empty()) {
589-
*ret_mem =
590-
cast<pi_mem>(FuncPtr(cast<cl_context>(context), supported.data(),
591-
cast<cl_mem_flags>(flags), size, host_ptr,
592-
cast<cl_int *>(&ret_err)));
593-
return ret_err;
594-
}
537+
*ret_mem = cast<pi_mem>(FuncPtr(cast<cl_context>(context), properties,
538+
cast<cl_mem_flags>(flags), size, host_ptr,
539+
cast<cl_int *>(&ret_err)));
540+
return ret_err;
595541
}
596542
}
597543

0 commit comments

Comments
 (0)