Skip to content

Commit

Permalink
#6347: Print built-in defines once only
Browse files Browse the repository at this point in the history
  • Loading branch information
ihamer-tt committed Mar 13, 2024
1 parent eac09c8 commit 8c9c00a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tt_metal/jit_build/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ void JitBuildState::compile_one(const string& log_file,
log_debug(tt::LogBuildKernels, " g++ compile cmd: {}", cmd);

if (tt::llrt::OptionsG.get_watcher_enabled() && settings) {
log_kernel_defines_and_args(env_.get_out_kernel_root_path(), settings->get_full_kernel_name(), defines_, defines);
log_kernel_defines_and_args(out_dir, settings->get_full_kernel_name(), defines);
}

if (!tt::utils::run_command(cmd, log_file, false)) {
Expand Down
14 changes: 9 additions & 5 deletions tt_metal/jit_build/kernel_args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,21 @@ void str_replace_all(string& source, const string& from, const string& to) {
}
}

void log_kernel_defines_and_args (const string &out_kernel_root_path, const string &full_kernel_name, const string &built_in_defines, const string &defines_and_args_str) {
void log_kernel_defines_and_args (const string &out_dir, const string &full_kernel_name, const string &defines_and_args_str) {
std::lock_guard<std::mutex> lock(mutex_kernel_defines_and_args_);
string defines_as_csv(built_in_defines + " " + defines_and_args_str);
string defines_as_csv(defines_and_args_str);

str_replace_all(defines_as_csv, "KERNEL_COMPILE_TIME_", "");
str_replace_all(defines_as_csv, "-D", ",");
str_replace_all(defines_as_csv, " ", "");
str_replace_all(defines_as_csv, ",", ", ");

if (kernel_defines_and_args_.find(full_kernel_name) == kernel_defines_and_args_.end()) {
kernel_defines_and_args_[full_kernel_name] = defines_as_csv;
if (kernel_defines_and_args_.find(out_dir) == kernel_defines_and_args_.end()) {
kernel_defines_and_args_[out_dir] = defines_as_csv;
} else {
// TT_ASSERT(kernel_defines_and_args_[full_kernel_name] == defines_as_csv, "Mismatched defines and args for kernel: {}. Expected:\n{}, Got: \n{}", full_kernel_name, kernel_defines_and_args_[full_kernel_name], defines_as_csv);
if (kernel_defines_and_args_[out_dir] != defines_as_csv) {
log_error ("Multiple distinct kernel arguments found for: {}. Existing:\n{}, New: \n{}", out_dir, kernel_defines_and_args_[full_kernel_name], defines_as_csv);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion tt_metal/jit_build/kernel_args.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ using namespace tt;
namespace tt::tt_metal {

// Log current kernel compile-time arguments
void log_kernel_defines_and_args (const string &out_kernel_root_path, const string &full_kernel_name, const string &built_in_defines, const string &defines_and_args_str);
void log_kernel_defines_and_args (const string &out_dir, const string &full_kernel_name, const string &defines_and_args_str);
// Dump all kernel compile-time arguments to a file
void dump_kernel_defines_and_args(const string &out_kernel_root_path);

Expand Down

0 comments on commit 8c9c00a

Please sign in to comment.