-
Notifications
You must be signed in to change notification settings - Fork 16
[Misc] QD_DUMP_IR dumps to files with the task_id added to the filename #441
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
Changes from all commits
085cbbb
a272a56
b3b8a9e
4210f8e
887a388
e465795
6a0bcfd
7c95229
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,11 +84,18 @@ JITSessionCUDA::JITSessionCUDA(QuadrantsLLVMContext *tlctx, | |
|
|
||
| JITModule *JITSessionCUDA::add_module(std::unique_ptr<llvm::Module> M, int max_reg) { | ||
| const char *dump_ir_env = std::getenv(DUMP_IR_ENV.data()); | ||
| if (dump_ir_env != nullptr && std::string(dump_ir_env) == "1") { | ||
| const char *load_ptx_env = std::getenv("QUADRANTS_LOAD_PTX"); | ||
|
|
||
| // Capture the dump name before compile_module_to_ptx renames functions via convert(). | ||
| std::string dump_name; | ||
| if (dump_ir_env != nullptr || load_ptx_env != nullptr) { | ||
| dump_name = moduleToDumpName(M.get()); | ||
|
Comment on lines
+89
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Capturing Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| if (dump_ir_env != nullptr && std::string(dump_ir_env) == "1" && !dump_name.empty()) { | ||
| std::filesystem::path ir_dump_dir = config_.debug_dump_path; | ||
| std::filesystem::create_directories(ir_dump_dir); | ||
| std::string dumpName = moduleToDumpName(M.get()); | ||
| std::filesystem::path filename = ir_dump_dir / (dumpName + "_before_ptx.ll"); | ||
| std::filesystem::path filename = ir_dump_dir / (dump_name + "_before_ptx.ll"); | ||
| std::error_code EC; | ||
| llvm::raw_fd_ostream dest_file(filename.string(), EC); | ||
| if (!EC) { | ||
|
|
@@ -105,22 +112,19 @@ JITModule *JITSessionCUDA::add_module(std::unique_ptr<llvm::Module> M, int max_r | |
| writer.write(ptx); | ||
| } | ||
|
|
||
| if (dump_ir_env != nullptr) { | ||
| if (dump_ir_env != nullptr && !dump_name.empty()) { | ||
| std::filesystem::path ir_dump_dir = config_.debug_dump_path; | ||
| std::filesystem::create_directories(ir_dump_dir); | ||
| std::string dumpName = moduleToDumpName(M.get()); | ||
| std::filesystem::path ptx_path = ir_dump_dir / (dumpName + ".ptx"); | ||
| std::filesystem::path ptx_path = ir_dump_dir / (dump_name + ".ptx"); | ||
| if (std::ofstream out_file(ptx_path); out_file.is_open()) { | ||
| out_file << ptx << std::endl; | ||
| std::cout << "PTX dumped to: " << ptx_path.string() << std::endl; | ||
| } | ||
| std::cout << "PTX dumped to: " << ptx_path.string() << std::endl; | ||
| } | ||
|
|
||
| const char *load_ptx_env = std::getenv("QUADRANTS_LOAD_PTX"); | ||
| if (load_ptx_env != nullptr) { | ||
| if (load_ptx_env != nullptr && !dump_name.empty()) { | ||
| std::filesystem::path ir_dump_dir = config_.debug_dump_path; | ||
| std::string dumpName = moduleToDumpName(M.get()); | ||
| std::filesystem::path ptx_path = ir_dump_dir / (dumpName + ".ptx"); | ||
| std::filesystem::path ptx_path = ir_dump_dir / (dump_name + ".ptx"); | ||
| std::ifstream in_file(ptx_path); | ||
| if (in_file.is_open()) { | ||
| QD_INFO("Loading PTX from file: {}", ptx_path.string()); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
offloaded_tasks[0].namedirectly in the path makes dump/load filenames inherit raw loop names fromqd.loop_config(name=...)(viainit_offloaded_task_function), and those names are not constrained to filesystem-safe characters. When a loop name includes separators or reserved characters (for example/,\,:,?),QD_DUMP_IR/QD_LOAD_IRcan fail to open the file or resolve outside the intended dump directory.Useful? React with 👍 / 👎.