Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GPU] OCL context check in benchmark app (#36663)

Mikolaj Roszczyke9c9aa07b625
diff --git a/samples/cpp/benchmark_app/remote_tensors_filling.cpp b/samples/cpp/benchmark_app/remote_tensors_filling.cpp
index 9a55986e8ad..f0533dda203 100644
--- a/samples/cpp/benchmark_app/remote_tensors_filling.cpp
+++ b/samples/cpp/benchmark_app/remote_tensors_filling.cpp
@@ -88,6 +88,22 @@ std::map<std::string, ov::TensorVector> get_remote_input_tensors(
std::map<std::string, ov::TensorVector> remoteTensors;
auto context = compiledModel.get_context();
+
+ // use GPU with OCL runtime or driver supporting LEO (OCL/ZE interoperability)
+ const auto& context_params = context.get_params();
+ if (context_params.count(ov::intel_gpu::context_type.name()) > 0) {
+ const auto context_type =
+ context_params.at(ov::intel_gpu::context_type.name()).as<ov::intel_gpu::ContextType>();
+ // when ZE runtime and interoperability is available, the context is set to OCL
+ // otherwise remote device memory is not enabled
+ OPENVINO_ASSERT(context_type == ov::intel_gpu::ContextType::ZE,
+ "[GPU] OCL context is required for remote device memory. "
+ "Driver needs to support LEO to enable OCL/ZE interoperability.");
+ } else {
+ OPENVINO_THROW("[GPU] OCL context is required for remote device memory. "
+ "No context type is set.");
+ }
+
auto& oclContext = static_cast<ov::intel_gpu::ocl::ClContext&>(context);
auto oclInstance = std::make_shared<gpu::OpenCL>(oclContext.get());