Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update simdlib to 4.9.107 + image IO backend #947

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
de1b75d
Update Simd lib to 4.9.107 version.
s-trinh Nov 3, 2021
04044b6
Add missing file.
s-trinh Nov 3, 2021
df04616
Remove not used SSE flags. Add missing SSE 4.1 implementation.
s-trinh Nov 3, 2021
9c19304
WIP code to add and test image loading/saving using Simd and for JPEG…
s-trinh Nov 3, 2021
aad93cd
Fix issue when writing big Jpeg images.
s-trinh Nov 4, 2021
a70090c
Experimental: wip code to try adding a backend system for image I/O.
s-trinh Nov 16, 2021
122e936
Update Simd lib to 4.9.107 version.
s-trinh Nov 3, 2021
94fee71
Add missing file.
s-trinh Nov 3, 2021
bd6dd78
Remove not used SSE flags. Add missing SSE 4.1 implementation.
s-trinh Nov 3, 2021
b75d200
WIP code to add and test image loading/saving using Simd and for JPEG…
s-trinh Nov 3, 2021
9d2183b
Fix issue when writing big Jpeg images.
s-trinh Nov 4, 2021
28c034e
Experimental: wip code to try adding a backend system for image I/O.
s-trinh Nov 16, 2021
7dcc2a1
Update vpImageIo backend option. Add JPEG compression quality. Update…
s-trinh Nov 21, 2021
66b12c5
Update stb_image.h to 2.27 version.
s-trinh Nov 21, 2021
fd312fa
Update stb_image_write.h to 1.16 version. Do we need to introduce ano…
s-trinh Nov 21, 2021
02895d0
Add missing file. Update Simd CMakeLists.txt. Add SimdFree().
s-trinh Nov 21, 2021
557f1be
Fix write with libjpeg. Try to fix ARM build.
s-trinh Nov 21, 2021
08f92df
Merge branch 'feat_update_simdlib_4.9.107' of github.com-s-trinh:s-tr…
s-trinh Nov 22, 2021
ca1cca3
This should allow running the benchmarks on Windows and Unix.
s-trinh Nov 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 17 additions & 71 deletions 3rdparty/simdlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,31 @@ file(GLOB_RECURSE SIMD_BASE_HDR ${CMAKE_CURRENT_SOURCE_DIR}/Simd/*.h ${CMAKE_CUR
if(X86 OR X86_64)

# Flags check
set(SSE_FLAG "")
set(SSE2_FLAG "")
set(SSE3_FLAG "")
set(SSSE3_FLAG "")
set(SSE4_1_FLAG "")
set(SSE4_2_FLAG "")
set(AVX_FLAG "")
set(AVX2_FLAG "")

if(MSVC)
if(NOT MSVC64)
vp_check_compiler_flag(CXX "/arch:SSE" HAVE_SSE_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_sse.cpp")
vp_check_compiler_flag(CXX "/arch:SSE2" HAVE_SSE2_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_sse2.cpp")
endif()

vp_check_compiler_flag(CXX "/arch:AVX" HAVE_AVX_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_avx.cpp")
vp_check_compiler_flag(CXX "/arch:AVX2" HAVE_AVX2_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_avx2.cpp")

if(HAVE_SSE_FLAG)
set(SSE_FLAG "/arch:SSE")
endif()
if(HAVE_SSE2_FLAG)
set(SSE2_FLAG "/arch:SSE2")
endif()
if(HAVE_AVX_FLAG)
set(AVX_FLAG "/arch:AVX")
set(SSE4_2_FLAG "/arch:AVX")
set(SSE4_1_FLAG "/arch:AVX")
set(SSSE3_FLAG "/arch:AVX")
set(SSE3_FLAG "/arch:AVX")
endif()
if(HAVE_AVX2_FLAG)
set(AVX2_FLAG "/arch:AVX2")
endif()
else()
vp_check_compiler_flag(CXX "-msse" HAVE_SSE_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_sse.cpp")
vp_check_compiler_flag(CXX "-msse2" HAVE_SSE2_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_sse2.cpp")
vp_check_compiler_flag(CXX "-msse3" HAVE_SSE3_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_sse3.cpp")
vp_check_compiler_flag(CXX "-mssse3" HAVE_SSSE3_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_ssse3.cpp")
vp_check_compiler_flag(CXX "-msse4.1" HAVE_SSE4_1_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_sse41.cpp")
vp_check_compiler_flag(CXX "-msse4.2" HAVE_SSE4_2_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_sse42.cpp")
vp_check_compiler_flag(CXX "-mavx" HAVE_AVX_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_avx.cpp")
vp_check_compiler_flag(CXX "-mavx2" HAVE_AVX2_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_avx2.cpp")
Expand All @@ -68,23 +53,11 @@ if(X86 OR X86_64)
vp_check_compiler_flag(CXX "-Wno-sign-compare" HAVE_NO_SIGN_COMPARE_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_warning.cpp")
vp_check_compiler_flag(CXX "-Wno-ignored-qualifiers" HAVE_NO_IGNORED_QUALIFIERS "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_warning.cpp")

if(HAVE_SSE_FLAG)
set(SSE_FLAG "-msse")
endif()
if(HAVE_SSE2_FLAG)
set(SSE2_FLAG "-msse2")
endif()
if(HAVE_SSE3_FLAG)
set(SSE3_FLAG "-msse3")
endif()
if(HAVE_SSSE3_FLAG)
set(SSSE3_FLAG "-mssse3")
endif()
if(HAVE_SSE4_1_FLAG)
set(SSE4_1_FLAG "-msse4.1")
set(SSE2_FLAG "-msse -msse2")
endif()
if(HAVE_SSE4_2_FLAG)
set(SSE4_2_FLAG "-msse4.2")
set(SSE4_2_FLAG "-msse3 -mssse3 -msse4.1 -msse4.2")
endif()
if(HAVE_AVX_FLAG)
set(AVX_FLAG "-mavx")
Expand All @@ -109,36 +82,32 @@ if(X86 OR X86_64)
file(GLOB_RECURSE SIMD_BASE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdBase*.cpp)
set_source_files_properties(${SIMD_BASE_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS}")

file(GLOB_RECURSE SIMD_SSE1_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdSse1*.cpp)
set_source_files_properties(${SIMD_SSE1_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${SSE_FLAG}")

file(GLOB_RECURSE SIMD_SSE2_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdSse2*.cpp)
set_source_files_properties(${SIMD_SSE2_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${SSE2_FLAG}")

file(GLOB_RECURSE SIMD_SSE3_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdSse3*.cpp)
set_source_files_properties(${SIMD_SSE3_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${SSE3_FLAG}")

file(GLOB_RECURSE SIMD_SSSE3_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdSsse3*.cpp)
set_source_files_properties(${SIMD_SSSE3_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${SSSE3_FLAG}")

file(GLOB_RECURSE SIMD_SSE41_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdSse41*.cpp)
set_source_files_properties(${SIMD_SSE41_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${SSE4_1_FLAG}")

file(GLOB_RECURSE SIMD_SSE42_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdSse42*.cpp)
set_source_files_properties(${SIMD_SSE42_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${SSE4_2_FLAG}")
set_source_files_properties(${SIMD_SSE41_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${SSE4_2_FLAG}")

file(GLOB_RECURSE SIMD_AVX1_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdAvx1*.cpp)
set_source_files_properties(${SIMD_AVX1_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${AVX_FLAG}")
if(MSVC)
set_source_files_properties(${SIMD_AVX1_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${AVX_FLAG} -mno-avx256-split-unaligned-load -mno-avx256-split-unaligned-store")
elseif((CMAKE_CXX_COMPILER MATCHES "clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
set_source_files_properties(${SIMD_AVX1_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${AVX_FLAG}")
else()
set_source_files_properties(${SIMD_AVX1_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${AVX_FLAG} -mno-avx256-split-unaligned-load -mno-avx256-split-unaligned-store")
endif()

file(GLOB_RECURSE SIMD_AVX2_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdAvx2*.cpp)
if(MSVC)
set_source_files_properties(${SIMD_AVX2_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${AVX2_FLAG}")
set_source_files_properties(${SIMD_AVX2_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${AVX2_FLAG} -mno-avx256-split-unaligned-load -mno-avx256-split-unaligned-store")
elseif((CMAKE_CXX_COMPILER MATCHES "clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
set_source_files_properties(${SIMD_AVX2_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${AVX2_FLAG} -mfma -mbmi -mbmi2 -mlzcnt")
else()
set_source_files_properties(${SIMD_AVX2_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${AVX2_FLAG} -mfma")
set_source_files_properties(${SIMD_AVX2_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${AVX2_FLAG} -mfma -mbmi -mbmi2 -mlzcnt -fabi-version=4 -mno-avx256-split-unaligned-load -mno-avx256-split-unaligned-store")
endif()

set(SIMD_LIB_FLAGS "${COMMON_CXX_FLAGS} ${AVX2_FLAG}")
set(SIMD_ALG_SRC ${SIMD_BASE_SRC} ${SIMD_SSE1_SRC} ${SIMD_SSE2_SRC} ${SIMD_SSE3_SRC} ${SIMD_SSSE3_SRC} ${SIMD_SSE41_SRC} ${SIMD_SSE42_SRC} ${SIMD_AVX1_SRC} ${SIMD_AVX2_SRC})
set(SIMD_ALG_SRC ${SIMD_BASE_SRC} ${SIMD_SSE2_SRC} ${SIMD_SSE41_SRC} ${SIMD_AVX1_SRC} ${SIMD_AVX2_SRC})

file(GLOB_RECURSE SIMD_LIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdLib.cpp)
set_source_files_properties(${SIMD_LIB_SRC} PROPERTIES COMPILE_FLAGS "${SIMD_LIB_FLAGS}")
Expand Down Expand Up @@ -183,32 +152,21 @@ elseif(WINRT)
add_library(${SIMD_LIBRARY} STATIC ${SIMD_LIB_SRC} ${SIMD_BASE_SRC} ${SIMD_NEON_SRC} ${SIMD_BASE_HDR})
else()
# Flags check
set(SSE_FLAG "")
set(SSE2_FLAG "")
set(SSE3_FLAG "")
set(SSSE3_FLAG "")
set(SSE4_1_FLAG "")
set(SSE4_2_FLAG "")
set(AVX_FLAG "")
set(AVX2_FLAG "")

vp_check_compiler_flag(CXX "/arch:SSE" HAVE_SSE_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_sse.cpp")
vp_check_compiler_flag(CXX "/arch:SSE2" HAVE_SSE2_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_sse2.cpp")
vp_check_compiler_flag(CXX "/arch:AVX" HAVE_AVX_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_avx.cpp")
vp_check_compiler_flag(CXX "/arch:AVX2" HAVE_AVX2_FLAG "${PROJECT_SOURCE_DIR}/cmake/checks/cpu_avx2.cpp")

if(HAVE_SSE_FLAG)
set(SSE_FLAG "/arch:SSE")
endif()
if(HAVE_SSE2_FLAG)
set(SSE2_FLAG "/arch:SSE2")
endif()
if(HAVE_AVX_FLAG)
set(AVX_FLAG "/arch:AVX")
set(SSE4_2_FLAG "/arch:AVX")
set(SSE4_1_FLAG "/arch:AVX")
set(SSSE3_FLAG "/arch:AVX")
set(SSE3_FLAG "/arch:AVX")
endif()
if(HAVE_AVX2_FLAG)
set(AVX2_FLAG "/arch:AVX2")
Expand All @@ -217,23 +175,11 @@ elseif(WINRT)
file(GLOB_RECURSE SIMD_BASE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdBase*.cpp)
set_source_files_properties(${SIMD_BASE_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS}")

file(GLOB_RECURSE SIMD_SSE1_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdSse1*.cpp)
set_source_files_properties(${SIMD_SSE1_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${SSE_FLAG}")

file(GLOB_RECURSE SIMD_SSE2_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdSse2*.cpp)
set_source_files_properties(${SIMD_SSE2_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${SSE2_FLAG}")

file(GLOB_RECURSE SIMD_SSE3_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdSse3*.cpp)
set_source_files_properties(${SIMD_SSE3_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${SSE3_FLAG}")

file(GLOB_RECURSE SIMD_SSSE3_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdSsse3*.cpp)
set_source_files_properties(${SIMD_SSSE3_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${SSSE3_FLAG}")

file(GLOB_RECURSE SIMD_SSE41_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdSse41*.cpp)
set_source_files_properties(${SIMD_SSE41_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${SSE4_1_FLAG}")

file(GLOB_RECURSE SIMD_SSE42_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdSse42*.cpp)
set_source_files_properties(${SIMD_SSE42_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${SSE4_2_FLAG}")
set_source_files_properties(${SIMD_SSE41_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${SSE4_2_FLAG}")

file(GLOB_RECURSE SIMD_AVX1_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdAvx1*.cpp)
set_source_files_properties(${SIMD_AVX1_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${AVX_FLAG}")
Expand All @@ -242,7 +188,7 @@ elseif(WINRT)
set_source_files_properties(${SIMD_AVX2_SRC} PROPERTIES COMPILE_FLAGS "${COMMON_CXX_FLAGS} ${AVX2_FLAG}")

set(SIMD_LIB_FLAGS "${COMMON_CXX_FLAGS} ${AVX2_FLAG}")
set(SIMD_ALG_SRC ${SIMD_BASE_SRC} ${SIMD_SSE1_SRC} ${SIMD_SSE2_SRC} ${SIMD_SSE3_SRC} ${SIMD_SSSE3_SRC} ${SIMD_SSE41_SRC} ${SIMD_SSE42_SRC} ${SIMD_AVX1_SRC} ${SIMD_AVX2_SRC})
set(SIMD_ALG_SRC ${SIMD_BASE_SRC} ${SIMD_SSE2_SRC} ${SIMD_SSE41_SRC} ${SIMD_AVX1_SRC} ${SIMD_AVX2_SRC})

file(GLOB_RECURSE SIMD_LIB_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Simd/SimdLib.cpp)
set_source_files_properties(${SIMD_LIB_SRC} PROPERTIES COMPILE_FLAGS "${SIMD_LIB_FLAGS}")
Expand Down
113 changes: 73 additions & 40 deletions 3rdparty/simdlib/Simd/SimdSse1.h → 3rdparty/simdlib/Simd/SimdAlignment.h
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,40 +1,73 @@
/*
* Simd Library (http://ermig1979.github.io/Simd).
*
* Copyright (c) 2011-2019 Yermalayeu Ihar.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef __SimdSse_h__
#define __SimdSse_h__

#include "Simd/SimdDefs.h"

namespace Simd
{
#ifdef SIMD_SSE_ENABLE
namespace Sse
{
void SquaredDifferenceSum32f(const float * a, const float * b, size_t size, float * sum);

void SquaredDifferenceKahanSum32f(const float * a, const float * b, size_t size, float * sum);
}
#endif// SIMD_SSE_ENABLE
}
#endif//__SimdSse_h__
/*
* Simd Library (http://ermig1979.github.io/Simd).
*
* Copyright (c) 2011-2021 Yermalayeu Ihar.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef __SimdAlignment_h__
#define __SimdAlignment_h__

#include "Simd/SimdEnable.h"

namespace Simd
{
SIMD_INLINE size_t GetAlignment()
{
#ifdef SIMD_AVX2_ENABLE
if (Avx2::Enable)
return sizeof(__m256i);
else
#endif
#ifdef SIMD_AVX_ENABLE
if (Avx::Enable)
return sizeof(__m256);
else
#endif
#ifdef SIMD_SSE41_ENABLE
if (Sse41::Enable)
return sizeof(__m128i);
else
#endif
#ifdef SIMD_SSE2_ENABLE
if (Sse2::Enable)
return sizeof(__m128i);
else
#endif
#ifdef SIMD_NEON_ENABLE
if (Neon::Enable)
return sizeof(uint8x16_t);
else
#endif
return sizeof(void *);
}

extern const size_t ALIGNMENT;

SIMD_INLINE size_t Alignment()
{
#if defined(WIN32)
return GetAlignment();
#else
return ALIGNMENT;
#endif
}
}

#endif//__SimdAlignment_h__
6 changes: 3 additions & 3 deletions 3rdparty/simdlib/Simd/SimdAllocator.hpp
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Simd Library (http://ermig1979.github.io/Simd).
*
* Copyright (c) 2011-2017 Yermalayeu Ihar.
* Copyright (c) 2011-2020 Yermalayeu Ihar.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -125,8 +125,8 @@ namespace Simd
*/
static SIMD_INLINE size_t Alignment()
{
#if defined(__SimdEnable_h__) && defined(WIN32)
return Simd::ALIGNMENT;
#if defined(__SimdAlignment_h__) && defined(WIN32)
return Simd::Alignment();
#else
return SimdAlignment();
#endif
Expand Down
30 changes: 25 additions & 5 deletions 3rdparty/simdlib/Simd/SimdArray.h
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Simd Library (http://ermig1979.github.io/Simd).
*
* Copyright (c) 2011-2019 Yermalayeu Ihar.
* Copyright (c) 2011-2021 Yermalayeu Ihar.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -57,15 +57,28 @@ namespace Simd
}
*(size_t*)&size = size_;
if (size_)
*(T**)&data = (T*)Simd::Allocate(size * sizeof(T), align);
*(T**)&data = (T*)Simd::Allocate(RawSize(), align);
}
if (clear)
Clear();
}

