diff --git a/include/lsp-plug.in/dsp/common/graphics.h b/include/lsp-plug.in/dsp/common/graphics.h index 9ca15fa0..ad32be6d 100644 --- a/include/lsp-plug.in/dsp/common/graphics.h +++ b/include/lsp-plug.in/dsp/common/graphics.h @@ -59,9 +59,9 @@ LSP_DSP_LIB_END_NAMESPACE * @param x destination vector for X coordinate * @param v delta vector to apply * @param zero graphics zero point shift - * @param norm_x X norming factor + * @param norm X norming factor */ -LSP_DSP_LIB_SYMBOL(void, axis_apply_lin1, float *x, const float *v, float zero, float norm_x, size_t count); +LSP_DSP_LIB_SYMBOL(void, axis_apply_lin1, float *x, const float *v, float zero, float norm, size_t count); /** Do logarithmic vector apply for 1D-schema: * x[i] = x[i] + norm_x * logf(absf(v[i]*zero)) diff --git a/include/private/dsp/arch/generic/graphics.h b/include/private/dsp/arch/generic/graphics.h index f38d3e16..55da3358 100644 --- a/include/private/dsp/arch/generic/graphics.h +++ b/include/private/dsp/arch/generic/graphics.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2020 Linux Studio Plugins Project - * (C) 2020 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-dsp-lib * Created on: 31 мар. 2020 г. @@ -26,50 +26,13 @@ #error "This header should not be included directly" #endif /* PRIVATE_DSP_ARCH_GENERIC_IMPL */ +#include #include namespace lsp { namespace generic { - void axis_apply_lin1(float *x, const float *v, float zero, float norm_x, size_t count) - { - for (size_t i=0; i + * (C) 2023 Vladimir Sadovnikov + * + * This file is part of lsp-dsp-lib + * Created on: 24 сент. 2023 г. + * + * lsp-dsp-lib is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * lsp-dsp-lib is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with lsp-dsp-lib. If not, see . + */ + +#ifndef PRIVATE_DSP_ARCH_GENERIC_GRAPHICS_AXIS_H_ +#define PRIVATE_DSP_ARCH_GENERIC_GRAPHICS_AXIS_H_ + +namespace lsp +{ + namespace generic + { + void axis_apply_lin1(float *x, const float *v, float zero, float norm, size_t count) + { + for (size_t i=0; i - * (C) 2020 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-dsp-lib * Created on: 31 мар. 2020 г. @@ -26,88 +26,7 @@ #error "This header should not be included directly" #endif /* PRIVATE_DSP_ARCH_X86_SSE_IMPL */ -namespace lsp -{ - namespace sse - { - #define FILL4_CORE \ - __ASM_EMIT("movss %[c0], %%xmm0") /* xmm0 = c0 */ \ - __ASM_EMIT("movss %[c1], %%xmm1") /* xmm1 = c1 */ \ - __ASM_EMIT("movss %[c2], %%xmm2") /* xmm2 = c2 */ \ - __ASM_EMIT("movss %[c3], %%xmm3") /* xmm3 = c3 */ \ - __ASM_EMIT("unpcklps %%xmm1, %%xmm0") /* xmm0 = c0 c1 ? ? */ \ - __ASM_EMIT("unpcklps %%xmm3, %%xmm2") /* xmm2 = c2 c3 ? ? */ \ - __ASM_EMIT("movlhps %%xmm2, %%xmm0") /* xmm0 = c0 c1 c2 c3 */ \ - __ASM_EMIT("movaps %%xmm0, %%xmm1") /* xmm1 = c0 c1 c2 c3 */ \ - __ASM_EMIT("movaps %%xmm0, %%xmm2") \ - __ASM_EMIT("movaps %%xmm1, %%xmm3") \ - \ - /* 8x blocks */ \ - __ASM_EMIT("sub $8, %[count]") \ - __ASM_EMIT("jb 2f") \ - __ASM_EMIT("1:") \ - __ASM_EMIT("movups %%xmm0, 0x00(%[dst])") \ - __ASM_EMIT("movups %%xmm1, 0x10(%[dst])") \ - __ASM_EMIT("movups %%xmm2, 0x20(%[dst])") \ - __ASM_EMIT("movups %%xmm3, 0x30(%[dst])") \ - __ASM_EMIT("movups %%xmm0, 0x40(%[dst])") \ - __ASM_EMIT("movups %%xmm1, 0x50(%[dst])") \ - __ASM_EMIT("movups %%xmm2, 0x60(%[dst])") \ - __ASM_EMIT("movups %%xmm3, 0x70(%[dst])") \ - __ASM_EMIT("add $0x80, %[dst]") \ - __ASM_EMIT("sub $8, %[count]") \ - __ASM_EMIT("jae 1b") \ - /* 4x block */ \ - __ASM_EMIT("2:") \ - __ASM_EMIT("add $4, %[count]") \ - __ASM_EMIT("jl 4f") \ - __ASM_EMIT("movups %%xmm0, 0x00(%[dst])") \ - __ASM_EMIT("movups %%xmm1, 0x10(%[dst])") \ - __ASM_EMIT("movups %%xmm2, 0x20(%[dst])") \ - __ASM_EMIT("movups %%xmm3, 0x30(%[dst])") \ - __ASM_EMIT("sub $4, %[count]") \ - __ASM_EMIT("add $0x40, %[dst]") \ - /* 2x block */ \ - __ASM_EMIT("4:") \ - __ASM_EMIT("add $2, %[count]") \ - __ASM_EMIT("jl 6f") \ - __ASM_EMIT("movups %%xmm0, 0x00(%[dst])") \ - __ASM_EMIT("movups %%xmm1, 0x10(%[dst])") \ - __ASM_EMIT("sub $2, %[count]") \ - __ASM_EMIT("add $0x20, %[dst]") \ - /* 1x block */ \ - __ASM_EMIT("6:") \ - __ASM_EMIT("add $1, %[count]") \ - __ASM_EMIT("jl 8f") \ - __ASM_EMIT("movups %%xmm0, 0x00(%[dst])") \ - __ASM_EMIT("8:") - - void fill_rgba(float *dst, float r, float g, float b, float a, size_t count) - { - ARCH_X86_ASM - ( - FILL4_CORE - : [dst] "+r" (dst), [count] "+r" (count) - : [c0] "m" (r), [c1] "m" (g), [c2] "m" (b), [c3] "m" (a) - : "cc", "memory", - "%xmm0", "%xmm1", "%xmm2", "%xmm3" - ); - } - - void fill_hsla(float *dst, float h, float s, float l, float a, size_t count) - { - ARCH_X86_ASM - ( - FILL4_CORE - : [dst] "+r" (dst), [count] "+r" (count) - : [c0] "m" (h), [c1] "m" (s), [c2] "m" (l), [c3] "m" (a) - : "cc", "memory", - "%xmm0", "%xmm1", "%xmm2", "%xmm3" - ); - } - - #undef FILL4_CORE - } -} +#include +#include #endif /* PRIVATE_DSP_ARCH_X86_SSE_GRAPHICS_H_ */ diff --git a/include/private/dsp/arch/x86/sse/graphics/axis.h b/include/private/dsp/arch/x86/sse/graphics/axis.h new file mode 100644 index 00000000..0b6ab6c4 --- /dev/null +++ b/include/private/dsp/arch/x86/sse/graphics/axis.h @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov + * + * This file is part of lsp-dsp-lib + * Created on: 23 сент. 2023 г. + * + * lsp-dsp-lib is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * lsp-dsp-lib is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with lsp-dsp-lib. If not, see . + */ + +#ifndef PRIVATE_DSP_ARCH_X86_SSE_GRAPHICS_AXIS_H_ +#define PRIVATE_DSP_ARCH_X86_SSE_GRAPHICS_AXIS_H_ + +#ifndef PRIVATE_DSP_ARCH_X86_SSE_IMPL + #error "This header should not be included directly" +#endif /* PRIVATE_DSP_ARCH_X86_SSE_IMPL */ + +namespace lsp +{ + namespace sse + { + + void axis_apply_lin1(float *x, const float *v, float zero, float norm, size_t count) + { + IF_ARCH_X86(size_t off); + ARCH_X86_ASM + ( + __ASM_EMIT("movss %[zero], %%xmm1") + __ASM_EMIT("xor %[off], %[off]") + __ASM_EMIT("shufps $0x00, %%xmm0, %%xmm0") + __ASM_EMIT("shufps $0x00, %%xmm1, %%xmm1") + __ASM_EMIT("sub $12, %[count]") + __ASM_EMIT("jb 2f") + /* 12x blocks */ + __ASM_EMIT("1:") + __ASM_EMIT("movups 0x00(%[v], %[off]), %%xmm5") + __ASM_EMIT("movups 0x10(%[v], %[off]), %%xmm6") + __ASM_EMIT("movups 0x20(%[v], %[off]), %%xmm7") + __ASM_EMIT("movups 0x00(%[x], %[off]), %%xmm2") + __ASM_EMIT("movups 0x10(%[x], %[off]), %%xmm3") + __ASM_EMIT("movups 0x20(%[x], %[off]), %%xmm4") + __ASM_EMIT("addps %%xmm1, %%xmm5") + __ASM_EMIT("addps %%xmm1, %%xmm6") + __ASM_EMIT("addps %%xmm1, %%xmm7") + __ASM_EMIT("mulps %%xmm0, %%xmm5") + __ASM_EMIT("mulps %%xmm0, %%xmm6") + __ASM_EMIT("mulps %%xmm0, %%xmm7") + __ASM_EMIT("addps %%xmm5, %%xmm2") + __ASM_EMIT("addps %%xmm6, %%xmm3") + __ASM_EMIT("addps %%xmm7, %%xmm4") + __ASM_EMIT("movups %%xmm2, 0x00(%[x], %[off])") + __ASM_EMIT("movups %%xmm3, 0x10(%[x], %[off])") + __ASM_EMIT("movups %%xmm4, 0x20(%[x], %[off])") + __ASM_EMIT("add $0x30, %[off]") + __ASM_EMIT("sub $12, %[count]") + __ASM_EMIT("jae 1b") + __ASM_EMIT("2:") + /* 8x block */ + __ASM_EMIT("add $4, %[count]") + __ASM_EMIT("jl 4f") + __ASM_EMIT("movups 0x00(%[v], %[off]), %%xmm5") + __ASM_EMIT("movups 0x10(%[v], %[off]), %%xmm6") + __ASM_EMIT("movups 0x00(%[x], %[off]), %%xmm2") + __ASM_EMIT("movups 0x10(%[x], %[off]), %%xmm3") + __ASM_EMIT("addps %%xmm1, %%xmm5") + __ASM_EMIT("addps %%xmm1, %%xmm6") + __ASM_EMIT("mulps %%xmm0, %%xmm5") + __ASM_EMIT("mulps %%xmm0, %%xmm6") + __ASM_EMIT("addps %%xmm5, %%xmm2") + __ASM_EMIT("addps %%xmm6, %%xmm3") + __ASM_EMIT("movups %%xmm2, 0x00(%[x], %[off])") + __ASM_EMIT("movups %%xmm3, 0x10(%[x], %[off])") + __ASM_EMIT("add $0x20, %[off]") + __ASM_EMIT("sub $8, %[count]") + __ASM_EMIT("4:") + /* 4x block */ + __ASM_EMIT("add $4, %[count]") + __ASM_EMIT("jl 6f") + __ASM_EMIT("movups 0x00(%[v], %[off]), %%xmm5") + __ASM_EMIT("movups 0x00(%[x], %[off]), %%xmm2") + __ASM_EMIT("addps %%xmm1, %%xmm5") + __ASM_EMIT("mulps %%xmm0, %%xmm5") + __ASM_EMIT("addps %%xmm5, %%xmm2") + __ASM_EMIT("movups %%xmm2, 0x00(%[x], %[off])") + __ASM_EMIT("add $0x10, %[off]") + __ASM_EMIT("sub $4, %[count]") + __ASM_EMIT("6:") + /* 1x blocks */ + __ASM_EMIT("add $3, %[count]") + __ASM_EMIT("jl 8f") + __ASM_EMIT("7:") + __ASM_EMIT("movss 0x00(%[v], %[off]), %%xmm5") + __ASM_EMIT("movss 0x00(%[x], %[off]), %%xmm2") + __ASM_EMIT("addss %%xmm1, %%xmm5") + __ASM_EMIT("mulss %%xmm0, %%xmm5") + __ASM_EMIT("addss %%xmm5, %%xmm2") + __ASM_EMIT("movss %%xmm2, 0x00(%[x], %[off])") + __ASM_EMIT("add $0x04, %[off]") + __ASM_EMIT("dec %[count]") + __ASM_EMIT("jge 7b") + __ASM_EMIT("8:") + + : [off] "=&r" (off), [count] "+r" (count), + [norm] "+Yz"(norm) + : [x] "r" (x), [v] "r" (v), + [zero] "m" (zero) + : "cc", "memory", + "%xmm1", "%xmm2", "%xmm3", + "%xmm4", "%xmm5", "%xmm6", "%xmm7" + ); + } + + } /* namespace sse */ +} /* namespace lsp */ + + +#endif /* PRIVATE_DSP_ARCH_X86_SSE_GRAPHICS_AXIS_H_ */ diff --git a/include/private/dsp/arch/x86/sse/graphics/fill.h b/include/private/dsp/arch/x86/sse/graphics/fill.h new file mode 100644 index 00000000..487fb465 --- /dev/null +++ b/include/private/dsp/arch/x86/sse/graphics/fill.h @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov + * + * This file is part of lsp-dsp-lib + * Created on: 23 сент. 2023 г. + * + * lsp-dsp-lib is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * lsp-dsp-lib is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with lsp-dsp-lib. If not, see . + */ + +#ifndef PRIVATE_DSP_ARCH_X86_SSE_GRAPHICS_FILL_H_ +#define PRIVATE_DSP_ARCH_X86_SSE_GRAPHICS_FILL_H_ + +#ifndef PRIVATE_DSP_ARCH_X86_SSE_IMPL + #error "This header should not be included directly" +#endif /* PRIVATE_DSP_ARCH_X86_SSE_IMPL */ + +namespace lsp +{ + namespace sse + { + #define FILL4_CORE \ + __ASM_EMIT("movss %[c0], %%xmm0") /* xmm0 = c0 */ \ + __ASM_EMIT("movss %[c1], %%xmm1") /* xmm1 = c1 */ \ + __ASM_EMIT("movss %[c2], %%xmm2") /* xmm2 = c2 */ \ + __ASM_EMIT("movss %[c3], %%xmm3") /* xmm3 = c3 */ \ + __ASM_EMIT("unpcklps %%xmm1, %%xmm0") /* xmm0 = c0 c1 ? ? */ \ + __ASM_EMIT("unpcklps %%xmm3, %%xmm2") /* xmm2 = c2 c3 ? ? */ \ + __ASM_EMIT("movlhps %%xmm2, %%xmm0") /* xmm0 = c0 c1 c2 c3 */ \ + __ASM_EMIT("movaps %%xmm0, %%xmm1") /* xmm1 = c0 c1 c2 c3 */ \ + __ASM_EMIT("movaps %%xmm0, %%xmm2") \ + __ASM_EMIT("movaps %%xmm1, %%xmm3") \ + \ + /* 8x blocks */ \ + __ASM_EMIT("sub $8, %[count]") \ + __ASM_EMIT("jb 2f") \ + __ASM_EMIT("1:") \ + __ASM_EMIT("movups %%xmm0, 0x00(%[dst])") \ + __ASM_EMIT("movups %%xmm1, 0x10(%[dst])") \ + __ASM_EMIT("movups %%xmm2, 0x20(%[dst])") \ + __ASM_EMIT("movups %%xmm3, 0x30(%[dst])") \ + __ASM_EMIT("movups %%xmm0, 0x40(%[dst])") \ + __ASM_EMIT("movups %%xmm1, 0x50(%[dst])") \ + __ASM_EMIT("movups %%xmm2, 0x60(%[dst])") \ + __ASM_EMIT("movups %%xmm3, 0x70(%[dst])") \ + __ASM_EMIT("add $0x80, %[dst]") \ + __ASM_EMIT("sub $8, %[count]") \ + __ASM_EMIT("jae 1b") \ + /* 4x block */ \ + __ASM_EMIT("2:") \ + __ASM_EMIT("add $4, %[count]") \ + __ASM_EMIT("jl 4f") \ + __ASM_EMIT("movups %%xmm0, 0x00(%[dst])") \ + __ASM_EMIT("movups %%xmm1, 0x10(%[dst])") \ + __ASM_EMIT("movups %%xmm2, 0x20(%[dst])") \ + __ASM_EMIT("movups %%xmm3, 0x30(%[dst])") \ + __ASM_EMIT("sub $4, %[count]") \ + __ASM_EMIT("add $0x40, %[dst]") \ + /* 2x block */ \ + __ASM_EMIT("4:") \ + __ASM_EMIT("add $2, %[count]") \ + __ASM_EMIT("jl 6f") \ + __ASM_EMIT("movups %%xmm0, 0x00(%[dst])") \ + __ASM_EMIT("movups %%xmm1, 0x10(%[dst])") \ + __ASM_EMIT("sub $2, %[count]") \ + __ASM_EMIT("add $0x20, %[dst]") \ + /* 1x block */ \ + __ASM_EMIT("6:") \ + __ASM_EMIT("add $1, %[count]") \ + __ASM_EMIT("jl 8f") \ + __ASM_EMIT("movups %%xmm0, 0x00(%[dst])") \ + __ASM_EMIT("8:") + + void fill_rgba(float *dst, float r, float g, float b, float a, size_t count) + { + ARCH_X86_ASM + ( + FILL4_CORE + : [dst] "+r" (dst), [count] "+r" (count) + : [c0] "m" (r), [c1] "m" (g), [c2] "m" (b), [c3] "m" (a) + : "cc", "memory", + "%xmm0", "%xmm1", "%xmm2", "%xmm3" + ); + } + + void fill_hsla(float *dst, float h, float s, float l, float a, size_t count) + { + ARCH_X86_ASM + ( + FILL4_CORE + : [dst] "+r" (dst), [count] "+r" (count) + : [c0] "m" (h), [c1] "m" (s), [c2] "m" (l), [c3] "m" (a) + : "cc", "memory", + "%xmm0", "%xmm1", "%xmm2", "%xmm3" + ); + } + + #undef FILL4_CORE + + } /* namespace sse */ +} /* namespace lsp */ + + + +#endif /* PRIVATE_DSP_ARCH_X86_SSE_GRAPHICS_FILL_H_ */ diff --git a/src/main/x86/sse.cpp b/src/main/x86/sse.cpp index 4af161da..87aeba74 100644 --- a/src/main/x86/sse.cpp +++ b/src/main/x86/sse.cpp @@ -353,6 +353,7 @@ EXPORT1(fill_rgba); EXPORT1(fill_hsla); + EXPORT1(axis_apply_lin1); EXPORT1(lanczos_resample_2x2); EXPORT1(lanczos_resample_2x3); diff --git a/src/test/ptest/graphics/axis_lin1.cpp b/src/test/ptest/graphics/axis_lin1.cpp new file mode 100644 index 00000000..b2b9d652 --- /dev/null +++ b/src/test/ptest/graphics/axis_lin1.cpp @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov + * + * This file is part of lsp-dsp-lib + * Created on: 24 сент. 2023 г. + * + * lsp-dsp-lib is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * lsp-dsp-lib is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with lsp-dsp-lib. If not, see . + */ + +#include +#include +#include +#include +#include + +#define MIN_RANK 8 +#define MAX_RANK 16 + +namespace lsp +{ + namespace generic + { + void axis_apply_lin1(float *x, const float *v, float zero, float norm_x, size_t count); + } + + IF_ARCH_X86( + namespace sse + { + void axis_apply_lin1(float *x, const float *v, float zero, float norm_x, size_t count); + } + ) + + IF_ARCH_ARM( + namespace neon_d32 + { + void axis_apply_lin1(float *x, const float *v, float zero, float norm_x, size_t count); + } + ) + + IF_ARCH_AARCH64( + namespace asimd + { + void axis_apply_lin1(float *x, const float *v, float zero, float norm_x, size_t count); + } + ) + + typedef void (* axis_apply_lin1_t)(float *x, const float *v, float zero, float norm_x, size_t count); +} + +//----------------------------------------------------------------------------- +// Performance test for logarithmic axis calculation +PTEST_BEGIN("dsp.graphics", axis_lin1, 5, 1000) + + void call(const char *label, float *x, const float *v, size_t count, axis_apply_lin1_t apply) + { + if (!PTEST_SUPPORTED(apply)) + return; + + char buf[80]; + sprintf(buf, "%s x %d", label, int(count)); + printf("Testing %s points...\n", buf); + + PTEST_LOOP(buf, + apply(x, v, 1.0f, 1.0f, count); + ); + } + + PTEST_MAIN + { + size_t buf_size = 1 << MAX_RANK; + uint8_t *data = NULL; + float *ptr = alloc_aligned(data, buf_size * 2, 64); + + float *x = ptr; + float *v = &x[buf_size]; + + for (size_t i=0; i + * (C) 2023 Vladimir Sadovnikov + * + * This file is part of lsp-dsp-lib + * Created on: 24 сент. 2023 г. + * + * lsp-dsp-lib is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * lsp-dsp-lib is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with lsp-dsp-lib. If not, see . + */ + +#include +#include +#include +#include +#include + +#define MIN_RANK 8 +#define MAX_RANK 16 + +namespace lsp +{ + namespace generic + { + void axis_apply_log1(float *x, const float *v, float zero, float norm_x, size_t count); + } + + IF_ARCH_X86( + namespace sse2 + { + void axis_apply_log1(float *x, const float *v, float zero, float norm_x, size_t count); + } + + IF_ARCH_X86_64( + namespace sse3 + { + void x64_axis_apply_log1(float *x, const float *v, float zero, float norm_x, size_t count); + } + ) + ) + + IF_ARCH_ARM( + namespace neon_d32 + { + void axis_apply_log1(float *x, const float *v, float zero, float norm_x, size_t count); + } + ) + + IF_ARCH_AARCH64( + namespace asimd + { + void axis_apply_log1(float *x, const float *v, float zero, float norm_x, size_t count); + } + ) + + typedef void (* axis_apply_log1_t)(float *x, const float *v, float zero, float norm_x, size_t count); +} + +//----------------------------------------------------------------------------- +// Performance test for logarithmic axis calculation +PTEST_BEGIN("dsp.graphics", axis_log1, 5, 1000) + + void call(const char *label, float *x, const float *v, size_t count, axis_apply_log1_t apply) + { + if (!PTEST_SUPPORTED(apply)) + return; + + char buf[80]; + sprintf(buf, "%s x %d", label, int(count)); + printf("Testing %s points...\n", buf); + + PTEST_LOOP(buf, + apply(x, v, 1.0f, 1.0f, count); + ); + } + + PTEST_MAIN + { + size_t buf_size = 1 << MAX_RANK; + uint8_t *data = NULL; + float *ptr = alloc_aligned(data, buf_size * 2, 64); + + float *x = ptr; + float *v = &x[buf_size]; + + for (size_t i=0; i - * (C) 2020 Vladimir Sadovnikov + * Copyright (C) 2023 Linux Studio Plugins Project + * (C) 2023 Vladimir Sadovnikov * * This file is part of lsp-dsp-lib * Created on: 31 мар. 2020 г. @@ -32,21 +32,18 @@ namespace lsp { namespace generic { - void axis_apply_log1(float *x, const float *v, float zero, float norm_x, size_t count); void axis_apply_log2(float *x, float *y, const float *v, float zero, float norm_x, float norm_y, size_t count); } IF_ARCH_X86( namespace sse2 { - void axis_apply_log1(float *x, const float *v, float zero, float norm_x, size_t count); void axis_apply_log2(float *x, float *y, const float *v, float zero, float norm_x, float norm_y, size_t count); } IF_ARCH_X86_64( namespace sse3 { - void x64_axis_apply_log1(float *x, const float *v, float zero, float norm_x, size_t count); void x64_axis_apply_log2(float *x, float *y, const float *v, float zero, float norm_x, float norm_y, size_t count); } ) @@ -55,7 +52,6 @@ namespace lsp IF_ARCH_ARM( namespace neon_d32 { - void axis_apply_log1(float *x, const float *v, float zero, float norm_x, size_t count); void axis_apply_log2(float *x, float *y, const float *v, float zero, float norm_x, float norm_y, size_t count); } ) @@ -63,32 +59,16 @@ namespace lsp IF_ARCH_AARCH64( namespace asimd { - void axis_apply_log1(float *x, const float *v, float zero, float norm_x, size_t count); void axis_apply_log2(float *x, float *y, const float *v, float zero, float norm_x, float norm_y, size_t count); } ) - typedef void (* axis_apply_log1_t)(float *x, const float *v, float zero, float norm_x, size_t count); typedef void (* axis_apply_log2_t)(float *x, float *y, const float *v, float zero, float norm_x, float norm_y, size_t count); } //----------------------------------------------------------------------------- // Performance test for logarithmic axis calculation -PTEST_BEGIN("dsp.graphics", axis, 5, 1000) - - void call(const char *label, float *x, const float *v, size_t count, axis_apply_log1_t apply) - { - if (!PTEST_SUPPORTED(apply)) - return; - - char buf[80]; - sprintf(buf, "%s x %d", label, int(count)); - printf("Testing %s points...\n", buf); - - PTEST_LOOP(buf, - apply(x, v, 1.0f, 1.0f, count); - ); - } +PTEST_BEGIN("dsp.graphics", axis_log2, 5, 1000) void call(const char *label, float *x, float *y, const float *v, size_t count, axis_apply_log2_t apply) { @@ -117,28 +97,19 @@ PTEST_BEGIN("dsp.graphics", axis, 5, 1000) for (size_t i=0; i + * (C) 2023 Vladimir Sadovnikov + * + * This file is part of lsp-dsp-lib + * Created on: 31 мар. 2020 г. + * + * lsp-dsp-lib is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * lsp-dsp-lib is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with lsp-dsp-lib. If not, see . + */ + +#include +#include +#include + +#define TOLERANCE 1e-2 + +namespace lsp +{ + namespace generic + { + void axis_apply_lin1(float *x, const float *v, float zero, float norm_x, size_t count); + } + + IF_ARCH_X86( + namespace sse + { + void axis_apply_lin1(float *x, const float *v, float zero, float norm_x, size_t count); + } + ) + + IF_ARCH_ARM( + namespace neon_d32 + { + void axis_apply_lin1(float *x, const float *v, float zero, float norm_x, size_t count); + } + ) + + IF_ARCH_AARCH64( + namespace asimd + { + void axis_apply_lin1(float *x, const float *v, float zero, float norm_x, size_t count); + } + ) + + typedef void (* axis_apply_lin1_t)(float *x, const float *v, float zero, float norm_x, size_t count); +} + +UTEST_BEGIN("dsp.graphics", axis_lin1) + void call(const char *label, size_t align, axis_apply_lin1_t func) + { + if (!UTEST_SUPPORTED(func)) + return; + + for (size_t mask=0; mask <= 0x03; ++mask) + { + UTEST_FOREACH(count, 0, 1, 2, 3, 4, 5, 8, 16, 24, 32, 33, 64, 47, 0x80, 0x1ff) + { + FloatBuffer v(count, align, mask & 0x01); + FloatBuffer x1(count, align, mask & 0x02); + FloatBuffer x2(x1); + + for (size_t i=0; i + * (C) 2023 Vladimir Sadovnikov + * + * This file is part of lsp-dsp-lib + * Created on: 31 мар. 2020 г. + * + * lsp-dsp-lib is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * lsp-dsp-lib is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with lsp-dsp-lib. If not, see . + */ + +#include +#include +#include + +#define TOLERANCE 1e-2 + +namespace lsp +{ + namespace generic + { + void axis_apply_log1(float *x, const float *v, float zero, float norm_x, size_t count); + } + + IF_ARCH_X86( + namespace sse2 + { + void axis_apply_log1(float *x, const float *v, float zero, float norm_x, size_t count); + } + + IF_ARCH_X86_64( + namespace sse3 + { + void x64_axis_apply_log1(float *x, const float *v, float zero, float norm_x, size_t count); + } + ) + ) + + IF_ARCH_ARM( + namespace neon_d32 + { + void axis_apply_log1(float *x, const float *v, float zero, float norm_x, size_t count); + } + ) + + IF_ARCH_AARCH64( + namespace asimd + { + void axis_apply_log1(float *x, const float *v, float zero, float norm_x, size_t count); + } + ) + + typedef void (* axis_apply_log1_t)(float *x, const float *v, float zero, float norm_x, size_t count); +} + +UTEST_BEGIN("dsp.graphics", axis_log1) + void call(const char *label, size_t align, axis_apply_log1_t func) + { + if (!UTEST_SUPPORTED(func)) + return; + + for (size_t mask=0; mask <= 0x03; ++mask) + { + UTEST_FOREACH(count, 0, 1, 2, 3, 4, 5, 8, 16, 24, 32, 33, 64, 47, 0x80, 0x1ff) + { + FloatBuffer v(count, align, mask & 0x01); + FloatBuffer x1(count, align, mask & 0x02); + FloatBuffer x2(x1); + + for (size_t i=0; i