Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,6 @@
[submodule "contrib/morton-nd"]
path = contrib/morton-nd
url = https://github.com/morton-nd/morton-nd
[submodule "contrib/crc32-vpmsum"]
path = contrib/crc32-vpmsum
url = https://github.com/antonblanchard/crc32-vpmsum.git
1 change: 1 addition & 0 deletions contrib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ endfunction()

add_contrib (miniselect-cmake miniselect)
add_contrib (pdqsort-cmake pdqsort)
add_contrib (crc32-vpmsum-cmake crc32-vpmsum)
add_contrib (sparsehash-c11-cmake sparsehash-c11)
add_contrib (abseil-cpp-cmake abseil-cpp)
add_contrib (magic-enum-cmake magic_enum)
Expand Down
1 change: 1 addition & 0 deletions contrib/crc32-vpmsum
Submodule crc32-vpmsum added at 452155
12 changes: 12 additions & 0 deletions contrib/crc32-vpmsum-cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
if (NOT ARCH_PPC64LE)
message(STATUS "crc32-vpmsum library is only supported on ppc64le")
return()
endif()

SET(LIBRARY_DIR "${ClickHouse_SOURCE_DIR}/contrib/crc32-vpmsum")

add_library(_crc32-vpmsum
"${LIBRARY_DIR}/vec_crc32.c"
)
target_include_directories(_crc32-vpmsum SYSTEM BEFORE PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
add_library(ch_contrib::crc32-vpmsum ALIAS _crc32-vpmsum)
8 changes: 8 additions & 0 deletions contrib/crc32-vpmsum-cmake/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# To Generate crc32_constants.h

- Run make file in `../crc32-vpmsum` diretory using folling options and CRC polynomial. These options should use the same polynomial and order used by intel intrinisic functions
```bash
make crc32_constants.h CRC="0x182f63b78" OPTIONS="-x"
```
- move the generated `crc32_constants.h` into this directory
- To understand more about this go here: https://masterchef2209.wordpress.com/2020/06/17/guide-to-intel-sse4-2-crc-intrinisics-implementation-for-simde/
2,031 changes: 2,031 additions & 0 deletions contrib/crc32-vpmsum-cmake/crc32_constants.h

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions contrib/crc32-vpmsum-cmake/vec_crc32.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef VEC_CRC32
#define VEC_CRC32


#ifdef __cplusplus
extern "C" {
#endif

unsigned int crc32_vpmsum(unsigned int crc, const unsigned char *p, unsigned long len);

static inline uint32_t crc32_ppc(uint64_t crc, unsigned char const *buffer, size_t len)
{
unsigned char *emptybuffer;
if (!buffer) {
emptybuffer = (unsigned char *)malloc(len);
bzero(emptybuffer, len);
crc = crc32_vpmsum(crc, emptybuffer, len);
free(emptybuffer);
} else {
crc = crc32_vpmsum(crc, buffer, (unsigned long)len);
}
return crc;
}

#ifdef __cplusplus
}
#endif

#endif
2 changes: 1 addition & 1 deletion contrib/zlib-ng
Submodule zlib-ng updated 71 files
+19 −20 .github/workflows/cmake.yml
+0 −111 .github/workflows/pigz.yml
+32 −130 CMakeLists.txt
+13 −13 FAQ.zlib
+1 −1 Makefile.in
+1 −1 PORTING.md
+11 −13 arch/arm/Makefile.in
+7 −0 arch/arm/arm.h
+8 −16 arch/arm/armfeature.c
+3 −11 arch/arm/chunkset_neon.c
+6 −7 arch/power/Makefile.in
+1 −1 arch/power/adler32_power8.c
+1 −1 arch/power/power.c
+0 −2 arch/power/power.h
+1 −1 arch/s390/README.md
+20 −21 arch/x86/Makefile.in
+0 −2 arch/x86/chunkset_avx.c
+0 −2 arch/x86/chunkset_sse.c
+4 −4 arch/x86/crc_folding.c
+10 −8 arch/x86/x86.c
+7 −0 arch/x86/x86.h
+0 −2 chunkset.c
+37 −54 chunkset_tpl.h
+0 −8 cmake/detect-arch.c
+2 −5 cmake/detect-arch.cmake
+2 −12 cmake/detect-coverage.cmake
+1 −11 cmake/detect-sanitizer.cmake
+1 −1 cmake/run-and-compare.cmake
+1 −1 cmake/run-and-redirect.cmake
+40 −91 cmake/test-compress.cmake
+15 −108 configure
+5 −0 crc32.c
+2 −2 deflate.c
+2 −2 deflate.h
+3 −0 deflate_p.h
+1 −1 doc/algorithm.txt
+1 −1 doc/rfc1952.txt
+20 −56 functable.c
+8 −1 functable.h
+24 −12 infback.c
+0 −12 inffast.c
+3 −1 inflate.c
+1 −1 inftrees.h
+1 −1 test/CVE-2003-0107.c
+ test/GH-979/pigz-2.6.tar.gz
+2 −2 test/README.md
+1 −1 test/abicheck.md
+4 −4 test/data/lcet10.txt
+1 −1 test/example.c
+8 −8 test/fuzz/checksum_fuzzer.c
+3 −3 test/fuzz/example_dict_fuzzer.c
+7 −16 test/fuzz/minigzip_fuzzer.c
+1 −3 test/fuzz/standalone_fuzz_target_runner.c
+3 −3 test/hash_head_0.c
+5 −5 test/infcover.c
+0 −3 test/minideflate.c
+4 −0 test/minigzip.c
+0 −198 test/pigz/CMakeLists.txt
+0 −2 test/switchlevels.c
+1 −1 trees_emit.h
+2 −2 win32/DLL_FAQ.txt
+1 −1 win32/Makefile.msc
+4 −4 win32/README-WIN32.txt
+1 −1 win32/zlib-ng1.rc
+1 −1 win32/zlib1.rc
+1 −8 zbuild.h
+8 −8 zlib-ng.h
+8 −15 zlib.h
+3 −3 zutil.c
+2 −10 zutil.h
+4 −2 zutil_p.h
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ target_link_libraries(clickhouse_common_io
PUBLIC
boost::program_options
boost::system
ch_contrib::crc32-vpmsum
ch_contrib::cityhash
ch_contrib::zlib
pcg_random
Expand Down
8 changes: 8 additions & 0 deletions src/Common/HashTable/Hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ inline DB::UInt64 intHash64(DB::UInt64 x)
#include <arm_acle.h>
#endif

#if (defined(__PPC64__) || defined(__powerpc64__)) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#include "vec_crc32.h"
#endif

/// NOTE: Intel intrinsic can be confusing.
/// - https://code.google.com/archive/p/sse-intrinsics/wikis/PmovIntrinsicBug.wiki
/// - https://stackoverflow.com/questions/15752770/mm-crc32-u64-poorly-defined
Expand All @@ -57,6 +61,8 @@ inline DB::UInt64 intHashCRC32(DB::UInt64 x)
return _mm_crc32_u64(-1ULL, x);
#elif defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
return __crc32cd(-1U, x);
#elif (defined(__PPC64__) || defined(__powerpc64__)) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
return crc32_ppc(-1U, reinterpret_cast<const unsigned char *>(&x), sizeof(x));
#else
/// On other platforms we do not have CRC32. NOTE This can be confusing.
/// NOTE: consider using intHash32()
Expand All @@ -69,6 +75,8 @@ inline DB::UInt64 intHashCRC32(DB::UInt64 x, DB::UInt64 updated_value)
return _mm_crc32_u64(updated_value, x);
#elif defined(__aarch64__) && defined(__ARM_FEATURE_CRC32)
return __crc32cd(static_cast<UInt32>(updated_value), x);
#elif (defined(__PPC64__) || defined(__powerpc64__)) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
return crc32_ppc(updated_value, reinterpret_cast<const unsigned char *>(&x), sizeof(x));
#else
/// On other platforms we do not have CRC32. NOTE This can be confusing.
return intHash64(x) ^ updated_value;
Expand Down