@@ -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
20492055int 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