Skip to content
This repository was archived by the owner on Feb 16, 2019. It is now read-only.

Commit 131add0

Browse files
authored
Merge pull request #17 from lcskrishna/non-amd-openclport
simplified logic for cl_amd_media_ops check and use emulation code when the extension is missing
2 parents 9188ca7 + 87ad275 commit 131add0

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

openvx/ago/ago_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ struct AgoContext {
673673
cl_uint opencl_num_devices;
674674
cl_device_id opencl_device_list[16];
675675
char opencl_build_options[256];
676-
bool isVendorAmd;
676+
bool isAmdMediaOpsSupported;
677677
#endif
678678
AgoTargetAffinityInfo_ attr_affinity;
679679
public:

openvx/ago/ago_util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3069,7 +3069,7 @@ AgoContext::AgoContext()
30693069
num_active_modules{ 0 }, num_active_references{ 0 }, callback_log{ nullptr }, callback_reentrant{ vx_false_e },
30703070
thread_config{ CONFIG_THREAD_DEFAULT }, importing_module_index_plus1{ 0 }, graph_garbage_data{ nullptr }, graph_garbage_node{ nullptr }, graph_garbage_list{ nullptr }
30713071
#if ENABLE_OPENCL
3072-
, opencl_context_imported{ false }, opencl_context{ nullptr }, opencl_cmdq{ nullptr }, opencl_config_flags{ 0 }, opencl_svmcaps{ 0 }, opencl_num_devices{ 0 }, isVendorAmd{ true }
3072+
, opencl_context_imported{ false }, opencl_context{ nullptr }, opencl_cmdq{ nullptr }, opencl_config_flags{ 0 }, opencl_svmcaps{ 0 }, opencl_num_devices{ 0 }, isAmdMediaOpsSupported{ true }
30733073
#endif
30743074
{
30753075
memset(&kernelList, 0, sizeof(kernelList));

openvx/ago/ago_util_opencl.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ int agoGpuOclCreateContext(AgoContext * context, cl_context opencl_context)
152152
return -1;
153153
}
154154
cl_platform_id platform_id = platform_list[0];
155-
context->isVendorAmd = false;
156155
for (int i = 0; i < (int)num_platforms; i++) {
157156
char vendor[128] = { 0 };
158157
if ((status = clGetPlatformInfo(platform_list[i], CL_PLATFORM_VENDOR, sizeof(vendor), vendor, NULL)) != CL_SUCCESS) {
@@ -215,6 +214,13 @@ int agoGpuOclCreateContext(AgoContext * context, cl_context opencl_context)
215214
agoAddLogEntry(&context->ref, VX_FAILURE, "ERROR: clGetDeviceInfo(%p,CL_DEVICE_NAME) => %d\n", context->opencl_device_list[device_id], status);
216215
return -1;
217216
}
217+
char extensions[2048] = { 0 };
218+
status = clGetDeviceInfo(context->opencl_device_list[device_id], CL_DEVICE_EXTENSIONS, sizeof(extensions) - 1, extensions, NULL);
219+
if (status) {
220+
agoAddLogEntry(&context->ref, VX_FAILURE, "ERROR: clGetDeviceInfo(%p,CL_DEVICE_EXTENSIONS) => %d\n", context->opencl_device_list[device_id], status);
221+
return -1;
222+
}
223+
context->isAmdMediaOpsSupported = strstr(extensions, "cl_amd_media_ops") ? true : false;
218224
agoAddLogEntry(&context->ref, VX_SUCCESS, "OK: OpenVX using GPU device#%d (%s) [%s] [SvmCaps " VX_FMT_SIZE " %d]\n", device_id, deviceName, deviceVersion, context->opencl_svmcaps, context->opencl_config_flags);
219225
memset(context->opencl_extensions, 0, sizeof(context->opencl_extensions));
220226
status = clGetDeviceInfo(context->opencl_device_list[device_id], CL_DEVICE_EXTENSIONS, sizeof(context->opencl_extensions), context->opencl_extensions, NULL);
@@ -1896,7 +1902,7 @@ int agoGpuOclSuperNodeFinalize(AgoGraph * graph, AgoSuperNode * supernode)
18961902
}
18971903
// generate code: end of function and save
18981904
code += "\t}\n}\n";
1899-
if (!(graph->ref.context->isVendorAmd)) {
1905+
if (!(graph->ref.context->isAmdMediaOpsSupported)) {
19001906
agoEmulateAmdMediaOpsInOpenCL(code);
19011907
}
19021908
supernode->opencl_code = code;
@@ -2048,7 +2054,7 @@ int agoGpuOclSuperNodeWait(AgoGraph * graph, AgoSuperNode * supernode)
20482054

20492055
int agoGpuOclSingleNodeFinalize(AgoGraph * graph, AgoNode * node)
20502056
{
2051-
if (!(graph->ref.context->isVendorAmd)) {
2057+
if (!(graph->ref.context->isAmdMediaOpsSupported)) {
20522058
agoEmulateAmdMediaOpsInOpenCL(node->opencl_code);
20532059
}
20542060
const char * opencl_code = node->opencl_code.c_str();

0 commit comments

Comments
 (0)