Skip to content
Closed
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
10 changes: 9 additions & 1 deletion src/driver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <migraphx/version.h>
#include <migraphx/env.hpp>
#include <migraphx/logger.hpp>
#include <migraphx/errors.hpp>

#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/eliminate_identity.hpp>
Expand Down Expand Up @@ -1255,7 +1256,14 @@ 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& e)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont really like catching exceptions in the driver as it reduces stopping at the exception in the debugger.

This also gpu-specific and the driver is for all targets.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stop reading my mind. I think this would be fine though if we caught a specific execption this is trying to block out vs a catch-all here?

{
(void)e;
}

// Dump all the MIGraphX (consumed) Environment Variables:
const auto mgx_env_map = migraphx::get_all_envs();
Expand Down
22 changes: 21 additions & 1 deletion src/include/migraphx/errors.hpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
*
Expand All @@ -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
*
Expand All @@ -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(...) \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be added to the errors. This a gpu-specific error.

throw migraphx::make_benchmark_mxr_dumped_exception(MIGRAPHX_MAKE_SOURCE_CTX(), __VA_ARGS__)

} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
Expand Down
6 changes: 6 additions & 0 deletions src/pass_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <migraphx/filesystem.hpp>
#include <migraphx/load_save.hpp>
#include <migraphx/logger.hpp>
#include <migraphx/errors.hpp>
#include <iostream>
#include <sstream>
#include <algorithm>
Expand Down Expand Up @@ -180,6 +181,11 @@ struct module_pm : module_pass_manager
{
f();
}
catch(const benchmark_mxr_dumped& e)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pass_manager shouldn't be catching gpu-specific exceptions.

{
log::info() << "Benchmark MXR dump " << p.name() << ": " << e.what();
throw;
}
catch(const std::exception& e)
{
log::error() << "Error " << p.name() << ": " << e.what();
Expand Down
3 changes: 2 additions & 1 deletion src/targets/gpu/compile_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/memory_coloring.hpp>
#include <migraphx/logger.hpp>
#include <migraphx/errors.hpp>
#include <migraphx/op/identity.hpp>
#include <migraphx/builtin.hpp>
#include <migraphx/load_save.hpp>
Expand Down Expand Up @@ -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(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of throwing an exception we can just print a message with log::info and then exit(0).

"Benchmark MXR files dumped to " + mxr_path +
". Run the MXR files to create a problem cache, then recompile with the cache.");
}
Expand Down
Loading