Skip to content

Commit 5ddbbfb

Browse files
committed
AVX-512 implementation of h_sum, h_sqr_sum and h_abs_sum
1 parent 7dd57a1 commit 5ddbbfb

File tree

9 files changed

+435
-12
lines changed

9 files changed

+435
-12
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2024 Vladimir Sadovnikov <sadko4u@gmail.com>
4+
*
5+
* This file is part of lsp-dsp-lib
6+
* Created on: 11 дек. 2024 г.
7+
*
8+
* lsp-dsp-lib is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Lesser General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* any later version.
12+
*
13+
* lsp-dsp-lib is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Lesser General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with lsp-dsp-lib. If not, see <https://www.gnu.org/licenses/>.
20+
*/
21+
22+
#ifndef PRIVATE_DSP_ARCH_X86_AVX512_HMATH_H_
23+
#define PRIVATE_DSP_ARCH_X86_AVX512_HMATH_H_
24+
25+
#ifndef PRIVATE_DSP_ARCH_X86_AVX512_IMPL
26+
#error "This header should not be included directly"
27+
#endif /* PRIVATE_DSP_ARCH_X86_AVX512_IMPL */
28+
29+
30+
#include <private/dsp/arch/x86/avx512/hmath/hsum.h>
31+
32+
33+
#endif /* PRIVATE_DSP_ARCH_X86_AVX512_HMATH_H_ */

include/private/dsp/arch/x86/avx512/hmath/hsum.h

Lines changed: 351 additions & 0 deletions
Large diffs are not rendered by default.

src/main/x86/avx512.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include <private/dsp/arch/x86/avx512/dynamics.h>
4848
#include <private/dsp/arch/x86/avx512/float.h>
4949
#include <private/dsp/arch/x86/avx512/graphics/axis.h>
50+
#include <private/dsp/arch/x86/avx512/hmath.h>
5051
#include <private/dsp/arch/x86/avx512/msmatrix.h>
5152
#include <private/dsp/arch/x86/avx512/pcomplex.h>
5253
#include <private/dsp/arch/x86/avx512/pmath.h>
@@ -315,14 +316,16 @@
315316
CEXPORT1(vl, mix2);
316317
CEXPORT1(vl, mix_copy2);
317318
CEXPORT1(vl, mix_add2);
318-
319319
CEXPORT1(vl, mix3);
320320
CEXPORT1(vl, mix_copy3);
321321
CEXPORT1(vl, mix_add3);
322-
323322
CEXPORT1(vl, mix4);
324323
CEXPORT1(vl, mix_copy4);
325324
CEXPORT1(vl, mix_add4);
325+
326+
CEXPORT1(vl, h_sum);
327+
CEXPORT1(vl, h_sqr_sum);
328+
CEXPORT1(vl, h_abs_sum);
326329
}
327330
} /* namespace avx2 */
328331
} /* namespace lsp */

src/test/ptest/hmath/h_abs_sum.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2023 Vladimir Sadovnikov <sadko4u@gmail.com>
2+
* Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2024 Vladimir Sadovnikov <sadko4u@gmail.com>
44
*
55
* This file is part of lsp-dsp-lib
66
* Created on: 31 мар. 2020 г.
@@ -44,6 +44,11 @@ namespace lsp
4444
{
4545
float h_abs_sum(const float *src, size_t count);
4646
}
47+
48+
namespace avx512
49+
{
50+
float h_abs_sum(const float *src, size_t count);
51+
}
4752
)
4853

4954
IF_ARCH_ARM(
@@ -98,6 +103,7 @@ PTEST_BEGIN("dsp.hmath", hsum, 5, 10000)
98103
CALL(generic::h_abs_sum);
99104
IF_ARCH_X86(CALL(sse::h_abs_sum));
100105
IF_ARCH_X86(CALL(avx::h_abs_sum));
106+
IF_ARCH_X86(CALL(avx512::h_abs_sum));
101107
IF_ARCH_ARM(CALL(neon_d32::h_abs_sum));
102108
IF_ARCH_AARCH64(CALL(asimd::h_abs_sum));
103109
PTEST_SEPARATOR;

src/test/ptest/hmath/h_sqr_sum.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2023 Vladimir Sadovnikov <sadko4u@gmail.com>
2+
* Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2024 Vladimir Sadovnikov <sadko4u@gmail.com>
44
*
55
* This file is part of lsp-dsp-lib
66
* Created on: 31 мар. 2020 г.
@@ -45,6 +45,11 @@ namespace lsp
4545
float h_sqr_sum(const float *src, size_t count);
4646
float h_sqr_sum_fma3(const float *src, size_t count);
4747
}
48+
49+
namespace avx512
50+
{
51+
float h_sqr_sum(const float *src, size_t count);
52+
}
4853
)
4954

