From 93967934817df3405845104ce5c4d2dd14738ba5 Mon Sep 17 00:00:00 2001 From: Christian Trott Date: Tue, 4 Apr 2023 10:38:36 -0600 Subject: [PATCH] Fix build of examples with bracket operator --- examples/dot_product/dot_product.cpp | 8 ++++++++ examples/tiled_layout/simple_tiled_layout.cpp | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/examples/dot_product/dot_product.cpp b/examples/dot_product/dot_product.cpp index 8337bbea..339c89ca 100644 --- a/examples/dot_product/dot_product.cpp +++ b/examples/dot_product/dot_product.cpp @@ -59,7 +59,11 @@ T dot_product( T result = 0; for(int i = 0; i < a.extent(0); ++i) { for(int j = 0; j < a.extent(1); ++j) { +#ifdef MDSPAN_USE_BRACKET_OPERATOR + result += a[i, j] * b[i, j]; +#else result += a(i, j) * b(i, j); +#endif } } return result; @@ -78,7 +82,11 @@ void fill_in_order( T count = 0; for(int i = 0; i < a.extent(0); ++i) { for(int j = 0; j < a.extent(1); ++j) { +#ifdef MDSPAN_USE_BRACKET_OPERATOR + a[i, j] = count++; +#else a(i, j) = count++; +#endif } } } diff --git a/examples/tiled_layout/simple_tiled_layout.cpp b/examples/tiled_layout/simple_tiled_layout.cpp index 3db34c62..e309ed51 100644 --- a/examples/tiled_layout/simple_tiled_layout.cpp +++ b/examples/tiled_layout/simple_tiled_layout.cpp @@ -186,13 +186,23 @@ int main() { int failures = 0; for (int irow = 0; irow < n_rows; ++irow) { for (int icol = 0; icol < n_cols; ++icol) { +#ifdef MDSPAN_USE_BRACKET_OPERATOR + if(tiled[irow, icol] != row_major[irow, icol]) { + std::cout << "Mismatch for entry " << irow << ", " << icol << ":" << std::endl; + std::cout << " tiled(" << irow << ", " << icol << ") = " + << tiled[irow, icol] << std::endl; + std::cout << " row_major(" << irow << ", " << icol << ") = " + << row_major[irow, icol] << std::endl; +#else if(tiled(irow, icol) != row_major(irow, icol)) { std::cout << "Mismatch for entry " << irow << ", " << icol << ":" << std::endl; std::cout << " tiled(" << irow << ", " << icol << ") = " << tiled(irow, icol) << std::endl; std::cout << " row_major(" << irow << ", " << icol << ") = " << row_major(irow, icol) << std::endl; +#endif ++failures; + } }