Skip to content

Commit

Permalink
ta_dense_device supports extents not evenly divisible by tile sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
evaleev committed Jul 23, 2024
1 parent 0b5244f commit 9d5ad23
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions examples/device/ta_dense_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ void do_main_body(TiledArray::World &world, const long Nm, const long Bm,
using RT = TiledArray::detail::scalar_t<Storage>;
constexpr auto complex_T = TiledArray::detail::is_complex_v<T>;

const std::size_t Tm = Nm / Bm;
const std::size_t Tn = Nn / Bn;
const std::size_t Tk = Nk / Bk;

const std::int64_t nflops =
(complex_T ? 8 : 2) // 1 multiply takes 6/1 flops for complex/real
// 1 add takes 2/1 flops for complex/real
Expand All @@ -64,16 +60,16 @@ void do_main_body(TiledArray::World &world, const long Nm, const long Bm,

// Construct TiledRange
std::vector<unsigned int> blocking_m;
blocking_m.reserve(Tm + 1);
for (long i = 0l; i <= Nm; i += Bm) blocking_m.push_back(i);
const std::size_t Tm = blocking_m.size() - 1;

std::vector<unsigned int> blocking_n;
blocking_n.reserve(Tn + 1);
for (long i = 0l; i <= Nn; i += Bn) blocking_n.push_back(i);
const std::size_t Tn = blocking_n.size() - 1;

std::vector<unsigned int> blocking_k;
blocking_k.reserve(Tk + 1);
for (long i = 0l; i <= Nk; i += Bk) blocking_k.push_back(i);
const std::size_t Tk = blocking_k.size();

// Structure of c
std::vector<TiledArray::TiledRange1> blocking_C;
Expand Down Expand Up @@ -255,11 +251,6 @@ int try_main(int argc, char **argv) {
std::cerr << "Error: block sizes must be greater than zero.\n";
return 1;
}
if ((Nm % Bm) != 0ul || Nn % Bn != 0ul || Nk % Bk != 0ul) {
std::cerr
<< "Error: dimension size must be evenly divisible by block size.\n";
return 1;
}
const long nrepeat = (argc >= 8 ? atol(argv[7]) : 5);
if (nrepeat <= 0) {
std::cerr << "Error: number of repetitions must be greater than zero.\n";
Expand Down

0 comments on commit 9d5ad23

Please sign in to comment.