|
23 | 23 | #include <iostream>
|
24 | 24 | #include <limits>
|
25 | 25 | #include <map>
|
26 |
| -#include <set> |
27 | 26 | #include <sstream>
|
28 | 27 | #include <string>
|
29 | 28 | #include <vector>
|
|
36 | 35 | }
|
37 | 36 |
|
38 | 37 | const char SupportedVersion[] = _PI_H_VERSION_STRING;
|
39 |
| -std::map<pi_context, std::set<std::string>> SupportedExtensions; |
40 | 38 |
|
41 | 39 | // Want all the needed casts be explicit, do not define conversion operators.
|
42 | 40 | template <class To, class From> To cast(From value) {
|
@@ -70,39 +68,6 @@ CONSTFIX char clSetProgramSpecializationConstantName[] =
|
70 | 68 |
|
71 | 69 | #undef CONSTFIX
|
72 | 70 |
|
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 |
| - |
106 | 71 | // USM helper function to get an extension function pointer
|
107 | 72 | template <const char *FuncName, typename T>
|
108 | 73 | 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,
|
561 | 526 | const pi_mem_properties *properties) {
|
562 | 527 | pi_result ret_err = PI_INVALID_OPERATION;
|
563 | 528 | if (properties) {
|
| 529 | + // TODO: need to check if all properties are supported by OpenCL RT and |
| 530 | + // ignore unsupported |
564 | 531 | clCreateBufferWithPropertiesINTEL_fn FuncPtr = nullptr;
|
565 |
| - const size_t propSize = sizeof(properties) / sizeof(pi_mem_properties); |
566 | 532 | // First we need to look up the function pointer
|
567 | 533 | ret_err = getExtFuncFromContext<clCreateBufferWithPropertiesName,
|
568 | 534 | clCreateBufferWithPropertiesINTEL_fn>(
|
569 | 535 | context, &FuncPtr);
|
570 | 536 | 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; |
595 | 541 | }
|
596 | 542 | }
|
597 | 543 |
|
|
0 commit comments