diff --git a/mace/core/runtime/opencl/opencl_extension.h b/mace/core/runtime/opencl/opencl_extension.h new file mode 100644 index 0000000000000000000000000000000000000000..d2e22d9a67230b14c38f7df2002324b098fca3dd --- /dev/null +++ b/mace/core/runtime/opencl/opencl_extension.h @@ -0,0 +1,28 @@ +// +// Copyright (c) 2017 XiaoMi All rights reserved. +// + +#ifndef MACE_CORE_RUNTIME_OPENCL_EXTENSION_H_ +#define MACE_CORE_RUNTIME_OPENCL_EXTENSION_H_ + +#include "mace/core/runtime/opencl/cl2_header.h" + +// Adreno extensions +// Adreno performance hints +typedef cl_uint cl_perf_hint; + +#define CL_CONTEXT_PERF_HINT_QCOM 0x40C2 +#define CL_PERF_HINT_HIGH_QCOM 0x40C3 +#define CL_PERF_HINT_NORMAL_QCOM 0x40C4 +#define CL_PERF_HINT_LOW_QCOM 0x40C5 + +// Adreno priority hints +typedef cl_uint cl_priority_hint; + +#define CL_PRIORITY_HINT_NONE_QCOM 0 +#define CL_CONTEXT_PRIORITY_HINT_QCOM 0x40C9 +#define CL_PRIORITY_HINT_HIGH_QCOM 0x40CA +#define CL_PRIORITY_HINT_NORMAL_QCOM 0x40CB +#define CL_PRIORITY_HINT_LOW_QCOM 0x40CC + +#endif // MACE_CORE_RUNTIME_OPENCL_EXTENSION_H_ diff --git a/mace/core/runtime/opencl/opencl_runtime.cc b/mace/core/runtime/opencl/opencl_runtime.cc index 4a18f630bc3126cf87e1be5446684fa800f5852f..ec29788167174e4fe591652665bd6ae6ed4f8431 100644 --- a/mace/core/runtime/opencl/opencl_runtime.cc +++ b/mace/core/runtime/opencl/opencl_runtime.cc @@ -7,6 +7,7 @@ #include #include +#include "mace/core/runtime/opencl/opencl_extension.h" #include "mace/core/runtime/opencl/opencl_runtime.h" #include "mace/public/mace.h" #include "mace/utils/tuner.h" @@ -108,9 +109,15 @@ OpenCLRuntime::OpenCLRuntime() { properties |= CL_QUEUE_PROFILING_ENABLE; } - // a context is like a "runtime link" to the device and platform; - // i.e. communication is possible - cl::Context context({gpu_device}); + // TODO (heliangliang) Make this configurable (e.g.HIGH for benchmark, + // disabled for Mali) + cl_context_properties context_properties[] = { + // Set context perf hint to normal + CL_CONTEXT_PERF_HINT_QCOM, CL_PERF_HINT_NORMAL_QCOM, + // Set context priority hint to low + CL_CONTEXT_PRIORITY_HINT_QCOM, CL_PRIORITY_HINT_LOW_QCOM, 0}; + + cl::Context context({gpu_device}, context_properties); cl::CommandQueue command_queue(context, gpu_device, properties); const char *kernel_path = getenv("MACE_KERNEL_PATH");