@@ -4,5 +4,63 @@ if(COMPRESSION_FUZZING)
4
4
add_compile_definitions (TS_COMPRESSION_FUZZING=1)
5
5
endif ()
6
6
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
7
65
add_subdirectory (test )
8
66
add_subdirectory (src)
0 commit comments