From c056e7fc61326558a247f63da551aacfda5fc8a2 Mon Sep 17 00:00:00 2001 From: Philippe FOUBERT Date: Thu, 28 Nov 2013 00:26:37 +0100 Subject: [PATCH] Correction to be able to compile using the directive PRINT_KERNEL_RUN_TIME --- modules/ocl/src/cl_context.cpp | 5 ++++- modules/ocl/src/cl_operations.cpp | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/modules/ocl/src/cl_context.cpp b/modules/ocl/src/cl_context.cpp index bf5eaae..67230c8 100644 --- a/modules/ocl/src/cl_context.cpp +++ b/modules/ocl/src/cl_context.cpp @@ -656,8 +656,11 @@ void ContextImpl::setContext(const DeviceInfo* deviceInfo) cl_context_properties cps[3] = { CL_CONTEXT_PLATFORM, (cl_context_properties)(infoImpl.platform_id), 0 }; cl_context clContext = clCreateContext(cps, 1, &infoImpl.device_id, NULL, NULL, &status); openCLVerifyCall(status); - // TODO add CL_QUEUE_PROFILING_ENABLE +#ifdef PRINT_KERNEL_RUN_TIME + cl_command_queue clCmdQueue = clCreateCommandQueue(clContext, infoImpl.device_id, CL_QUEUE_PROFILING_ENABLE, &status); +#else /*PRINT_KERNEL_RUN_TIME*/ cl_command_queue clCmdQueue = clCreateCommandQueue(clContext, infoImpl.device_id, 0, &status); +#endif /*PRINT_KERNEL_RUN_TIME*/ openCLVerifyCall(status); ContextImpl* ctx = new ContextImpl(infoImpl.info, infoImpl.device_id); diff --git a/modules/ocl/src/cl_operations.cpp b/modules/ocl/src/cl_operations.cpp index f618e02..e4ea151 100644 --- a/modules/ocl/src/cl_operations.cpp +++ b/modules/ocl/src/cl_operations.cpp @@ -459,28 +459,28 @@ void openCLExecuteKernel(Context *ctx, const cv::ocl::ProgramEntry* source, Stri openCLExecuteKernel_(ctx, source, kernelName, globalThreads, localThreads, args, channels, depth, build_options); #else - string data_type[] = { "uchar", "char", "ushort", "short", "int", "float", "double"}; - cout << endl; - cout << "Function Name: " << kernelName; + std::string data_type[] = { "uchar", "char", "ushort", "short", "int", "float", "double"}; + std::cout << std::endl; + std::cout << "Function Name: " << kernelName; if(depth >= 0) - cout << " |data type: " << data_type[depth]; - cout << " |channels: " << channels; - cout << " |Time Unit: " << "ms" << endl; + std::cout << " |data type: " << data_type[depth]; + std::cout << " |channels: " << channels; + std::cout << " |Time Unit: " << "ms" << std::endl; total_execute_time = 0; total_kernel_time = 0; - cout << "-------------------------------------" << endl; + std::cout << "-------------------------------------" << std::endl; - cout << setiosflags(ios::left) << setw(15) << "execute time"; - cout << setiosflags(ios::left) << setw(15) << "launch time"; - cout << setiosflags(ios::left) << setw(15) << "kernel time" << endl; + std::cout << std::setiosflags(std::ios::left) << std::setw(15) << "execute time"; + std::cout << std::setiosflags(std::ios::left) << std::setw(15) << "launch time"; + std::cout << std::setiosflags(std::ios::left) << std::setw(15) << "kernel time" << std::endl; int i = 0; for(i = 0; i < RUN_TIMES; i++) openCLExecuteKernel_(ctx, source, kernelName, globalThreads, localThreads, args, channels, depth, build_options); - cout << "average kernel execute time: " << total_execute_time / RUN_TIMES << endl; // "ms" << endl; - cout << "average kernel total time: " << total_kernel_time / RUN_TIMES << endl; // "ms" << endl; + std::cout << "average kernel execute time: " << total_execute_time / RUN_TIMES << std::endl; // "ms" << std::endl; + std::cout << "average kernel total time: " << total_kernel_time / RUN_TIMES << std::endl; // "ms" << std::endl; #endif } -- 2.7.4