From 8e8a2a17d67abd901e1ca4c74924d304a7262f96 Mon Sep 17 00:00:00 2001 From: Artem Zuikov Date: Fri, 15 May 2020 02:57:22 +0300 Subject: [PATCH] build fixes --- CMakeLists.txt | 7 +- programs/server/Server.cpp | 6 +- src/Common/tests/CMakeLists.txt | 6 +- src/Interpreters/sortBlock.cpp | 3 +- .../01280_opencl_bitonic_order_by.reference | 336 ++++++++++++++++++ .../01280_opencl_bitonic_order_by.sql | 10 + ...80_opencl_bitonic_order_by_uint8.reference | 42 --- .../01280_opencl_bitonic_order_by_uint8.sql | 1 - ...281_opencl_bitonic_order_by_int8.reference | 42 --- .../01281_opencl_bitonic_order_by_int8.sql | 1 - ...2_opencl_bitonic_order_by_uint16.reference | 42 --- .../01282_opencl_bitonic_order_by_uint16.sql | 1 - ...83_opencl_bitonic_order_by_int16.reference | 42 --- .../01283_opencl_bitonic_order_by_int16.sql | 1 - ...4_opencl_bitonic_order_by_uint32.reference | 42 --- .../01284_opencl_bitonic_order_by_uint32.sql | 1 - ...85_opencl_bitonic_order_by_int32.reference | 42 --- .../01285_opencl_bitonic_order_by_int32.sql | 1 - ...6_opencl_bitonic_order_by_uint64.reference | 42 --- .../01286_opencl_bitonic_order_by_uint64.sql | 1 - ...87_opencl_bitonic_order_by_int64.reference | 42 --- .../01287_opencl_bitonic_order_by_int64.sql | 1 - 22 files changed, 359 insertions(+), 353 deletions(-) create mode 100644 tests/queries/0_stateless/01280_opencl_bitonic_order_by.reference create mode 100644 tests/queries/0_stateless/01280_opencl_bitonic_order_by.sql delete mode 100644 tests/queries/0_stateless/01280_opencl_bitonic_order_by_uint8.reference delete mode 100644 tests/queries/0_stateless/01280_opencl_bitonic_order_by_uint8.sql delete mode 100644 tests/queries/0_stateless/01281_opencl_bitonic_order_by_int8.reference delete mode 100644 tests/queries/0_stateless/01281_opencl_bitonic_order_by_int8.sql delete mode 100644 tests/queries/0_stateless/01282_opencl_bitonic_order_by_uint16.reference delete mode 100644 tests/queries/0_stateless/01282_opencl_bitonic_order_by_uint16.sql delete mode 100644 tests/queries/0_stateless/01283_opencl_bitonic_order_by_int16.reference delete mode 100644 tests/queries/0_stateless/01283_opencl_bitonic_order_by_int16.sql delete mode 100644 tests/queries/0_stateless/01284_opencl_bitonic_order_by_uint32.reference delete mode 100644 tests/queries/0_stateless/01284_opencl_bitonic_order_by_uint32.sql delete mode 100644 tests/queries/0_stateless/01285_opencl_bitonic_order_by_int32.reference delete mode 100644 tests/queries/0_stateless/01285_opencl_bitonic_order_by_int32.sql delete mode 100644 tests/queries/0_stateless/01286_opencl_bitonic_order_by_uint64.reference delete mode 100644 tests/queries/0_stateless/01286_opencl_bitonic_order_by_uint64.sql delete mode 100644 tests/queries/0_stateless/01287_opencl_bitonic_order_by_int64.reference delete mode 100644 tests/queries/0_stateless/01287_opencl_bitonic_order_by_int64.sql diff --git a/CMakeLists.txt b/CMakeLists.txt index 22fe14e5b55..dd21ff123da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -384,11 +384,12 @@ if (OS_LINUX AND NOT ENABLE_JEMALLOC) endif () if (USE_OPENCL) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBITONIC_SORT_PREFERRED") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBITONIC_SORT_PREFERRED") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_OPENCL=1") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_OPENCL=1") if (OS_DARWIN) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework OpenCL") + set(OPENCL_LINKER_FLAGS "-framework OpenCL") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPENCL_LINKER_FLAGS}") endif () endif () diff --git a/programs/server/Server.cpp b/programs/server/Server.cpp index 691ede66eb4..7c119b40ac8 100644 --- a/programs/server/Server.cpp +++ b/programs/server/Server.cpp @@ -61,7 +61,7 @@ #include #include "MySQLHandlerFactory.h" -#ifdef BITONIC_SORT_PREFERRED +#ifdef USE_OPENCL #include "Common/BitonicSort.h" #endif @@ -225,9 +225,9 @@ int Server::main(const std::vector & /*args*/) registerDictionaries(); registerDisks(); - #if defined (BITONIC_SORT_PREFERRED) +#if defined (USE_OPENCL) BitonicSort::getInstance().configure(); - #endif +#endif CurrentMetrics::set(CurrentMetrics::Revision, ClickHouseRevision::get()); CurrentMetrics::set(CurrentMetrics::VersionInteger, ClickHouseRevision::getVersionInteger()); diff --git a/src/Common/tests/CMakeLists.txt b/src/Common/tests/CMakeLists.txt index 87ae4858bf1..495663bc5d8 100644 --- a/src/Common/tests/CMakeLists.txt +++ b/src/Common/tests/CMakeLists.txt @@ -35,8 +35,10 @@ target_link_libraries (compact_array PRIVATE clickhouse_common_io) add_executable (radix_sort radix_sort.cpp) target_link_libraries (radix_sort PRIVATE clickhouse_common_io) -add_executable (bitonic_sort bitonic_sort.cpp) -target_link_libraries (bitonic_sort PRIVATE clickhouse_common_io "-framework OpenCL") +if (USE_OPENCL) + add_executable (bitonic_sort bitonic_sort.cpp) + target_link_libraries (bitonic_sort PRIVATE clickhouse_common_io ${OPENCL_LINKER_FLAGS}) +endif () add_executable (arena_with_free_lists arena_with_free_lists.cpp) target_link_libraries (arena_with_free_lists PRIVATE dbms) diff --git a/src/Interpreters/sortBlock.cpp b/src/Interpreters/sortBlock.cpp index dccea6e8449..0e98dc0eb4b 100644 --- a/src/Interpreters/sortBlock.cpp +++ b/src/Interpreters/sortBlock.cpp @@ -140,8 +140,9 @@ void sortBlock(Block & block, const SortDescription & description, UInt64 limit) /// will be passed to `getPermutation` method with value 42. if (description[0].special_sort == SpecialSort::OPENCL_BITONIC) { +#ifdef USE_OPENCL nan_direction_hint = 42; -#ifndef BITONIC_SORT_PREFERRED +#else throw DB::Exception("Bitonic sort specified as preferred, but OpenCL not available", DB::ErrorCodes::OPENCL_ERROR); #endif } diff --git a/tests/queries/0_stateless/01280_opencl_bitonic_order_by.reference b/tests/queries/0_stateless/01280_opencl_bitonic_order_by.reference new file mode 100644 index 00000000000..436b874be62 --- /dev/null +++ b/tests/queries/0_stateless/01280_opencl_bitonic_order_by.reference @@ -0,0 +1,336 @@ +82 +80 +78 +76 +74 +72 +70 +68 +66 +64 +62 +60 +58 +56 +54 +52 +50 +48 +46 +44 +42 +40 +38 +36 +34 +32 +30 +28 +26 +24 +22 +20 +18 +16 +14 +12 +10 +8 +6 +4 +2 +0 +82 +80 +78 +76 +74 +72 +70 +68 +66 +64 +62 +60 +58 +56 +54 +52 +50 +48 +46 +44 +42 +40 +38 +36 +34 +32 +30 +28 +26 +24 +22 +20 +18 +16 +14 +12 +10 +8 +6 +4 +2 +0 +82 +80 +78 +76 +74 +72 +70 +68 +66 +64 +62 +60 +58 +56 +54 +52 +50 +48 +46 +44 +42 +40 +38 +36 +34 +32 +30 +28 +26 +24 +22 +20 +18 +16 +14 +12 +10 +8 +6 +4 +2 +0 +82 +80 +78 +76 +74 +72 +70 +68 +66 +64 +62 +60 +58 +56 +54 +52 +50 +48 +46 +44 +42 +40 +38 +36 +34 +32 +30 +28 +26 +24 +22 +20 +18 +16 +14 +12 +10 +8 +6 +4 +2 +0 +82 +80 +78 +76 +74 +72 +70 +68 +66 +64 +62 +60 +58 +56 +54 +52 +50 +48 +46 +44 +42 +40 +38 +36 +34 +32 +30 +28 +26 +24 +22 +20 +18 +16 +14 +12 +10 +8 +6 +4 +2 +0 +82 +80 +78 +76 +74 +72 +70 +68 +66 +64 +62 +60 +58 +56 +54 +52 +50 +48 +46 +44 +42 +40 +38 +36 +34 +32 +30 +28 +26 +24 +22 +20 +18 +16 +14 +12 +10 +8 +6 +4 +2 +0 +82 +80 +78 +76 +74 +72 +70 +68 +66 +64 +62 +60 +58 +56 +54 +52 +50 +48 +46 +44 +42 +40 +38 +36 +34 +32 +30 +28 +26 +24 +22 +20 +18 +16 +14 +12 +10 +8 +6 +4 +2 +0 +82 +80 +78 +76 +74 +72 +70 +68 +66 +64 +62 +60 +58 +56 +54 +52 +50 +48 +46 +44 +42 +40 +38 +36 +34 +32 +30 +28 +26 +24 +22 +20 +18 +16 +14 +12 +10 +8 +6 +4 +2 +0 diff --git a/tests/queries/0_stateless/01280_opencl_bitonic_order_by.sql b/tests/queries/0_stateless/01280_opencl_bitonic_order_by.sql new file mode 100644 index 00000000000..ed32a3d37ca --- /dev/null +++ b/tests/queries/0_stateless/01280_opencl_bitonic_order_by.sql @@ -0,0 +1,10 @@ +-- TODO: set special_sort = 'opencl_bitonic'; + +select toUInt8(number * 2) as x from numbers(42) order by x desc; +select toInt8(number * 2) as x from numbers(42) order by x desc; +select toUInt16(number * 2) as x from numbers(42) order by x desc; +select toInt16(number * 2) as x from numbers(42) order by x desc; +select toUInt32(number * 2) as x from numbers(42) order by x desc; +select toInt32(number * 2) as x from numbers(42) order by x desc; +select toUInt64(number * 2) as x from numbers(42) order by x desc; +select toInt64(number * 2) as x from numbers(42) order by x desc; diff --git a/tests/queries/0_stateless/01280_opencl_bitonic_order_by_uint8.reference b/tests/queries/0_stateless/01280_opencl_bitonic_order_by_uint8.reference deleted file mode 100644 index 0d1c70bed38..00000000000 --- a/tests/queries/0_stateless/01280_opencl_bitonic_order_by_uint8.reference +++ /dev/null @@ -1,42 +0,0 @@ -82 -80 -78 -76 -74 -72 -70 -68 -66 -64 -62 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 -0 diff --git a/tests/queries/0_stateless/01280_opencl_bitonic_order_by_uint8.sql b/tests/queries/0_stateless/01280_opencl_bitonic_order_by_uint8.sql deleted file mode 100644 index 6c6efdfd23c..00000000000 --- a/tests/queries/0_stateless/01280_opencl_bitonic_order_by_uint8.sql +++ /dev/null @@ -1 +0,0 @@ -select toUInt8(number * 2) as x from numbers(42) order by x desc settings special_sort = 'opencl_bitonic' diff --git a/tests/queries/0_stateless/01281_opencl_bitonic_order_by_int8.reference b/tests/queries/0_stateless/01281_opencl_bitonic_order_by_int8.reference deleted file mode 100644 index 0d1c70bed38..00000000000 --- a/tests/queries/0_stateless/01281_opencl_bitonic_order_by_int8.reference +++ /dev/null @@ -1,42 +0,0 @@ -82 -80 -78 -76 -74 -72 -70 -68 -66 -64 -62 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 -0 diff --git a/tests/queries/0_stateless/01281_opencl_bitonic_order_by_int8.sql b/tests/queries/0_stateless/01281_opencl_bitonic_order_by_int8.sql deleted file mode 100644 index dee3bea1435..00000000000 --- a/tests/queries/0_stateless/01281_opencl_bitonic_order_by_int8.sql +++ /dev/null @@ -1 +0,0 @@ -select toInt8(number * 2) as x from numbers(42) order by x desc settings special_sort = 'opencl_bitonic' diff --git a/tests/queries/0_stateless/01282_opencl_bitonic_order_by_uint16.reference b/tests/queries/0_stateless/01282_opencl_bitonic_order_by_uint16.reference deleted file mode 100644 index 0d1c70bed38..00000000000 --- a/tests/queries/0_stateless/01282_opencl_bitonic_order_by_uint16.reference +++ /dev/null @@ -1,42 +0,0 @@ -82 -80 -78 -76 -74 -72 -70 -68 -66 -64 -62 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 -0 diff --git a/tests/queries/0_stateless/01282_opencl_bitonic_order_by_uint16.sql b/tests/queries/0_stateless/01282_opencl_bitonic_order_by_uint16.sql deleted file mode 100644 index b83e0bc8073..00000000000 --- a/tests/queries/0_stateless/01282_opencl_bitonic_order_by_uint16.sql +++ /dev/null @@ -1 +0,0 @@ -select toUInt16(number * 2) as x from numbers(42) order by x desc settings special_sort = 'opencl_bitonic' diff --git a/tests/queries/0_stateless/01283_opencl_bitonic_order_by_int16.reference b/tests/queries/0_stateless/01283_opencl_bitonic_order_by_int16.reference deleted file mode 100644 index 0d1c70bed38..00000000000 --- a/tests/queries/0_stateless/01283_opencl_bitonic_order_by_int16.reference +++ /dev/null @@ -1,42 +0,0 @@ -82 -80 -78 -76 -74 -72 -70 -68 -66 -64 -62 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 -0 diff --git a/tests/queries/0_stateless/01283_opencl_bitonic_order_by_int16.sql b/tests/queries/0_stateless/01283_opencl_bitonic_order_by_int16.sql deleted file mode 100644 index 02f6dea47f1..00000000000 --- a/tests/queries/0_stateless/01283_opencl_bitonic_order_by_int16.sql +++ /dev/null @@ -1 +0,0 @@ -select toInt16(number * 2) as x from numbers(42) order by x desc settings special_sort = 'opencl_bitonic' diff --git a/tests/queries/0_stateless/01284_opencl_bitonic_order_by_uint32.reference b/tests/queries/0_stateless/01284_opencl_bitonic_order_by_uint32.reference deleted file mode 100644 index 0d1c70bed38..00000000000 --- a/tests/queries/0_stateless/01284_opencl_bitonic_order_by_uint32.reference +++ /dev/null @@ -1,42 +0,0 @@ -82 -80 -78 -76 -74 -72 -70 -68 -66 -64 -62 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 -0 diff --git a/tests/queries/0_stateless/01284_opencl_bitonic_order_by_uint32.sql b/tests/queries/0_stateless/01284_opencl_bitonic_order_by_uint32.sql deleted file mode 100644 index ee035f2d0d8..00000000000 --- a/tests/queries/0_stateless/01284_opencl_bitonic_order_by_uint32.sql +++ /dev/null @@ -1 +0,0 @@ -select toUInt32(number * 2) as x from numbers(42) order by x desc settings special_sort = 'opencl_bitonic' diff --git a/tests/queries/0_stateless/01285_opencl_bitonic_order_by_int32.reference b/tests/queries/0_stateless/01285_opencl_bitonic_order_by_int32.reference deleted file mode 100644 index 0d1c70bed38..00000000000 --- a/tests/queries/0_stateless/01285_opencl_bitonic_order_by_int32.reference +++ /dev/null @@ -1,42 +0,0 @@ -82 -80 -78 -76 -74 -72 -70 -68 -66 -64 -62 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 -0 diff --git a/tests/queries/0_stateless/01285_opencl_bitonic_order_by_int32.sql b/tests/queries/0_stateless/01285_opencl_bitonic_order_by_int32.sql deleted file mode 100644 index bf799dfb45e..00000000000 --- a/tests/queries/0_stateless/01285_opencl_bitonic_order_by_int32.sql +++ /dev/null @@ -1 +0,0 @@ -select toInt32(number * 2) as x from numbers(42) order by x desc settings special_sort = 'opencl_bitonic' diff --git a/tests/queries/0_stateless/01286_opencl_bitonic_order_by_uint64.reference b/tests/queries/0_stateless/01286_opencl_bitonic_order_by_uint64.reference deleted file mode 100644 index 0d1c70bed38..00000000000 --- a/tests/queries/0_stateless/01286_opencl_bitonic_order_by_uint64.reference +++ /dev/null @@ -1,42 +0,0 @@ -82 -80 -78 -76 -74 -72 -70 -68 -66 -64 -62 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 -0 diff --git a/tests/queries/0_stateless/01286_opencl_bitonic_order_by_uint64.sql b/tests/queries/0_stateless/01286_opencl_bitonic_order_by_uint64.sql deleted file mode 100644 index e593ac86561..00000000000 --- a/tests/queries/0_stateless/01286_opencl_bitonic_order_by_uint64.sql +++ /dev/null @@ -1 +0,0 @@ -select toUInt64(number * 2) as x from numbers(42) order by x desc settings special_sort = 'opencl_bitonic' diff --git a/tests/queries/0_stateless/01287_opencl_bitonic_order_by_int64.reference b/tests/queries/0_stateless/01287_opencl_bitonic_order_by_int64.reference deleted file mode 100644 index 0d1c70bed38..00000000000 --- a/tests/queries/0_stateless/01287_opencl_bitonic_order_by_int64.reference +++ /dev/null @@ -1,42 +0,0 @@ -82 -80 -78 -76 -74 -72 -70 -68 -66 -64 -62 -60 -58 -56 -54 -52 -50 -48 -46 -44 -42 -40 -38 -36 -34 -32 -30 -28 -26 -24 -22 -20 -18 -16 -14 -12 -10 -8 -6 -4 -2 -0 diff --git a/tests/queries/0_stateless/01287_opencl_bitonic_order_by_int64.sql b/tests/queries/0_stateless/01287_opencl_bitonic_order_by_int64.sql deleted file mode 100644 index a6c30dc4887..00000000000 --- a/tests/queries/0_stateless/01287_opencl_bitonic_order_by_int64.sql +++ /dev/null @@ -1 +0,0 @@ -select toInt64(number * 2) as x from numbers(42) order by x desc settings special_sort = 'opencl_bitonic'