Skip to content

Commit 2b0011e

Browse files
authored
Import the UMASH hashing library (#7616)
We use it for vectorized hash grouping. For now, add the library separately to figure out the required CMake and CI changes.
1 parent 5c2f6b5 commit 2b0011e

File tree

6 files changed

+1992
-3
lines changed

6 files changed

+1992
-3
lines changed

.github/workflows/windows-build-and-test.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,23 @@ jobs:
245245
name: PostgreSQL ${{ matrix.pg }} log ${{ matrix.os }} ${{ matrix.build_type }} Build
246246
path: ${{ env.PGDATA }}\log\postmaster.log
247247

248+
- name: Upload CMake Logs
249+
if: always()
250+
uses: actions/upload-artifact@v4
251+
with:
252+
name: CMake Logs ${{ matrix.pg }} ${{ matrix.os }} ${{ matrix.build_type }}
253+
path: |
254+
build_win/CMakeCache.txt
255+
build_win/CMakeFiles/CMakeConfigureLog.yaml
256+
build_win/CMakeFiles/CMakeError.log
257+
build_win/CMakeFiles/CMakeOutput.log
258+
build_win/compile_commands.json
259+
build_wsl/CMakeCache.txt
260+
build_wsl/CMakeFiles/CMakeConfigureLog.yaml
261+
build_wsl/CMakeFiles/CMakeError.log
262+
build_wsl/CMakeFiles/CMakeOutput.log
263+
build_wsl/compile_commands.json
264+
248265
- name: Upload test results to the database
249266
if: always()
250267
shell: wsl-bash {0}

scripts/clang_format_all.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ SCRIPT_DIR=$(cd "$(dirname $0)" || exit; pwd)
55
BASE_DIR=$(dirname $SCRIPT_DIR)
66

77
find ${BASE_DIR} \( -path "${BASE_DIR}/src/*" -or -path "${BASE_DIR}/test/*" -or -path "${BASE_DIR}/tsl/*" \) \
8-
-and -not \( -path "*/.*" -or -path "*CMake*" \) \
8+
-and -not \( -path "*/.*" -or -path "*CMake*" -or -path "${BASE_DIR}/tsl/src/import/*" \) \
99
-and \( -name '*.c' -or -name '*.h' \) -print0 | xargs -0 ${SCRIPT_DIR}/clang_format_wrapper.sh -style=file -i

tsl/CMakeLists.txt

+58
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,63 @@ if(COMPRESSION_FUZZING)
44
add_compile_definitions(TS_COMPRESSION_FUZZING=1)
55
endif()
66

7+
# We use the UMASH library for hashing in vectorized grouping. If it was not
8+
# explicitly disabled already, detect if we can compile it on this platform.
9+
if((NOT DEFINED USE_UMASH) OR USE_UMASH)
10+
# Check whether we can enable the pclmul instruction required for the UMASH
11+
# hashing on amd64. Shouldn't be done if the user has manually specified the
12+
# target architecture, no idea how to detect this, but at least we shouldn't
13+
# do this when cross-compiling.
14+
if(NOT CMAKE_CROSSCOMPILING)
15+
check_c_compiler_flag(-mpclmul CC_PCLMUL)
16+
if(CC_PCLMUL)
17+
add_compile_options(-mpclmul)
18+
# The "C source compiles" check below doesn't use the global compilation
19+
# flags, so we have to modify its flags separately.
20+
set(CMAKE_REQUIRED_FLAGS -mpclmul)
21+
endif()
22+
endif()
23+
24+
set(CMAKE_REQUIRED_FLAGS
25+
"${CMAKE_REQUIRED_FLAGS} -Werror=implicit-function-declaration")
26+
check_c_source_compiles(
27+
"
28+
#if defined(__PCLMUL__)
29+
#include <stdint.h>
30+
#include <immintrin.h>
31+
/*
32+
* For some reason, this doesn't compile on our i386 CI, but I also can't detect
33+
* it using the standard condition of defined(__x86_64__) && !defined(__ILP32__),
34+
* as described at https://wiki.debian.org/X32Port .
35+
*/
36+
static void test() { (void) _mm_cvtsi64_si128((uint64_t) 0); }
37+
#elif defined(__ARM_FEATURE_CRYPTO)
38+
/* OK */
39+
#else
40+
#error Unsupported platform for UMASH
41+
#endif
42+
void main(void) {};
43+
"
44+
UMASH_SUPPORTED)
45+
unset(CMAKE_REQUIRED_FLAGS)
46+
else()
47+
set(UMASH_SUPPORTED OFF)
48+
endif()
49+
50+
option(USE_UMASH
51+
"Use the UMASH hash for string and multi-column vectorized grouping"
52+
${UMASH_SUPPORTED})
53+
54+
if(USE_UMASH)
55+
if(NOT UMASH_SUPPORTED)
56+
message(
57+
FATAL_ERROR
58+
"UMASH use is requested, but it is not supported in the current configuration"
59+
)
60+
endif()
61+
add_compile_definitions(TS_USE_UMASH)
62+
endif()
63+
64+
# Add the subdirectories
765
add_subdirectory(test)
866
add_subdirectory(src)

tsl/src/import/CMakeLists.txt

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1-
set(SOURCES "")
2-
target_sources(${PROJECT_NAME} PRIVATE ${SOURCES})
1+
set(SOURCES)
2+
3+
if(USE_UMASH)
4+
list(APPEND SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/umash.c)
5+
endif()
6+
7+
if(SOURCES)
8+
# Disable clang-tidy for imported code
9+
add_library(target_no_static_code_analysis OBJECT ${SOURCES})
10+
set_target_properties(target_no_static_code_analysis PROPERTIES C_CLANG_TIDY
11+
"")
12+
13+
target_link_libraries(${TSL_LIBRARY_NAME}
14+
$<TARGET_OBJECTS:target_no_static_code_analysis>)
15+
endif()

0 commit comments

Comments
 (0)