|
|
|
@ -28,20 +28,53 @@ int main(int argc, char** argv) {
|
|
|
|
|
for (int i = 0; i < argc; ++i) {
|
|
|
|
|
new_argv.push_back(argv[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> envs;
|
|
|
|
|
std::vector<std::string> undefok;
|
|
|
|
|
#if defined(PADDLE_WITH_DISTRIBUTE) && !defined(PADDLE_WITH_GRPC)
|
|
|
|
|
envs.push_back("max_body_size");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
|
|
|
|
|
new_argv.push_back(
|
|
|
|
|
strdup("--tryfromenv=fraction_of_gpu_memory_to_use,allocator_strategy"));
|
|
|
|
|
envs.push_back("fraction_of_gpu_memory_to_use");
|
|
|
|
|
envs.push_back("allocator_strategy");
|
|
|
|
|
#elif __clang__
|
|
|
|
|
new_argv.push_back(
|
|
|
|
|
strdup("--tryfromenv=use_mkldnn,initial_cpu_memory_in_"
|
|
|
|
|
"mb,allocator_strategy"));
|
|
|
|
|
new_argv.push_back(strdup("--undefok=use_mkldnn,initial_cpu_memory_in_mb"));
|
|
|
|
|
envs.push_back("use_mkldnn");
|
|
|
|
|
envs.push_back("initial_cpu_memory_in_mb");
|
|
|
|
|
envs.push_back("allocator_strategy");
|
|
|
|
|
|
|
|
|
|
undefok.push_back("use_mkldnn");
|
|
|
|
|
undefok.push_back("initial_cpu_memory_in_mb");
|
|
|
|
|
#else
|
|
|
|
|
new_argv.push_back(
|
|
|
|
|
strdup("--tryfromenv=use_pinned_memory,use_mkldnn,initial_cpu_memory_in_"
|
|
|
|
|
"mb,allocator_strategy"));
|
|
|
|
|
new_argv.push_back(strdup("--undefok=use_mkldnn,initial_cpu_memory_in_mb"));
|
|
|
|
|
envs.push_back("use_pinned_memory");
|
|
|
|
|
envs.push_back("use_mkldnn");
|
|
|
|
|
envs.push_back("initial_cpu_memory_in_mb");
|
|
|
|
|
envs.push_back("allocator_strategy");
|
|
|
|
|
|
|
|
|
|
undefok.push_back("use_mkldnn");
|
|
|
|
|
undefok.push_back("initial_cpu_memory_in_mb");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (envs.size() > 0) {
|
|
|
|
|
std::string env_string = "--tryfromenv=";
|
|
|
|
|
for (auto t : envs) {
|
|
|
|
|
env_string += t + ",";
|
|
|
|
|
}
|
|
|
|
|
env_string = env_string.substr(0, env_string.length() - 1);
|
|
|
|
|
new_argv.push_back(strdup(env_string.c_str()));
|
|
|
|
|
VLOG(1) << "gtest env_string:" << env_string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (undefok.size() > 0) {
|
|
|
|
|
std::string undefok_string = "--undefok=";
|
|
|
|
|
for (auto t : undefok) {
|
|
|
|
|
undefok_string += t + ",";
|
|
|
|
|
}
|
|
|
|
|
undefok_string = undefok_string.substr(0, undefok_string.length() - 1);
|
|
|
|
|
new_argv.push_back(strdup(undefok_string.c_str()));
|
|
|
|
|
VLOG(1) << "gtest undefok_string:" << undefok_string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int new_argc = static_cast<int>(new_argv.size());
|
|
|
|
|
char** new_argv_address = new_argv.data();
|
|
|
|
|
google::ParseCommandLineFlags(&new_argc, &new_argv_address, false);
|
|
|
|
|