diff --git a/taichi/program/program.cpp b/taichi/program/program.cpp index c99a15528bd99..0516dd0fd3cce 100644 --- a/taichi/program/program.cpp +++ b/taichi/program/program.cpp @@ -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)) { diff --git a/taichi/util/offline_cache.cpp b/taichi/util/offline_cache.cpp index aec5b5ed60391..2cf7797ac8929 100644 --- a/taichi/util/offline_cache.cpp +++ b/taichi/util/offline_cache.cpp @@ -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)) { diff --git a/taichi/util/offline_cache.h b/taichi/util/offline_cache.h index 665ebaf3f70ff..df1eb863d2286 100644 --- a/taichi/util/offline_cache.h +++ b/taichi/util/offline_cache.h @@ -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 { @@ -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);