9#if defined(__x86_64__) && defined(__GNUC__) && \
10 defined(EIGEN_VECTORIZE_FMA) && !defined(EIGEN_VECTORIZE_AVX512) && \
11 !defined(EIGEN_USE_BLAS)
19#if defined(__x86_64__) && defined(__GNUC__) && \
20 defined(EIGEN_VECTORIZE_FMA) && !defined(EIGEN_VECTORIZE_AVX512) && \
21 !defined(EIGEN_USE_BLAS)
22 static const bool available =
23 __builtin_cpu_supports(
"avx512f") && __builtin_cpu_supports(
"fma");
30#if defined(__x86_64__) && defined(__GNUC__) && \
31 defined(EIGEN_VECTORIZE_FMA) && !defined(EIGEN_VECTORIZE_AVX512) && \
32 !defined(EIGEN_USE_BLAS)
35template <
bool TransposeRight,
int RowVectors>
36__attribute__((target(
"avx512f,fma"))) inline
void subtractFullTileRowsWide(
37 double*
out,
std::ptrdiff_t out_stride, const
double* left,
38 const
double* right,
int first_row)
40 for (
int j = 0; j < 64; j += 8) {
41 __m512d sums[8][RowVectors];
43 for (
int column = 0; column < 8; ++column)
45 for (
int row = 0; row < RowVectors; ++row)
46 sums[column][row] = _mm512_setzero_pd();
47 for (
int k = 0; k < 64; ++k) {
48 __m512d a[RowVectors];
50 for (
int row = 0; row < RowVectors; ++row)
51 a[row] = _mm512_loadu_pd(left + first_row + 8 * row + 64 * k);
53 right + (TransposeRight ? j + 64 * k : k + 64 * j);
54 constexpr int stride = TransposeRight ? 1 : 64;
56 for (
int column = 0; column < 8; ++column) {
57 const __m512d value = _mm512_set1_pd(b[column * stride]);
59 for (
int row = 0; row < RowVectors; ++row)
61 _mm512_fmadd_pd(a[row], value, sums[column][row]);
65 for (
int column = 0; column < 8; ++column) {
67 for (
int row = 0; row < RowVectors; ++row) {
68 const int i = first_row + 8 * row;
69 double* c =
out + i + out_stride * (j + column);
71 _mm512_sub_pd(_mm512_loadu_pd(c), sums[column][row]);
72 _mm512_mask_storeu_pd(c, i == 56 ? 0x0f : 0xff, value);
81template <
bool TransposeRight>
82__attribute__((target(
"avx512f,fma"))) inline
void subtractFullTileWide(
83 double*
out, std::ptrdiff_t out_stride, const
double* left,
86 subtractFullTileRowsWide<TransposeRight, 3>(
out, out_stride, left, right,
88 subtractFullTileRowsWide<TransposeRight, 3>(
out, out_stride, left, right,
90 subtractFullTileRowsWide<TransposeRight, 2>(
out, out_stride, left, right,
92 for (
int j = 0; j < 64; j += 4) {
93 __m256d even[4], odd[4];
94 for (
int q = 0; q < 4; ++q)
95 even[q] = odd[q] = _mm256_setzero_pd();
96 for (
int k = 0; k < 64; k += 2) {
97 const __m256d ae = _mm256_loadu_pd(left + 60 + 64 * k);
98 const __m256d ao = _mm256_loadu_pd(left + 60 + 64 * (k + 1));
99 for (
int q = 0; q < 4; ++q) {
101 TransposeRight ? j + q + 64 * k : k + 64 * (j + q);
102 constexpr int next = TransposeRight ? 64 : 1;
104 _mm256_fmadd_pd(ae, _mm256_set1_pd(right[offset]), even[q]);
105 odd[q] = _mm256_fmadd_pd(
106 ao, _mm256_set1_pd(right[offset + next]), odd[q]);
109 for (
int q = 0; q < 4; ++q) {
110 double* c =
out + 60 + out_stride * (j + q);
111 _mm256_storeu_pd(c, _mm256_sub_pd(_mm256_loadu_pd(c),
112 _mm256_add_pd(even[q], odd[q])));
120template <
bool TransposeRight = false,
class Target,
class Left,
class Right>
124#if defined(__x86_64__) && defined(__GNUC__) && \
125 defined(EIGEN_VECTORIZE_FMA) && !defined(EIGEN_VECTORIZE_AVX512) && \
126 !defined(EIGEN_USE_BLAS)
127 if constexpr (!std::decay_t<Target>::IsRowMajor && !Left::IsRowMajor &&
128 !Right::IsRowMajor) {
129 if (
out.rows() == 64 &&
out.cols() == 64 && left.rows() == 64 &&
130 left.cols() == 64 && right.rows() == 64 && right.cols() == 64 &&
131 out.innerStride() == 1 &&
out.outerStride() >= 64 &&
132 left.innerStride() == 1 && left.outerStride() == 64 &&
133 right.innerStride() == 1 && right.outerStride() == 64 &&
135 subtractFullTileWide<TransposeRight>(
out.data(),
out.outerStride(),
136 left.data(), right.data());
141 if constexpr (TransposeRight)
142 out.noalias() -= left * right.transpose();
144 out.noalias() -= left * right;
__attribute__((visibility("default"))) void *gpr_training_product_create_v1(char *error
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
bool wideTileProductAvailable() noexcept
void subtractTileProduct(Target &&out, const Left &left, const Right &right)