5055
IF_ARCH_ARM(
@@ -100,6 +105,7 @@ PTEST_BEGIN("dsp.hmath", h_sqr_sum, 5, 10000)
100105
IF_ARCH_X86(CALL(sse::h_sqr_sum));
101106
IF_ARCH_X86(CALL(avx::h_sqr_sum));
102107
IF_ARCH_X86(CALL(avx::h_sqr_sum_fma3));
108+
IF_ARCH_X86(CALL(avx512::h_sqr_sum));
103109
IF_ARCH_ARM(CALL(neon_d32::h_sqr_sum));
104110
IF_ARCH_AARCH64(CALL(asimd::h_sqr_sum));
105111
PTEST_SEPARATOR;

src/test/ptest/hmath/h_sum.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2023 Vladimir Sadovnikov <sadko4u@gmail.com>
2+
* Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2024 Vladimir Sadovnikov <sadko4u@gmail.com>
44
*
55
* This file is part of lsp-dsp-lib
66
* Created on: 31 мар. 2020 г.
@@ -44,6 +44,11 @@ namespace lsp
4444
{
4545
float h_sum(const float *src, size_t count);
4646
}
47+
48+
namespace avx512
49+
{
50+
float h_sum(const float *src, size_t count);
51+
}
4752
)
4853

4954
IF_ARCH_ARM(
@@ -98,6 +103,7 @@ PTEST_BEGIN("dsp.hmath", h_sum, 5, 10000)
98103
CALL(generic::h_sum);
99104
IF_ARCH_X86(CALL(sse::h_sum));
100105
IF_ARCH_X86(CALL(avx::h_sum));
106+
IF_ARCH_X86(CALL(avx512::h_sum));
101107
IF_ARCH_ARM(CALL(neon_d32::h_sum));
102108
IF_ARCH_AARCH64(CALL(asimd::h_sum));
103109
PTEST_SEPARATOR;

src/test/utest/hmath/h_abs_sum.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2023 Vladimir Sadovnikov <sadko4u@gmail.com>
2+
* Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2024 Vladimir Sadovnikov <sadko4u@gmail.com>
44
*
55
* This file is part of lsp-dsp-lib
66
* Created on: 31 мар. 2020 г.
@@ -49,6 +49,11 @@ namespace lsp
4949
{
5050
float h_abs_sum(const float *src, size_t count);
5151
}
52+
53+
namespace avx512
54+
{
55+
float h_abs_sum(const float *src, size_t count);
56+
}
5257
)
5358

5459
IF_ARCH_ARM(
@@ -110,6 +115,7 @@ UTEST_BEGIN("dsp.hmath", h_abs_sum)
110115

111116
IF_ARCH_X86(CALL(generic::h_abs_sum, sse::h_abs_sum, 16));
112117
IF_ARCH_X86(CALL(generic::h_abs_sum, avx::h_abs_sum, 32));
118+
IF_ARCH_X86(CALL(generic::h_abs_sum, avx512::h_abs_sum, 64));
113119
IF_ARCH_ARM(CALL(generic::h_abs_sum, neon_d32::h_abs_sum, 16));
114120
IF_ARCH_AARCH64(CALL(generic::h_abs_sum, asimd::h_abs_sum, 16));
115121
}

src/test/utest/hmath/h_sqr_sum.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ namespace lsp
5050
float h_sqr_sum(const float *src, size_t count);
5151
float h_sqr_sum_fma3(const float *src, size_t count);
5252
}
53+
54+
namespace avx512
55+
{
56+
float h_sqr_sum(const float *src, size_t count);
57+
}
5358
)
5459

5560
IF_ARCH_ARM(
@@ -114,6 +119,7 @@ UTEST_BEGIN("dsp.hmath", h_sqr_sum)
114119
IF_ARCH_X86(CALL(generic::h_sqr_sum, sse::h_sqr_sum, 16));
115120
IF_ARCH_X86(CALL(generic::h_sqr_sum, avx::h_sqr_sum, 32));
116121
IF_ARCH_X86(CALL(generic::h_sqr_sum, avx::h_sqr_sum_fma3, 32));
122+
IF_ARCH_X86(CALL(generic::h_sqr_sum, avx512::h_sqr_sum, 64));
117123
IF_ARCH_ARM(CALL(generic::h_sqr_sum, neon_d32::h_sqr_sum, 16));
118124
IF_ARCH_AARCH64(CALL(generic::h_sqr_sum, asimd::h_sqr_sum, 16));
119125
}

src/test/utest/hmath/h_sum.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2023 Vladimir Sadovnikov <sadko4u@gmail.com>
2+
* Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2024 Vladimir Sadovnikov <sadko4u@gmail.com>
44
*
55
* This file is part of lsp-dsp-lib
66
* Created on: 31 мар. 2020 г.
@@ -49,6 +49,11 @@ namespace lsp
4949
{
5050
float h_sum(const float *src, size_t count);
5151
}
52+
53+
namespace avx512
54+
{
55+
float h_sum(const float *src, size_t count);
56+
}
5257
)
5358

5459
IF_ARCH_ARM(
@@ -110,6 +115,7 @@ UTEST_BEGIN("dsp.hmath", h_sum)
110115

111116
IF_ARCH_X86(CALL(generic::h_sum, sse::h_sum, 16));
112117
IF_ARCH_X86(CALL(generic::h_sum, avx::h_sum, 32));
118+
IF_ARCH_X86(CALL(generic::h_sum, avx512::h_sum, 64));
113119
IF_ARCH_ARM(CALL(generic::h_sum, neon_d32::h_sum, 16));
114120
IF_ARCH_AARCH64(CALL(generic::h_sum, asimd::h_sum, 16));
115121
}

0 commit comments

Comments
 (0)