Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lin-hitonami committed Nov 9, 2022
1 parent b5e661d commit 3fcac2c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions taichi/program/program.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <optional>
#include <atomic>
#include <stack>
#include <shared_mutex>

#define TI_RUNTIME_HOST
#include "taichi/aot/module_builder.h"
Expand Down Expand Up @@ -126,9 +127,11 @@ class TI_DLL_EXPORT Program {
CompileConfig &this_thread_config() {
auto thread_id = std::this_thread::get_id();
if (!configs.count(thread_id)) {
std::lock_guard<std::mutex> _(compile_config_mut);
std::unique_lock<std::shared_mutex> _(compile_config_mut);
configs[thread_id] = configs[main_thread_id_];
return configs[thread_id];
}
std::shared_lock<std::shared_mutex> _(compile_config_mut);
return configs[thread_id];
}

Expand Down Expand Up @@ -397,7 +400,7 @@ class TI_DLL_EXPORT Program {
std::vector<std::unique_ptr<Ndarray>> ndarrays_;
std::vector<std::unique_ptr<Texture>> textures_;

std::mutex compile_config_mut;
mutable std::shared_mutex compile_config_mut;
};

} // namespace taichi::lang

0 comments on commit 3fcac2c

Please sign in to comment.