Skip to content

Commit

Permalink
Merge pull request #2992 from ROCm/rocm61_2987
Browse files Browse the repository at this point in the history
Limit parallelism for constant propagation cherry-pick
  • Loading branch information
vamovsik authored May 2, 2024
2 parents 11d19e3 + cba5184 commit 5ec76bd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/propagate_constant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <migraphx/functional.hpp>
#include <migraphx/simple_par_for.hpp>
#include <migraphx/env.hpp>
#include <thread>
#include <unordered_set>

namespace migraphx {
Expand Down Expand Up @@ -83,7 +84,12 @@ void propagate_constant::apply(module& m) const
// Compute literals in parallel
std::vector<instruction_ref> const_instrs_vec{const_instrs.begin(), const_instrs.end()};
std::vector<argument> literals(const_instrs_vec.size());
simple_par_for(const_instrs_vec.size(), 1, [&](const auto i) {
std::size_t grainsize = 1;
#if !MIGRAPHX_HAS_EXECUTORS
std::size_t n = std::max<std::size_t>(2048 / std::thread::hardware_concurrency(), 1);
grainsize = const_instrs_vec.size() / n;
#endif
simple_par_for(const_instrs_vec.size(), grainsize, [&](const auto i) {
literals[i] = const_instrs_vec[i]->eval();
});

Expand Down

0 comments on commit 5ec76bd

Please sign in to comment.