mpi acc xpr -> acc xpr

This commit is contained in:
Christian Zimmermann 2024-10-15 13:35:47 -07:00
parent e36b9bc6fd
commit 0ee2e0fca2
3 changed files with 80 additions and 54 deletions

View file

@ -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 <SizeT L, class Xpr, class F = NoF>
constexpr AccXpr<L,Xpr,F>::AccXpr(SizeT n, const IndexId<L>& id,
const Xpr& xpr, F&& f) :
mN(n),
mId(id),
mXpr(xpr),
mExt(mXpr.rootSteps(mId)),
mF(std::forward<F>(f))
{}
template <SizeT L, class Xpr, class F = NoF>
template <class PosT>
inline decltype(auto) AccXpr<L,Xpr,F>::operator()(const PosT& last) const
{
if constexpr(std::is_same<typename std::remove_reference<F>::type,NoF>::value){
const auto pos = last + mExt( UPos(mN) );
mXpr(pos);
return None {};
}
else {
typedef typename
std::remove_reference<decltype(mXpr(last + mExt( UPos(0) )))>::type OutT;
auto o = OutT();
const auto pos = last + mExt( UPos(mN) );
mF(o, mXpr(pos));
return o;
}
}
template <SizeT L, class Xpr, class F = NoF>
inline decltype(auto) AccXpr<L,Xpr,F>::operator()() const
{
if constexpr(std::is_same<typename std::remove_reference<F>::type,NoF>::value){
const auto pos = mExt( UPos(mN) );
mXpr(pos);
return None {};
}
else {
typedef typename
std::remove_reference<decltype(mXpr(last + mExt( UPos(0) )))>::type OutT;
auto o = OutT();
const auto pos = mExt( UPos(mN) );
mF(o, mXpr(pos));
return o;
}
}
template <SizeT L, class Xpr, class F = NoF>
template <SizeT I>
inline decltype(auto) AccXpr<L,Xpr,F>::rootSteps(const IndexId<I>& id) const
{
return mXpr.rootSteps(id);
}
template <SizeT L, class Xpr, class F = NoF>
constexpr decltype(auto) accxpr(SizeT n, const IndexId<L>& id, const Xpr& xpr, F&& f)
{
return AccXpr<L,Xpr,F>(size, id, xpr, std::forward<F>(f));
}
}
}
#endif

View file

@ -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 <SizeT L, class Xpr, class F = NoF>
class RankAccXpr : public XprInterface<RankAccXpr<L,Xpr,F>>
class AccXpr : public XprInterface<AccXpr<L,Xpr,F>>
{
public:
DEFAULT_MEMBERS(RankAccXpr);
DEFAULT_MEMBERS(AccXpr);
constexpr RankAccXpr(SizeT size, const IndexId<L>& id, const Xpr& xpr, F&& f);
constexpr AccXpr(SizeT n, const IndexId<L>& id, const Xpr& xpr, F&& f);
template <class PosT>
inline decltype(auto) operator()(const PosT& last) const;
@ -28,7 +28,7 @@ namespace CNORXZ
inline decltype(auto) rootSteps(const IndexId<I>& id) const;
private:
SizeT mSize = 0;
SizeT mN = 0;
IndexId<L> mId;
Xpr mXpr;
typedef decltype(mXpr.rootSteps(mId)) XPosT;
@ -37,8 +37,7 @@ namespace CNORXZ
};
template <SizeT L, class Xpr, class F = NoF>
constexpr decltype(auto) rankaccxpr(SizeT size, const IndexId<L>& id,
const Xpr& xpr, F&& f);
constexpr decltype(auto) accxpr(SizeT n, const IndexId<L>& id, const Xpr& xpr, F&& f);
}
}

View file

@ -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 <SizeT L, class Xpr, class F = NoF>
constexpr RankAccXpr<L,Xpr,F>::RankAccXpr(SizeT size, const IndexId<L>& id,
const Xpr& xpr, F&& f) :
{}
template <SizeT L, class Xpr, class F = NoF>
template <class PosT>
inline decltype(auto) RankAccXpr<L,Xpr,F>::operator()(const PosT& last) const
{
}
template <SizeT L, class Xpr, class F = NoF>
inline decltype(auto) RankAccXpr<L,Xpr,F>::operator()() const
{
}
template <SizeT L, class Xpr, class F = NoF>
template <SizeT I>
inline decltype(auto) RankAccXpr<L,Xpr,F>::rootSteps(const IndexId<I>& id) const
{
}
template <SizeT L, class Xpr, class F = NoF>
constexpr decltype(auto) rankaccxpr(SizeT size, const IndexId<L>& id,
const Xpr& xpr, F&& f)
{
return RankAccXpr<L,Xpr,F>(size, id, xpr, std::forward<F>(f));
}
}
}
#endif