Browse Source

Added DCT tests paths for nosimd/avx/avx+fma

pull/1632/head
Dmitry Pentin 5 years ago
parent
commit
8d321a5dc2
  1. 34
      tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs

34
tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs

@ -7,7 +7,7 @@ using System.Runtime.Intrinsics.X86;
#endif #endif
using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils; using SixLabors.ImageSharp.Tests.Formats.Jpg.Utils;
using SixLabors.ImageSharp.Tests.TestUtilities;
using Xunit; using Xunit;
using Xunit.Abstractions; using Xunit.Abstractions;
@ -159,6 +159,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(2)] [InlineData(2)]
public void TransformIDCT(int seed) public void TransformIDCT(int seed)
{ {
static void RunTest(string serialized)
{
int seed = FeatureTestRunner.Deserialize<int>(serialized);
Span<float> src = Create8x8RoundedRandomFloatData(-200, 200, seed); Span<float> src = Create8x8RoundedRandomFloatData(-200, 200, seed);
var srcBlock = default(Block8x8F); var srcBlock = default(Block8x8F);
srcBlock.LoadFrom(src); srcBlock.LoadFrom(src);
@ -181,6 +185,18 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f)); Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f));
} }
// 3 paths:
// 1. AllowAll - call avx/fma implementation
// 2. DisableFMA - call avx implementation without fma acceleration
// 3. DisableAvx - call fallback code of Vector4 implementation
//
// DisableSSE isn't needed because fallback Vector4 code will compile to either sse or fallback code with same result
FeatureTestRunner.RunWithHwIntrinsicsFeature(
RunTest,
seed,
HwIntrinsics.AllowAll | HwIntrinsics.DisableFMA | HwIntrinsics.DisableAVX);
}
// Forward transform // Forward transform
[Theory] [Theory]
[InlineData(1)] [InlineData(1)]
@ -276,6 +292,10 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
[InlineData(2)] [InlineData(2)]
public void TransformFDCT(int seed) public void TransformFDCT(int seed)
{ {
static void RunTest(string serialized)
{
int seed = FeatureTestRunner.Deserialize<int>(serialized);
Span<float> src = Create8x8RoundedRandomFloatData(-200, 200, seed); Span<float> src = Create8x8RoundedRandomFloatData(-200, 200, seed);
var srcBlock = default(Block8x8F); var srcBlock = default(Block8x8F);
srcBlock.LoadFrom(src); srcBlock.LoadFrom(src);
@ -297,6 +317,18 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f)); Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f));
} }
// 3 paths:
// 1. AllowAll - call avx/fma implementation
// 2. DisableFMA - call avx implementation without fma acceleration
// 3. DisableAvx - call fallback code of Vector4 implementation
//
// DisableSSE isn't needed because fallback Vector4 code will compile to either sse or fallback code with same result
FeatureTestRunner.RunWithHwIntrinsicsFeature(
RunTest,
seed,
HwIntrinsics.AllowAll | HwIntrinsics.DisableFMA | HwIntrinsics.DisableAVX);
}
} }
} }
} }

Loading…
Cancel
Save