Skip to content

Commit

Permalink
Replace some macros with lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
kcat committed Jan 14, 2024
1 parent 96e7157 commit 2757bde
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions common/pffft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,10 @@ NOINLINE void passf5_ps(const size_t ido, const size_t l1, const v4sf *cc, v4sf
const v4sf ti11{LD_PS1(0.951056516295154f*fsign)};
const v4sf ti12{LD_PS1(0.587785252292473f*fsign)};

#define cc_ref(a_1,a_2) cc[((a_2)-1)*ido + (a_1) + 1]
#define ch_ref(a_1,a_3) ch[((a_3)-1)*l1*ido + (a_1) + 1]
auto cc_ref = [&cc,ido](size_t a_1, size_t a_2) noexcept -> auto&
{ return cc[(a_2-1)*ido + a_1 + 1]; };
auto ch_ref = [&ch,ido,l1](size_t a_1, size_t a_3) noexcept -> auto&
{ return ch[(a_3-1)*l1*ido + a_1 + 1]; };

assert(ido > 2);

Expand Down Expand Up @@ -606,8 +608,6 @@ NOINLINE void passf5_ps(const size_t ido, const size_t l1, const v4sf *cc, v4sf
ch_ref(i, 5) = di5;
}
}
#undef ch_ref
#undef cc_ref
}

NOINLINE void radf2_ps(const size_t ido, const size_t l1, const v4sf *RESTRICT cc,
Expand Down Expand Up @@ -984,8 +984,10 @@ void radf5_ps(const size_t ido, const size_t l1, const v4sf *RESTRICT cc, v4sf *
const v4sf tr12{LD_PS1(-0.809016994374947f)};
const v4sf ti12{LD_PS1(0.587785252292473f)};

#define cc_ref(a_1,a_2,a_3) cc[((a_3)*l1 + (a_2))*ido + (a_1)]
#define ch_ref(a_1,a_2,a_3) ch[((a_3)*5 + (a_2))*ido + (a_1)]
auto cc_ref = [&cc,l1,ido](size_t a_1, size_t a_2, size_t a_3) noexcept -> auto&
{ return cc[(a_3*l1 + a_2)*ido + a_1]; };
auto ch_ref = [&ch,ido](size_t a_1, size_t a_2, size_t a_3) noexcept -> auto&
{ return ch[(a_3*5 + a_2)*ido + a_1]; };

/* Parameter adjustments */
ch -= 1 + ido * 6;
Expand Down Expand Up @@ -1058,8 +1060,6 @@ void radf5_ps(const size_t ido, const size_t l1, const v4sf *RESTRICT cc, v4sf *
ch_ref(ic , 4, k) = VSUB(ti4, ti3);
}
}
#undef cc_ref
#undef ch_ref
} /* radf5 */

void radb5_ps(const size_t ido, const size_t l1, const v4sf *RESTRICT cc, v4sf *RESTRICT ch,
Expand All @@ -1070,8 +1070,10 @@ void radb5_ps(const size_t ido, const size_t l1, const v4sf *RESTRICT cc, v4sf *
const v4sf tr12{LD_PS1(-0.809016994374947f)};
const v4sf ti12{LD_PS1(0.587785252292473f)};

#define cc_ref(a_1,a_2,a_3) cc[((a_3)*5 + (a_2))*ido + (a_1)]
#define ch_ref(a_1,a_2,a_3) ch[((a_3)*l1 + (a_2))*ido + (a_1)]
auto cc_ref = [&cc,ido](size_t a_1, size_t a_2, size_t a_3) noexcept -> auto&
{ return cc[(a_3*5 + a_2)*ido + a_1]; };
auto ch_ref = [&ch,ido,l1](size_t a_1, size_t a_2, size_t a_3) noexcept -> auto&
{ return ch[(a_3*l1 + a_2)*ido + a_1]; };

/* Parameter adjustments */
ch -= 1 + ido*(1 + l1);
Expand Down Expand Up @@ -1144,8 +1146,6 @@ void radb5_ps(const size_t ido, const size_t l1, const v4sf *RESTRICT cc, v4sf *
ch_ref(i-1, k, 5) = dr5; ch_ref(i, k, 5) = di5;
}
}
#undef cc_ref
#undef ch_ref
} /* radb5 */

NOINLINE v4sf *rfftf1_ps(const size_t n, const v4sf *input_readonly, v4sf *work1, v4sf *work2,
Expand Down

0 comments on commit 2757bde

Please sign in to comment.