From f454bbfdc1a3a222f5e767f6cb3a9602a5bf9e8e Mon Sep 17 00:00:00 2001 From: ikalinic Date: Tue, 30 Jun 2026 11:50:04 +0200 Subject: [PATCH 1/2] Handle benchmark MXR dump as successful compile --- src/driver/main.cpp | 9 ++++++++- src/include/migraphx/errors.hpp | 22 +++++++++++++++++++++- src/pass_manager.cpp | 6 ++++++ src/targets/gpu/compile_ops.cpp | 3 ++- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/driver/main.cpp b/src/driver/main.cpp index d6dbe0ed914..0ab0b6a8d85 100644 --- a/src/driver/main.cpp +++ b/src/driver/main.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -1255,7 +1256,13 @@ int main(int argc, const char* argv[], const char* envp[]) auto start_time = std::chrono::system_clock::now(); - m.at(cmd)(ap, {args.begin() + 1, args.end()}); + try + { + m.at(cmd)(ap, {args.begin() + 1, args.end()}); + } + catch(const migraphx::benchmark_mxr_dumped&) + { + } // Dump all the MIGraphX (consumed) Environment Variables: const auto mgx_env_map = migraphx::get_all_envs(); diff --git a/src/include/migraphx/errors.hpp b/src/include/migraphx/errors.hpp index aff4cbf233d..b68370eb9f7 100644 --- a/src/include/migraphx/errors.hpp +++ b/src/include/migraphx/errors.hpp @@ -1,7 +1,7 @@ /* * The MIT License (MIT) * - * Copyright (c) 2015-2022 Advanced Micro Devices, Inc. All rights reserved. + * Copyright (c) 2015-2026 Advanced Micro Devices, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -41,6 +41,11 @@ struct exception : std::runtime_error } }; +struct benchmark_mxr_dumped : exception +{ + benchmark_mxr_dumped(unsigned int e = 0, const std::string& msg = "") : exception(e, msg) {} +}; + /** * @brief Create an exception object * @@ -59,6 +64,19 @@ make_exception(const std::string& context, unsigned int e, const std::string& me return {e, context + ": " + message}; } +inline benchmark_mxr_dumped make_benchmark_mxr_dumped_exception(const std::string& context, + const std::string& message = "") +{ + return {0, context + ": " + message}; +} + +inline benchmark_mxr_dumped make_benchmark_mxr_dumped_exception(const std::string& context, + unsigned int e, + const std::string& message = "") +{ + return {e, context + ": " + message}; +} + /** * @brief Create a message of a file location * @@ -79,6 +97,8 @@ inline std::string make_source_context(const std::string& file, int line, const * @brief Throw an exception with context information */ #define MIGRAPHX_THROW(...) throw migraphx::make_exception(MIGRAPHX_MAKE_SOURCE_CTX(), __VA_ARGS__) +#define MIGRAPHX_THROW_BENCHMARK_MXR_DUMPED(...) \ + throw migraphx::make_benchmark_mxr_dumped_exception(MIGRAPHX_MAKE_SOURCE_CTX(), __VA_ARGS__) } // namespace MIGRAPHX_INLINE_NS } // namespace migraphx diff --git a/src/pass_manager.cpp b/src/pass_manager.cpp index 999465ede7c..6d8790d02dd 100644 --- a/src/pass_manager.cpp +++ b/src/pass_manager.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -180,6 +181,11 @@ struct module_pm : module_pass_manager { f(); } + catch(const benchmark_mxr_dumped& e) + { + log::info() << "Benchmark MXR dump " << p.name() << ": " << e.what(); + throw; + } catch(const std::exception& e) { log::error() << "Error " << p.name() << ": " << e.what(); diff --git a/src/targets/gpu/compile_ops.cpp b/src/targets/gpu/compile_ops.cpp index 69d6cf0d9ee..3dfa5c376c0 100644 --- a/src/targets/gpu/compile_ops.cpp +++ b/src/targets/gpu/compile_ops.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -586,7 +587,7 @@ struct compile_manager // root module has had a chance to dump its benchmark MXR files. if(dump_mxr and is_root) { - MIGRAPHX_THROW( + MIGRAPHX_THROW_BENCHMARK_MXR_DUMPED( "Benchmark MXR files dumped to " + mxr_path + ". Run the MXR files to create a problem cache, then recompile with the cache."); } From 71ea83021a9bcdb92dacb1522d33d9c2c443dcd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilija=20Kalini=C4=87?= Date: Tue, 30 Jun 2026 15:49:23 +0200 Subject: [PATCH 2/2] Explicitly discard benchmark MXR dump exception --- src/driver/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/driver/main.cpp b/src/driver/main.cpp index 0ab0b6a8d85..349b263e581 100644 --- a/src/driver/main.cpp +++ b/src/driver/main.cpp @@ -1260,8 +1260,9 @@ int main(int argc, const char* argv[], const char* envp[]) { m.at(cmd)(ap, {args.begin() + 1, args.end()}); } - catch(const migraphx::benchmark_mxr_dumped&) + catch(const migraphx::benchmark_mxr_dumped& e) { + (void)e; } // Dump all the MIGraphX (consumed) Environment Variables: