From 1471c8b94f94aec6abecf96419527e3887f4689a Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Fri, 13 Sep 2024 06:07:29 -0400 Subject: [PATCH] like contraction, reduction expression and binary expression can ignore absolute positions if ignore_tile_position() is on --- src/TiledArray/expressions/binary_engine.h | 22 +++++++++++++++++----- src/TiledArray/expressions/expr.h | 17 +++++++++++++++-- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/TiledArray/expressions/binary_engine.h b/src/TiledArray/expressions/binary_engine.h index 33318b57a6..486c5421a1 100644 --- a/src/TiledArray/expressions/binary_engine.h +++ b/src/TiledArray/expressions/binary_engine.h @@ -235,18 +235,30 @@ class BinaryEngine : public ExprEngine { left_.init_struct(left_indices_); right_.init_struct(right_indices_); #ifndef NDEBUG - if (left_.trange() != right_.trange()) { + if (ignore_tile_position()) { + if (!is_congruent(left_.trange(), right_.trange())) { + if (TiledArray::get_default_world().rank() == 0) { + TA_USER_ERROR_MESSAGE( + "The TiledRanges of the left- and right-hand arguments the " + "binary " + "expression are not congruent:" + << "\n left = " << left_.trange() + << "\n right = " << right_.trange()); + } + TA_EXCEPTION( + "The TiledRange objects of a binary expression are not congruent."); + } + } else if (left_.trange() != right_.trange()) { if (TiledArray::get_default_world().rank() == 0) { TA_USER_ERROR_MESSAGE( - "The TiledRanges of the left- and right-hand arguments of the " - "binary operation are not equal:" + "The TiledRanges of the left- and right-hand arguments the binary " + "expression are not equal:" << "\n left = " << left_.trange() << "\n right = " << right_.trange()); } TA_EXCEPTION( - "The TiledRanges of the left- and right-hand arguments " - "of the binary operation are not equal."); + "The TiledRange objects of a binary expression are not equal."); } #endif // NDEBUG ExprEngine_::init_struct(target_indices); diff --git a/src/TiledArray/expressions/expr.h b/src/TiledArray/expressions/expr.h index 8e3f925310..3b1e9f43be 100644 --- a/src/TiledArray/expressions/expr.h +++ b/src/TiledArray/expressions/expr.h @@ -664,7 +664,20 @@ class Expr { right_dist_eval.eval(); #ifndef NDEBUG - if (left_dist_eval.trange() != right_dist_eval.trange()) { + if (ignore_tile_position()) { + if (!is_congruent(left_dist_eval.trange(), right_dist_eval.trange())) { + if (TiledArray::get_default_world().rank() == 0) { + TA_USER_ERROR_MESSAGE( + "The TiledRanges of the left- and right-hand arguments the " + "binary " + "reduction are not congruent:" + << "\n left = " << left_dist_eval.trange() + << "\n right = " << right_dist_eval.trange()); + } + TA_EXCEPTION( + "The TiledRange objects of a binary reduction are not congruent."); + } + } else if (left_dist_eval.trange() != right_dist_eval.trange()) { if (TiledArray::get_default_world().rank() == 0) { TA_USER_ERROR_MESSAGE( "The TiledRanges of the left- and right-hand arguments the binary " @@ -674,7 +687,7 @@ class Expr { } TA_EXCEPTION( - "The TiledRange objects of a binary expression are not equal."); + "The TiledRange objects of a binary reduction are not equal."); } #endif // NDEBUG