-
Notifications
You must be signed in to change notification settings - Fork 459
Improve selection of OpenCL platform and target device #2043
Conversation
|
||
for(std::vector<std::string>::iterator extNameIt = m_requiredOclExtensions.begin(); extNameIt != m_requiredOclExtensions.end(); ++extNameIt) | ||
{ | ||
isDeviceAppropriate = isDeviceAppropriate && (std::strstr(&extNamesBuffer[0], extNameIt->c_str()) != NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you check the first extension only: extNamesBuffer[0]? the one you need might not be the first one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
& extNamesBuffer[0] was a way to access all vector elements. Changed it to vector.data()
|
||
bool isDeviceAppropriate = true; | ||
|
||
for(std::vector<std::string>::iterator extNameIt = m_requiredOclExtensions.begin(); extNameIt != m_requiredOclExtensions.end(); ++extNameIt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (const auto& ext: m_requireOclExtensions)
form would be preferable whenever possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, definitely.
for(std::vector<std::string>::iterator extNameIt = m_requiredOclExtensions.begin(); extNameIt != m_requiredOclExtensions.end(); ++extNameIt) | ||
{ | ||
isDeviceAppropriate = isDeviceAppropriate && (std::strstr(&extNamesBuffer[0], extNameIt->c_str()) != NULL); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, you actually did not check for required extensions... You checked that the first extension reported is in your whitelist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
& extNamesBuffer[0] was a way to access all vector elements, so all of the extensions were checked. Changed it to vector.data()
} | ||
} | ||
|
||
_select_platform_loop_end: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can achieve pretty the same without goto label. Just return from the function when you need to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.
continue; | ||
} | ||
|
||
size_t extNamesBufferSize = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename these variables to something more simple. extensionsNum
and extensions
would be better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed.
e8da276
to
3a2b9a4
Compare
*) For-each. *) Defines. *) vector.data usage instead of &vector[0].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to squash these commits to a single commit upon merge.
@dvrogozh your call?
|
||
if(strstr(platform, "Intel")) // Use only Intel platfroms | ||
error = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, devices.size(), &devices[0], 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&devices[0] -> devices.data()
#include "opencl_filter_dx11.h" | ||
#include "sample_defs.h" | ||
|
||
#include "stdexcept" | ||
|
||
// INTEL DX9 sharing functions declared deprecated in OpenCL 1.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this is applicable for dx11.cpp file? both comment and pragma-warning?
@@ -10,11 +10,9 @@ include_directories ( | |||
|
|||
set( LDFLAGS "${LDFLAGS} -Wl,--version-script=${PLUGINS_COMMON_PATH}/mfx_plugin.map" ) | |||
|
|||
# for clCreateFromGLTexture2D and clCreateFromGLTexture3D in CL/cl_gl.h | |||
set( CFLAGS "-DCL_USE_DEPRECATED_OPENCL_1_1_APIS" ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need CL_USE_DEPRECATED_OPENCL_1_1_APIS?
#include <va/va.h> | ||
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS 1 | ||
#endif | ||
|
||
#undef CL_VERSION_1_2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where do we define CL_VERSION_1_2 and why do we need undef?
#include <CL/cl_d3d11.h> | ||
|
||
using std::endl; | ||
|
||
#define INIT_CL_EXT_FUNC(x) x = (x ## _fn)clGetExtensionFunctionAddress(#x); | ||
#define SAFE_OCL_FREE(P, FREE_FUNC) { if (P) { FREE_FUNC(P); P = NULL; } } | ||
|
||
#define MAX_PLATFORMS 32 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, check whether we need these 2 defines? I thought we've moved to std::vector?
Remove outdated include and defines. Amendment for Intel-Media-SDK#2190. Includes changes from Intel-Media-SDK#2043 Co-authored-by: abelaykov <belaykov.alexander.a@gmail.com>
Changes merged with minimal modifications as part of #2243. |
Remove outdated include and defines. Amendment for Intel-Media-SDK#2190. Includes changes from Intel-Media-SDK#2043 Co-authored-by: abelaykov <belaykov.alexander.a@gmail.com>
No description provided.