From f21c4c0c43fbe7ac6a4a582868dd1e3626393679 Mon Sep 17 00:00:00 2001 From: yanwei Date: Tue, 9 Nov 2021 01:28:04 +0800 Subject: [PATCH 01/18] add potential exception handle & open session_option to optimize --- ODLA/platforms/odla_popart/odla_popart.h | 1 + ODLA/platforms/odla_popart/popart_config.cc | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/ODLA/platforms/odla_popart/odla_popart.h b/ODLA/platforms/odla_popart/odla_popart.h index a3d744bed..098506261 100644 --- a/ODLA/platforms/odla_popart/odla_popart.h +++ b/ODLA/platforms/odla_popart/odla_popart.h @@ -134,6 +134,7 @@ struct _odla_computation { builder->setAttribute(popart::sVirtualGraphAttribute, 0); } std::string set_pipeline_stage(); + void init(bool is_compile = false); void set_session_opts(); bool use_pipeline(); diff --git a/ODLA/platforms/odla_popart/popart_config.cc b/ODLA/platforms/odla_popart/popart_config.cc index 204740186..8ff111105 100644 --- a/ODLA/platforms/odla_popart/popart_config.cc +++ b/ODLA/platforms/odla_popart/popart_config.cc @@ -97,6 +97,16 @@ odla_status PopartConfig::load_config(const char* env_file_path) { } else { popart::logging::info("use default config"); } +odla_status PopartConfig::load_config(const char* file_path) { + odla_status ret_value = ODLA_SUCCESS; + if (inited_) { + popart::logging::info("config already inited"); + return ODLA_SUCCESS; + } + popart::logging::info("use default config"); + use_default(); + if (file_path != nullptr) { + load_from_file(file_path); } return ODLA_SUCCESS; } From c6f6a212337edbf709b86941852e67d80d262fe9 Mon Sep 17 00:00:00 2001 From: yanwei Date: Tue, 9 Nov 2021 14:09:45 +0800 Subject: [PATCH 02/18] update odla_computation::init() to return odla_status value --- ODLA/platforms/odla_popart/odla_popart.h | 1 - ODLA/platforms/odla_popart/popart_config.cc | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ODLA/platforms/odla_popart/odla_popart.h b/ODLA/platforms/odla_popart/odla_popart.h index 098506261..a3d744bed 100644 --- a/ODLA/platforms/odla_popart/odla_popart.h +++ b/ODLA/platforms/odla_popart/odla_popart.h @@ -134,7 +134,6 @@ struct _odla_computation { builder->setAttribute(popart::sVirtualGraphAttribute, 0); } std::string set_pipeline_stage(); - void init(bool is_compile = false); void set_session_opts(); bool use_pipeline(); diff --git a/ODLA/platforms/odla_popart/popart_config.cc b/ODLA/platforms/odla_popart/popart_config.cc index 8ff111105..19aa12eca 100644 --- a/ODLA/platforms/odla_popart/popart_config.cc +++ b/ODLA/platforms/odla_popart/popart_config.cc @@ -98,7 +98,6 @@ odla_status PopartConfig::load_config(const char* env_file_path) { popart::logging::info("use default config"); } odla_status PopartConfig::load_config(const char* file_path) { - odla_status ret_value = ODLA_SUCCESS; if (inited_) { popart::logging::info("config already inited"); return ODLA_SUCCESS; @@ -107,6 +106,8 @@ odla_status PopartConfig::load_config(const char* file_path) { use_default(); if (file_path != nullptr) { load_from_file(file_path); + } else { + return ODLA_FILE_NOT_EXIST; } return ODLA_SUCCESS; } From 73c5260d65fbcbe9df9ac956060bf6dc6ca31001 Mon Sep 17 00:00:00 2001 From: yanwei Date: Tue, 9 Nov 2021 14:51:51 +0800 Subject: [PATCH 03/18] fix popart_config load error --- ODLA/platforms/odla_popart/popart_config.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ODLA/platforms/odla_popart/popart_config.cc b/ODLA/platforms/odla_popart/popart_config.cc index 19aa12eca..4fa06754a 100644 --- a/ODLA/platforms/odla_popart/popart_config.cc +++ b/ODLA/platforms/odla_popart/popart_config.cc @@ -102,12 +102,11 @@ odla_status PopartConfig::load_config(const char* file_path) { popart::logging::info("config already inited"); return ODLA_SUCCESS; } - popart::logging::info("use default config"); use_default(); if (file_path != nullptr) { load_from_file(file_path); } else { - return ODLA_FILE_NOT_EXIST; + popart::logging::info("use default config"); } return ODLA_SUCCESS; } From 613c2bfe8b5ad3a81e50540543e7a180d6abde90 Mon Sep 17 00:00:00 2001 From: yanwei Date: Thu, 11 Nov 2021 14:10:43 +0800 Subject: [PATCH 04/18] improve load config logic --- ODLA/platforms/odla_popart/popart_config.cc | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ODLA/platforms/odla_popart/popart_config.cc b/ODLA/platforms/odla_popart/popart_config.cc index 4fa06754a..204740186 100644 --- a/ODLA/platforms/odla_popart/popart_config.cc +++ b/ODLA/platforms/odla_popart/popart_config.cc @@ -97,16 +97,6 @@ odla_status PopartConfig::load_config(const char* env_file_path) { } else { popart::logging::info("use default config"); } -odla_status PopartConfig::load_config(const char* file_path) { - if (inited_) { - popart::logging::info("config already inited"); - return ODLA_SUCCESS; - } - use_default(); - if (file_path != nullptr) { - load_from_file(file_path); - } else { - popart::logging::info("use default config"); } return ODLA_SUCCESS; } From bf2494f2d703dad1c4caee3ebf57cd1bff8084f3 Mon Sep 17 00:00:00 2001 From: gcuser Date: Sat, 13 Nov 2021 00:39:53 +0000 Subject: [PATCH 05/18] Check the sdk version of the cache --- ODLA/platforms/odla_popart/odla_popart.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/ODLA/platforms/odla_popart/odla_popart.cc b/ODLA/platforms/odla_popart/odla_popart.cc index 93af085fc..a751f4107 100644 --- a/ODLA/platforms/odla_popart/odla_popart.cc +++ b/ODLA/platforms/odla_popart/odla_popart.cc @@ -139,7 +139,6 @@ odla_status _odla_computation::compile_and_export() { config_string.insert(1, version_string); popart::logging::info("the config_string with sdk_version is: {}", config_string); - // added the sdk_version information to the file content int config_size = config_string.size(); cache_fs.write((char*)&config_size, sizeof(config_size)); cache_fs.write(config_string.c_str(), config_string.size()); From be816ecc81db5cb9fe5d14d7da1572e364a5298b Mon Sep 17 00:00:00 2001 From: gcuser Date: Mon, 15 Nov 2021 02:07:52 +0000 Subject: [PATCH 06/18] Format the codes to pass lint checking --- ODLA/platforms/odla_popart/odla_popart.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/ODLA/platforms/odla_popart/odla_popart.cc b/ODLA/platforms/odla_popart/odla_popart.cc index a751f4107..93af085fc 100644 --- a/ODLA/platforms/odla_popart/odla_popart.cc +++ b/ODLA/platforms/odla_popart/odla_popart.cc @@ -139,6 +139,7 @@ odla_status _odla_computation::compile_and_export() { config_string.insert(1, version_string); popart::logging::info("the config_string with sdk_version is: {}", config_string); + // added the sdk_version information to the file content int config_size = config_string.size(); cache_fs.write((char*)&config_size, sizeof(config_size)); cache_fs.write(config_string.c_str(), config_string.size()); From 1bf11794c3f53eace7de4bb79230fc4ab5218b70 Mon Sep 17 00:00:00 2001 From: yanwei Date: Thu, 18 Nov 2021 02:07:22 +0800 Subject: [PATCH 07/18] reset other necessary popart config value --- ODLA/platforms/odla_popart/popart_config.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ODLA/platforms/odla_popart/popart_config.h b/ODLA/platforms/odla_popart/popart_config.h index dfadf5519..626b64e60 100644 --- a/ODLA/platforms/odla_popart/popart_config.h +++ b/ODLA/platforms/odla_popart/popart_config.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -87,6 +88,7 @@ class PopartConfig { std::shared_ptr cache_fs; + std::mutex config_mutex_; static PopartConfig* instance_; odla_status load_from_file(const std::string& file_path); @@ -107,9 +109,17 @@ class PopartConfig { static PopartConfig* instance() { return instance_; } const std::string& version() { return version_; } inline void reset_init_state() { - inited_ = false; - if (cache_fs->is_open()) { - cache_fs->close(); + if (inited_) { + std::lock_guard guard(config_mutex_); + if (inited_) { + inited_ = false; + if (cache_fs->is_open()) { + cache_fs->close(); + } + pipeline_setting_.clear(); + load_or_save_cache_ = false; + sdk_version_ = "NA"; + } } } inline float amp() { return amp_; }; From 8234499f8c151de02d2ebcdfcf41145085f2718c Mon Sep 17 00:00:00 2001 From: yanwei Date: Thu, 18 Nov 2021 23:35:18 +0800 Subject: [PATCH 08/18] add return value in computation::init() --- ODLA/platforms/odla_popart/odla_popart.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/ODLA/platforms/odla_popart/odla_popart.cc b/ODLA/platforms/odla_popart/odla_popart.cc index 93af085fc..01a1e385a 100644 --- a/ODLA/platforms/odla_popart/odla_popart.cc +++ b/ODLA/platforms/odla_popart/odla_popart.cc @@ -307,6 +307,7 @@ odla_status _odla_computation::init(bool is_compile) { std::move(new_session); // set session after all initialization done. } } + return ODLA_SUCCESS; } // Now we set this by config file, should set by the caller? From 409356a5c5530507a45d1db18e9074e42ad41de3 Mon Sep 17 00:00:00 2001 From: yanwei Date: Thu, 18 Nov 2021 23:38:02 +0800 Subject: [PATCH 09/18] clear cache_fs before write new data --- ODLA/platforms/odla_popart/odla_popart.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ODLA/platforms/odla_popart/odla_popart.cc b/ODLA/platforms/odla_popart/odla_popart.cc index 01a1e385a..846ae588e 100644 --- a/ODLA/platforms/odla_popart/odla_popart.cc +++ b/ODLA/platforms/odla_popart/odla_popart.cc @@ -109,7 +109,8 @@ odla_status _odla_computation::compile_and_export() { std::string config_file_name(cache_file_name.substr(0, file_prefix) + ".json"); std::fstream cache_fs(cache_file_name, - std::ios_base::out | std::ifstream::binary); + std::ios_base::out | std::ifstream::binary | + std::ios_base::trunc); if (!cache_fs.is_open()) { popart::logging::err("Open or create cache file falied"); return ODLA_FAILURE; From 77062659ea2f35ec418bd58a89bc9e8ad976081f Mon Sep 17 00:00:00 2001 From: yanwei Date: Thu, 18 Nov 2021 23:41:23 +0800 Subject: [PATCH 10/18] clear fstream after close --- ODLA/platforms/odla_popart/popart_config.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ODLA/platforms/odla_popart/popart_config.h b/ODLA/platforms/odla_popart/popart_config.h index 626b64e60..48fa92b26 100644 --- a/ODLA/platforms/odla_popart/popart_config.h +++ b/ODLA/platforms/odla_popart/popart_config.h @@ -115,6 +115,7 @@ class PopartConfig { inited_ = false; if (cache_fs->is_open()) { cache_fs->close(); + cache_fs->clear(); } pipeline_setting_.clear(); load_or_save_cache_ = false; From 01849224b6f33368d3b6bf1f839487f43c6801ee Mon Sep 17 00:00:00 2001 From: yanwei Date: Thu, 18 Nov 2021 23:46:21 +0800 Subject: [PATCH 11/18] fix lint error --- ODLA/platforms/odla_popart/odla_popart.cc | 6 +++--- ODLA/platforms/odla_popart/popart_config.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ODLA/platforms/odla_popart/odla_popart.cc b/ODLA/platforms/odla_popart/odla_popart.cc index 846ae588e..c1e3b0dc2 100644 --- a/ODLA/platforms/odla_popart/odla_popart.cc +++ b/ODLA/platforms/odla_popart/odla_popart.cc @@ -108,9 +108,9 @@ odla_status _odla_computation::compile_and_export() { } std::string config_file_name(cache_file_name.substr(0, file_prefix) + ".json"); - std::fstream cache_fs(cache_file_name, - std::ios_base::out | std::ifstream::binary | - std::ios_base::trunc); + std::fstream cache_fs(cache_file_name, std::ios_base::out | + std::ifstream::binary | + std::ios_base::trunc); if (!cache_fs.is_open()) { popart::logging::err("Open or create cache file falied"); return ODLA_FAILURE; diff --git a/ODLA/platforms/odla_popart/popart_config.h b/ODLA/platforms/odla_popart/popart_config.h index 48fa92b26..83f06d0af 100644 --- a/ODLA/platforms/odla_popart/popart_config.h +++ b/ODLA/platforms/odla_popart/popart_config.h @@ -115,7 +115,7 @@ class PopartConfig { inited_ = false; if (cache_fs->is_open()) { cache_fs->close(); - cache_fs->clear(); + cache_fs->clear(); } pipeline_setting_.clear(); load_or_save_cache_ = false; From 7ab31701836618c3c7f77e56185b90b05c50188f Mon Sep 17 00:00:00 2001 From: yanwei Date: Sun, 21 Nov 2021 00:42:02 +0800 Subject: [PATCH 12/18] fix error message issue --- ODLA/platforms/odla_popart/odla_popart.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ODLA/platforms/odla_popart/odla_popart.cc b/ODLA/platforms/odla_popart/odla_popart.cc index c1e3b0dc2..d0f694f2f 100644 --- a/ODLA/platforms/odla_popart/odla_popart.cc +++ b/ODLA/platforms/odla_popart/odla_popart.cc @@ -79,7 +79,7 @@ void compute_loop(odla_computation comp) { popart::logging::err("Poplar unrecoverable_runtime_error exception caught"); QManager::instance()->set_status(ODLA_UNRECOVERABLE_ERR); } catch (poplar::unknown_runtime_error& e) { - popart::logging::info("Poplar unknown runtime exception caught}"); + popart::logging::info("Poplar unknown runtime exception caught"); QManager::instance()->set_status(ODLA_UNRECOVERABLE_ERR); } catch (...) { popart::logging::info("Poplar unknown exception caught"); @@ -544,10 +544,10 @@ odla_status Sequence::compute(odla_computation comp, odla_context context, popart::logging::err("Poplar unrecoverable_runtime_error exception caught"); return ODLA_UNRECOVERABLE_ERR; } catch (poplar::unknown_runtime_error& e) { - popart::logging::info("Poplar unknown runtime exception caught}"); + popart::logging::err("Poplar unknown runtime exception caught."); return ODLA_UNRECOVERABLE_ERR; } catch (...) { - popart::logging::info("Poplar unknown exception caught"); + popart::logging::err("Poplar unknown exception caught"); return ODLA_UNRECOVERABLE_ERR; } return ODLA_SUCCESS; From 31a686d728b5236734397c5af7299e1c470c7f74 Mon Sep 17 00:00:00 2001 From: yanwei Date: Thu, 25 Nov 2021 22:44:42 +0800 Subject: [PATCH 13/18] keep load_or_save_cache value --- ODLA/platforms/odla_popart/popart_config.h | 1 - 1 file changed, 1 deletion(-) diff --git a/ODLA/platforms/odla_popart/popart_config.h b/ODLA/platforms/odla_popart/popart_config.h index 83f06d0af..67017c305 100644 --- a/ODLA/platforms/odla_popart/popart_config.h +++ b/ODLA/platforms/odla_popart/popart_config.h @@ -118,7 +118,6 @@ class PopartConfig { cache_fs->clear(); } pipeline_setting_.clear(); - load_or_save_cache_ = false; sdk_version_ = "NA"; } } From 49a9b40c867c9303bb6fb02d6408253617805d57 Mon Sep 17 00:00:00 2001 From: yanwei Date: Tue, 23 Nov 2021 19:30:04 +0800 Subject: [PATCH 14/18] add log --- ODLA/platforms/odla_popart/odla_compute.cc | 4 ++++ ODLA/platforms/odla_popart/odla_popart.cc | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ODLA/platforms/odla_popart/odla_compute.cc b/ODLA/platforms/odla_popart/odla_compute.cc index 379d030c3..287037d92 100644 --- a/ODLA/platforms/odla_popart/odla_compute.cc +++ b/ODLA/platforms/odla_popart/odla_compute.cc @@ -167,13 +167,17 @@ odla_status odla_DestroyContext(odla_context ctx) { } odla_status odla_DestroyComputation(odla_computation comp) { + popart::logging::err("call odla_destroyComputation-----"); if (comp != nullptr) { + popart::logging::err("call odla_destroyComputation-----1"); if (!comp->is_compile_only()) { comp->mark_done(); QManager::instance()->deleteQ(); // delete current queue } + popart::logging::err("call odla_destroyComputation-----2"); comp->release_session(); _odla_computation::destruct(); // release the real computation + popart::logging::err("call odla_destroyComputation-----3 finish"); } popart::logging::info("reset config state"); PopartConfig::instance()->reset_init_state(); diff --git a/ODLA/platforms/odla_popart/odla_popart.cc b/ODLA/platforms/odla_popart/odla_popart.cc index d0f694f2f..c46ff9c1d 100644 --- a/ODLA/platforms/odla_popart/odla_popart.cc +++ b/ODLA/platforms/odla_popart/odla_popart.cc @@ -525,6 +525,8 @@ odla_status Sequence::compute(odla_computation comp, odla_context context, std::chrono::duration elapsed_seconds = end - start; popart::logging::info("[ {} ] [Sequence::compute] takes {} s.", i++, elapsed_seconds.count()); + popart::logging::err("[ {} ] [Sequence::compute] takes {} s.", i++, + elapsed_seconds.count()); popart::logging::info("<<< Sequence::compute() with ctx: {}", context); } catch (poplar::application_runtime_error& e) { popart::logging::err("Poplar exception application_runtime_error caught:"); From 57a4cc9be1aa0e4ea1408ce8e1a835cd92d67cbc Mon Sep 17 00:00:00 2001 From: yanwei Date: Tue, 23 Nov 2021 19:40:47 +0800 Subject: [PATCH 15/18] fix lint --- ODLA/platforms/odla_popart/odla_popart.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ODLA/platforms/odla_popart/odla_popart.cc b/ODLA/platforms/odla_popart/odla_popart.cc index c46ff9c1d..b99e95bec 100644 --- a/ODLA/platforms/odla_popart/odla_popart.cc +++ b/ODLA/platforms/odla_popart/odla_popart.cc @@ -526,7 +526,7 @@ odla_status Sequence::compute(odla_computation comp, odla_context context, popart::logging::info("[ {} ] [Sequence::compute] takes {} s.", i++, elapsed_seconds.count()); popart::logging::err("[ {} ] [Sequence::compute] takes {} s.", i++, - elapsed_seconds.count()); + elapsed_seconds.count()); popart::logging::info("<<< Sequence::compute() with ctx: {}", context); } catch (poplar::application_runtime_error& e) { popart::logging::err("Poplar exception application_runtime_error caught:"); From 29c4f6b6f0e6d57a869a7dc610e7f2572f94a65d Mon Sep 17 00:00:00 2001 From: yanwei Date: Tue, 23 Nov 2021 21:32:53 +0800 Subject: [PATCH 16/18] open popart log --- ODLA/platforms/odla_popart/odla_compute.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ODLA/platforms/odla_popart/odla_compute.cc b/ODLA/platforms/odla_popart/odla_compute.cc index 287037d92..afb275c06 100644 --- a/ODLA/platforms/odla_popart/odla_compute.cc +++ b/ODLA/platforms/odla_popart/odla_compute.cc @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -62,6 +63,7 @@ odla_status odla_SetComputationItem(odla_computation comp, odla_item_type type, comp->opts.cache_dir = (reinterpret_cast(value)); break; case 1001: // load cache directly, need set path of cache file + setenv("POPART_LOG_LEVEL", "INFO", 1); PopartConfig::instance()->set_load_or_save_cache(true); PopartConfig::instance()->set_cache_path( (std::string) reinterpret_cast(value)); From db1a23c21ec0dfcef8c4f69176efba8c8d6a6027 Mon Sep 17 00:00:00 2001 From: yanwei Date: Fri, 26 Nov 2021 13:15:28 +0800 Subject: [PATCH 17/18] change popart version to poplar version --- ODLA/platforms/odla_popart/odla_popart.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ODLA/platforms/odla_popart/odla_popart.cc b/ODLA/platforms/odla_popart/odla_popart.cc index b99e95bec..4098d2df3 100644 --- a/ODLA/platforms/odla_popart/odla_popart.cc +++ b/ODLA/platforms/odla_popart/odla_popart.cc @@ -134,7 +134,7 @@ odla_status _odla_computation::compile_and_export() { config_string = PopartConfig::instance()->get_default_config_string(); } // add sdk_version in the file content - std::string version_string(popart::core::versionString()); + std::string version_string(poplar::packageHash()); popart::logging::info("the popart version is: {}", version_string); version_string = "\n\"sdk_version\":\"" + version_string + "\","; config_string.insert(1, version_string); @@ -236,7 +236,7 @@ odla_status _odla_computation::init(bool is_compile) { if (!is_compile) { if (PopartConfig::instance()->load_or_save_cache()) { popart::logging::info("Load cachefile from existing stream"); - std::string version_string(popart::core::versionString()); + std::string version_string(poplar::packageHash()); if (!PopartConfig::instance()->sdk_version_match(version_string)) { popart::logging::err("The sdk version of cache does not match {}", version_string); From 4509f93bd91c4ed0aaeca0e583159ec800ba8374 Mon Sep 17 00:00:00 2001 From: yanwei Date: Fri, 26 Nov 2021 19:42:16 +0800 Subject: [PATCH 18/18] update some log type to err & get sdk packagehash in use_default() --- ODLA/platforms/odla_popart/odla_compute.cc | 5 +-- ODLA/platforms/odla_popart/odla_popart.cc | 18 ++++----- ODLA/platforms/odla_popart/popart_config.cc | 41 ++++++++++++++------- ODLA/platforms/odla_popart/popart_config.h | 2 + 4 files changed, 40 insertions(+), 26 deletions(-) diff --git a/ODLA/platforms/odla_popart/odla_compute.cc b/ODLA/platforms/odla_popart/odla_compute.cc index afb275c06..9d28911ae 100644 --- a/ODLA/platforms/odla_popart/odla_compute.cc +++ b/ODLA/platforms/odla_popart/odla_compute.cc @@ -169,17 +169,14 @@ odla_status odla_DestroyContext(odla_context ctx) { } odla_status odla_DestroyComputation(odla_computation comp) { - popart::logging::err("call odla_destroyComputation-----"); + popart::logging::info("call odla_destroyComputation"); if (comp != nullptr) { - popart::logging::err("call odla_destroyComputation-----1"); if (!comp->is_compile_only()) { comp->mark_done(); QManager::instance()->deleteQ(); // delete current queue } - popart::logging::err("call odla_destroyComputation-----2"); comp->release_session(); _odla_computation::destruct(); // release the real computation - popart::logging::err("call odla_destroyComputation-----3 finish"); } popart::logging::info("reset config state"); PopartConfig::instance()->reset_init_state(); diff --git a/ODLA/platforms/odla_popart/odla_popart.cc b/ODLA/platforms/odla_popart/odla_popart.cc index 4098d2df3..3a26f7cc1 100644 --- a/ODLA/platforms/odla_popart/odla_popart.cc +++ b/ODLA/platforms/odla_popart/odla_popart.cc @@ -79,14 +79,14 @@ void compute_loop(odla_computation comp) { popart::logging::err("Poplar unrecoverable_runtime_error exception caught"); QManager::instance()->set_status(ODLA_UNRECOVERABLE_ERR); } catch (poplar::unknown_runtime_error& e) { - popart::logging::info("Poplar unknown runtime exception caught"); + popart::logging::err("Poplar unknown runtime exception caught"); QManager::instance()->set_status(ODLA_UNRECOVERABLE_ERR); } catch (...) { - popart::logging::info("Poplar unknown exception caught"); + popart::logging::err("Poplar unknown exception caught"); QManager::instance()->set_status(ODLA_UNRECOVERABLE_ERR); } - popart::logging::warn("The pipeline loop finished"); + popart::logging::info("The pipeline loop finished"); comp->thread_done(); } @@ -134,10 +134,12 @@ odla_status _odla_computation::compile_and_export() { config_string = PopartConfig::instance()->get_default_config_string(); } // add sdk_version in the file content - std::string version_string(poplar::packageHash()); + std::string version_string(popart::core::packageHash()); popart::logging::info("the popart version is: {}", version_string); - version_string = "\n\"sdk_version\":\"" + version_string + "\","; - config_string.insert(1, version_string); + if (config_string.find("sdk_version") == std::string::npos) { + std::string item_string = "\n\"sdk_version\":\"" + version_string + "\","; + config_string.insert(1, item_string); + } popart::logging::info("the config_string with sdk_version is: {}", config_string); // added the sdk_version information to the file content @@ -236,7 +238,7 @@ odla_status _odla_computation::init(bool is_compile) { if (!is_compile) { if (PopartConfig::instance()->load_or_save_cache()) { popart::logging::info("Load cachefile from existing stream"); - std::string version_string(poplar::packageHash()); + std::string version_string(popart::core::packageHash()); if (!PopartConfig::instance()->sdk_version_match(version_string)) { popart::logging::err("The sdk version of cache does not match {}", version_string); @@ -525,8 +527,6 @@ odla_status Sequence::compute(odla_computation comp, odla_context context, std::chrono::duration elapsed_seconds = end - start; popart::logging::info("[ {} ] [Sequence::compute] takes {} s.", i++, elapsed_seconds.count()); - popart::logging::err("[ {} ] [Sequence::compute] takes {} s.", i++, - elapsed_seconds.count()); popart::logging::info("<<< Sequence::compute() with ctx: {}", context); } catch (poplar::application_runtime_error& e) { popart::logging::err("Poplar exception application_runtime_error caught:"); diff --git a/ODLA/platforms/odla_popart/popart_config.cc b/ODLA/platforms/odla_popart/popart_config.cc index 204740186..e0006780b 100644 --- a/ODLA/platforms/odla_popart/popart_config.cc +++ b/ODLA/platforms/odla_popart/popart_config.cc @@ -27,6 +27,10 @@ #include "json.hpp" PopartConfig* PopartConfig::instance_ = new PopartConfig(); +std::vector PopartConfig::mode = {"unknown", "pipeline", + "parallel", "sequence"}; + +const char* bool_to_str(const bool& value) { return value ? "true" : "false"; } const std::string& get_config_path_from_cache_file( const std::string& cache_path) { @@ -43,6 +47,7 @@ const std::string& get_config_path_from_cache_file( void PopartConfig::use_default() { amp_ = 0.6; + sdk_version_ = popart::core::packageHash(); version_ = "1.0.0"; batches_per_step_ = 1; ipu_num_ = 1; @@ -54,19 +59,27 @@ void PopartConfig::use_default() { queue_type_ = "LockFreeQueue"; queue_capacity_ = 1024 * 1024; debug_ = false; - default_config_string_ = + char config_base[] = "{\n\ - \"version\":\"1.0.0\",\n\ - \"amp\":0.6,\n\ - \"batches_per_step\":1,\n\ - \"execution_mode\":\"sequence\",\n\ - \"ipu_num\":1,\n\ - \"load_onnx\":false, \n\ - \"load_onnx_path\":\"test-load-time.onnx\",\n\ - \"queue_type\":\"LockFreeQueue\",\n\ - \"queue_capacity\":1048576,\n\ - \"debug\": false\n\ + \"sdk_version\":\"%s\",\n\ + \"version\":\"%s\",\n\ + \"amp\":%f,\n\ + \"batches_per_step\":%d,\n\ + \"execution_mode\":\"%s\",\n\ + \"ipu_num\":%d,\n\ + \"load_onnx\":%s, \n\ + \"load_onnx_path\":\"%s\",\n\ + \"queue_type\":\"%s\",\n\ + \"queue_capacity\":%d,\n\ + \"debug\":%s\n\ }\n"; + char raw_default_config[1024] = {0}; + snprintf(raw_default_config, 1024, config_base, sdk_version_.c_str(), + version_.c_str(), amp_, batches_per_step_, + PopartConfig::mode[(int)execution_mode_].c_str(), ipu_num_, + bool_to_str(load_onnx_), load_onnx_path_.c_str(), + queue_type_.c_str(), queue_capacity_, bool_to_str(debug_)); + default_config_string_ = raw_default_config; } odla_status PopartConfig::load_config(const char* env_file_path) { @@ -104,6 +117,8 @@ odla_status PopartConfig::load_config(const char* env_file_path) { void PopartConfig::parse_from_json(const json& jf) { if (jf.contains("sdk_version")) { sdk_version_ = jf["sdk_version"].get(); + } else { + sdk_version_ = popart::core::packageHash(); } if (jf.contains("amp")) { amp_ = jf["amp"].get(); @@ -196,12 +211,12 @@ odla_status PopartConfig::load_from_file(const std::string& file_path) { void PopartConfig::print() { std::string line(80, '='); popart::logging::info(line); + popart::logging::info("sdk_version: {}", sdk_version_); popart::logging::info("version: {}", version_); popart::logging::info("amp: {}", amp_); popart::logging::info("batch_per_step: {}", batches_per_step_); - std::string mode[] = {"UNKNOWN", "PIPELINE", "PARALLEL", "SEQUENCE"}; popart::logging::info("execution_mode: {}", - mode[(long unsigned int)execution_mode_]); + PopartConfig::mode[(long unsigned int)execution_mode_]); popart::logging::info("ipu_num: {}", ipu_num_); std::string bool_value[] = {"false", "true"}; popart::logging::info("load_onnx: {}", diff --git a/ODLA/platforms/odla_popart/popart_config.h b/ODLA/platforms/odla_popart/popart_config.h index 67017c305..54e55fd71 100644 --- a/ODLA/platforms/odla_popart/popart_config.h +++ b/ODLA/platforms/odla_popart/popart_config.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -61,6 +62,7 @@ class PopartConfig { std::string sdk_version_; // version of the sdk int batches_per_step_; // Batch per step for PIPELINE & PARALLEL execution // mode + static std::vector mode; // string value of execution mode ExecutionMode execution_mode_; // The execution mode {PIPELINE, PARALLEL, SEQUENCE} bool load_onnx_; // Whether load onnx model to run instead of the model