Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master grimoire by Pavel Vinogradov (a462816d503f0ce07ace6d55e6eecfbbc55b9f39)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Pavel Vinogradov <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master grimoire by Pavel Vinogradov (a462816d503f0ce07ace6d55e6eecfbbc55b9f39)
  • Date: Wed, 5 Apr 2023 00:44:49 +0000

GIT changes to master grimoire by Pavel Vinogradov <public AT sourcemage.org>:

http/firefox/HISTORY
| 3
http/firefox/patches/0033-bmo-1821363-use-fully-specified-xsimd-batch.patch
| 41

http/firefox/patches/0034-bmo-1822901-declare-arch-specific-xsimd-specialization.patch
| 755 ++++++++++
3 files changed, 799 insertions(+)

New commits:
commit a462816d503f0ce07ace6d55e6eecfbbc55b9f39
Author: Pavel Vinogradov <public AT sourcemage.org>
Commit: Pavel Vinogradov <public AT sourcemage.org>

http/firefox: updated the patches for 111

diff --git a/http/firefox/HISTORY b/http/firefox/HISTORY
index 4ab3ee8..b199e05 100644
--- a/http/firefox/HISTORY
+++ b/http/firefox/HISTORY
@@ -1,3 +1,6 @@
+2023-04-04 Pavel Vinogradov <public AT sourcemage.org>
+ * patches/*: updated
+
2023-04-01 Conner Clere <xenanthropy AT sourcemage.org>
* CONFIGURE, PRE_BUILD, DEPENDS: add support for sccache

diff --git
a/http/firefox/patches/0033-bmo-1821363-use-fully-specified-xsimd-batch.patch
b/http/firefox/patches/0033-bmo-1821363-use-fully-specified-xsimd-batch.patch
new file mode 100644
index 0000000..22e9633
--- /dev/null
+++
b/http/firefox/patches/0033-bmo-1821363-use-fully-specified-xsimd-batch.patch
@@ -0,0 +1,41 @@
+
+# HG changeset patch
+# User serge-sans-paille <sguelton AT mozilla.com>
+# Date 1678865227 0
+# Node ID cbc55e58a4b14ab484486c72a47f595fa223336b
+# Parent 7d86c3224520ce8b5c53ebd7122671f0f69fb796
+Bug 1821363 - Use fully specified xsimd::batch type r=padenot, a=dsmith
+
+That way we cannot have one type using the default architecture that
+interacts with the parametric type required by the user.
+
+Differential Revision: https://phabricator.services.mozilla.com/D172126
+
+diff --git a/dom/media/webaudio/AudioNodeEngineGeneric.h
b/dom/media/webaudio/AudioNodeEngineGeneric.h
+--- a/dom/media/webaudio/AudioNodeEngineGeneric.h
++++ b/dom/media/webaudio/AudioNodeEngineGeneric.h
+@@ -200,20 +200,20 @@ struct Engine {
+ MOZ_ASSERT(is_aligned<Arch>(aInput), "aInput is aligned");
+ MOZ_ASSERT(is_aligned<Arch>(aOutput), "aOutput is aligned");
+ MOZ_ASSERT(is_aligned<Arch>(aScale), "aScale is aligned");
+ MOZ_ASSERT((aSize % xsimd::batch<float, Arch>::size == 0),
+ "requires tail processing");
+
+ MOZ_UNROLL(2)
+ for (unsigned i = 0; i < aSize * 2;
+- i += 2 * xsimd::batch<std::complex<float>>::size) {
+- auto in1 = xsimd::batch<std::complex<float>>::load_aligned(
++ i += 2 * xsimd::batch<std::complex<float>, Arch>::size) {
++ auto in1 = xsimd::batch<std::complex<float>, Arch>::load_aligned(
+ reinterpret_cast<const std::complex<float>*>(&aInput[i]));
+- auto in2 = xsimd::batch<std::complex<float>>::load_aligned(
++ auto in2 = xsimd::batch<std::complex<float>, Arch>::load_aligned(
+ reinterpret_cast<const std::complex<float>*>(&aScale[i]));
+ auto out = in1 * in2;
+
out.store_aligned(reinterpret_cast<std::complex<float>*>(&aOutput[i]));
+ }
+ };
+
+ static float AudioBufferSumOfSquares(const float* aInput, uint32_t
aLength) {
+ float sum = 0.f;
+
diff --git
a/http/firefox/patches/0034-bmo-1822901-declare-arch-specific-xsimd-specialization.patch

b/http/firefox/patches/0034-bmo-1822901-declare-arch-specific-xsimd-specialization.patch
new file mode 100644
index 0000000..30809a0
--- /dev/null
+++
b/http/firefox/patches/0034-bmo-1822901-declare-arch-specific-xsimd-specialization.patch
@@ -0,0 +1,755 @@
+
+# HG changeset patch
+# User serge-sans-paille <sguelton AT mozilla.com>
+# Date 1679317658 0
+# Node ID 403ac74192e3c477f0802b76a5f13f348f651269
+# Parent cbc55e58a4b14ab484486c72a47f595fa223336b
+Bug 1822901 - Forward declare arch-specific xsimd specialization r=padenot,
a=dsmith
+
+Otherwise the compiler tries to instantiate the generic version based on
+its current architecture flags, which may not be enough, resulting in
+error along those lines:
+
+ 'xsimd::batch<float, xsimd::neon> vgainr' has incomplete type
+
+Differential Revision: https://phabricator.services.mozilla.com/D172864
+
+diff --git a/dom/media/webaudio/AudioNodeEngineGeneric.h
b/dom/media/webaudio/AudioNodeEngineGeneric.h
+--- a/dom/media/webaudio/AudioNodeEngineGeneric.h
++++ b/dom/media/webaudio/AudioNodeEngineGeneric.h
+@@ -2,334 +2,57 @@
+ /* this source code form is subject to the terms of the mozilla public
+ * license, v. 2.0. if a copy of the mpl was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+ #ifndef MOZILLA_AUDIONODEENGINEGENERIC_H_
+ #define MOZILLA_AUDIONODEENGINEGENERIC_H_
+
+ #include "AudioNodeEngine.h"
+-#include "AlignmentUtils.h"
+
+ #include "xsimd/xsimd.hpp"
+
+-#if defined(__GNUC__) && __GNUC__ > 7
+-# define MOZ_PRAGMA(tokens) _Pragma(#tokens)
+-# define MOZ_UNROLL(factor) MOZ_PRAGMA(GCC unroll factor)
+-#elif defined(__INTEL_COMPILER) || (defined(__clang__) && __clang_major__ >
3)
+-# define MOZ_PRAGMA(tokens) _Pragma(#tokens)
+-# define MOZ_UNROLL(factor) MOZ_PRAGMA(unroll factor)
+-#else
+-# define MOZ_UNROLL(_)
+-#endif
+-
+ namespace mozilla {
+
+ template <class Arch>
+-static bool is_aligned(const void* ptr) {
+- return (reinterpret_cast<uintptr_t>(ptr) &
+- ~(static_cast<uintptr_t>(Arch::alignment()) - 1)) ==
+- reinterpret_cast<uintptr_t>(ptr);
+-};
+-
+-template <class Arch>
+ struct Engine {
+ static void AudioBufferAddWithScale(const float* aInput, float aScale,
+- float* aOutput, uint32_t aSize) {
+- if constexpr (Arch::requires_alignment()) {
+- if (aScale == 1.0f) {
+- while (!is_aligned<Arch>(aInput) || !is_aligned<Arch>(aOutput)) {
+- if (!aSize) return;
+- *aOutput += *aInput;
+- ++aOutput;
+- ++aInput;
+- --aSize;
+- }
+- } else {
+- while (!is_aligned<Arch>(aInput) || !is_aligned<Arch>(aOutput)) {
+- if (!aSize) return;
+- *aOutput += *aInput * aScale;
+- ++aOutput;
+- ++aInput;
+- --aSize;
+- }
+- }
+- }
+- MOZ_ASSERT(is_aligned<Arch>(aInput), "aInput is aligned");
+- MOZ_ASSERT(is_aligned<Arch>(aOutput), "aOutput is aligned");
+-
+- xsimd::batch<float, Arch> vgain(aScale);
+-
+- uint32_t aVSize = aSize & ~(xsimd::batch<float, Arch>::size - 1);
+- MOZ_UNROLL(4)
+- for (unsigned i = 0; i < aVSize; i += xsimd::batch<float, Arch>::size) {
+- auto vin1 = xsimd::batch<float, Arch>::load_aligned(&aInput[i]);
+- auto vin2 = xsimd::batch<float, Arch>::load_aligned(&aOutput[i]);
+- auto vout = xsimd::fma(vin1, vgain, vin2);
+- vout.store_aligned(&aOutput[i]);
+- }
+-
+- for (unsigned i = aVSize; i < aSize; ++i) {
+- aOutput[i] += aInput[i] * aScale;
+- }
+- };
++ float* aOutput, uint32_t aSize);
+
+ static void AudioBlockCopyChannelWithScale(const float* aInput, float
aScale,
+- float* aOutput) {
+- MOZ_ASSERT(is_aligned<Arch>(aInput), "aInput is aligned");
+- MOZ_ASSERT(is_aligned<Arch>(aOutput), "aOutput is aligned");
+-
+- MOZ_ASSERT((WEBAUDIO_BLOCK_SIZE % xsimd::batch<float, Arch>::size == 0),
+- "requires tail processing");
+-
+- xsimd::batch<float, Arch> vgain = (aScale);
+-
+- MOZ_UNROLL(4)
+- for (unsigned i = 0; i < WEBAUDIO_BLOCK_SIZE;
+- i += xsimd::batch<float, Arch>::size) {
+- auto vin = xsimd::batch<float, Arch>::load_aligned(&aInput[i]);
+- auto vout = vin * vgain;
+- vout.store_aligned(&aOutput[i]);
+- }
+- };
++ float* aOutput);
+
+ static void AudioBlockCopyChannelWithScale(
+ const float aInput[WEBAUDIO_BLOCK_SIZE],
+ const float aScale[WEBAUDIO_BLOCK_SIZE],
+- float aOutput[WEBAUDIO_BLOCK_SIZE]) {
+- MOZ_ASSERT(is_aligned<Arch>(aInput), "aInput is aligned");
+- MOZ_ASSERT(is_aligned<Arch>(aOutput), "aOutput is aligned");
+- MOZ_ASSERT(is_aligned<Arch>(aScale), "aScale is aligned");
+-
+- MOZ_ASSERT((WEBAUDIO_BLOCK_SIZE % xsimd::batch<float, Arch>::size == 0),
+- "requires tail processing");
+-
+- MOZ_UNROLL(4)
+- for (unsigned i = 0; i < WEBAUDIO_BLOCK_SIZE;
+- i += xsimd::batch<float, Arch>::size) {
+- auto vscaled = xsimd::batch<float, Arch>::load_aligned(&aScale[i]);
+- auto vin = xsimd::batch<float, Arch>::load_aligned(&aInput[i]);
+- auto vout = vin * vscaled;
+- vout.store_aligned(&aOutput[i]);
+- }
+- };
++ float aOutput[WEBAUDIO_BLOCK_SIZE]);
+
+ static void AudioBufferInPlaceScale(float* aBlock, float aScale,
+- uint32_t aSize) {
+- MOZ_ASSERT(is_aligned<Arch>(aBlock), "aBlock is aligned");
+-
+- xsimd::batch<float, Arch> vgain(aScale);
+-
+- uint32_t aVSize = aSize & ~(xsimd::batch<float, Arch>::size - 1);
+- MOZ_UNROLL(4)
+- for (unsigned i = 0; i < aVSize; i += xsimd::batch<float, Arch>::size) {
+- auto vin = xsimd::batch<float, Arch>::load_aligned(&aBlock[i]);
+- auto vout = vin * vgain;
+- vout.store_aligned(&aBlock[i]);
+- }
+- for (unsigned i = aVSize; i < aSize; ++i) aBlock[i] *= aScale;
+- };
++ uint32_t aSize);
+
+ static void AudioBufferInPlaceScale(float* aBlock, float* aScale,
+- uint32_t aSize) {
+- MOZ_ASSERT(is_aligned<Arch>(aBlock), "aBlock is aligned");
+- MOZ_ASSERT(is_aligned<Arch>(aScale), "aScale is aligned");
+-
+- uint32_t aVSize = aSize & ~(xsimd::batch<float, Arch>::size - 1);
+- MOZ_UNROLL(4)
+- for (unsigned i = 0; i < aVSize; i += xsimd::batch<float, Arch>::size) {
+- auto vin = xsimd::batch<float, Arch>::load_aligned(&aBlock[i]);
+- auto vgain = xsimd::batch<float, Arch>::load_aligned(&aScale[i]);
+- auto vout = vin * vgain;
+- vout.store_aligned(&aBlock[i]);
+- }
+- for (uint32_t i = aVSize; i < aSize; ++i) {
+- *aBlock++ *= *aScale++;
+- }
+- };
++ uint32_t aSize);
+
+ static void AudioBlockPanStereoToStereo(
+ const float aInputL[WEBAUDIO_BLOCK_SIZE],
+ const float aInputR[WEBAUDIO_BLOCK_SIZE], float aGainL, float aGainR,
+ bool aIsOnTheLeft, float aOutputL[WEBAUDIO_BLOCK_SIZE],
+- float aOutputR[WEBAUDIO_BLOCK_SIZE]) {
+- MOZ_ASSERT(is_aligned<Arch>(aInputL), "aInputL is aligned");
+- MOZ_ASSERT(is_aligned<Arch>(aInputR), "aInputR is aligned");
+- MOZ_ASSERT(is_aligned<Arch>(aOutputL), "aOutputL is aligned");
+- MOZ_ASSERT(is_aligned<Arch>(aOutputR), "aOutputR is aligned");
+-
+- MOZ_ASSERT((WEBAUDIO_BLOCK_SIZE % xsimd::batch<float, Arch>::size == 0),
+- "requires tail processing");
+-
+- xsimd::batch<float, Arch> vgainl(aGainL);
+- xsimd::batch<float, Arch> vgainr(aGainR);
+-
+- if (aIsOnTheLeft) {
+- MOZ_UNROLL(2)
+- for (unsigned i = 0; i < WEBAUDIO_BLOCK_SIZE;
+- i += xsimd::batch<float, Arch>::size) {
+- auto vinl = xsimd::batch<float, Arch>::load_aligned(&aInputL[i]);
+- auto vinr = xsimd::batch<float, Arch>::load_aligned(&aInputR[i]);
+-
+- /* left channel : aOutputL = aInputL + aInputR * gainL */
+- auto vout = xsimd::fma(vinr, vgainl, vinl);
+- vout.store_aligned(&aOutputL[i]);
+-
+- /* right channel : aOutputR = aInputR * gainR */
+- auto vscaled = vinr * vgainr;
+- vscaled.store_aligned(&aOutputR[i]);
+- }
+- } else {
+- MOZ_UNROLL(2)
+- for (unsigned i = 0; i < WEBAUDIO_BLOCK_SIZE;
+- i += xsimd::batch<float, Arch>::size) {
+- auto vinl = xsimd::batch<float, Arch>::load_aligned(&aInputL[i]);
+- auto vinr = xsimd::batch<float, Arch>::load_aligned(&aInputR[i]);
+-
+- /* left channel : aInputL * gainL */
+- auto vscaled = vinl * vgainl;
+- vscaled.store_aligned(&aOutputL[i]);
+-
+- /* right channel: aOutputR = aInputR + aInputL * gainR */
+- auto vout = xsimd::fma(vinl, vgainr, vinr);
+- vout.store_aligned(&aOutputR[i]);
+- }
+- }
+- };
++ float aOutputR[WEBAUDIO_BLOCK_SIZE]);
+
+ static void BufferComplexMultiply(const float* aInput, const float*
aScale,
+- float* aOutput, uint32_t aSize) {
+- MOZ_ASSERT(is_aligned<Arch>(aInput), "aInput is aligned");
+- MOZ_ASSERT(is_aligned<Arch>(aOutput), "aOutput is aligned");
+- MOZ_ASSERT(is_aligned<Arch>(aScale), "aScale is aligned");
+- MOZ_ASSERT((aSize % xsimd::batch<float, Arch>::size == 0),
+- "requires tail processing");
+-
+- MOZ_UNROLL(2)
+- for (unsigned i = 0; i < aSize * 2;
+- i += 2 * xsimd::batch<std::complex<float>, Arch>::size) {
+- auto in1 = xsimd::batch<std::complex<float>, Arch>::load_aligned(
+- reinterpret_cast<const std::complex<float>*>(&aInput[i]));
+- auto in2 = xsimd::batch<std::complex<float>, Arch>::load_aligned(
+- reinterpret_cast<const std::complex<float>*>(&aScale[i]));
+- auto out = in1 * in2;
+-
out.store_aligned(reinterpret_cast<std::complex<float>*>(&aOutput[i]));
+- }
+- };
+-
+- static float AudioBufferSumOfSquares(const float* aInput, uint32_t
aLength) {
+- float sum = 0.f;
+-
+- if constexpr (Arch::requires_alignment()) {
+- while (!is_aligned<Arch>(aInput)) {
+- if (!aLength) {
+- return sum;
+- }
+- sum += *aInput * *aInput;
+- ++aInput;
+- --aLength;
+- }
+- }
+-
+- MOZ_ASSERT(is_aligned<Arch>(aInput), "aInput is aligned");
+-
+- constexpr uint32_t unroll_factor = 4;
+- xsimd::batch<float, Arch> accs[unroll_factor] = {0.f, 0.f, 0.f, 0.f};
+-
+- uint32_t vLength =
+- aLength & ~(unroll_factor * xsimd::batch<float, Arch>::size - 1);
++ float* aOutput, uint32_t aSize);
+
+- for (uint32_t i = 0; i < vLength;
+- i += unroll_factor * xsimd::batch<float, Arch>::size) {
+- MOZ_UNROLL(4)
+- for (uint32_t j = 0; j < unroll_factor; ++j) {
+- auto in = xsimd::batch<float, Arch>::load_aligned(
+- &aInput[i + xsimd::batch<float, Arch>::size * j]);
+- accs[j] = xsimd::fma(in, in, accs[j]);
+- }
+- }
+-
+- sum += reduce_add((accs[0] + accs[1]) + (accs[2] + accs[3]));
+- for (uint32_t i = vLength; i < aLength; ++i) sum += aInput[i] *
aInput[i];
+- return sum;
+- };
++ static float AudioBufferSumOfSquares(const float* aInput, uint32_t
aLength);
+
+- static void NaNToZeroInPlace(float* aSamples, size_t aCount) {
+- if constexpr (Arch::requires_alignment()) {
+- while (!is_aligned<Arch>(aSamples)) {
+- if (!aCount) {
+- return;
+- }
+- if (*aSamples != *aSamples) {
+- *aSamples = 0.0;
+- }
+- ++aSamples;
+- --aCount;
+- }
+- }
+-
+- MOZ_ASSERT(is_aligned<Arch>(aSamples), "aSamples is aligned");
+-
+- uint32_t vCount = aCount & ~(xsimd::batch<float, Arch>::size - 1);
+-
+- MOZ_UNROLL(4)
+- for (uint32_t i = 0; i < vCount; i += xsimd::batch<float, Arch>::size) {
+- auto vin = xsimd::batch<float, Arch>::load_aligned(&aSamples[i]);
+- auto vout =
+- xsimd::select(xsimd::isnan(vin), xsimd::batch<float, Arch>(0.f),
vin);
+- vout.store_aligned(&aSamples[i]);
+- }
+-
+- for (uint32_t i = vCount; i < aCount; i++) {
+- if (aSamples[i] != aSamples[i]) {
+- aSamples[i] = 0.0;
+- }
+- }
+- };
++ static void NaNToZeroInPlace(float* aSamples, size_t aCount);
+
+ static void AudioBlockPanStereoToStereo(
+ const float aInputL[WEBAUDIO_BLOCK_SIZE],
+ const float aInputR[WEBAUDIO_BLOCK_SIZE],
+ const float aGainL[WEBAUDIO_BLOCK_SIZE],
+ const float aGainR[WEBAUDIO_BLOCK_SIZE],
+ const bool aIsOnTheLeft[WEBAUDIO_BLOCK_SIZE],
+- float aOutputL[WEBAUDIO_BLOCK_SIZE],
+- float aOutputR[WEBAUDIO_BLOCK_SIZE]) {
+- MOZ_ASSERT(is_aligned<Arch>(aInputL), "aInputL is aligned");
+- MOZ_ASSERT(is_aligned<Arch>(aInputR), "aInputR is aligned");
+- MOZ_ASSERT(is_aligned<Arch>(aGainL), "aGainL is aligned");
+- MOZ_ASSERT(is_aligned<Arch>(aGainR), "aGainR is aligned");
+- MOZ_ASSERT(is_aligned<Arch>(aIsOnTheLeft), "aIsOnTheLeft is aligned");
+- MOZ_ASSERT(is_aligned<Arch>(aOutputL), "aOutputL is aligned");
+- MOZ_ASSERT(is_aligned<Arch>(aOutputR), "aOutputR is aligned");
+-
+- MOZ_ASSERT((WEBAUDIO_BLOCK_SIZE % xsimd::batch<float, Arch>::size == 0),
+- "requires tail processing");
+-
+- MOZ_UNROLL(2)
+- for (uint32_t i = 0; i < WEBAUDIO_BLOCK_SIZE;
+- i += xsimd::batch<float, Arch>::size) {
+- auto mask =
+- xsimd::batch_bool<float, Arch>::load_aligned(&aIsOnTheLeft[i]);
+-
+- auto inputL = xsimd::batch<float, Arch>::load_aligned(&aInputL[i]);
+- auto inputR = xsimd::batch<float, Arch>::load_aligned(&aInputR[i]);
+- auto gainL = xsimd::batch<float, Arch>::load_aligned(&aGainL[i]);
+- auto gainR = xsimd::batch<float, Arch>::load_aligned(&aGainR[i]);
+-
+- auto outL_true = xsimd::fma(inputR, gainL, inputL);
+- auto outR_true = inputR * gainR;
+-
+- auto outL_false = inputL * gainL;
+- auto outR_false = xsimd::fma(inputL, gainR, inputR);
+-
+- auto outL = xsimd::select(mask, outL_true, outL_false);
+- auto outR = xsimd::select(mask, outR_true, outR_false);
+-
+- outL.store_aligned(&aOutputL[i]);
+- outR.store_aligned(&aOutputR[i]);
+- }
+- }
++ float aOutputL[WEBAUDIO_BLOCK_SIZE], float
aOutputR[WEBAUDIO_BLOCK_SIZE]);
+ };
+
+ } // namespace mozilla
+
+ #endif
+diff --git a/dom/media/webaudio/AudioNodeEngineGenericImpl.h
b/dom/media/webaudio/AudioNodeEngineGenericImpl.h
+new file mode 100644
+--- /dev/null
++++ b/dom/media/webaudio/AudioNodeEngineGenericImpl.h
+@@ -0,0 +1,341 @@
++/* -*- mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2
-*- */
++/* this source code form is subject to the terms of the mozilla public
++ * license, v. 2.0. if a copy of the mpl was not distributed with this file,
++ * You can obtain one at http://mozilla.org/MPL/2.0/. */
++
++#ifndef MOZILLA_AUDIONODEENGINEGENERICIMPL_H_
++#define MOZILLA_AUDIONODEENGINEGENERICIMPL_H_
++
++#include "AudioNodeEngineGeneric.h"
++#include "AlignmentUtils.h"
++
++#if defined(__GNUC__) && __GNUC__ > 7
++# define MOZ_PRAGMA(tokens) _Pragma(#tokens)
++# define MOZ_UNROLL(factor) MOZ_PRAGMA(GCC unroll factor)
++#elif defined(__INTEL_COMPILER) || (defined(__clang__) && __clang_major__ >
3)
++# define MOZ_PRAGMA(tokens) _Pragma(#tokens)
++# define MOZ_UNROLL(factor) MOZ_PRAGMA(unroll factor)
++#else
++# define MOZ_UNROLL(_)
++#endif
++
++namespace mozilla {
++
++template <class Arch>
++static bool is_aligned(const void* ptr) {
++ return (reinterpret_cast<uintptr_t>(ptr) &
++ ~(static_cast<uintptr_t>(Arch::alignment()) - 1)) ==
++ reinterpret_cast<uintptr_t>(ptr);
++};
++
++template <class Arch>
++void Engine<Arch>::AudioBufferAddWithScale(const float* aInput, float
aScale,
++ float* aOutput, uint32_t aSize) {
++ if constexpr (Arch::requires_alignment()) {
++ if (aScale == 1.0f) {
++ while (!is_aligned<Arch>(aInput) || !is_aligned<Arch>(aOutput)) {
++ if (!aSize) return;
++ *aOutput += *aInput;
++ ++aOutput;
++ ++aInput;
++ --aSize;
++ }
++ } else {
++ while (!is_aligned<Arch>(aInput) || !is_aligned<Arch>(aOutput)) {
++ if (!aSize) return;
++ *aOutput += *aInput * aScale;
++ ++aOutput;
++ ++aInput;
++ --aSize;
++ }
++ }
++ }
++ MOZ_ASSERT(is_aligned<Arch>(aInput), "aInput is aligned");
++ MOZ_ASSERT(is_aligned<Arch>(aOutput), "aOutput is aligned");
++
++ xsimd::batch<float, Arch> vgain(aScale);
++
++ uint32_t aVSize = aSize & ~(xsimd::batch<float, Arch>::size - 1);
++ MOZ_UNROLL(4)
++ for (unsigned i = 0; i < aVSize; i += xsimd::batch<float, Arch>::size) {
++ auto vin1 = xsimd::batch<float, Arch>::load_aligned(&aInput[i]);
++ auto vin2 = xsimd::batch<float, Arch>::load_aligned(&aOutput[i]);
++ auto vout = xsimd::fma(vin1, vgain, vin2);
++ vout.store_aligned(&aOutput[i]);
++ }
++
++ for (unsigned i = aVSize; i < aSize; ++i) {
++ aOutput[i] += aInput[i] * aScale;
++ }
++}
++
++template <class Arch>
++void Engine<Arch>::AudioBlockCopyChannelWithScale(const float* aInput,
++ float aScale,
++ float* aOutput) {
++ MOZ_ASSERT(is_aligned<Arch>(aInput), "aInput is aligned");
++ MOZ_ASSERT(is_aligned<Arch>(aOutput), "aOutput is aligned");
++
++ MOZ_ASSERT((WEBAUDIO_BLOCK_SIZE % xsimd::batch<float, Arch>::size == 0),
++ "requires tail processing");
++
++ xsimd::batch<float, Arch> vgain = (aScale);
++
++ MOZ_UNROLL(4)
++ for (unsigned i = 0; i < WEBAUDIO_BLOCK_SIZE;
++ i += xsimd::batch<float, Arch>::size) {
++ auto vin = xsimd::batch<float, Arch>::load_aligned(&aInput[i]);
++ auto vout = vin * vgain;
++ vout.store_aligned(&aOutput[i]);
++ }
++};
++
++template <class Arch>
++void Engine<Arch>::AudioBlockCopyChannelWithScale(
++ const float aInput[WEBAUDIO_BLOCK_SIZE],
++ const float aScale[WEBAUDIO_BLOCK_SIZE],
++ float aOutput[WEBAUDIO_BLOCK_SIZE]) {
++ MOZ_ASSERT(is_aligned<Arch>(aInput), "aInput is aligned");
++ MOZ_ASSERT(is_aligned<Arch>(aOutput), "aOutput is aligned");
++ MOZ_ASSERT(is_aligned<Arch>(aScale), "aScale is aligned");
++
++ MOZ_ASSERT((WEBAUDIO_BLOCK_SIZE % xsimd::batch<float, Arch>::size == 0),
++ "requires tail processing");
++
++ MOZ_UNROLL(4)
++ for (unsigned i = 0; i < WEBAUDIO_BLOCK_SIZE;
++ i += xsimd::batch<float, Arch>::size) {
++ auto vscaled = xsimd::batch<float, Arch>::load_aligned(&aScale[i]);
++ auto vin = xsimd::batch<float, Arch>::load_aligned(&aInput[i]);
++ auto vout = vin * vscaled;
++ vout.store_aligned(&aOutput[i]);
++ }
++};
++
++template <class Arch>
++void Engine<Arch>::AudioBufferInPlaceScale(float* aBlock, float aScale,
++ uint32_t aSize) {
++ MOZ_ASSERT(is_aligned<Arch>(aBlock), "aBlock is aligned");
++
++ xsimd::batch<float, Arch> vgain(aScale);
++
++ uint32_t aVSize = aSize & ~(xsimd::batch<float, Arch>::size - 1);
++ MOZ_UNROLL(4)
++ for (unsigned i = 0; i < aVSize; i += xsimd::batch<float, Arch>::size) {
++ auto vin = xsimd::batch<float, Arch>::load_aligned(&aBlock[i]);
++ auto vout = vin * vgain;
++ vout.store_aligned(&aBlock[i]);
++ }
++ for (unsigned i = aVSize; i < aSize; ++i) aBlock[i] *= aScale;
++};
++
++template <class Arch>
++void Engine<Arch>::AudioBufferInPlaceScale(float* aBlock, float* aScale,
++ uint32_t aSize) {
++ MOZ_ASSERT(is_aligned<Arch>(aBlock), "aBlock is aligned");
++ MOZ_ASSERT(is_aligned<Arch>(aScale), "aScale is aligned");
++
++ uint32_t aVSize = aSize & ~(xsimd::batch<float, Arch>::size - 1);
++ MOZ_UNROLL(4)
++ for (unsigned i = 0; i < aVSize; i += xsimd::batch<float, Arch>::size) {
++ auto vin = xsimd::batch<float, Arch>::load_aligned(&aBlock[i]);
++ auto vgain = xsimd::batch<float, Arch>::load_aligned(&aScale[i]);
++ auto vout = vin * vgain;
++ vout.store_aligned(&aBlock[i]);
++ }
++ for (uint32_t i = aVSize; i < aSize; ++i) {
++ *aBlock++ *= *aScale++;
++ }
++};
++
++template <class Arch>
++void Engine<Arch>::AudioBlockPanStereoToStereo(
++ const float aInputL[WEBAUDIO_BLOCK_SIZE],
++ const float aInputR[WEBAUDIO_BLOCK_SIZE], float aGainL, float aGainR,
++ bool aIsOnTheLeft, float aOutputL[WEBAUDIO_BLOCK_SIZE],
++ float aOutputR[WEBAUDIO_BLOCK_SIZE]) {
++ MOZ_ASSERT(is_aligned<Arch>(aInputL), "aInputL is aligned");
++ MOZ_ASSERT(is_aligned<Arch>(aInputR), "aInputR is aligned");
++ MOZ_ASSERT(is_aligned<Arch>(aOutputL), "aOutputL is aligned");
++ MOZ_ASSERT(is_aligned<Arch>(aOutputR), "aOutputR is aligned");
++
++ MOZ_ASSERT((WEBAUDIO_BLOCK_SIZE % xsimd::batch<float, Arch>::size == 0),
++ "requires tail processing");
++
++ xsimd::batch<float, Arch> vgainl(aGainL);
++ xsimd::batch<float, Arch> vgainr(aGainR);
++
++ if (aIsOnTheLeft) {
++ MOZ_UNROLL(2)
++ for (unsigned i = 0; i < WEBAUDIO_BLOCK_SIZE;
++ i += xsimd::batch<float, Arch>::size) {
++ auto vinl = xsimd::batch<float, Arch>::load_aligned(&aInputL[i]);
++ auto vinr = xsimd::batch<float, Arch>::load_aligned(&aInputR[i]);
++
++ /* left channel : aOutputL = aInputL + aInputR * gainL */
++ auto vout = xsimd::fma(vinr, vgainl, vinl);
++ vout.store_aligned(&aOutputL[i]);
++
++ /* right channel : aOutputR = aInputR * gainR */
++ auto vscaled = vinr * vgainr;
++ vscaled.store_aligned(&aOutputR[i]);
++ }
++ } else {
++ MOZ_UNROLL(2)
++ for (unsigned i = 0; i < WEBAUDIO_BLOCK_SIZE;
++ i += xsimd::batch<float, Arch>::size) {
++ auto vinl = xsimd::batch<float, Arch>::load_aligned(&aInputL[i]);
++ auto vinr = xsimd::batch<float, Arch>::load_aligned(&aInputR[i]);
++
++ /* left channel : aInputL * gainL */
++ auto vscaled = vinl * vgainl;
++ vscaled.store_aligned(&aOutputL[i]);
++
++ /* right channel: aOutputR = aInputR + aInputL * gainR */
++ auto vout = xsimd::fma(vinl, vgainr, vinr);
++ vout.store_aligned(&aOutputR[i]);
++ }
++ }
++};
++
++template <class Arch>
++void Engine<Arch>::BufferComplexMultiply(const float* aInput,
++ const float* aScale, float*
aOutput,
++ uint32_t aSize) {
++ MOZ_ASSERT(is_aligned<Arch>(aInput), "aInput is aligned");
++ MOZ_ASSERT(is_aligned<Arch>(aOutput), "aOutput is aligned");
++ MOZ_ASSERT(is_aligned<Arch>(aScale), "aScale is aligned");
++ MOZ_ASSERT((aSize % xsimd::batch<float, Arch>::size == 0),
++ "requires tail processing");
++
++ MOZ_UNROLL(2)
++ for (unsigned i = 0; i < aSize * 2;
++ i += 2 * xsimd::batch<std::complex<float>, Arch>::size) {
++ auto in1 = xsimd::batch<std::complex<float>, Arch>::load_aligned(
++ reinterpret_cast<const std::complex<float>*>(&aInput[i]));
++ auto in2 = xsimd::batch<std::complex<float>, Arch>::load_aligned(
++ reinterpret_cast<const std::complex<float>*>(&aScale[i]));
++ auto out = in1 * in2;
++ out.store_aligned(reinterpret_cast<std::complex<float>*>(&aOutput[i]));
++ }
++};
++
++template <class Arch>
++float Engine<Arch>::AudioBufferSumOfSquares(const float* aInput,
++ uint32_t aLength) {
++ float sum = 0.f;
++
++ if constexpr (Arch::requires_alignment()) {
++ while (!is_aligned<Arch>(aInput)) {
++ if (!aLength) {
++ return sum;
++ }
++ sum += *aInput * *aInput;
++ ++aInput;
++ --aLength;
++ }
++ }
++
++ MOZ_ASSERT(is_aligned<Arch>(aInput), "aInput is aligned");
++
++ constexpr uint32_t unroll_factor = 4;
++ xsimd::batch<float, Arch> accs[unroll_factor] = {0.f, 0.f, 0.f, 0.f};
++
++ uint32_t vLength =
++ aLength & ~(unroll_factor * xsimd::batch<float, Arch>::size - 1);
++
++ for (uint32_t i = 0; i < vLength;
++ i += unroll_factor * xsimd::batch<float, Arch>::size) {
++ MOZ_UNROLL(4)
++ for (uint32_t j = 0; j < unroll_factor; ++j) {
++ auto in = xsimd::batch<float, Arch>::load_aligned(
++ &aInput[i + xsimd::batch<float, Arch>::size * j]);
++ accs[j] = xsimd::fma(in, in, accs[j]);
++ }
++ }
++
++ sum += reduce_add((accs[0] + accs[1]) + (accs[2] + accs[3]));
++ for (uint32_t i = vLength; i < aLength; ++i) sum += aInput[i] * aInput[i];
++ return sum;
++};
++
++template <class Arch>
++void Engine<Arch>::NaNToZeroInPlace(float* aSamples, size_t aCount) {
++ if constexpr (Arch::requires_alignment()) {
++ while (!is_aligned<Arch>(aSamples)) {
++ if (!aCount) {
++ return;
++ }
++ if (*aSamples != *aSamples) {
++ *aSamples = 0.0;
++ }
++ ++aSamples;
++ --aCount;
++ }
++ }
++
++ MOZ_ASSERT(is_aligned<Arch>(aSamples), "aSamples is aligned");
++
++ uint32_t vCount = aCount & ~(xsimd::batch<float, Arch>::size - 1);
++
++ MOZ_UNROLL(4)
++ for (uint32_t i = 0; i < vCount; i += xsimd::batch<float, Arch>::size) {
++ auto vin = xsimd::batch<float, Arch>::load_aligned(&aSamples[i]);
++ auto vout =
++ xsimd::select(xsimd::isnan(vin), xsimd::batch<float, Arch>(0.f),
vin);
++ vout.store_aligned(&aSamples[i]);
++ }
++
++ for (uint32_t i = vCount; i < aCount; i++) {
++ if (aSamples[i] != aSamples[i]) {
++ aSamples[i] = 0.0;
++ }
++ }
++};
++
++template <class Arch>
++void Engine<Arch>::AudioBlockPanStereoToStereo(
++ const float aInputL[WEBAUDIO_BLOCK_SIZE],
++ const float aInputR[WEBAUDIO_BLOCK_SIZE],
++ const float aGainL[WEBAUDIO_BLOCK_SIZE],
++ const float aGainR[WEBAUDIO_BLOCK_SIZE],
++ const bool aIsOnTheLeft[WEBAUDIO_BLOCK_SIZE],
++ float aOutputL[WEBAUDIO_BLOCK_SIZE], float
aOutputR[WEBAUDIO_BLOCK_SIZE]) {
++ MOZ_ASSERT(is_aligned<Arch>(aInputL), "aInputL is aligned");
++ MOZ_ASSERT(is_aligned<Arch>(aInputR), "aInputR is aligned");
++ MOZ_ASSERT(is_aligned<Arch>(aGainL), "aGainL is aligned");
++ MOZ_ASSERT(is_aligned<Arch>(aGainR), "aGainR is aligned");
++ MOZ_ASSERT(is_aligned<Arch>(aIsOnTheLeft), "aIsOnTheLeft is aligned");
++ MOZ_ASSERT(is_aligned<Arch>(aOutputL), "aOutputL is aligned");
++ MOZ_ASSERT(is_aligned<Arch>(aOutputR), "aOutputR is aligned");
++
++ MOZ_ASSERT((WEBAUDIO_BLOCK_SIZE % xsimd::batch<float, Arch>::size == 0),
++ "requires tail processing");
++
++ MOZ_UNROLL(2)
++ for (uint32_t i = 0; i < WEBAUDIO_BLOCK_SIZE;
++ i += xsimd::batch<float, Arch>::size) {
++ auto mask = xsimd::batch_bool<float,
Arch>::load_aligned(&aIsOnTheLeft[i]);
++
++ auto inputL = xsimd::batch<float, Arch>::load_aligned(&aInputL[i]);
++ auto inputR = xsimd::batch<float, Arch>::load_aligned(&aInputR[i]);
++ auto gainL = xsimd::batch<float, Arch>::load_aligned(&aGainL[i]);
++ auto gainR = xsimd::batch<float, Arch>::load_aligned(&aGainR[i]);
++
++ auto outL_true = xsimd::fma(inputR, gainL, inputL);
++ auto outR_true = inputR * gainR;
++
++ auto outL_false = inputL * gainL;
++ auto outR_false = xsimd::fma(inputL, gainR, inputR);
++
++ auto outL = xsimd::select(mask, outL_true, outL_false);
++ auto outR = xsimd::select(mask, outR_true, outR_false);
++
++ outL.store_aligned(&aOutputL[i]);
++ outR.store_aligned(&aOutputR[i]);
++ }
++}
++
++} // namespace mozilla
++
++#endif
+diff --git a/dom/media/webaudio/AudioNodeEngineNEON.cpp
b/dom/media/webaudio/AudioNodeEngineNEON.cpp
+--- a/dom/media/webaudio/AudioNodeEngineNEON.cpp
++++ b/dom/media/webaudio/AudioNodeEngineNEON.cpp
+@@ -1,9 +1,9 @@
+ /* -*- mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2
-*- */
+ /* this source code form is subject to the terms of the mozilla public
+ * license, v. 2.0. if a copy of the mpl was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+-#include "AudioNodeEngineGeneric.h"
++#include "AudioNodeEngineGenericImpl.h"
+ namespace mozilla {
+ template struct Engine<xsimd::neon>;
+ } // namespace mozilla
+diff --git a/dom/media/webaudio/AudioNodeEngineSSE2.cpp
b/dom/media/webaudio/AudioNodeEngineSSE2.cpp
+--- a/dom/media/webaudio/AudioNodeEngineSSE2.cpp
++++ b/dom/media/webaudio/AudioNodeEngineSSE2.cpp
+@@ -1,10 +1,10 @@
+ /* -*- mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2
-*- */
+ /* this source code form is subject to the terms of the mozilla public
+ * license, v. 2.0. if a copy of the mpl was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+-#include "AudioNodeEngineGeneric.h"
++#include "AudioNodeEngineGenericImpl.h"
+
+ namespace mozilla {
+ template struct Engine<xsimd::sse2>;
+ } // namespace mozilla
+diff --git a/dom/media/webaudio/AudioNodeEngineSSE4_2_FMA3.cpp
b/dom/media/webaudio/AudioNodeEngineSSE4_2_FMA3.cpp
+--- a/dom/media/webaudio/AudioNodeEngineSSE4_2_FMA3.cpp
++++ b/dom/media/webaudio/AudioNodeEngineSSE4_2_FMA3.cpp
+@@ -1,10 +1,10 @@
+ /* -*- mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2
-*- */
+ /* this source code form is subject to the terms of the mozilla public
+ * license, v. 2.0. if a copy of the mpl was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+-#include "AudioNodeEngineGeneric.h"
++#include "AudioNodeEngineGenericImpl.h"
+
+ namespace mozilla {
+ template struct Engine<xsimd::fma3<xsimd::sse4_2>>;
+ } // namespace mozilla
+



  • [SM-Commit] GIT changes to master grimoire by Pavel Vinogradov (a462816d503f0ce07ace6d55e6eecfbbc55b9f39), Pavel Vinogradov, 04/04/2023

Archive powered by MHonArc 2.6.24.

Top of Page