提交 75b995b5 编写于 作者: Y yejianwu

fix benchmark, avoid alwayslink for mace:core

上级 50636e91
......@@ -36,7 +36,7 @@ cc_binary(
"//external:gflags_nothreads",
"//mace/codegen:generated_models",
"//mace/codegen:generated_mace_engine_factory",
"//mace/ops:ops",
"//mace/libmace:libmace",
],
)
......
......@@ -70,7 +70,6 @@ cc_library(
]) + if_hexagon_enabled([
"//third_party/nnlib:libhexagon",
]),
alwayslink = 1,
)
cc_library(
......@@ -109,5 +108,4 @@ cc_library(
"//external:gflags_nothreads",
"//mace/utils",
],
alwayslink = 1,
)
......@@ -206,22 +206,5 @@ MaceStatus SetOpenMPThreadsAndAffinityPolicy(int omp_num_threads_hint,
return SetOpenMPThreadsAndAffinityCPUs(omp_num_threads_hint, use_cpu_ids);
}
MaceStatus SetOpenMPThreadPolicy(int num_threads_hint,
CPUAffinityPolicy policy) {
VLOG(1) << "Set OpenMP threads number hint: " << num_threads_hint
<< ", affinity policy: " << policy;
return SetOpenMPThreadsAndAffinityPolicy(num_threads_hint, policy);
}
MaceStatus SetOpenMPThreadAffinity(int num_threads,
const std::vector<int> &cpu_ids) {
return SetOpenMPThreadsAndAffinityCPUs(num_threads, cpu_ids);
}
MaceStatus GetBigLittleCoreIDs(std::vector<int> *big_core_ids,
std::vector<int> *little_core_ids) {
return GetCPUBigLittleCoreIDs(big_core_ids, little_core_ids);
}
} // namespace mace
......@@ -33,20 +33,12 @@
namespace mace {
extern const std::map<std::string, std::vector<unsigned char>>
kEncryptedProgramMap;
std::shared_ptr<KVStorageFactory> kStorageFactory = nullptr;
void SetGPUHints(GPUPerfHint gpu_perf_hint, GPUPriorityHint gpu_priority_hint) {
VLOG(1) << "Set GPU configurations, gpu_perf_hint: " << gpu_perf_hint
<< ", gpu_priority_hint: " << gpu_priority_hint;
OpenCLRuntime::Configure(gpu_perf_hint, gpu_priority_hint);
}
// Set OpenCL Compiled Binary paths, just call once. (Not thread-safe)
void SetOpenCLBinaryPaths(const std::vector<std::string> &paths) {
OpenCLRuntime::ConfigureOpenCLBinaryPath(paths);
}
std::string kOpenCLParameterPath; // NOLINT(runtime/string)
extern const std::map<std::string, std::vector<unsigned char>>
kEncryptedProgramMap;
const std::string OpenCLErrorToString(cl_int error) {
switch (error) {
......
......@@ -15,6 +15,8 @@
#include <iostream>
#include "gflags/gflags.h"
#include "mace/core/runtime/cpu/cpu_runtime.h"
#include "mace/core/runtime/opencl/opencl_runtime.h"
#include "mace/core/testing/test_benchmark.h"
#include "mace/public/mace.h"
#include "mace/public/mace_runtime.h"
......@@ -34,13 +36,13 @@ int main(int argc, char **argv) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
// config runtime
mace::MaceStatus status = mace::SetOpenMPThreadPolicy(
mace::MaceStatus status = mace::SetOpenMPThreadsAndAffinityPolicy(
FLAGS_omp_num_threads,
static_cast<mace::CPUAffinityPolicy >(FLAGS_cpu_affinity_policy));
if (status != mace::MACE_SUCCESS) {
LOG(WARNING) << "Set openmp or cpu affinity failed.";
}
mace::SetGPUHints(
mace::OpenCLRuntime::Configure(
static_cast<mace::GPUPerfHint>(FLAGS_gpu_perf_hint),
static_cast<mace::GPUPriorityHint>(FLAGS_gpu_priority_hint));
......
......@@ -12,22 +12,53 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "mace/core/runtime/cpu/cpu_runtime.h"
#include "mace/core/runtime/opencl/opencl_runtime.h"
#include "mace/public/mace_runtime.h"
#include "mace/utils/logging.h"
namespace mace {
std::shared_ptr<KVStorageFactory> kStorageFactory = nullptr;
extern std::shared_ptr<KVStorageFactory> kStorageFactory;
void SetKVStorageFactory(std::shared_ptr<KVStorageFactory> storage_factory) {
VLOG(1) << "Set internal KV Storage Engine";
kStorageFactory = storage_factory;
}
std::string kOpenCLParameterPath; // NOLINT(runtime/string)
// Set OpenCL Compiled Binary paths, just call once. (Not thread-safe)
void SetOpenCLBinaryPaths(const std::vector<std::string> &paths) {
OpenCLRuntime::ConfigureOpenCLBinaryPath(paths);
}
extern std::string kOpenCLParameterPath;
void SetOpenCLParameterPath(const std::string &path) {
kOpenCLParameterPath = path;
}
void SetGPUHints(GPUPerfHint gpu_perf_hint, GPUPriorityHint gpu_priority_hint) {
VLOG(1) << "Set GPU configurations, gpu_perf_hint: " << gpu_perf_hint
<< ", gpu_priority_hint: " << gpu_priority_hint;
OpenCLRuntime::Configure(gpu_perf_hint, gpu_priority_hint);
}
MaceStatus SetOpenMPThreadPolicy(int num_threads_hint,
CPUAffinityPolicy policy) {
VLOG(1) << "Set OpenMP threads number hint: " << num_threads_hint
<< ", affinity policy: " << policy;
return SetOpenMPThreadsAndAffinityPolicy(num_threads_hint, policy);
}
MaceStatus SetOpenMPThreadAffinity(int num_threads,
const std::vector<int> &cpu_ids) {
return SetOpenMPThreadsAndAffinityCPUs(num_threads, cpu_ids);
}
MaceStatus GetBigLittleCoreIDs(std::vector<int> *big_core_ids,
std::vector<int> *little_core_ids) {
return GetCPUBigLittleCoreIDs(big_core_ids, little_core_ids);
}
}; // namespace mace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册