From 0ee2e0fca2efd434ce968671604328e55d4e96d8 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Tue, 15 Oct 2024 13:35:47 -0700 Subject: [PATCH] mpi acc xpr -> acc xpr --- src/include/xpr/racc_xpr.cc.h | 73 +++++++++++++++++++ .../mpi/include => include/xpr}/racc_xpr.h | 15 ++-- src/opt/mpi/include/racc_xpr.cc.h | 46 ------------ 3 files changed, 80 insertions(+), 54 deletions(-) create mode 100644 src/include/xpr/racc_xpr.cc.h rename src/{opt/mpi/include => include/xpr}/racc_xpr.h (62%) delete mode 100644 src/opt/mpi/include/racc_xpr.cc.h diff --git a/src/include/xpr/racc_xpr.cc.h b/src/include/xpr/racc_xpr.cc.h new file mode 100644 index 0000000..0326baf --- /dev/null +++ b/src/include/xpr/racc_xpr.cc.h @@ -0,0 +1,73 @@ + +#ifndef __cxz_racc_xpr_cc_h__ +#define __cxz_racc_xpr_cc_h__ + +#include "racc_xpr.h" + +namespace CNOXRZ +{ + namespace mpi + { + template + constexpr AccXpr::AccXpr(SizeT n, const IndexId& id, + const Xpr& xpr, F&& f) : + mN(n), + mId(id), + mXpr(xpr), + mExt(mXpr.rootSteps(mId)), + mF(std::forward(f)) + {} + + template + template + inline decltype(auto) AccXpr::operator()(const PosT& last) const + { + if constexpr(std::is_same::type,NoF>::value){ + const auto pos = last + mExt( UPos(mN) ); + mXpr(pos); + return None {}; + } + else { + typedef typename + std::remove_reference::type OutT; + auto o = OutT(); + const auto pos = last + mExt( UPos(mN) ); + mF(o, mXpr(pos)); + return o; + } + } + + template + inline decltype(auto) AccXpr::operator()() const + { + if constexpr(std::is_same::type,NoF>::value){ + const auto pos = mExt( UPos(mN) ); + mXpr(pos); + return None {}; + } + else { + typedef typename + std::remove_reference::type OutT; + auto o = OutT(); + const auto pos = mExt( UPos(mN) ); + mF(o, mXpr(pos)); + return o; + } + } + + template + template + inline decltype(auto) AccXpr::rootSteps(const IndexId& id) const + { + return mXpr.rootSteps(id); + } + + template + constexpr decltype(auto) accxpr(SizeT n, const IndexId& id, const Xpr& xpr, F&& f) + { + return AccXpr(size, id, xpr, std::forward(f)); + } + } +} + +#endif diff --git a/src/opt/mpi/include/racc_xpr.h b/src/include/xpr/racc_xpr.h similarity index 62% rename from src/opt/mpi/include/racc_xpr.h rename to src/include/xpr/racc_xpr.h index 23b84fd..66ce09a 100644 --- a/src/opt/mpi/include/racc_xpr.h +++ b/src/include/xpr/racc_xpr.h @@ -1,8 +1,8 @@ // rank access expression, fix rank position to current rank -#ifndef __cxz_mpi_racc_xpr_h__ -#define __cxz_mpi_racc_xpr_h__ +#ifndef __cxz_racc_xpr_h__ +#define __cxz_racc_xpr_h__ #include "mpi_base.h" @@ -12,12 +12,12 @@ namespace CNORXZ { template - class RankAccXpr : public XprInterface> + class AccXpr : public XprInterface> { public: - DEFAULT_MEMBERS(RankAccXpr); + DEFAULT_MEMBERS(AccXpr); - constexpr RankAccXpr(SizeT size, const IndexId& id, const Xpr& xpr, F&& f); + constexpr AccXpr(SizeT n, const IndexId& id, const Xpr& xpr, F&& f); template inline decltype(auto) operator()(const PosT& last) const; @@ -28,7 +28,7 @@ namespace CNORXZ inline decltype(auto) rootSteps(const IndexId& id) const; private: - SizeT mSize = 0; + SizeT mN = 0; IndexId mId; Xpr mXpr; typedef decltype(mXpr.rootSteps(mId)) XPosT; @@ -37,8 +37,7 @@ namespace CNORXZ }; template - constexpr decltype(auto) rankaccxpr(SizeT size, const IndexId& id, - const Xpr& xpr, F&& f); + constexpr decltype(auto) accxpr(SizeT n, const IndexId& id, const Xpr& xpr, F&& f); } } diff --git a/src/opt/mpi/include/racc_xpr.cc.h b/src/opt/mpi/include/racc_xpr.cc.h deleted file mode 100644 index 5ed1b31..0000000 --- a/src/opt/mpi/include/racc_xpr.cc.h +++ /dev/null @@ -1,46 +0,0 @@ - -#ifndef __cxz_mpi_racc_xpr_cc_h__ -#define __cxz_mpi_racc_xpr_cc_h__ - -#include "racc_xpr.h" - -namespace CNOXRZ -{ - namespace mpi - { - template - constexpr RankAccXpr::RankAccXpr(SizeT size, const IndexId& id, - const Xpr& xpr, F&& f) : - - {} - - template - template - inline decltype(auto) RankAccXpr::operator()(const PosT& last) const - { - - } - - template - inline decltype(auto) RankAccXpr::operator()() const - { - - } - - template - template - inline decltype(auto) RankAccXpr::rootSteps(const IndexId& id) const - { - - } - - template - constexpr decltype(auto) rankaccxpr(SizeT size, const IndexId& id, - const Xpr& xpr, F&& f) - { - return RankAccXpr(size, id, xpr, std::forward(f)); - } - } -} - -#endif