SIMD_INLINE void Assign(const T * src, size_t size_)
{
Resize(size_, src == NULL);
if(src)
memcpy(data, src, RawSize());
}

SIMD_INLINE void Clear()
{
::memset(data, 0, size * sizeof(T));
memset(data, 0, RawSize());
}

SIMD_INLINE void Swap(const Array & array)
{
Simd::Swap((T*&)data, (T*&)(array.data));
Simd::Swap((size_t&)size, (size_t&)(array.size));
}

SIMD_INLINE T & operator[] (size_t i)
Expand All @@ -77,21 +90,28 @@ namespace Simd
{
return data[i];
}

SIMD_INLINE size_t RawSize() const
{
return size * sizeof(T);
}
};

typedef Array<int8_t> Array8i;
typedef Array<uint8_t> Array8u;
typedef Array<int16_t> Array16i;
typedef Array<uint16_t> Array16u;
typedef Array<int32_t> Array32i;
typedef Array<uint32_t> Array32u;
typedef Array<float> Array32f;

#if defined(__GNUC__) && __GNUC__ >= 6
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wignored-attributes"
#endif

#ifdef SIMD_SSE_ENABLE
namespace Sse
#ifdef SIMD_SSE2_ENABLE
namespace Sse2
{
typedef Array<__m128> Array128f;
}
Expand Down
Loading