Skip to content

Commit

Permalink
[misc] Disable the offline cache if printing ir is enabled (#6234)
Browse files Browse the repository at this point in the history
Issue: fixes #6218

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
PGZXB and pre-commit-ci[bot] authored Oct 8, 2022
1 parent 5c6ad43 commit 758aba9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions taichi/program/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Program::Program(Arch desired_arch) : snode_rw_accessors_bank_(this) {
// TODO: allow users to run in debug mode without out-of-bound checks
if (config.debug)
config.check_out_of_bound = true;
offline_cache::disable_offline_cache_if_needed(&config);

profiler = make_profiler(config.arch, config.kernel_profiler);
if (arch_uses_llvm(config.arch)) {
Expand Down
13 changes: 13 additions & 0 deletions taichi/util/offline_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ namespace taichi::lang::offline_cache {
constexpr std::size_t offline_cache_key_length = 65;
constexpr std::size_t min_mangled_name_length = offline_cache_key_length + 2;

void disable_offline_cache_if_needed(CompileConfig *config) {
TI_ASSERT(config);
if (config->offline_cache) {
if (config->print_preprocessed_ir || config->print_ir ||
config->print_accessor_ir) {
config->offline_cache = false;
TI_WARN(
"Disable offline_cache because print_preprocessed_ir or print_ir or "
"print_accessor_ir is enabled");
}
}
}

std::string get_cache_path_by_arch(const std::string &base_path, Arch arch) {
std::string subdir;
if (arch_uses_llvm(arch)) {
Expand Down
2 changes: 2 additions & 0 deletions taichi/util/offline_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "taichi/rhi/arch.h"
#include "taichi/util/io.h"
#include "taichi/util/lock.h"
#include "taichi/program/compile_config.h"

namespace taichi::lang {
namespace offline_cache {
Expand Down Expand Up @@ -286,6 +287,7 @@ class CacheCleaner {
}
};

void disable_offline_cache_if_needed(CompileConfig *config);
std::string get_cache_path_by_arch(const std::string &base_path, Arch arch);
bool enabled_wip_offline_cache(bool enable_hint);
std::string mangle_name(const std::string &primal_name, const std::string &key);
Expand Down

0 comments on commit 758aba9

Please sign in to comment.