@@ -24,15 +24,12 @@ namespace paddle {
24
24
namespace lite {
25
25
26
26
CLRuntime* CLRuntime::Global () {
27
- static CLRuntime cl_runtime_;
27
+ thread_local CLRuntime cl_runtime_;
28
28
cl_runtime_.Init ();
29
29
return &cl_runtime_;
30
30
}
31
31
32
32
CLRuntime::~CLRuntime () {
33
- SaveProgram ();
34
- SaveTuned ();
35
-
36
33
#ifdef LITE_WITH_LOG
37
34
LOG (INFO) << " is_cl_runtime_initialized_:" << is_cl_runtime_initialized_;
38
35
#endif
@@ -399,9 +396,7 @@ void CLRuntime::SaveTuned() {
399
396
if (tuned_path_name_.empty () || auto_tune () == lite_api::CL_TUNE_NONE) return ;
400
397
std::string tuned_file =
401
398
tuned_path_name_.at (0 ) + " /" + tuned_path_name_.at (1 );
402
- if (tuned_file == " /" ) {
403
- LOG (INFO) << " invalid tuned_file:" << tuned_file;
404
- } else if (IsFileExists (tuned_file)) {
399
+ if (IsFileExists (tuned_file)) {
405
400
LOG (INFO) << " OpenCL Tuned file existed:" << tuned_file;
406
401
} else {
407
402
bool ret = Serialize (tuned_file, tuned_lwss_map_);
@@ -848,15 +843,14 @@ void CLRuntime::set_auto_tune(lite_api::CLTuneMode tune_mode,
848
843
auto_tune_ = lite_api::CL_TUNE_NONE;
849
844
}
850
845
lws_repeats_ = lws_repeats;
851
- if (tuned_path_name_.empty ()) {
852
- tuned_path_name_.push_back (path);
853
- tuned_path_name_.push_back (name);
854
- }
855
- const std::string tuned_file = path + " /" + name;
856
- LOG (INFO) << " tuned_file.size():" << tuned_file.size ()
857
- << " , tuned_file:" << tuned_file;
858
- if (tuned_file.size () > 2 && IsFileExists (tuned_file) &&
859
- auto_tune () != lite_api::CL_TUNE_NONE) {
846
+
847
+ tuned_path_name_.clear ();
848
+ tuned_path_name_.push_back (path);
849
+ tuned_path_name_.push_back (name);
850
+ const std::string tuned_file =
851
+ tuned_path_name_.at (0 ) + " /" + tuned_path_name_.at (1 );
852
+ LOG (INFO) << " tuned_file:" << tuned_file;
853
+ if (IsFileExists (tuned_file) && auto_tune () != lite_api::CL_TUNE_NONE) {
860
854
LOG (INFO) << " Load tuned file: " << tuned_file;
861
855
bool status = Deserialize (tuned_file, &tuned_lwss_map_);
862
856
if (!status) {
@@ -865,7 +859,6 @@ void CLRuntime::set_auto_tune(lite_api::CLTuneMode tune_mode,
865
859
} else {
866
860
LOG (INFO) << " Not found tuned file:" << tuned_file;
867
861
}
868
- command_queue_ = CreateCommandQueue (context ());
869
862
}
870
863
871
864
bool CLRuntime::HasTunedLocalWorkSizeMap (const std::string& key,
0 commit comments