Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[misc] Disable the offline cache if printing ir is enabled #6234

Merged
merged 2 commits into from
Oct 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
strongoier marked this conversation as resolved.
Show resolved Hide resolved
config->offline_cache = false;
TI_WARN(
"Disable offline_cache because print_preprocessed_ir or print_ir or "
"print_accessor_ir is enabled");
strongoier marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

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