Skip to content

Commit

Permalink
Use minimum block size of 64 threads (#1427)
Browse files Browse the repository at this point in the history
Local Threads of multiples 32 were introduced in #1348
But LocalThreads that are not multiple of 64 are causing correctness issues.
  • Loading branch information
umangyadav authored and causten committed Nov 3, 2022
1 parent 4d471bd commit 788ce62
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/targets/gpu/compile_hip_code_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,8 @@ compute_global_for(context& ctx, std::size_t n, std::size_t over)

std::size_t compute_block_size(std::size_t n, std::size_t max_block_size)
{
const std::size_t min_block_size = 64;
const std::size_t base_block_size = 32;
auto block_size = (((n - 1) / base_block_size + 1)) * base_block_size;
const std::size_t min_block_size = 64;
auto block_size = (((n - 1) / min_block_size + 1)) * min_block_size;
return std::min(std::max(min_block_size, block_size), max_block_size);
}

Expand Down
15 changes: 14 additions & 1 deletion test/verify/test_reduce_op_large.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ template struct test_reduce_op_large<migraphx::op::reduce_min, 1, migraphx::shap
template struct test_reduce_op_large<migraphx::op::reduce_prod, 2, migraphx::shape::float_type>;
template struct test_reduce_op_large<migraphx::op::reduce_sum, 1, migraphx::shape::float_type>;

struct test_reduce_mean : verify_program<test_reduce_mean>
struct test_reduce_mean_1 : verify_program<test_reduce_mean_1>
{
migraphx::program create_program() const
{
Expand All @@ -63,3 +63,16 @@ struct test_reduce_mean : verify_program<test_reduce_mean>
return p;
};
};

struct test_reduce_mean_2 : verify_program<test_reduce_mean_2>
{
migraphx::program create_program() const
{
migraphx::program p;
auto* mm = p.get_main_module();
migraphx::shape s{migraphx::shape::float_type, {336, 400}};
auto x = mm->add_parameter("x", s);
mm->add_instruction(migraphx::op::reduce_mean{{1}}, x);
return p;
};
};

0 comments on commit 788ce62

Please sign in to comment.