// Copyright (c) the JPEG XL Project Authors. All rights reserved. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file.
// Simple wrapper that ensures that a function will not be inlined. template <typename T, typename... Args>
JXL_NOINLINE void NoInlineWrapper(const T& f, const Args&... args) { return f(args...);
}
// TODO(veluca): it's not super useful to have this in the SIMD namespace. template <size_t ROWS_or_0, size_t COLS_or_0, class From, class To>
JXL_INLINE_TRANSPOSE void GenericTransposeBlock(
TransposeSimdTag<false> /* tag */, const From& from, const To& to,
size_t ROWSp, size_t COLSp) {
size_t ROWS = ROWS_or_0 == 0 ? ROWSp : ROWS_or_0;
size_t COLS = COLS_or_0 == 0 ? COLSp : COLS_or_0; for (size_t n = 0; n < ROWS; ++n) { for (size_t m = 0; m < COLS; ++m) {
to.Write(from.Read(n, m), m, n);
}
}
}
to.StorePart(d, r0, m + 0, n + 0);
to.StorePart(d, r1, m + 1, n + 0);
to.StorePart(d, r2, m + 2, n + 0);
to.StorePart(d, r3, m + 3, n + 0);
}
}
} #else
constexpr bool TransposeUseSimd(size_t ROWS, size_t COLS) { returnfalse; } #endif
template <size_t N, size_t M, typename = void> struct Transpose { template <typename From, typename To> staticvoid Run(const From& from, const To& to) { // This does not guarantee anything, just saves from the most stupid // mistakes.
JXL_DASSERT(from.Address(0, 0) != to.Address(0, 0));
TransposeSimdTag<TransposeUseSimd(N, M)> tag;
GenericTransposeBlock<N, M>(tag, from, to, N, M);
}
};
// Avoid inlining and unrolling transposes for large blocks. template <size_t N, size_t M> struct Transpose<
N, M, typename std::enable_if<(N >= 8 && M >= 8 && N * M >= 512)>::type> { template <typename From, typename To> staticvoid Run(const From& from, const To& to) { // This does not guarantee anything, just saves from the most stupid // mistakes.
JXL_DASSERT(from.Address(0, 0) != to.Address(0, 0));
TransposeSimdTag<TransposeUseSimd(N, M)> tag;
constexpr void (*transpose)(TransposeSimdTag<TransposeUseSimd(N, M)>, const From&, const To&, size_t, size_t) =
GenericTransposeBlock<0, 0, From, To>;
NoInlineWrapper(transpose, tag, from, to, N, M);
}
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.