├── .gitignore ├── CMakeLists.txt ├── LICENSE.txt ├── LICENSE_APACHE.txt ├── LICENSE_BSD.txt ├── cmake └── FindNuma.cmake ├── src └── dtl │ ├── adept.hpp │ ├── barrier.hpp │ ├── batchwise.hpp │ ├── bits.hpp │ ├── bitset.hpp │ ├── bitset_util.hpp │ ├── color.hpp │ ├── div.hpp │ ├── dtl.hpp │ ├── env.hpp │ ├── filter │ ├── README.md │ ├── bbf_32.cpp │ ├── bbf_32.hpp │ ├── bbf_64.cpp │ ├── bbf_64.hpp │ ├── bcf.cpp │ ├── bcf.hpp │ ├── blocked_bloomfilter │ │ ├── CMakeLists.txt │ │ ├── block_addressing_logic.hpp │ │ ├── blocked_bloomfilter.hpp │ │ ├── blocked_bloomfilter_batch_dispatch.hpp │ │ ├── blocked_bloomfilter_block_logic.hpp │ │ ├── blocked_bloomfilter_block_logic_sgew.hpp │ │ ├── blocked_bloomfilter_block_logic_sgew_specialization.hpp │ │ ├── blocked_bloomfilter_block_logic_sltw.hpp │ │ ├── blocked_bloomfilter_block_logic_zoned.hpp │ │ ├── blocked_bloomfilter_config.hpp │ │ ├── blocked_bloomfilter_logic.hpp │ │ ├── blocked_bloomfilter_tune.hpp │ │ ├── blocked_bloomfilter_tune_impl.hpp │ │ ├── fpr.hpp │ │ ├── hash_family.hpp │ │ ├── instances │ │ │ ├── blocked_bloomfilter_block_logic_instance.hpp │ │ │ ├── blocked_bloomfilter_block_logic_u32_w1.cpp │ │ │ ├── blocked_bloomfilter_block_logic_u32_w1.hpp │ │ │ ├── blocked_bloomfilter_block_logic_u32_w16.cpp │ │ │ ├── blocked_bloomfilter_block_logic_u32_w16.hpp │ │ │ ├── blocked_bloomfilter_block_logic_u32_w2.cpp │ │ │ ├── blocked_bloomfilter_block_logic_u32_w2.hpp │ │ │ ├── blocked_bloomfilter_block_logic_u32_w4.cpp │ │ │ ├── blocked_bloomfilter_block_logic_u32_w4.hpp │ │ │ ├── blocked_bloomfilter_block_logic_u32_w8.cpp │ │ │ ├── blocked_bloomfilter_block_logic_u32_w8.hpp │ │ │ ├── blocked_bloomfilter_block_logic_u64_w1.cpp │ │ │ ├── blocked_bloomfilter_block_logic_u64_w1.hpp │ │ │ ├── blocked_bloomfilter_block_logic_u64_w16.cpp │ │ │ ├── blocked_bloomfilter_block_logic_u64_w16.hpp │ │ │ ├── blocked_bloomfilter_block_logic_u64_w2.cpp │ │ │ ├── blocked_bloomfilter_block_logic_u64_w2.hpp │ │ │ ├── blocked_bloomfilter_block_logic_u64_w4.cpp │ │ │ ├── blocked_bloomfilter_block_logic_u64_w4.hpp │ │ │ ├── blocked_bloomfilter_block_logic_u64_w8.cpp │ │ │ ├── blocked_bloomfilter_block_logic_u64_w8.hpp │ │ │ ├── blocked_bloomfilter_instance.hpp │ │ │ ├── blocked_bloomfilter_logic_instance.inc │ │ │ ├── blocked_bloomfilter_logic_u32_instance.hpp │ │ │ ├── blocked_bloomfilter_logic_u32_w1.cpp │ │ │ ├── blocked_bloomfilter_logic_u32_w1.hpp │ │ │ ├── blocked_bloomfilter_logic_u32_w16.cpp │ │ │ ├── blocked_bloomfilter_logic_u32_w16.hpp │ │ │ ├── blocked_bloomfilter_logic_u32_w2.cpp │ │ │ ├── blocked_bloomfilter_logic_u32_w2.hpp │ │ │ ├── blocked_bloomfilter_logic_u32_w4.cpp │ │ │ ├── blocked_bloomfilter_logic_u32_w4.hpp │ │ │ ├── blocked_bloomfilter_logic_u32_w8.cpp │ │ │ ├── blocked_bloomfilter_logic_u32_w8.hpp │ │ │ ├── blocked_bloomfilter_logic_u64_instance.hpp │ │ │ ├── blocked_bloomfilter_logic_u64_w1.cpp │ │ │ ├── blocked_bloomfilter_logic_u64_w1.hpp │ │ │ ├── blocked_bloomfilter_logic_u64_w16.cpp │ │ │ ├── blocked_bloomfilter_logic_u64_w16.hpp │ │ │ ├── blocked_bloomfilter_logic_u64_w2.cpp │ │ │ ├── blocked_bloomfilter_logic_u64_w2.hpp │ │ │ ├── blocked_bloomfilter_logic_u64_w4.cpp │ │ │ ├── blocked_bloomfilter_logic_u64_w4.hpp │ │ │ ├── blocked_bloomfilter_logic_u64_w8.cpp │ │ │ ├── blocked_bloomfilter_logic_u64_w8.hpp │ │ │ ├── zoned_blocked_bloomfilter_logic_instance.inc │ │ │ ├── zoned_blocked_bloomfilter_logic_u32_instance.hpp │ │ │ ├── zoned_blocked_bloomfilter_logic_u32_w16.cpp │ │ │ ├── zoned_blocked_bloomfilter_logic_u32_w16.hpp │ │ │ ├── zoned_blocked_bloomfilter_logic_u32_w4.cpp │ │ │ ├── zoned_blocked_bloomfilter_logic_u32_w4.hpp │ │ │ ├── zoned_blocked_bloomfilter_logic_u32_w8.cpp │ │ │ ├── zoned_blocked_bloomfilter_logic_u32_w8.hpp │ │ │ ├── zoned_blocked_bloomfilter_logic_u64_instance.hpp │ │ │ ├── zoned_blocked_bloomfilter_logic_u64_w16.cpp │ │ │ ├── zoned_blocked_bloomfilter_logic_u64_w16.hpp │ │ │ ├── zoned_blocked_bloomfilter_logic_u64_w4.cpp │ │ │ ├── zoned_blocked_bloomfilter_logic_u64_w4.hpp │ │ │ ├── zoned_blocked_bloomfilter_logic_u64_w8.cpp │ │ │ └── zoned_blocked_bloomfilter_logic_u64_w8.hpp │ │ ├── math.hpp │ │ ├── vector_helper.hpp │ │ ├── zoned_blocked_bloomfilter.hpp │ │ └── zoned_blocked_bloomfilter_tune_impl.hpp │ ├── blocked_cuckoofilter │ │ ├── README.md │ │ ├── blocked_cuckoofilter.hpp │ │ ├── blocked_cuckoofilter_block_logic.hpp │ │ ├── blocked_cuckoofilter_logic.hpp │ │ ├── blocked_cuckoofilter_multiword_table.hpp │ │ ├── blocked_cuckoofilter_simd.hpp │ │ ├── blocked_cuckoofilter_util.hpp │ │ └── blocked_cuckoofilter_word_table.hpp │ ├── bloomfilter │ │ ├── README.md │ │ └── bloomfilter_logic.hpp │ ├── cf.cpp │ ├── cf.hpp │ ├── cuckoofilter │ │ ├── bitsutil.hpp │ │ ├── cuckoofilter.hpp │ │ ├── cuckoofilter_config.hpp │ │ ├── cuckoofilter_logic.hpp │ │ ├── cuckoofilter_table.hpp │ │ ├── cuckoofilter_table_scalar.hpp │ │ ├── cuckoofilter_table_scalar_cuda.hpp │ │ ├── cuckoofilter_table_simd.hpp │ │ ├── cuckoofilter_table_simd_avx2.hpp │ │ ├── cuckoofilter_table_simd_avx512f.hpp │ │ ├── cuckoofilter_tune.hpp │ │ └── cuckoofilter_tune_impl.hpp │ ├── dynamic_blocked_bloomfilter │ │ ├── README.md │ │ ├── block_addressing_logic.hpp │ │ ├── blocked_bloomfilter.hpp │ │ ├── blocked_bloomfilter_block_logic.hpp │ │ ├── blocked_bloomfilter_logic.hpp │ │ └── hash.hpp │ ├── filter.hpp │ ├── filter_base.hpp │ ├── filter_test.cpp │ ├── model │ │ ├── benchmark.cpp │ │ ├── benchmark.hpp │ │ ├── benchmark_test.cpp │ │ ├── calibration.cpp │ │ ├── calibration.hpp │ │ ├── calibration_data.cpp │ │ ├── calibration_data.hpp │ │ ├── calibration_data_test.cpp │ │ ├── calibration_test.cpp │ │ ├── cost_fn.hpp │ │ ├── optimizer.cpp │ │ ├── optimizer.hpp │ │ ├── optimizer_test.cpp │ │ ├── skyline_matrix.hpp │ │ ├── timing.hpp │ │ ├── tuning_params.hpp │ │ └── util.hpp │ ├── platform.cpp │ ├── platform.hpp │ ├── platform_test.cpp │ ├── zbbf_32.cpp │ ├── zbbf_32.hpp │ ├── zbbf_64.cpp │ └── zbbf_64.hpp │ ├── hash.hpp │ ├── hash_fvn.hpp │ ├── lockstripe.hpp │ ├── math.hpp │ ├── mem.hpp │ ├── polyfill.hpp │ ├── simd.hpp │ ├── simd │ ├── CMakeLists.txt │ ├── bitset.hpp │ ├── extensions.hpp │ ├── intrin_avx2.hpp │ ├── intrin_avx512.hpp │ ├── intrin_sse.hpp │ ├── intrin_x64.hpp │ ├── intrinsics.hpp │ ├── types.hpp │ ├── vec.hpp │ └── vec_readme.md │ ├── thread.hpp │ └── type_traits.hpp ├── test ├── CMakeLists.txt ├── bitset_test.cpp ├── cuckoofilter_test.cpp ├── div_test.cpp ├── enumerate_groups_test.cpp ├── helper.h ├── lib │ └── googletest │ │ ├── .gitignore │ │ ├── CHANGES │ │ ├── CMakeLists.txt │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ ├── Makefile.am │ │ ├── README.md │ │ ├── build-aux │ │ └── .keep │ │ ├── cmake │ │ └── internal_utils.cmake │ │ ├── codegear │ │ ├── gtest.cbproj │ │ ├── gtest.groupproj │ │ ├── gtest_all.cc │ │ ├── gtest_link.cc │ │ ├── gtest_main.cbproj │ │ └── gtest_unittest.cbproj │ │ ├── configure.ac │ │ ├── docs │ │ ├── AdvancedGuide.md │ │ ├── DevGuide.md │ │ ├── Documentation.md │ │ ├── FAQ.md │ │ ├── Primer.md │ │ ├── PumpManual.md │ │ ├── Samples.md │ │ ├── V1_5_AdvancedGuide.md │ │ ├── V1_5_Documentation.md │ │ ├── V1_5_FAQ.md │ │ ├── V1_5_Primer.md │ │ ├── V1_5_PumpManual.md │ │ ├── V1_5_XcodeGuide.md │ │ ├── V1_6_AdvancedGuide.md │ │ ├── V1_6_Documentation.md │ │ ├── V1_6_FAQ.md │ │ ├── V1_6_Primer.md │ │ ├── V1_6_PumpManual.md │ │ ├── V1_6_Samples.md │ │ ├── V1_6_XcodeGuide.md │ │ ├── V1_7_AdvancedGuide.md │ │ ├── V1_7_Documentation.md │ │ ├── V1_7_FAQ.md │ │ ├── V1_7_Primer.md │ │ ├── V1_7_PumpManual.md │ │ ├── V1_7_Samples.md │ │ ├── V1_7_XcodeGuide.md │ │ └── XcodeGuide.md │ │ ├── include │ │ └── gtest │ │ │ ├── gtest-death-test.h │ │ │ ├── gtest-message.h │ │ │ ├── gtest-param-test.h │ │ │ ├── gtest-param-test.h.pump │ │ │ ├── gtest-printers.h │ │ │ ├── gtest-spi.h │ │ │ ├── gtest-test-part.h │ │ │ ├── gtest-typed-test.h │ │ │ ├── gtest.h │ │ │ ├── gtest_pred_impl.h │ │ │ ├── gtest_prod.h │ │ │ └── internal │ │ │ ├── custom │ │ │ ├── gtest-port.h │ │ │ ├── gtest-printers.h │ │ │ └── gtest.h │ │ │ ├── gtest-death-test-internal.h │ │ │ ├── gtest-filepath.h │ │ │ ├── gtest-internal.h │ │ │ ├── gtest-linked_ptr.h │ │ │ ├── gtest-param-util-generated.h │ │ │ ├── gtest-param-util-generated.h.pump │ │ │ ├── gtest-param-util.h │ │ │ ├── gtest-port-arch.h │ │ │ ├── gtest-port.h │ │ │ ├── gtest-string.h │ │ │ ├── gtest-tuple.h │ │ │ ├── gtest-tuple.h.pump │ │ │ ├── gtest-type-util.h │ │ │ └── gtest-type-util.h.pump │ │ ├── m4 │ │ ├── acx_pthread.m4 │ │ └── gtest.m4 │ │ ├── make │ │ └── Makefile │ │ ├── msvc │ │ ├── gtest-md.sln │ │ ├── gtest-md.vcproj │ │ ├── gtest.sln │ │ ├── gtest.vcproj │ │ ├── gtest_main-md.vcproj │ │ ├── gtest_main.vcproj │ │ ├── gtest_prod_test-md.vcproj │ │ ├── gtest_prod_test.vcproj │ │ ├── gtest_unittest-md.vcproj │ │ └── gtest_unittest.vcproj │ │ ├── samples │ │ ├── prime_tables.h │ │ ├── sample1.cc │ │ ├── sample1.h │ │ ├── sample10_unittest.cc │ │ ├── sample1_unittest.cc │ │ ├── sample2.cc │ │ ├── sample2.h │ │ ├── sample2_unittest.cc │ │ ├── sample3-inl.h │ │ ├── sample3_unittest.cc │ │ ├── sample4.cc │ │ ├── sample4.h │ │ ├── sample4_unittest.cc │ │ ├── sample5_unittest.cc │ │ ├── sample6_unittest.cc │ │ ├── sample7_unittest.cc │ │ ├── sample8_unittest.cc │ │ └── sample9_unittest.cc │ │ ├── scripts │ │ ├── common.py │ │ ├── fuse_gtest_files.py │ │ ├── gen_gtest_pred_impl.py │ │ ├── gtest-config.in │ │ ├── pump.py │ │ ├── release_docs.py │ │ ├── test │ │ │ └── Makefile │ │ ├── upload.py │ │ └── upload_gtest.py │ │ ├── src │ │ ├── gtest-all.cc │ │ ├── gtest-death-test.cc │ │ ├── gtest-filepath.cc │ │ ├── gtest-internal-inl.h │ │ ├── gtest-port.cc │ │ ├── gtest-printers.cc │ │ ├── gtest-test-part.cc │ │ ├── gtest-typed-test.cc │ │ ├── gtest.cc │ │ └── gtest_main.cc │ │ ├── test │ │ ├── gtest-death-test_ex_test.cc │ │ ├── gtest-death-test_test.cc │ │ ├── gtest-filepath_test.cc │ │ ├── gtest-linked_ptr_test.cc │ │ ├── gtest-listener_test.cc │ │ ├── gtest-message_test.cc │ │ ├── gtest-options_test.cc │ │ ├── gtest-param-test2_test.cc │ │ ├── gtest-param-test_test.cc │ │ ├── gtest-param-test_test.h │ │ ├── gtest-port_test.cc │ │ ├── gtest-printers_test.cc │ │ ├── gtest-test-part_test.cc │ │ ├── gtest-tuple_test.cc │ │ ├── gtest-typed-test2_test.cc │ │ ├── gtest-typed-test_test.cc │ │ ├── gtest-typed-test_test.h │ │ ├── gtest-unittest-api_test.cc │ │ ├── gtest_all_test.cc │ │ ├── gtest_break_on_failure_unittest.py │ │ ├── gtest_break_on_failure_unittest_.cc │ │ ├── gtest_catch_exceptions_test.py │ │ ├── gtest_catch_exceptions_test_.cc │ │ ├── gtest_color_test.py │ │ ├── gtest_color_test_.cc │ │ ├── gtest_env_var_test.py │ │ ├── gtest_env_var_test_.cc │ │ ├── gtest_environment_test.cc │ │ ├── gtest_filter_unittest.py │ │ ├── gtest_filter_unittest_.cc │ │ ├── gtest_help_test.py │ │ ├── gtest_help_test_.cc │ │ ├── gtest_list_tests_unittest.py │ │ ├── gtest_list_tests_unittest_.cc │ │ ├── gtest_main_unittest.cc │ │ ├── gtest_no_test_unittest.cc │ │ ├── gtest_output_test.py │ │ ├── gtest_output_test_.cc │ │ ├── gtest_output_test_golden_lin.txt │ │ ├── gtest_pred_impl_unittest.cc │ │ ├── gtest_premature_exit_test.cc │ │ ├── gtest_prod_test.cc │ │ ├── gtest_repeat_test.cc │ │ ├── gtest_shuffle_test.py │ │ ├── gtest_shuffle_test_.cc │ │ ├── gtest_sole_header_test.cc │ │ ├── gtest_stress_test.cc │ │ ├── gtest_test_utils.py │ │ ├── gtest_throw_on_failure_ex_test.cc │ │ ├── gtest_throw_on_failure_test.py │ │ ├── gtest_throw_on_failure_test_.cc │ │ ├── gtest_uninitialized_test.py │ │ ├── gtest_uninitialized_test_.cc │ │ ├── gtest_unittest.cc │ │ ├── gtest_xml_outfile1_test_.cc │ │ ├── gtest_xml_outfile2_test_.cc │ │ ├── gtest_xml_outfiles_test.py │ │ ├── gtest_xml_output_unittest.py │ │ ├── gtest_xml_output_unittest_.cc │ │ ├── gtest_xml_test_utils.py │ │ ├── production.cc │ │ └── production.h │ │ └── xcode │ │ ├── Config │ │ ├── DebugProject.xcconfig │ │ ├── FrameworkTarget.xcconfig │ │ ├── General.xcconfig │ │ ├── ReleaseProject.xcconfig │ │ ├── StaticLibraryTarget.xcconfig │ │ └── TestTarget.xcconfig │ │ ├── Resources │ │ └── Info.plist │ │ ├── Samples │ │ └── FrameworkSample │ │ │ ├── Info.plist │ │ │ ├── WidgetFramework.xcodeproj │ │ │ └── project.pbxproj │ │ │ ├── runtests.sh │ │ │ ├── widget.cc │ │ │ ├── widget.h │ │ │ └── widget_test.cc │ │ ├── Scripts │ │ ├── runtests.sh │ │ └── versiongenerate.py │ │ └── gtest.xcodeproj │ │ └── project.pbxproj ├── mem_test.cpp └── vec_test.cpp ├── thirdparty └── libdivide │ ├── LICENSE.txt │ ├── divide_by_constants_codegen_reference.c │ └── libdivide.h └── tool └── calibration └── src ├── filter-calibration-tool.cpp ├── skyline_matrix_builder.cpp ├── skyline_matrix_builder.hpp └── util.hpp /.gitignore: -------------------------------------------------------------------------------- 1 | **/.idea 2 | **/cmake-build* 3 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | This work is dual-licensed under BSD (3-clause) and Apache 2.0 (or any later version). 2 | You can choose between one of them if you use this work. 3 | 4 | See files LICENSE_BSD.txt and LICENSE_APACHE.txt for details. 5 | 6 | 7 | Third party dependencies: 8 | 9 | Cuckoo filter: 10 | Parts of the Cuckoo filter implementation are derived from 11 | https://github.com/efficient/cuckoofilter which 12 | is available under the Apache License, Version 2.0. 13 | 14 | Libdivide: 15 | Usable under the terms in either zlib or Boost license. 16 | See 'thirdparty/libdivide/LICENSE.txt' for details. 17 | -------------------------------------------------------------------------------- /LICENSE_APACHE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2018 Harald Lang (TUM), Peter Boncz (CWI Amsterdam) 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /LICENSE_BSD.txt: -------------------------------------------------------------------------------- 1 | Copyright 2018 Harald Lang (TUM), Peter Boncz (CWI Amsterdam) 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | * Neither the name of the copyright holder nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /cmake/FindNuma.cmake: -------------------------------------------------------------------------------- 1 | include(FindPackageHandleStandardArgs) 2 | 3 | find_path(NUMA_ROOT_DIR 4 | NAMES include/numa.h 5 | PATHS ENV NUMA_ROOT 6 | DOC "NUMA root directory") 7 | 8 | find_path(NUMA_INCLUDE_DIR 9 | NAMES numa.h 10 | HINTS ${NUMA_ROOT_DIR} 11 | PATH_SUFFIXES include 12 | DOC "NUMA include directory") 13 | 14 | find_library(NUMA_LIBRARY 15 | NAMES numa 16 | HINTS ${NUMA_ROOT_DIR} 17 | DOC "NUMA library") 18 | 19 | if (NUMA_LIBRARY) 20 | get_filename_component(NUMA_LIBRARY_DIR ${NUMA_LIBRARY} PATH) 21 | endif() 22 | 23 | mark_as_advanced(NUMA_INCLUDE_DIR NUMA_LIBRARY_DIR NUMA_LIBRARY) 24 | 25 | find_package_handle_standard_args(NUMA REQUIRED_VARS NUMA_ROOT_DIR NUMA_INCLUDE_DIR NUMA_LIBRARY) 26 | -------------------------------------------------------------------------------- /src/dtl/batchwise.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dtl { 6 | 7 | //===----------------------------------------------------------------------===// 8 | // The number of items processed in one go. 9 | const size_t BATCH_SIZE = 1024; 10 | 11 | template 12 | void batch_wise(it begin, it end, binary_fn fn) { 13 | it i = begin; 14 | while (i + batch_size < end) { 15 | fn(i, i + batch_size); 16 | i += batch_size; 17 | } 18 | if (i < end) { 19 | fn(i, end); 20 | } 21 | } 22 | //===----------------------------------------------------------------------===// 23 | 24 | } // namespace dtl 25 | 26 | -------------------------------------------------------------------------------- /src/dtl/color.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dtl { 6 | 7 | enum class color : uint32_t { 8 | red = 31, 9 | green = 32, 10 | light_green = 92, 11 | yellow = 33, 12 | light_yellow = 93, 13 | 14 | blue = 34, 15 | light_blue = 94, 16 | dark_gray = 90, 17 | gray = 39, 18 | BG_RED = 41, 19 | BG_GREEN = 42, 20 | BG_BLUE = 44, 21 | bg_gray = 49, 22 | }; 23 | 24 | struct color_modifier { 25 | color code; 26 | 27 | color_modifier(color code) : code(code) {} 28 | friend std::ostream& 29 | operator<<(std::ostream& os, const color_modifier& mod) { 30 | return os << "\033[" << static_cast(mod.code) << "m"; 31 | } 32 | std::string str() const { 33 | return "\033[" + std::to_string(static_cast(code)) + "m"; } 34 | }; 35 | 36 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/dtl.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // TODO undefine FAST_BUILD 4 | //#define FAST_BUILD 1 5 | 6 | #include "polyfill.hpp" 7 | #include "adept.hpp" -------------------------------------------------------------------------------- /src/dtl/env.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dtl { 6 | 7 | 8 | template 9 | struct env {}; 10 | 11 | template<> 12 | struct env { 13 | 14 | static std::string 15 | get(const std::string name, const std::string default_value = "") { 16 | std::string value = default_value; 17 | if (const char* env = std::getenv(name.c_str())) { 18 | value = std::string(env); 19 | } 20 | return value; 21 | } 22 | 23 | }; 24 | 25 | template<> 26 | struct env<$i32> { 27 | 28 | static $i32 29 | get(const std::string name, const $i32 default_value = 0) { 30 | $i32 value = default_value; 31 | if (const char* env = std::getenv(name.c_str())) { 32 | value = std::stoi(env); 33 | } 34 | return value; 35 | } 36 | 37 | }; 38 | 39 | template<> 40 | struct env<$u32> { 41 | 42 | static $u32 43 | get(const std::string name, const $u32 default_value = 0) { 44 | $u32 value = default_value; 45 | if (const char* env = std::getenv(name.c_str())) { 46 | value = std::stoi(env); 47 | } 48 | return value; 49 | } 50 | 51 | }; 52 | 53 | template<> 54 | struct env<$i64> { 55 | 56 | static $i64 57 | get(const std::string name, const $i64 default_value = 0) { 58 | $i64 value = default_value; 59 | if (const char* env = std::getenv(name.c_str())) { 60 | value = std::stoll(env); 61 | } 62 | return value; 63 | } 64 | 65 | }; 66 | 67 | template<> 68 | struct env<$u64> { 69 | 70 | static $u64 71 | get(const std::string name, const $u64 default_value = 0) { 72 | $u64 value = default_value; 73 | if (const char* env = std::getenv(name.c_str())) { 74 | value = std::stoull(env); 75 | } 76 | return value; 77 | } 78 | 79 | }; 80 | 81 | template<> 82 | struct env<$f64> { 83 | 84 | static $f64 85 | get(const std::string name, const $f64 default_value = 0.0) { 86 | $f64 value = default_value; 87 | if (const char* env = std::getenv(name.c_str())) { 88 | value = std::stod(env); 89 | } 90 | return value; 91 | } 92 | 93 | }; 94 | 95 | } // namespace dtl 96 | -------------------------------------------------------------------------------- /src/dtl/filter/README.md: -------------------------------------------------------------------------------- 1 | # Throughput optimized filters 2 | 3 | ## Implementation 4 | The API is designed for batched queries. -------------------------------------------------------------------------------- /src/dtl/filter/bbf_32.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "filter_base.hpp" 5 | 6 | namespace dtl { 7 | 8 | //===----------------------------------------------------------------------===// 9 | // PImpl wrapper to reduce compilation time. 10 | //===----------------------------------------------------------------------===// 11 | class bbf_32 : public dtl::filter::filter_base { 12 | class impl; 13 | std::unique_ptr pimpl; 14 | 15 | public: 16 | 17 | using key_t = $u32; 18 | using word_t = $u64; // internally, 32-bit words are used 19 | 20 | //===----------------------------------------------------------------------===// 21 | // The API functions. 22 | //===----------------------------------------------------------------------===// 23 | $u1 24 | insert(word_t* __restrict filter_data, key_t key); 25 | 26 | $u1 27 | batch_insert(word_t* __restrict filter_data, const key_t* __restrict keys, u32 key_cnt); 28 | 29 | $u1 30 | contains(const word_t* __restrict filter_data, key_t key) const; 31 | 32 | $u64 33 | batch_contains(const word_t* __restrict filter_data, 34 | const key_t* __restrict keys, u32 key_cnt, 35 | $u32* __restrict match_positions, u32 match_offset) const; 36 | 37 | std::string 38 | name() const; 39 | 40 | std::size_t 41 | size_in_bytes() const; 42 | 43 | std::size_t 44 | size() const; 45 | 46 | static void 47 | calibrate(u64 filter_size_bits = 4ull * 1024 * 8); 48 | 49 | static void 50 | force_unroll_factor(u32 u); 51 | //===----------------------------------------------------------------------===// 52 | 53 | bbf_32(std::size_t m, u32 k, u32 word_cnt_per_block = 1, u32 sector_cnt = 1); 54 | ~bbf_32() override; 55 | bbf_32(bbf_32&&) noexcept; 56 | bbf_32(const bbf_32&) = delete; 57 | bbf_32& operator=(bbf_32&&); 58 | bbf_32& operator=(const bbf_32&) = delete; 59 | 60 | }; 61 | 62 | } // namespace dtl 63 | -------------------------------------------------------------------------------- /src/dtl/filter/bbf_64.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "bbf_64.hpp" 4 | 5 | #include "blocked_bloomfilter/instances/blocked_bloomfilter_logic_u64_instance.hpp" // extern templates to parallelize builds 6 | #include "blocked_bloomfilter/blocked_bloomfilter.hpp" 7 | #include "blocked_bloomfilter/blocked_bloomfilter_tune_impl.hpp" 8 | 9 | namespace dtl { 10 | 11 | 12 | namespace { 13 | static dtl::blocked_bloomfilter_tune_impl<$u64> tuner; 14 | } // anonymous namespace 15 | 16 | 17 | struct bbf_64::impl { 18 | using bbf_t = dtl::blocked_bloomfilter<$u64>; 19 | bbf_t instance; 20 | 21 | impl(const size_t m, u32 k, u32 word_cnt_per_block, u32 sector_cnt) 22 | : instance(m, k, word_cnt_per_block, sector_cnt, tuner) { }; 23 | ~impl() = default; 24 | impl(impl&&) = default; 25 | impl(const impl&) = delete; 26 | impl& operator=(impl&&) = default; 27 | impl& operator=(const impl&) = delete; 28 | }; 29 | 30 | bbf_64::bbf_64(const size_t m, u32 k, u32 word_cnt_per_block, u32 sector_cnt) 31 | : pimpl{ std::make_unique(m, k, word_cnt_per_block, sector_cnt) } {} 32 | bbf_64::bbf_64(bbf_64&&) noexcept = default; 33 | bbf_64::~bbf_64() = default; 34 | bbf_64& bbf_64::operator=(bbf_64&&) = default; 35 | 36 | $u1 37 | bbf_64::insert(bbf_64::word_t* __restrict filter_data, u32 key) { 38 | pimpl->instance.insert(filter_data, key); 39 | return true; // inserts never fail 40 | } 41 | 42 | $u1 43 | bbf_64::batch_insert(bbf_64::word_t* __restrict filter_data, u32* __restrict keys, u32 key_cnt) { 44 | pimpl->instance.batch_insert(filter_data, keys, key_cnt); 45 | return true; // inserts never fail 46 | } 47 | 48 | $u1 49 | bbf_64::contains(const bbf_64::word_t* __restrict filter_data, u32 key) const { 50 | return pimpl->instance.contains(filter_data, key); 51 | } 52 | 53 | $u64 54 | bbf_64::batch_contains(const bbf_64::word_t* __restrict filter_data, 55 | u32* __restrict keys, u32 key_cnt, 56 | $u32* __restrict match_positions, u32 match_offset) const { 57 | return pimpl->instance.batch_contains(filter_data, keys, key_cnt, match_positions, match_offset); 58 | } 59 | 60 | void 61 | bbf_64::calibrate(u64 filter_size_bits) { 62 | tuner.tune_unroll_factor(filter_size_bits); 63 | } 64 | 65 | void 66 | bbf_64::force_unroll_factor(u32 u) { 67 | tuner.set_unroll_factor(u); 68 | } 69 | 70 | std::string 71 | bbf_64::name() const { 72 | return pimpl->instance.name(); 73 | } 74 | 75 | std::size_t 76 | bbf_64::size_in_bytes() const { 77 | return pimpl->instance.size_in_bytes(); 78 | } 79 | 80 | std::size_t 81 | bbf_64::size() const { 82 | return pimpl->instance.size(); 83 | } 84 | 85 | } // namespace dtl 86 | -------------------------------------------------------------------------------- /src/dtl/filter/bbf_64.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "filter_base.hpp" 5 | 6 | namespace dtl { 7 | 8 | //===----------------------------------------------------------------------===// 9 | // PImpl wrapper to reduce compilation time. 10 | //===----------------------------------------------------------------------===// 11 | class bbf_64 : public dtl::filter::filter_base { 12 | class impl; 13 | std::unique_ptr pimpl; 14 | 15 | public: 16 | 17 | using key_t = $u32; 18 | using word_t = $u64; 19 | 20 | //===----------------------------------------------------------------------===// 21 | // The API functions. 22 | //===----------------------------------------------------------------------===// 23 | $u1 24 | insert(word_t* __restrict filter_data, key_t key); 25 | 26 | $u1 27 | batch_insert(word_t* __restrict filter_data, const key_t* __restrict keys, u32 key_cnt); 28 | 29 | $u1 30 | contains(const word_t* __restrict filter_data, key_t key) const; 31 | 32 | $u64 33 | batch_contains(const word_t* __restrict filter_data, 34 | const key_t* __restrict keys, u32 key_cnt, 35 | $u32* __restrict match_positions, u32 match_offset) const; 36 | 37 | std::string 38 | name() const; 39 | 40 | std::size_t 41 | size_in_bytes() const; 42 | 43 | std::size_t 44 | size() const; 45 | 46 | static void 47 | calibrate(u64 filter_size_bits = 4ull * 1024 * 8); 48 | 49 | static void 50 | force_unroll_factor(u32 u); 51 | //===----------------------------------------------------------------------===// 52 | 53 | 54 | bbf_64(std::size_t m, u32 k, u32 word_cnt_per_block = 1, u32 sector_cnt = 1); 55 | ~bbf_64() override; 56 | bbf_64(bbf_64&&) noexcept; 57 | bbf_64(const bbf_64&) = delete; 58 | bbf_64& operator=(bbf_64&&); 59 | bbf_64& operator=(const bbf_64&) = delete; 60 | 61 | }; 62 | 63 | } // namespace dtl 64 | -------------------------------------------------------------------------------- /src/dtl/filter/bcf.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "bcf.hpp" 4 | 5 | #include "blocked_cuckoofilter/blocked_cuckoofilter.hpp" 6 | 7 | namespace dtl { 8 | 9 | struct bcf::impl { 10 | using bcf_t = dtl::blocked_cuckoofilter; 11 | bcf_t instance; 12 | 13 | impl(size_t m, u32 block_size_bytes = 64, u32 tag_size_bits = 16, u32 associativity = 4) 14 | : instance(m, block_size_bytes, tag_size_bits, associativity) { }; 15 | ~impl() = default; 16 | impl(impl&&) = default; 17 | impl(const impl&) = delete; 18 | impl& operator=(impl&&) = default; 19 | impl& operator=(const impl&) = delete; 20 | }; 21 | 22 | bcf::bcf(const size_t m, u32 block_size_bytes, u32 tag_size_bits, u32 associativity) 23 | : pimpl{ std::make_unique(m, block_size_bytes, tag_size_bits, associativity) } {} 24 | bcf::bcf(bcf&&) noexcept = default; 25 | bcf::~bcf() = default; 26 | bcf& bcf::operator=(bcf&&) = default; 27 | 28 | $u1 29 | bcf::insert(bcf::word_t* __restrict filter_data, u32 key) { 30 | pimpl->instance.insert(filter_data, key); 31 | return true; // inserts never fail 32 | } 33 | 34 | $u1 35 | bcf::batch_insert(bcf::word_t* __restrict filter_data, u32* __restrict keys, u32 key_cnt) { 36 | pimpl->instance.batch_insert(filter_data, keys, key_cnt); 37 | return true; // inserts never fail 38 | } 39 | 40 | $u1 41 | bcf::contains(const bcf::word_t* __restrict filter_data, u32 key) const { 42 | return pimpl->instance.contains(filter_data, key); 43 | } 44 | 45 | $u64 46 | bcf::batch_contains(const bcf::word_t* __restrict filter_data, 47 | u32* __restrict keys, u32 key_cnt, 48 | $u32* __restrict match_positions, u32 match_offset) const { 49 | return pimpl->instance.batch_contains(filter_data, keys, key_cnt, match_positions, match_offset); 50 | } 51 | 52 | void 53 | bcf::calibrate(u64 filter_size_bits) { 54 | impl::bcf_t::calibrate(filter_size_bits); 55 | } 56 | 57 | void 58 | bcf::force_unroll_factor(u32 u) { 59 | impl::bcf_t::force_unroll_factor(u); 60 | } 61 | 62 | std::string 63 | bcf::name() const { 64 | return pimpl->instance.name(); 65 | } 66 | 67 | std::size_t 68 | bcf::size_in_bytes() const { 69 | return pimpl->instance.size_in_bytes(); 70 | } 71 | 72 | std::size_t 73 | bcf::size() const { 74 | return pimpl->instance.size(); 75 | } 76 | 77 | } // namespace dtl 78 | -------------------------------------------------------------------------------- /src/dtl/filter/bcf.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "filter_base.hpp" 5 | 6 | namespace dtl { 7 | 8 | //===----------------------------------------------------------------------===// 9 | // PImpl wrapper to reduce compilation time. 10 | //===----------------------------------------------------------------------===// 11 | class bcf /*: public dtl::filter::filter_base*/ { 12 | class impl; 13 | std::unique_ptr pimpl; 14 | 15 | public: 16 | 17 | using key_t = $u32; 18 | using word_t = $u32; 19 | 20 | //===----------------------------------------------------------------------===// 21 | // The API functions. 22 | //===----------------------------------------------------------------------===// 23 | $u1 24 | insert(word_t* __restrict filter_data, key_t key); 25 | 26 | $u1 27 | batch_insert(word_t* __restrict filter_data, const key_t* __restrict keys, u32 key_cnt); 28 | 29 | $u1 30 | contains(const word_t* __restrict filter_data, key_t key) const; 31 | 32 | $u64 33 | batch_contains(const word_t* __restrict filter_data, 34 | const key_t* __restrict keys, u32 key_cnt, 35 | $u32* __restrict match_positions, u32 match_offset) const; 36 | 37 | std::string 38 | name() const; 39 | 40 | std::size_t 41 | size_in_bytes() const; 42 | 43 | std::size_t 44 | size() const; 45 | 46 | static void 47 | calibrate(u64 filter_size_bits = 4ull * 1024 * 8); 48 | 49 | static void 50 | force_unroll_factor(u32 u); 51 | 52 | void print(); 53 | 54 | //===----------------------------------------------------------------------===// 55 | 56 | explicit 57 | bcf(size_t m, u32 block_size_bytes = 64, u32 tag_size_bits = 16, u32 associativity = 4); 58 | ~bcf(); 59 | bcf(bcf&&) noexcept; 60 | bcf(const bcf&) = delete; 61 | bcf& operator=(bcf&&); 62 | bcf& operator=(const bcf&) = delete; 63 | 64 | }; 65 | 66 | } // namespace dtl 67 | -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(SOURCE_FILES ${SOURCE_FILES} 3 | block_addressing_logic.hpp 4 | blocked_bloomfilter.hpp 5 | blocked_bloomfilter_batch_dispatch.hpp 6 | blocked_bloomfilter_block_logic.hpp 7 | blocked_bloomfilter_block_logic_sgew.hpp 8 | blocked_bloomfilter_block_logic_sltw.hpp 9 | blocked_bloomfilter_block_logic_zoned.hpp 10 | blocked_bloomfilter_config.hpp 11 | blocked_bloomfilter_logic.hpp 12 | blocked_bloomfilter_tune.hpp 13 | blocked_bloomfilter_tune_impl.hpp 14 | 15 | fpr.hpp 16 | hash_family.hpp 17 | math.hpp 18 | vector_helper.hpp 19 | 20 | zoned_blocked_bloomfilter.hpp 21 | zoned_blocked_bloomfilter_tune_impl.hpp 22 | 23 | PARENT_SCOPE) 24 | -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/blocked_bloomfilter_block_logic.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "blocked_bloomfilter_block_logic_sgew.hpp" // sector_cnt >= word_cnt 4 | #include "blocked_bloomfilter_block_logic_sltw.hpp" // sector_cnt < word_cnt 5 | #include "blocked_bloomfilter_block_logic_zoned.hpp" // sector_cnt == word_cnt + zoning 6 | #include "hash_family.hpp" 7 | 8 | namespace dtl { 9 | 10 | //===----------------------------------------------------------------------===// 11 | // Type switch: 12 | // 'multiword_block' is used iff the number of sectors is greater or equal 13 | // to the number of words per block, 'multisector_block' otherwise. 14 | //===----------------------------------------------------------------------===// 15 | template< 16 | typename key_t, // the key type 17 | typename word_t, // the word type 18 | u32 word_cnt, // the number of words per block 19 | u32 sector_cnt, // the numbers of sectors (must be a power of two and greater or equal to word_cnt)) 20 | u32 k, // the number of bits to set/test 21 | template class hasher, // the hash function family to use 22 | typename hash_value_t, // the hash value type to use 23 | u1 early_out, // allows for branching out during lookups 24 | u32 hash_fn_idx // current hash function index (used for recursion) 25 | > 26 | struct blocked_bloomfilter_block_logic { 27 | 28 | using sgew_t = multiword_block; 30 | 31 | using sltw_t = multisector_block; 33 | 34 | // Refers to the implementation 35 | using type = typename std::conditional= word_cnt, sgew_t, sltw_t>::type; 36 | 37 | }; 38 | //===----------------------------------------------------------------------===// 39 | 40 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/blocked_bloomfilter_config.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include "block_addressing_logic.hpp" 7 | 8 | namespace dtl { 9 | 10 | //===----------------------------------------------------------------------===// 11 | struct blocked_bloomfilter_config { 12 | $u32 k = 8; 13 | $u32 word_size = 4; // [byte] 14 | $u32 word_cnt_per_block = 1; 15 | $u32 sector_cnt = 1; 16 | dtl::block_addressing addr_mode = dtl::block_addressing::POWER_OF_TWO; 17 | $u32 zone_cnt = 1; 18 | 19 | bool 20 | operator<(const blocked_bloomfilter_config& o) const { 21 | return k < o.k 22 | || (k == o.k && word_size < o.word_size) 23 | || (k == o.k && word_size == o.word_size && word_cnt_per_block < o.word_cnt_per_block) 24 | || (k == o.k && word_size == o.word_size && word_cnt_per_block == o.word_cnt_per_block && sector_cnt < o.sector_cnt) 25 | || (k == o.k && word_size == o.word_size && word_cnt_per_block == o.word_cnt_per_block && sector_cnt == o.sector_cnt && addr_mode < o.addr_mode) 26 | || (k == o.k && word_size == o.word_size && word_cnt_per_block == o.word_cnt_per_block && sector_cnt == o.sector_cnt && addr_mode == o.addr_mode && zone_cnt < o.zone_cnt); 27 | } 28 | 29 | bool 30 | operator==(const blocked_bloomfilter_config& o) const { 31 | return k == o.k && word_size == o.word_size && word_cnt_per_block == o.word_cnt_per_block && sector_cnt == o.sector_cnt && addr_mode == o.addr_mode && zone_cnt == o.zone_cnt; 32 | } 33 | 34 | bool 35 | operator!=(const blocked_bloomfilter_config& o) const { 36 | return !(*this == o); 37 | } 38 | 39 | void print(std::ostream& os) const { 40 | std::stringstream str; 41 | str << "bbf" 42 | << ",k=" << k 43 | << ",word_size=" << word_size 44 | << ",word_cnt=" << word_cnt_per_block 45 | << ",sector_cnt=" << sector_cnt 46 | << ",addr=" << (addr_mode == dtl::block_addressing::POWER_OF_TWO ? "pow2" : "magic") 47 | << ",zone_cnt=" << zone_cnt; 48 | os << str.str(); 49 | } 50 | 51 | }; 52 | //===----------------------------------------------------------------------===// 53 | 54 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/blocked_bloomfilter_tune.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "block_addressing_logic.hpp" 10 | #include "blocked_bloomfilter_config.hpp" 11 | 12 | #include "immintrin.h" 13 | 14 | #include "../model/tuning_params.hpp" 15 | 16 | namespace dtl { 17 | 18 | 19 | //===----------------------------------------------------------------------===// 20 | /// Provides tuning parameters to the Bloom filter instance. 21 | struct blocked_bloomfilter_tune { 22 | 23 | /// Sets the SIMD unrolling factor for the given blocked Bloom filter config. 24 | /// Note: unrolling by 0 means -> scalar code (no SIMD) 25 | virtual void 26 | set_unroll_factor(const blocked_bloomfilter_config& config, 27 | u32 unroll_factor) { 28 | throw std::runtime_error("Not supported"); 29 | } 30 | 31 | 32 | /// Returns the SIMD unrolling factor for the given blocked Bloom filter config. 33 | /// Note: unrolling by 0 means -> scalar code (no SIMD) 34 | virtual $u32 35 | get_unroll_factor(const blocked_bloomfilter_config& config) const { 36 | return 1; // default 37 | } 38 | 39 | 40 | /// Determines the best performing SIMD unrolling factor for the given 41 | /// blocked Bloom filter config. 42 | virtual $u32 43 | tune_unroll_factor(const blocked_bloomfilter_config& config, 44 | u64 filter_size_bits) { 45 | throw std::runtime_error("Not supported"); 46 | } 47 | 48 | 49 | /// Determines the best performing SIMD unrolling factor for all valid 50 | /// blocked Bloom filter configs. 51 | virtual void 52 | tune_unroll_factor(u64 filter_size_bits) { 53 | throw std::runtime_error("Not supported"); 54 | } 55 | 56 | }; 57 | //===----------------------------------------------------------------------===// 58 | 59 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/fpr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "blocked_bloomfilter_config.hpp" 6 | #include "math.hpp" 7 | 8 | namespace dtl { 9 | namespace bloomfilter { 10 | 11 | static $f64 12 | fpr(u64 m, 13 | u64 n, 14 | u64 k, 15 | u64 B, /* block size in bits */ 16 | $u64 S = 0, /* sector size in bits */ 17 | u64 z = 1, /* the number of zones */ 18 | u1 self_collisions = true) { 19 | 20 | f64 epsilon = 0.00001; 21 | 22 | if (B == 0) { 23 | // Standard Bloom filter 24 | return fpr(m, n, k); 25 | } 26 | 27 | if (S == 0) { 28 | S = B; // default sector size to block size 29 | } 30 | 31 | if (S == B && z == 1) { 32 | // Blocked Bloom filter 33 | return fpr_blocked(m, n, k, B, self_collisions, epsilon); 34 | } 35 | 36 | if (S < B && z == 1) { 37 | // Sectorized Blocked Bloom filter 38 | return fpr_blocked_sectorized(m, n, k, B, S, self_collisions, epsilon); 39 | } 40 | 41 | if (S < B && z > 1) { 42 | // Zoned Sectorized Blocked Bloom filter 43 | return fpr_zoned(m, n, k, B, S, z, self_collisions, epsilon); 44 | } 45 | 46 | throw std::invalid_argument("Invalid blocked Bloom filter configuration: B=" + std::to_string(B) 47 | + ", S=" + std::to_string(S) 48 | + ", z=" + std::to_string(z)); 49 | } 50 | 51 | 52 | static f64 53 | fpr(u64 m, 54 | u64 n, 55 | const blocked_bloomfilter_config& c, u1 self_collisions = true) { 56 | 57 | auto block_size_bits = c.word_size * 8 * c.word_cnt_per_block; 58 | auto sector_size_bits = block_size_bits / c.sector_cnt; 59 | return fpr(m, n, c.k, block_size_bits, sector_size_bits, c.zone_cnt, self_collisions); 60 | } 61 | 62 | } // namespace filter 63 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_block_logic_instance.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //===----------------------------------------------------------------------===// 4 | // Extern templates to parallelize builds 5 | //===----------------------------------------------------------------------===// 6 | //#include "blocked_bloomfilter_block_logic_u32_w1.hpp" 7 | //#include "blocked_bloomfilter_block_logic_u32_w2.hpp" 8 | //#include "blocked_bloomfilter_block_logic_u32_w4.hpp" 9 | //#include "blocked_bloomfilter_block_logic_u32_w8.hpp" 10 | //#include "blocked_bloomfilter_block_logic_u32_w16.hpp" 11 | //#include "blocked_bloomfilter_block_logic_u64_w1.hpp" 12 | //#include "blocked_bloomfilter_block_logic_u64_w2.hpp" 13 | //#include "blocked_bloomfilter_block_logic_u64_w4.hpp" 14 | //#include "blocked_bloomfilter_block_logic_u64_w8.hpp" 15 | //#include "blocked_bloomfilter_block_logic_u64_w16.hpp" 16 | -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_block_logic_u32_w1.cpp: -------------------------------------------------------------------------------- 1 | #include "blocked_bloomfilter_block_logic_u32_w1.hpp" 2 | #include "dtl/bloomfilter/blocked_bloomfilter_block_logic.hpp" 3 | 4 | namespace dtl { 5 | 6 | template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 1, hasher, $u32, 1>; 7 | template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 2, hasher, $u32, 1>; 8 | template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 3, hasher, $u32, 1>; 9 | template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 4, hasher, $u32, 1>; 10 | template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 5, hasher, $u32, 1>; 11 | template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 6, hasher, $u32, 1>; 12 | template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 7, hasher, $u32, 1>; 13 | template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 8, hasher, $u32, 1>; 14 | template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 9, hasher, $u32, 1>; 15 | template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 10, hasher, $u32, 1>; 16 | template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 11, hasher, $u32, 1>; 17 | template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 12, hasher, $u32, 1>; 18 | template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 13, hasher, $u32, 1>; 19 | template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 14, hasher, $u32, 1>; 20 | template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 15, hasher, $u32, 1>; 21 | template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 16, hasher, $u32, 1>; 22 | 23 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_block_logic_u32_w1.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "dtl/bloomfilter/blocked_bloomfilter_block_logic.hpp" 7 | #include "dtl/bloomfilter/hash_family.hpp" 8 | 9 | namespace dtl { 10 | 11 | extern template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 1, hasher, $u32, 1>; 12 | //extern template dtl::vec<$u32,8>::mask_t blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 1, hasher, $u32, 1>::contains<8ull>(dtl::vec<$u32,8>&,u32*,const dtl::vec<$u32,8>&); 13 | extern template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 2, hasher, $u32, 1>; 14 | extern template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 3, hasher, $u32, 1>; 15 | extern template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 4, hasher, $u32, 1>; 16 | extern template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 5, hasher, $u32, 1>; 17 | extern template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 6, hasher, $u32, 1>; 18 | extern template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 7, hasher, $u32, 1>; 19 | extern template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 8, hasher, $u32, 1>; 20 | extern template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 9, hasher, $u32, 1>; 21 | extern template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 10, hasher, $u32, 1>; 22 | extern template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 11, hasher, $u32, 1>; 23 | extern template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 12, hasher, $u32, 1>; 24 | extern template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 13, hasher, $u32, 1>; 25 | extern template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 14, hasher, $u32, 1>; 26 | extern template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 15, hasher, $u32, 1>; 27 | extern template struct blocked_bloomfilter_block_logic<$u32, $u32, 1, 1, 16, hasher, $u32, 1>; 28 | 29 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_block_logic_u64_w1.cpp: -------------------------------------------------------------------------------- 1 | #include "blocked_bloomfilter_block_logic_u64_w1.hpp" 2 | #include "dtl/bloomfilter/blocked_bloomfilter_block_logic.hpp" 3 | 4 | namespace dtl { 5 | 6 | template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 1, hasher, $u32, 1>; 7 | template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 2, hasher, $u32, 1>; 8 | template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 3, hasher, $u32, 1>; 9 | template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 4, hasher, $u32, 1>; 10 | template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 5, hasher, $u32, 1>; 11 | template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 6, hasher, $u32, 1>; 12 | template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 7, hasher, $u32, 1>; 13 | template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 8, hasher, $u32, 1>; 14 | template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 9, hasher, $u32, 1>; 15 | template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 10, hasher, $u32, 1>; 16 | template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 11, hasher, $u32, 1>; 17 | template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 12, hasher, $u32, 1>; 18 | template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 13, hasher, $u32, 1>; 19 | template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 14, hasher, $u32, 1>; 20 | template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 15, hasher, $u32, 1>; 21 | template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 16, hasher, $u32, 1>; 22 | 23 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_block_logic_u64_w1.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "dtl/bloomfilter/blocked_bloomfilter_block_logic.hpp" 6 | #include "dtl/bloomfilter/hash_family.hpp" 7 | 8 | namespace dtl { 9 | 10 | extern template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 1, hasher, $u32, 1>; 11 | extern template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 2, hasher, $u32, 1>; 12 | extern template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 3, hasher, $u32, 1>; 13 | extern template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 4, hasher, $u32, 1>; 14 | extern template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 5, hasher, $u32, 1>; 15 | extern template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 6, hasher, $u32, 1>; 16 | extern template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 7, hasher, $u32, 1>; 17 | extern template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 8, hasher, $u32, 1>; 18 | extern template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 9, hasher, $u32, 1>; 19 | extern template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 10, hasher, $u32, 1>; 20 | extern template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 11, hasher, $u32, 1>; 21 | extern template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 12, hasher, $u32, 1>; 22 | extern template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 13, hasher, $u32, 1>; 23 | extern template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 14, hasher, $u32, 1>; 24 | extern template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 15, hasher, $u32, 1>; 25 | extern template struct blocked_bloomfilter_block_logic<$u32, $u64, 1, 1, 16, hasher, $u32, 1>; 26 | 27 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_instance.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "blocked_bloomfilter_logic_u64_instance.hpp" 8 | 9 | namespace dtl { 10 | 11 | //===----------------------------------------------------------------------===// 12 | // Externalize templates to parallelize builds. 13 | //===----------------------------------------------------------------------===// 14 | extern template struct blocked_bloomfilter<$u32>; 15 | 16 | } // namespace dtl 17 | -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u32_w1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "blocked_bloomfilter_logic_instance.inc" 5 | 6 | namespace dtl { 7 | 8 | GENERATE($u32, 1, 1, 1) 9 | GENERATE($u32, 1, 1, 2) 10 | GENERATE($u32, 1, 1, 3) 11 | GENERATE($u32, 1, 1, 4) 12 | GENERATE($u32, 1, 1, 5) 13 | GENERATE($u32, 1, 1, 6) 14 | GENERATE($u32, 1, 1, 7) 15 | GENERATE($u32, 1, 1, 8) 16 | GENERATE($u32, 1, 1, 9) 17 | GENERATE($u32, 1, 1, 10) 18 | GENERATE($u32, 1, 1, 11) 19 | GENERATE($u32, 1, 1, 12) 20 | GENERATE($u32, 1, 1, 13) 21 | GENERATE($u32, 1, 1, 14) 22 | GENERATE($u32, 1, 1, 15) 23 | GENERATE($u32, 1, 1, 16) 24 | GENERATE($u32, 1, 2, 2) 25 | GENERATE($u32, 1, 2, 4) 26 | GENERATE($u32, 1, 2, 6) 27 | GENERATE($u32, 1, 2, 8) 28 | GENERATE($u32, 1, 2, 10) 29 | GENERATE($u32, 1, 2, 12) 30 | GENERATE($u32, 1, 2, 14) 31 | GENERATE($u32, 1, 2, 16) 32 | GENERATE($u32, 1, 4, 4) 33 | GENERATE($u32, 1, 4, 8) 34 | GENERATE($u32, 1, 4, 12) 35 | GENERATE($u32, 1, 4, 16) 36 | 37 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u32_w1.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | 11 | GENERATE_EXTERN($u32, 1, 1, 1) 12 | GENERATE_EXTERN($u32, 1, 1, 2) 13 | GENERATE_EXTERN($u32, 1, 1, 3) 14 | GENERATE_EXTERN($u32, 1, 1, 4) 15 | GENERATE_EXTERN($u32, 1, 1, 5) 16 | GENERATE_EXTERN($u32, 1, 1, 6) 17 | GENERATE_EXTERN($u32, 1, 1, 7) 18 | GENERATE_EXTERN($u32, 1, 1, 8) 19 | GENERATE_EXTERN($u32, 1, 1, 9) 20 | GENERATE_EXTERN($u32, 1, 1, 10) 21 | GENERATE_EXTERN($u32, 1, 1, 11) 22 | GENERATE_EXTERN($u32, 1, 1, 12) 23 | GENERATE_EXTERN($u32, 1, 1, 13) 24 | GENERATE_EXTERN($u32, 1, 1, 14) 25 | GENERATE_EXTERN($u32, 1, 1, 15) 26 | GENERATE_EXTERN($u32, 1, 1, 16) 27 | GENERATE_EXTERN($u32, 1, 2, 2) 28 | GENERATE_EXTERN($u32, 1, 2, 4) 29 | GENERATE_EXTERN($u32, 1, 2, 6) 30 | GENERATE_EXTERN($u32, 1, 2, 8) 31 | GENERATE_EXTERN($u32, 1, 2, 10) 32 | GENERATE_EXTERN($u32, 1, 2, 12) 33 | GENERATE_EXTERN($u32, 1, 2, 14) 34 | GENERATE_EXTERN($u32, 1, 2, 16) 35 | GENERATE_EXTERN($u32, 1, 4, 4) 36 | GENERATE_EXTERN($u32, 1, 4, 8) 37 | GENERATE_EXTERN($u32, 1, 4, 12) 38 | GENERATE_EXTERN($u32, 1, 4, 16) 39 | 40 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u32_w16.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "blocked_bloomfilter_logic_instance.inc" 5 | 6 | namespace dtl { 7 | 8 | GENERATE($u32, 16, 1, 1) 9 | GENERATE($u32, 16, 1, 2) 10 | GENERATE($u32, 16, 1, 3) 11 | GENERATE($u32, 16, 1, 4) 12 | GENERATE($u32, 16, 1, 5) 13 | GENERATE($u32, 16, 1, 6) 14 | GENERATE($u32, 16, 1, 7) 15 | GENERATE($u32, 16, 1, 8) 16 | GENERATE($u32, 16, 1, 9) 17 | GENERATE($u32, 16, 1, 10) 18 | GENERATE($u32, 16, 1, 11) 19 | GENERATE($u32, 16, 1, 12) 20 | GENERATE($u32, 16, 1, 13) 21 | GENERATE($u32, 16, 1, 14) 22 | GENERATE($u32, 16, 1, 15) 23 | GENERATE($u32, 16, 1, 16) 24 | GENERATE($u32, 16, 2, 2) 25 | GENERATE($u32, 16, 2, 4) 26 | GENERATE($u32, 16, 2, 6) 27 | GENERATE($u32, 16, 2, 8) 28 | GENERATE($u32, 16, 2, 10) 29 | GENERATE($u32, 16, 2, 12) 30 | GENERATE($u32, 16, 2, 14) 31 | GENERATE($u32, 16, 2, 16) 32 | GENERATE($u32, 16, 4, 4) 33 | GENERATE($u32, 16, 4, 8) 34 | GENERATE($u32, 16, 4, 12) 35 | GENERATE($u32, 16, 4, 16) 36 | GENERATE($u32, 16, 8, 8) 37 | GENERATE($u32, 16, 8, 16) 38 | GENERATE($u32, 16,16, 16) 39 | 40 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u32_w16.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | 11 | GENERATE_EXTERN($u32, 16, 1, 1) 12 | GENERATE_EXTERN($u32, 16, 1, 2) 13 | GENERATE_EXTERN($u32, 16, 1, 3) 14 | GENERATE_EXTERN($u32, 16, 1, 4) 15 | GENERATE_EXTERN($u32, 16, 1, 5) 16 | GENERATE_EXTERN($u32, 16, 1, 6) 17 | GENERATE_EXTERN($u32, 16, 1, 7) 18 | GENERATE_EXTERN($u32, 16, 1, 8) 19 | GENERATE_EXTERN($u32, 16, 1, 9) 20 | GENERATE_EXTERN($u32, 16, 1, 10) 21 | GENERATE_EXTERN($u32, 16, 1, 11) 22 | GENERATE_EXTERN($u32, 16, 1, 12) 23 | GENERATE_EXTERN($u32, 16, 1, 13) 24 | GENERATE_EXTERN($u32, 16, 1, 14) 25 | GENERATE_EXTERN($u32, 16, 1, 15) 26 | GENERATE_EXTERN($u32, 16, 1, 16) 27 | GENERATE_EXTERN($u32, 16, 2, 2) 28 | GENERATE_EXTERN($u32, 16, 2, 4) 29 | GENERATE_EXTERN($u32, 16, 2, 6) 30 | GENERATE_EXTERN($u32, 16, 2, 8) 31 | GENERATE_EXTERN($u32, 16, 2, 10) 32 | GENERATE_EXTERN($u32, 16, 2, 12) 33 | GENERATE_EXTERN($u32, 16, 2, 14) 34 | GENERATE_EXTERN($u32, 16, 2, 16) 35 | GENERATE_EXTERN($u32, 16, 4, 4) 36 | GENERATE_EXTERN($u32, 16, 4, 8) 37 | GENERATE_EXTERN($u32, 16, 4, 12) 38 | GENERATE_EXTERN($u32, 16, 4, 16) 39 | GENERATE_EXTERN($u32, 16, 8, 8) 40 | GENERATE_EXTERN($u32, 16, 8, 16) 41 | GENERATE_EXTERN($u32, 16,16, 16) 42 | 43 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u32_w2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "blocked_bloomfilter_logic_instance.inc" 5 | 6 | namespace dtl { 7 | 8 | GENERATE($u32, 2, 1, 1) 9 | GENERATE($u32, 2, 1, 2) 10 | GENERATE($u32, 2, 1, 3) 11 | GENERATE($u32, 2, 1, 4) 12 | GENERATE($u32, 2, 1, 5) 13 | GENERATE($u32, 2, 1, 6) 14 | GENERATE($u32, 2, 1, 7) 15 | GENERATE($u32, 2, 1, 8) 16 | GENERATE($u32, 2, 1, 9) 17 | GENERATE($u32, 2, 1, 10) 18 | GENERATE($u32, 2, 1, 11) 19 | GENERATE($u32, 2, 1, 12) 20 | GENERATE($u32, 2, 1, 13) 21 | GENERATE($u32, 2, 1, 14) 22 | GENERATE($u32, 2, 1, 15) 23 | GENERATE($u32, 2, 1, 16) 24 | GENERATE($u32, 2, 2, 2) 25 | GENERATE($u32, 2, 2, 4) 26 | GENERATE($u32, 2, 2, 6) 27 | GENERATE($u32, 2, 2, 8) 28 | GENERATE($u32, 2, 2, 10) 29 | GENERATE($u32, 2, 2, 12) 30 | GENERATE($u32, 2, 2, 14) 31 | GENERATE($u32, 2, 2, 16) 32 | GENERATE($u32, 2, 4, 4) 33 | GENERATE($u32, 2, 4, 8) 34 | GENERATE($u32, 2, 4, 12) 35 | GENERATE($u32, 2, 4, 16) 36 | GENERATE($u32, 2, 8, 8) 37 | GENERATE($u32, 2, 8, 16) 38 | 39 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u32_w2.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | 11 | GENERATE_EXTERN($u32, 2, 1, 1) 12 | GENERATE_EXTERN($u32, 2, 1, 2) 13 | GENERATE_EXTERN($u32, 2, 1, 3) 14 | GENERATE_EXTERN($u32, 2, 1, 4) 15 | GENERATE_EXTERN($u32, 2, 1, 5) 16 | GENERATE_EXTERN($u32, 2, 1, 6) 17 | GENERATE_EXTERN($u32, 2, 1, 7) 18 | GENERATE_EXTERN($u32, 2, 1, 8) 19 | GENERATE_EXTERN($u32, 2, 1, 9) 20 | GENERATE_EXTERN($u32, 2, 1, 10) 21 | GENERATE_EXTERN($u32, 2, 1, 11) 22 | GENERATE_EXTERN($u32, 2, 1, 12) 23 | GENERATE_EXTERN($u32, 2, 1, 13) 24 | GENERATE_EXTERN($u32, 2, 1, 14) 25 | GENERATE_EXTERN($u32, 2, 1, 15) 26 | GENERATE_EXTERN($u32, 2, 1, 16) 27 | GENERATE_EXTERN($u32, 2, 2, 2) 28 | GENERATE_EXTERN($u32, 2, 2, 4) 29 | GENERATE_EXTERN($u32, 2, 2, 6) 30 | GENERATE_EXTERN($u32, 2, 2, 8) 31 | GENERATE_EXTERN($u32, 2, 2, 10) 32 | GENERATE_EXTERN($u32, 2, 2, 12) 33 | GENERATE_EXTERN($u32, 2, 2, 14) 34 | GENERATE_EXTERN($u32, 2, 2, 16) 35 | GENERATE_EXTERN($u32, 2, 4, 4) 36 | GENERATE_EXTERN($u32, 2, 4, 8) 37 | GENERATE_EXTERN($u32, 2, 4, 12) 38 | GENERATE_EXTERN($u32, 2, 4, 16) 39 | GENERATE_EXTERN($u32, 2, 8, 8) 40 | GENERATE_EXTERN($u32, 2, 8, 16) 41 | 42 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u32_w4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "blocked_bloomfilter_logic_instance.inc" 5 | 6 | namespace dtl { 7 | 8 | GENERATE($u32, 4, 1, 1) 9 | GENERATE($u32, 4, 1, 2) 10 | GENERATE($u32, 4, 1, 3) 11 | GENERATE($u32, 4, 1, 4) 12 | GENERATE($u32, 4, 1, 5) 13 | GENERATE($u32, 4, 1, 6) 14 | GENERATE($u32, 4, 1, 7) 15 | GENERATE($u32, 4, 1, 8) 16 | GENERATE($u32, 4, 1, 9) 17 | GENERATE($u32, 4, 1, 10) 18 | GENERATE($u32, 4, 1, 11) 19 | GENERATE($u32, 4, 1, 12) 20 | GENERATE($u32, 4, 1, 13) 21 | GENERATE($u32, 4, 1, 14) 22 | GENERATE($u32, 4, 1, 15) 23 | GENERATE($u32, 4, 1, 16) 24 | GENERATE($u32, 4, 2, 2) 25 | GENERATE($u32, 4, 2, 4) 26 | GENERATE($u32, 4, 2, 6) 27 | GENERATE($u32, 4, 2, 8) 28 | GENERATE($u32, 4, 2, 10) 29 | GENERATE($u32, 4, 2, 12) 30 | GENERATE($u32, 4, 2, 14) 31 | GENERATE($u32, 4, 2, 16) 32 | GENERATE($u32, 4, 4, 4) 33 | GENERATE($u32, 4, 4, 8) 34 | GENERATE($u32, 4, 4, 12) 35 | GENERATE($u32, 4, 4, 16) 36 | GENERATE($u32, 4, 8, 8) 37 | GENERATE($u32, 4, 8, 16) 38 | GENERATE($u32, 4,16, 16) 39 | 40 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u32_w4.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | 11 | GENERATE_EXTERN($u32, 4, 1, 1) 12 | GENERATE_EXTERN($u32, 4, 1, 2) 13 | GENERATE_EXTERN($u32, 4, 1, 3) 14 | GENERATE_EXTERN($u32, 4, 1, 4) 15 | GENERATE_EXTERN($u32, 4, 1, 5) 16 | GENERATE_EXTERN($u32, 4, 1, 6) 17 | GENERATE_EXTERN($u32, 4, 1, 7) 18 | GENERATE_EXTERN($u32, 4, 1, 8) 19 | GENERATE_EXTERN($u32, 4, 1, 9) 20 | GENERATE_EXTERN($u32, 4, 1, 10) 21 | GENERATE_EXTERN($u32, 4, 1, 11) 22 | GENERATE_EXTERN($u32, 4, 1, 12) 23 | GENERATE_EXTERN($u32, 4, 1, 13) 24 | GENERATE_EXTERN($u32, 4, 1, 14) 25 | GENERATE_EXTERN($u32, 4, 1, 15) 26 | GENERATE_EXTERN($u32, 4, 1, 16) 27 | GENERATE_EXTERN($u32, 4, 2, 2) 28 | GENERATE_EXTERN($u32, 4, 2, 4) 29 | GENERATE_EXTERN($u32, 4, 2, 6) 30 | GENERATE_EXTERN($u32, 4, 2, 8) 31 | GENERATE_EXTERN($u32, 4, 2, 10) 32 | GENERATE_EXTERN($u32, 4, 2, 12) 33 | GENERATE_EXTERN($u32, 4, 2, 14) 34 | GENERATE_EXTERN($u32, 4, 2, 16) 35 | GENERATE_EXTERN($u32, 4, 4, 4) 36 | GENERATE_EXTERN($u32, 4, 4, 8) 37 | GENERATE_EXTERN($u32, 4, 4, 12) 38 | GENERATE_EXTERN($u32, 4, 4, 16) 39 | GENERATE_EXTERN($u32, 4, 8, 8) 40 | GENERATE_EXTERN($u32, 4, 8, 16) 41 | GENERATE_EXTERN($u32, 4,16, 16) 42 | 43 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u32_w8.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "blocked_bloomfilter_logic_instance.inc" 5 | 6 | namespace dtl { 7 | 8 | GENERATE($u32, 8, 1, 1) 9 | GENERATE($u32, 8, 1, 2) 10 | GENERATE($u32, 8, 1, 3) 11 | GENERATE($u32, 8, 1, 4) 12 | GENERATE($u32, 8, 1, 5) 13 | GENERATE($u32, 8, 1, 6) 14 | GENERATE($u32, 8, 1, 7) 15 | GENERATE($u32, 8, 1, 8) 16 | GENERATE($u32, 8, 1, 9) 17 | GENERATE($u32, 8, 1, 10) 18 | GENERATE($u32, 8, 1, 11) 19 | GENERATE($u32, 8, 1, 12) 20 | GENERATE($u32, 8, 1, 13) 21 | GENERATE($u32, 8, 1, 14) 22 | GENERATE($u32, 8, 1, 15) 23 | GENERATE($u32, 8, 1, 16) 24 | GENERATE($u32, 8, 2, 2) 25 | GENERATE($u32, 8, 2, 4) 26 | GENERATE($u32, 8, 2, 6) 27 | GENERATE($u32, 8, 2, 8) 28 | GENERATE($u32, 8, 2, 10) 29 | GENERATE($u32, 8, 2, 12) 30 | GENERATE($u32, 8, 2, 14) 31 | GENERATE($u32, 8, 2, 16) 32 | GENERATE($u32, 8, 4, 4) 33 | GENERATE($u32, 8, 4, 8) 34 | GENERATE($u32, 8, 4, 12) 35 | GENERATE($u32, 8, 4, 16) 36 | GENERATE($u32, 8, 8, 8) 37 | GENERATE($u32, 8, 8, 16) 38 | GENERATE($u32, 8,16, 16) 39 | 40 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u32_w8.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | 11 | GENERATE_EXTERN($u32, 8, 1, 1) 12 | GENERATE_EXTERN($u32, 8, 1, 2) 13 | GENERATE_EXTERN($u32, 8, 1, 3) 14 | GENERATE_EXTERN($u32, 8, 1, 4) 15 | GENERATE_EXTERN($u32, 8, 1, 5) 16 | GENERATE_EXTERN($u32, 8, 1, 6) 17 | GENERATE_EXTERN($u32, 8, 1, 7) 18 | GENERATE_EXTERN($u32, 8, 1, 8) 19 | GENERATE_EXTERN($u32, 8, 1, 9) 20 | GENERATE_EXTERN($u32, 8, 1, 10) 21 | GENERATE_EXTERN($u32, 8, 1, 11) 22 | GENERATE_EXTERN($u32, 8, 1, 12) 23 | GENERATE_EXTERN($u32, 8, 1, 13) 24 | GENERATE_EXTERN($u32, 8, 1, 14) 25 | GENERATE_EXTERN($u32, 8, 1, 15) 26 | GENERATE_EXTERN($u32, 8, 1, 16) 27 | GENERATE_EXTERN($u32, 8, 2, 2) 28 | GENERATE_EXTERN($u32, 8, 2, 4) 29 | GENERATE_EXTERN($u32, 8, 2, 6) 30 | GENERATE_EXTERN($u32, 8, 2, 8) 31 | GENERATE_EXTERN($u32, 8, 2, 10) 32 | GENERATE_EXTERN($u32, 8, 2, 12) 33 | GENERATE_EXTERN($u32, 8, 2, 14) 34 | GENERATE_EXTERN($u32, 8, 2, 16) 35 | GENERATE_EXTERN($u32, 8, 4, 4) 36 | GENERATE_EXTERN($u32, 8, 4, 8) 37 | GENERATE_EXTERN($u32, 8, 4, 12) 38 | GENERATE_EXTERN($u32, 8, 4, 16) 39 | GENERATE_EXTERN($u32, 8, 8, 8) 40 | GENERATE_EXTERN($u32, 8, 8, 16) 41 | GENERATE_EXTERN($u32, 8,16, 16) 42 | 43 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u64_w1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "blocked_bloomfilter_logic_instance.inc" 5 | 6 | namespace dtl { 7 | 8 | GENERATE($u64, 1, 1, 1) 9 | GENERATE($u64, 1, 1, 2) 10 | GENERATE($u64, 1, 1, 3) 11 | GENERATE($u64, 1, 1, 4) 12 | GENERATE($u64, 1, 1, 5) 13 | GENERATE($u64, 1, 1, 6) 14 | GENERATE($u64, 1, 1, 7) 15 | GENERATE($u64, 1, 1, 8) 16 | GENERATE($u64, 1, 1, 9) 17 | GENERATE($u64, 1, 1, 10) 18 | GENERATE($u64, 1, 1, 11) 19 | GENERATE($u64, 1, 1, 12) 20 | GENERATE($u64, 1, 1, 13) 21 | GENERATE($u64, 1, 1, 14) 22 | GENERATE($u64, 1, 1, 15) 23 | GENERATE($u64, 1, 1, 16) 24 | GENERATE($u64, 1, 2, 2) 25 | GENERATE($u64, 1, 2, 4) 26 | GENERATE($u64, 1, 2, 6) 27 | GENERATE($u64, 1, 2, 8) 28 | GENERATE($u64, 1, 2, 10) 29 | GENERATE($u64, 1, 2, 12) 30 | GENERATE($u64, 1, 2, 14) 31 | GENERATE($u64, 1, 2, 16) 32 | GENERATE($u64, 1, 4, 4) 33 | GENERATE($u64, 1, 4, 8) 34 | GENERATE($u64, 1, 4, 12) 35 | GENERATE($u64, 1, 4, 16) 36 | GENERATE($u64, 1, 8, 8) 37 | GENERATE($u64, 1, 8, 16) 38 | 39 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u64_w1.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | 11 | GENERATE_EXTERN($u64, 1, 1, 1) 12 | GENERATE_EXTERN($u64, 1, 1, 2) 13 | GENERATE_EXTERN($u64, 1, 1, 3) 14 | GENERATE_EXTERN($u64, 1, 1, 4) 15 | GENERATE_EXTERN($u64, 1, 1, 5) 16 | GENERATE_EXTERN($u64, 1, 1, 6) 17 | GENERATE_EXTERN($u64, 1, 1, 7) 18 | GENERATE_EXTERN($u64, 1, 1, 8) 19 | GENERATE_EXTERN($u64, 1, 1, 9) 20 | GENERATE_EXTERN($u64, 1, 1, 10) 21 | GENERATE_EXTERN($u64, 1, 1, 11) 22 | GENERATE_EXTERN($u64, 1, 1, 12) 23 | GENERATE_EXTERN($u64, 1, 1, 13) 24 | GENERATE_EXTERN($u64, 1, 1, 14) 25 | GENERATE_EXTERN($u64, 1, 1, 15) 26 | GENERATE_EXTERN($u64, 1, 1, 16) 27 | GENERATE_EXTERN($u64, 1, 2, 2) 28 | GENERATE_EXTERN($u64, 1, 2, 4) 29 | GENERATE_EXTERN($u64, 1, 2, 6) 30 | GENERATE_EXTERN($u64, 1, 2, 8) 31 | GENERATE_EXTERN($u64, 1, 2, 10) 32 | GENERATE_EXTERN($u64, 1, 2, 12) 33 | GENERATE_EXTERN($u64, 1, 2, 14) 34 | GENERATE_EXTERN($u64, 1, 2, 16) 35 | GENERATE_EXTERN($u64, 1, 4, 4) 36 | GENERATE_EXTERN($u64, 1, 4, 8) 37 | GENERATE_EXTERN($u64, 1, 4, 12) 38 | GENERATE_EXTERN($u64, 1, 4, 16) 39 | GENERATE_EXTERN($u64, 1, 8, 8) 40 | GENERATE_EXTERN($u64, 1, 8, 16) 41 | 42 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u64_w16.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "blocked_bloomfilter_logic_instance.inc" 5 | 6 | namespace dtl { 7 | 8 | GENERATE($u64, 16, 1, 1) 9 | GENERATE($u64, 16, 1, 2) 10 | GENERATE($u64, 16, 1, 3) 11 | GENERATE($u64, 16, 1, 4) 12 | GENERATE($u64, 16, 1, 5) 13 | GENERATE($u64, 16, 1, 6) 14 | GENERATE($u64, 16, 1, 7) 15 | GENERATE($u64, 16, 1, 8) 16 | GENERATE($u64, 16, 1, 9) 17 | GENERATE($u64, 16, 1, 10) 18 | GENERATE($u64, 16, 1, 11) 19 | GENERATE($u64, 16, 1, 12) 20 | GENERATE($u64, 16, 1, 13) 21 | GENERATE($u64, 16, 1, 14) 22 | GENERATE($u64, 16, 1, 15) 23 | GENERATE($u64, 16, 1, 16) 24 | GENERATE($u64, 16, 2, 2) 25 | GENERATE($u64, 16, 2, 4) 26 | GENERATE($u64, 16, 2, 6) 27 | GENERATE($u64, 16, 2, 8) 28 | GENERATE($u64, 16, 2, 10) 29 | GENERATE($u64, 16, 2, 12) 30 | GENERATE($u64, 16, 2, 14) 31 | GENERATE($u64, 16, 2, 16) 32 | GENERATE($u64, 16, 4, 4) 33 | GENERATE($u64, 16, 4, 8) 34 | GENERATE($u64, 16, 4, 12) 35 | GENERATE($u64, 16, 4, 16) 36 | GENERATE($u64, 16, 8, 8) 37 | GENERATE($u64, 16, 8, 16) 38 | GENERATE($u64, 16,16, 16) 39 | 40 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u64_w16.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | 11 | GENERATE_EXTERN($u64, 16, 1, 1) 12 | GENERATE_EXTERN($u64, 16, 1, 2) 13 | GENERATE_EXTERN($u64, 16, 1, 3) 14 | GENERATE_EXTERN($u64, 16, 1, 4) 15 | GENERATE_EXTERN($u64, 16, 1, 5) 16 | GENERATE_EXTERN($u64, 16, 1, 6) 17 | GENERATE_EXTERN($u64, 16, 1, 7) 18 | GENERATE_EXTERN($u64, 16, 1, 8) 19 | GENERATE_EXTERN($u64, 16, 1, 9) 20 | GENERATE_EXTERN($u64, 16, 1, 10) 21 | GENERATE_EXTERN($u64, 16, 1, 11) 22 | GENERATE_EXTERN($u64, 16, 1, 12) 23 | GENERATE_EXTERN($u64, 16, 1, 13) 24 | GENERATE_EXTERN($u64, 16, 1, 14) 25 | GENERATE_EXTERN($u64, 16, 1, 15) 26 | GENERATE_EXTERN($u64, 16, 1, 16) 27 | GENERATE_EXTERN($u64, 16, 2, 2) 28 | GENERATE_EXTERN($u64, 16, 2, 4) 29 | GENERATE_EXTERN($u64, 16, 2, 6) 30 | GENERATE_EXTERN($u64, 16, 2, 8) 31 | GENERATE_EXTERN($u64, 16, 2, 10) 32 | GENERATE_EXTERN($u64, 16, 2, 12) 33 | GENERATE_EXTERN($u64, 16, 2, 14) 34 | GENERATE_EXTERN($u64, 16, 2, 16) 35 | GENERATE_EXTERN($u64, 16, 4, 4) 36 | GENERATE_EXTERN($u64, 16, 4, 8) 37 | GENERATE_EXTERN($u64, 16, 4, 12) 38 | GENERATE_EXTERN($u64, 16, 4, 16) 39 | GENERATE_EXTERN($u64, 16, 8, 8) 40 | GENERATE_EXTERN($u64, 16, 8, 16) 41 | GENERATE_EXTERN($u64, 16,16, 16) 42 | 43 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u64_w2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "blocked_bloomfilter_logic_instance.inc" 5 | 6 | namespace dtl { 7 | 8 | GENERATE($u64, 2, 1, 1) 9 | GENERATE($u64, 2, 1, 2) 10 | GENERATE($u64, 2, 1, 3) 11 | GENERATE($u64, 2, 1, 4) 12 | GENERATE($u64, 2, 1, 5) 13 | GENERATE($u64, 2, 1, 6) 14 | GENERATE($u64, 2, 1, 7) 15 | GENERATE($u64, 2, 1, 8) 16 | GENERATE($u64, 2, 1, 9) 17 | GENERATE($u64, 2, 1, 10) 18 | GENERATE($u64, 2, 1, 11) 19 | GENERATE($u64, 2, 1, 12) 20 | GENERATE($u64, 2, 1, 13) 21 | GENERATE($u64, 2, 1, 14) 22 | GENERATE($u64, 2, 1, 15) 23 | GENERATE($u64, 2, 1, 16) 24 | GENERATE($u64, 2, 2, 2) 25 | GENERATE($u64, 2, 2, 4) 26 | GENERATE($u64, 2, 2, 6) 27 | GENERATE($u64, 2, 2, 8) 28 | GENERATE($u64, 2, 2, 10) 29 | GENERATE($u64, 2, 2, 12) 30 | GENERATE($u64, 2, 2, 14) 31 | GENERATE($u64, 2, 2, 16) 32 | GENERATE($u64, 2, 4, 4) 33 | GENERATE($u64, 2, 4, 8) 34 | GENERATE($u64, 2, 4, 12) 35 | GENERATE($u64, 2, 4, 16) 36 | GENERATE($u64, 2, 8, 8) 37 | GENERATE($u64, 2, 8, 16) 38 | GENERATE($u64, 2,16, 16) 39 | 40 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u64_w2.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | 11 | GENERATE_EXTERN($u64, 2, 1, 1) 12 | GENERATE_EXTERN($u64, 2, 1, 2) 13 | GENERATE_EXTERN($u64, 2, 1, 3) 14 | GENERATE_EXTERN($u64, 2, 1, 4) 15 | GENERATE_EXTERN($u64, 2, 1, 5) 16 | GENERATE_EXTERN($u64, 2, 1, 6) 17 | GENERATE_EXTERN($u64, 2, 1, 7) 18 | GENERATE_EXTERN($u64, 2, 1, 8) 19 | GENERATE_EXTERN($u64, 2, 1, 9) 20 | GENERATE_EXTERN($u64, 2, 1, 10) 21 | GENERATE_EXTERN($u64, 2, 1, 11) 22 | GENERATE_EXTERN($u64, 2, 1, 12) 23 | GENERATE_EXTERN($u64, 2, 1, 13) 24 | GENERATE_EXTERN($u64, 2, 1, 14) 25 | GENERATE_EXTERN($u64, 2, 1, 15) 26 | GENERATE_EXTERN($u64, 2, 1, 16) 27 | GENERATE_EXTERN($u64, 2, 2, 2) 28 | GENERATE_EXTERN($u64, 2, 2, 4) 29 | GENERATE_EXTERN($u64, 2, 2, 6) 30 | GENERATE_EXTERN($u64, 2, 2, 8) 31 | GENERATE_EXTERN($u64, 2, 2, 10) 32 | GENERATE_EXTERN($u64, 2, 2, 12) 33 | GENERATE_EXTERN($u64, 2, 2, 14) 34 | GENERATE_EXTERN($u64, 2, 2, 16) 35 | GENERATE_EXTERN($u64, 2, 4, 4) 36 | GENERATE_EXTERN($u64, 2, 4, 8) 37 | GENERATE_EXTERN($u64, 2, 4, 12) 38 | GENERATE_EXTERN($u64, 2, 4, 16) 39 | GENERATE_EXTERN($u64, 2, 8, 8) 40 | GENERATE_EXTERN($u64, 2, 8, 16) 41 | GENERATE_EXTERN($u64, 2,16, 16) 42 | 43 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u64_w4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "blocked_bloomfilter_logic_instance.inc" 5 | 6 | namespace dtl { 7 | 8 | GENERATE($u64, 4, 1, 1) 9 | GENERATE($u64, 4, 1, 2) 10 | GENERATE($u64, 4, 1, 3) 11 | GENERATE($u64, 4, 1, 4) 12 | GENERATE($u64, 4, 1, 5) 13 | GENERATE($u64, 4, 1, 6) 14 | GENERATE($u64, 4, 1, 7) 15 | GENERATE($u64, 4, 1, 8) 16 | GENERATE($u64, 4, 1, 9) 17 | GENERATE($u64, 4, 1, 10) 18 | GENERATE($u64, 4, 1, 11) 19 | GENERATE($u64, 4, 1, 12) 20 | GENERATE($u64, 4, 1, 13) 21 | GENERATE($u64, 4, 1, 14) 22 | GENERATE($u64, 4, 1, 15) 23 | GENERATE($u64, 4, 1, 16) 24 | GENERATE($u64, 4, 2, 2) 25 | GENERATE($u64, 4, 2, 4) 26 | GENERATE($u64, 4, 2, 6) 27 | GENERATE($u64, 4, 2, 8) 28 | GENERATE($u64, 4, 2, 10) 29 | GENERATE($u64, 4, 2, 12) 30 | GENERATE($u64, 4, 2, 14) 31 | GENERATE($u64, 4, 2, 16) 32 | GENERATE($u64, 4, 4, 4) 33 | GENERATE($u64, 4, 4, 8) 34 | GENERATE($u64, 4, 4, 12) 35 | GENERATE($u64, 4, 4, 16) 36 | GENERATE($u64, 4, 8, 8) 37 | GENERATE($u64, 4, 8, 16) 38 | GENERATE($u64, 4,16, 16) 39 | 40 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u64_w4.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | 11 | GENERATE_EXTERN($u64, 4, 1, 1) 12 | GENERATE_EXTERN($u64, 4, 1, 2) 13 | GENERATE_EXTERN($u64, 4, 1, 3) 14 | GENERATE_EXTERN($u64, 4, 1, 4) 15 | GENERATE_EXTERN($u64, 4, 1, 5) 16 | GENERATE_EXTERN($u64, 4, 1, 6) 17 | GENERATE_EXTERN($u64, 4, 1, 7) 18 | GENERATE_EXTERN($u64, 4, 1, 8) 19 | GENERATE_EXTERN($u64, 4, 1, 9) 20 | GENERATE_EXTERN($u64, 4, 1, 10) 21 | GENERATE_EXTERN($u64, 4, 1, 11) 22 | GENERATE_EXTERN($u64, 4, 1, 12) 23 | GENERATE_EXTERN($u64, 4, 1, 13) 24 | GENERATE_EXTERN($u64, 4, 1, 14) 25 | GENERATE_EXTERN($u64, 4, 1, 15) 26 | GENERATE_EXTERN($u64, 4, 1, 16) 27 | GENERATE_EXTERN($u64, 4, 2, 2) 28 | GENERATE_EXTERN($u64, 4, 2, 4) 29 | GENERATE_EXTERN($u64, 4, 2, 6) 30 | GENERATE_EXTERN($u64, 4, 2, 8) 31 | GENERATE_EXTERN($u64, 4, 2, 10) 32 | GENERATE_EXTERN($u64, 4, 2, 12) 33 | GENERATE_EXTERN($u64, 4, 2, 14) 34 | GENERATE_EXTERN($u64, 4, 2, 16) 35 | GENERATE_EXTERN($u64, 4, 4, 4) 36 | GENERATE_EXTERN($u64, 4, 4, 8) 37 | GENERATE_EXTERN($u64, 4, 4, 12) 38 | GENERATE_EXTERN($u64, 4, 4, 16) 39 | GENERATE_EXTERN($u64, 4, 8, 8) 40 | GENERATE_EXTERN($u64, 4, 8, 16) 41 | GENERATE_EXTERN($u64, 4,16, 16) 42 | 43 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u64_w8.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "blocked_bloomfilter_logic_instance.inc" 5 | 6 | namespace dtl { 7 | 8 | GENERATE($u64, 8, 1, 1) 9 | GENERATE($u64, 8, 1, 2) 10 | GENERATE($u64, 8, 1, 3) 11 | GENERATE($u64, 8, 1, 4) 12 | GENERATE($u64, 8, 1, 5) 13 | GENERATE($u64, 8, 1, 6) 14 | GENERATE($u64, 8, 1, 7) 15 | GENERATE($u64, 8, 1, 8) 16 | GENERATE($u64, 8, 1, 9) 17 | GENERATE($u64, 8, 1, 10) 18 | GENERATE($u64, 8, 1, 11) 19 | GENERATE($u64, 8, 1, 12) 20 | GENERATE($u64, 8, 1, 13) 21 | GENERATE($u64, 8, 1, 14) 22 | GENERATE($u64, 8, 1, 15) 23 | GENERATE($u64, 8, 1, 16) 24 | GENERATE($u64, 8, 2, 2) 25 | GENERATE($u64, 8, 2, 4) 26 | GENERATE($u64, 8, 2, 6) 27 | GENERATE($u64, 8, 2, 8) 28 | GENERATE($u64, 8, 2, 10) 29 | GENERATE($u64, 8, 2, 12) 30 | GENERATE($u64, 8, 2, 14) 31 | GENERATE($u64, 8, 2, 16) 32 | GENERATE($u64, 8, 4, 4) 33 | GENERATE($u64, 8, 4, 8) 34 | GENERATE($u64, 8, 4, 12) 35 | GENERATE($u64, 8, 4, 16) 36 | GENERATE($u64, 8, 8, 8) 37 | GENERATE($u64, 8, 8, 16) 38 | GENERATE($u64, 8,16, 16) 39 | 40 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/blocked_bloomfilter_logic_u64_w8.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | 11 | GENERATE_EXTERN($u64, 8, 1, 1) 12 | GENERATE_EXTERN($u64, 8, 1, 2) 13 | GENERATE_EXTERN($u64, 8, 1, 3) 14 | GENERATE_EXTERN($u64, 8, 1, 4) 15 | GENERATE_EXTERN($u64, 8, 1, 5) 16 | GENERATE_EXTERN($u64, 8, 1, 6) 17 | GENERATE_EXTERN($u64, 8, 1, 7) 18 | GENERATE_EXTERN($u64, 8, 1, 8) 19 | GENERATE_EXTERN($u64, 8, 1, 9) 20 | GENERATE_EXTERN($u64, 8, 1, 10) 21 | GENERATE_EXTERN($u64, 8, 1, 11) 22 | GENERATE_EXTERN($u64, 8, 1, 12) 23 | GENERATE_EXTERN($u64, 8, 1, 13) 24 | GENERATE_EXTERN($u64, 8, 1, 14) 25 | GENERATE_EXTERN($u64, 8, 1, 15) 26 | GENERATE_EXTERN($u64, 8, 1, 16) 27 | GENERATE_EXTERN($u64, 8, 2, 2) 28 | GENERATE_EXTERN($u64, 8, 2, 4) 29 | GENERATE_EXTERN($u64, 8, 2, 6) 30 | GENERATE_EXTERN($u64, 8, 2, 8) 31 | GENERATE_EXTERN($u64, 8, 2, 10) 32 | GENERATE_EXTERN($u64, 8, 2, 12) 33 | GENERATE_EXTERN($u64, 8, 2, 14) 34 | GENERATE_EXTERN($u64, 8, 2, 16) 35 | GENERATE_EXTERN($u64, 8, 4, 4) 36 | GENERATE_EXTERN($u64, 8, 4, 8) 37 | GENERATE_EXTERN($u64, 8, 4, 12) 38 | GENERATE_EXTERN($u64, 8, 4, 16) 39 | GENERATE_EXTERN($u64, 8, 8, 8) 40 | GENERATE_EXTERN($u64, 8, 8, 16) 41 | GENERATE_EXTERN($u64, 8,16, 16) 42 | 43 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/zoned_blocked_bloomfilter_logic_u32_w16.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "zoned_blocked_bloomfilter_logic_instance.inc" 5 | 6 | namespace dtl { 7 | 8 | GENERATE($u32, 16, 2, 2) 9 | GENERATE($u32, 16, 2, 4) 10 | GENERATE($u32, 16, 2, 6) 11 | GENERATE($u32, 16, 2, 8) 12 | GENERATE($u32, 16, 2, 10) 13 | GENERATE($u32, 16, 2, 12) 14 | GENERATE($u32, 16, 2, 14) 15 | GENERATE($u32, 16, 2, 16) 16 | GENERATE($u32, 16, 4, 4) 17 | GENERATE($u32, 16, 4, 8) 18 | GENERATE($u32, 16, 4, 12) 19 | GENERATE($u32, 16, 4, 16) 20 | GENERATE($u32, 16, 8, 8) 21 | GENERATE($u32, 16, 8, 16) 22 | 23 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/zoned_blocked_bloomfilter_logic_u32_w16.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | 11 | GENERATE_EXTERN($u32, 16, 2, 2) 12 | GENERATE_EXTERN($u32, 16, 2, 4) 13 | GENERATE_EXTERN($u32, 16, 2, 6) 14 | GENERATE_EXTERN($u32, 16, 2, 8) 15 | GENERATE_EXTERN($u32, 16, 2, 10) 16 | GENERATE_EXTERN($u32, 16, 2, 12) 17 | GENERATE_EXTERN($u32, 16, 2, 14) 18 | GENERATE_EXTERN($u32, 16, 2, 16) 19 | GENERATE_EXTERN($u32, 16, 4, 4) 20 | GENERATE_EXTERN($u32, 16, 4, 8) 21 | GENERATE_EXTERN($u32, 16, 4, 12) 22 | GENERATE_EXTERN($u32, 16, 4, 16) 23 | GENERATE_EXTERN($u32, 16, 8, 8) 24 | GENERATE_EXTERN($u32, 16, 8, 16) 25 | 26 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/zoned_blocked_bloomfilter_logic_u32_w4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "zoned_blocked_bloomfilter_logic_instance.inc" 5 | 6 | namespace dtl { 7 | 8 | GENERATE($u32, 4, 2, 2) 9 | GENERATE($u32, 4, 2, 4) 10 | GENERATE($u32, 4, 2, 6) 11 | GENERATE($u32, 4, 2, 8) 12 | GENERATE($u32, 4, 2, 10) 13 | GENERATE($u32, 4, 2, 12) 14 | GENERATE($u32, 4, 2, 14) 15 | GENERATE($u32, 4, 2, 16) 16 | 17 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/zoned_blocked_bloomfilter_logic_u32_w4.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | 11 | GENERATE_EXTERN($u32, 4, 2, 2) 12 | GENERATE_EXTERN($u32, 4, 2, 4) 13 | GENERATE_EXTERN($u32, 4, 2, 6) 14 | GENERATE_EXTERN($u32, 4, 2, 8) 15 | GENERATE_EXTERN($u32, 4, 2, 10) 16 | GENERATE_EXTERN($u32, 4, 2, 12) 17 | GENERATE_EXTERN($u32, 4, 2, 14) 18 | GENERATE_EXTERN($u32, 4, 2, 16) 19 | 20 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/zoned_blocked_bloomfilter_logic_u32_w8.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "zoned_blocked_bloomfilter_logic_instance.inc" 5 | 6 | namespace dtl { 7 | 8 | GENERATE($u32, 8, 2, 2) 9 | GENERATE($u32, 8, 2, 4) 10 | GENERATE($u32, 8, 2, 6) 11 | GENERATE($u32, 8, 2, 8) 12 | GENERATE($u32, 8, 2, 10) 13 | GENERATE($u32, 8, 2, 12) 14 | GENERATE($u32, 8, 2, 14) 15 | GENERATE($u32, 8, 2, 16) 16 | GENERATE($u32, 8, 4, 4) 17 | GENERATE($u32, 8, 4, 8) 18 | GENERATE($u32, 8, 4, 12) 19 | GENERATE($u32, 8, 4, 16) 20 | 21 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/zoned_blocked_bloomfilter_logic_u32_w8.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | 11 | GENERATE_EXTERN($u32, 8, 2, 2) 12 | GENERATE_EXTERN($u32, 8, 2, 4) 13 | GENERATE_EXTERN($u32, 8, 2, 6) 14 | GENERATE_EXTERN($u32, 8, 2, 8) 15 | GENERATE_EXTERN($u32, 8, 2, 10) 16 | GENERATE_EXTERN($u32, 8, 2, 12) 17 | GENERATE_EXTERN($u32, 8, 2, 14) 18 | GENERATE_EXTERN($u32, 8, 2, 16) 19 | GENERATE_EXTERN($u32, 8, 4, 4) 20 | GENERATE_EXTERN($u32, 8, 4, 8) 21 | GENERATE_EXTERN($u32, 8, 4, 12) 22 | GENERATE_EXTERN($u32, 8, 4, 16) 23 | 24 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/zoned_blocked_bloomfilter_logic_u64_w16.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "zoned_blocked_bloomfilter_logic_instance.inc" 5 | 6 | namespace dtl { 7 | 8 | GENERATE($u64, 16, 2, 2) 9 | GENERATE($u64, 16, 2, 4) 10 | GENERATE($u64, 16, 2, 6) 11 | GENERATE($u64, 16, 2, 8) 12 | GENERATE($u64, 16, 2, 10) 13 | GENERATE($u64, 16, 2, 12) 14 | GENERATE($u64, 16, 2, 14) 15 | GENERATE($u64, 16, 2, 16) 16 | GENERATE($u64, 16, 4, 4) 17 | GENERATE($u64, 16, 4, 8) 18 | GENERATE($u64, 16, 4, 12) 19 | GENERATE($u64, 16, 4, 16) 20 | GENERATE($u64, 16, 8, 8) 21 | GENERATE($u64, 16, 8, 16) 22 | 23 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/zoned_blocked_bloomfilter_logic_u64_w16.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | 11 | GENERATE_EXTERN($u64, 16, 2, 2) 12 | GENERATE_EXTERN($u64, 16, 2, 4) 13 | GENERATE_EXTERN($u64, 16, 2, 6) 14 | GENERATE_EXTERN($u64, 16, 2, 8) 15 | GENERATE_EXTERN($u64, 16, 2, 10) 16 | GENERATE_EXTERN($u64, 16, 2, 12) 17 | GENERATE_EXTERN($u64, 16, 2, 14) 18 | GENERATE_EXTERN($u64, 16, 2, 16) 19 | GENERATE_EXTERN($u64, 16, 4, 4) 20 | GENERATE_EXTERN($u64, 16, 4, 8) 21 | GENERATE_EXTERN($u64, 16, 4, 12) 22 | GENERATE_EXTERN($u64, 16, 4, 16) 23 | GENERATE_EXTERN($u64, 16, 8, 8) 24 | GENERATE_EXTERN($u64, 16, 8, 16) 25 | 26 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/zoned_blocked_bloomfilter_logic_u64_w4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "zoned_blocked_bloomfilter_logic_instance.inc" 5 | 6 | namespace dtl { 7 | 8 | GENERATE($u64, 4, 2, 2) 9 | GENERATE($u64, 4, 2, 4) 10 | GENERATE($u64, 4, 2, 6) 11 | GENERATE($u64, 4, 2, 8) 12 | GENERATE($u64, 4, 2, 10) 13 | GENERATE($u64, 4, 2, 12) 14 | GENERATE($u64, 4, 2, 14) 15 | GENERATE($u64, 4, 2, 16) 16 | 17 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/zoned_blocked_bloomfilter_logic_u64_w4.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | 11 | GENERATE_EXTERN($u64, 4, 2, 2) 12 | GENERATE_EXTERN($u64, 4, 2, 4) 13 | GENERATE_EXTERN($u64, 4, 2, 6) 14 | GENERATE_EXTERN($u64, 4, 2, 8) 15 | GENERATE_EXTERN($u64, 4, 2, 10) 16 | GENERATE_EXTERN($u64, 4, 2, 12) 17 | GENERATE_EXTERN($u64, 4, 2, 14) 18 | GENERATE_EXTERN($u64, 4, 2, 16) 19 | 20 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/zoned_blocked_bloomfilter_logic_u64_w8.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "zoned_blocked_bloomfilter_logic_instance.inc" 5 | 6 | namespace dtl { 7 | 8 | GENERATE($u64, 8, 2, 2) 9 | GENERATE($u64, 8, 2, 4) 10 | GENERATE($u64, 8, 2, 6) 11 | GENERATE($u64, 8, 2, 8) 12 | GENERATE($u64, 8, 2, 10) 13 | GENERATE($u64, 8, 2, 12) 14 | GENERATE($u64, 8, 2, 14) 15 | GENERATE($u64, 8, 2, 16) 16 | GENERATE($u64, 8, 4, 4) 17 | GENERATE($u64, 8, 4, 8) 18 | GENERATE($u64, 8, 4, 12) 19 | GENERATE($u64, 8, 4, 16) 20 | 21 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_bloomfilter/instances/zoned_blocked_bloomfilter_logic_u64_w8.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | 11 | GENERATE_EXTERN($u64, 8, 2, 2) 12 | GENERATE_EXTERN($u64, 8, 2, 4) 13 | GENERATE_EXTERN($u64, 8, 2, 6) 14 | GENERATE_EXTERN($u64, 8, 2, 8) 15 | GENERATE_EXTERN($u64, 8, 2, 10) 16 | GENERATE_EXTERN($u64, 8, 2, 12) 17 | GENERATE_EXTERN($u64, 8, 2, 14) 18 | GENERATE_EXTERN($u64, 8, 2, 16) 19 | GENERATE_EXTERN($u64, 8, 4, 4) 20 | GENERATE_EXTERN($u64, 8, 4, 8) 21 | GENERATE_EXTERN($u64, 8, 4, 12) 22 | GENERATE_EXTERN($u64, 8, 4, 16) 23 | 24 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/blocked_cuckoofilter/README.md: -------------------------------------------------------------------------------- 1 | # Blocked Cuckoo filter 2 | 3 | !!! EXPERIMENTAL CODE !!! 4 | 5 | -------------------------------------------------------------------------------- /src/dtl/filter/bloomfilter/README.md: -------------------------------------------------------------------------------- 1 | # (Classic) Bloom filter 2 | 3 | A classic Bloom filter implementation that supports batch-lookups. 4 | The lookup code makes use of SIMD instructions, but without any 5 | divergence handling (like in [1]). 6 | 7 | 8 | ## References 9 | [1] Orestis Polychroniou and Kenneth A. Ross, 10 | _Vectorized Bloom filters for advanced SIMD processors_, 11 | DaMoN'14 12 | -------------------------------------------------------------------------------- /src/dtl/filter/cf.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "filter_base.hpp" 5 | 6 | namespace dtl { 7 | 8 | //===----------------------------------------------------------------------===// 9 | // PImpl wrapper to reduce compilation time. 10 | //===----------------------------------------------------------------------===// 11 | class cf : public dtl::filter::filter_base { 12 | class impl; 13 | std::unique_ptr pimpl; 14 | std::size_t bits_per_tag; 15 | std::size_t tags_per_bucket; 16 | 17 | public: 18 | 19 | using key_t = $u32; 20 | using word_t = $u64; // internally, 32-bit words are used 21 | 22 | 23 | //===----------------------------------------------------------------------===// 24 | // The API functions. 25 | //===----------------------------------------------------------------------===// 26 | $u1 27 | insert(word_t* __restrict filter_data, key_t key); 28 | 29 | $u1 30 | batch_insert(word_t* __restrict filter_data, const key_t* __restrict keys, u32 key_cnt); 31 | 32 | $u1 33 | contains(const word_t* __restrict filter_data, key_t key) const; 34 | 35 | $u64 36 | batch_contains(const word_t* __restrict filter_data, 37 | const key_t* __restrict keys, u32 key_cnt, 38 | $u32* __restrict match_positions, u32 match_offset) const; 39 | 40 | std::string 41 | name() const; 42 | 43 | std::size_t 44 | size_in_bytes() const; 45 | 46 | std::size_t 47 | size() const; 48 | 49 | static void 50 | calibrate(u64 filter_size_bits = 4ull * 1024 * 8); 51 | 52 | static void 53 | force_unroll_factor(u32 u); 54 | 55 | // Cuckoo specific functions 56 | std::size_t 57 | get_bits_per_tag() const { 58 | return bits_per_tag; 59 | }; 60 | 61 | std::size_t 62 | get_tags_per_bucket() const { 63 | return tags_per_bucket; 64 | }; 65 | 66 | std::size_t 67 | get_bucket_count() const; 68 | 69 | std::size_t 70 | count_occupied_slots(const word_t* __restrict filter_data) const; 71 | 72 | //===----------------------------------------------------------------------===// 73 | 74 | explicit 75 | cf(std::size_t m, u32 bits_per_tag = 16, u32 tags_per_bucket = 4); 76 | ~cf() override; 77 | cf(cf&&) noexcept; 78 | cf(const cf&) = delete; 79 | cf& operator=(cf&&); 80 | cf& operator=(const cf&) = delete; 81 | 82 | }; 83 | 84 | } // namespace dtl 85 | -------------------------------------------------------------------------------- /src/dtl/filter/cuckoofilter/bitsutil.hpp: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // This file is taken from the original Cuckoo filter implementation, 3 | // that can be found on GitHub: https://github.com/efficient/cuckoofilter 4 | // Usable under the terms in the Apache License, Version 2.0. 5 | //===----------------------------------------------------------------------===// 6 | 7 | //===----------------------------------------------------------------------===// 8 | // 9 | // Copyright (C) 2013, Carnegie Mellon University and Intel Corporation 10 | // 11 | // Licensed under the Apache License, Version 2.0 (the "License"); 12 | // you may not use this file except in compliance with the License. 13 | // You may obtain a copy of the License at 14 | // 15 | // http://www.apache.org/licenses/LICENSE-2.0 16 | // 17 | // Unless required by applicable law or agreed to in writing, software 18 | // distributed under the License is distributed on an "AS IS" BASIS, 19 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | // See the License for the specific language governing permissions and 21 | // limitations under the License. 22 | // 23 | //===----------------------------------------------------------------------===// 24 | #pragma once 25 | 26 | 27 | namespace dtl { 28 | namespace cuckoofilter { 29 | namespace internal { 30 | 31 | // inspired from 32 | // http://www-graphics.stanford.edu/~seander/bithacks.html#ZeroInWord 33 | #define haszero2(x) (((x)-0x5555ULL) & (~(x)) & 0xAAAAULL) 34 | #define hasvalue2(x, n) (haszero2((x) ^ (0x5555ULL * (n)))) 35 | 36 | #define haszero4(x) (((x)-0x1111ULL) & (~(x)) & 0x8888ULL) 37 | #define hasvalue4(x, n) (haszero4((x) ^ (0x1111ULL * (n)))) 38 | 39 | #define haszero8(x) (((x)-0x01010101ULL) & (~(x)) & 0x80808080ULL) 40 | #define hasvalue8(x, n) (haszero8((x) ^ (0x01010101ULL * (n)))) 41 | 42 | #define haszero12(x) (((x)-0x001001001001ULL) & (~(x)) & 0x800800800800ULL) 43 | #define hasvalue12(x, n) (haszero12((x) ^ (0x001001001001ULL * (n)))) 44 | 45 | #define haszero16(x) \ 46 | (((x)-0x0001000100010001ULL) & (~(x)) & 0x8000800080008000ULL) 47 | #define hasvalue16(x, n) (haszero16((x) ^ (0x0001000100010001ULL * (n)))) 48 | 49 | inline uint64_t upperpower2(uint64_t x) { 50 | x--; 51 | x |= x >> 1; 52 | x |= x >> 2; 53 | x |= x >> 4; 54 | x |= x >> 8; 55 | x |= x >> 16; 56 | x |= x >> 32; 57 | x++; 58 | return x; 59 | } 60 | 61 | } // namespace internal 62 | } // namespace cuckoofilter 63 | } // namespace dtl 64 | 65 | -------------------------------------------------------------------------------- /src/dtl/filter/cuckoofilter/cuckoofilter_config.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace dtl { 9 | namespace cuckoofilter { 10 | 11 | 12 | //===----------------------------------------------------------------------===// 13 | struct config { 14 | $u32 bits_per_tag = 8; 15 | $u32 tags_per_bucket = 2; 16 | dtl::block_addressing addr_mode = dtl::block_addressing::POWER_OF_TWO; 17 | 18 | bool 19 | operator<(const config &o) const { 20 | return bits_per_tag < o.bits_per_tag 21 | || (bits_per_tag == o.bits_per_tag && tags_per_bucket < o.tags_per_bucket) 22 | || (bits_per_tag == o.bits_per_tag && tags_per_bucket == o.tags_per_bucket && addr_mode < o.addr_mode); 23 | } 24 | 25 | bool 26 | operator==(const config& o) const { 27 | return bits_per_tag == o.bits_per_tag && tags_per_bucket == o.tags_per_bucket && addr_mode == o.addr_mode; 28 | } 29 | 30 | bool 31 | operator!=(const config& o) const { 32 | return !(*this == o); 33 | } 34 | 35 | void print(std::ostream& os) const { 36 | std::stringstream str; 37 | str << "cf" 38 | << ",bits_per_tag=" << bits_per_tag 39 | << ",tags_per_bucket=" << tags_per_bucket 40 | << ",addr=" << (addr_mode == dtl::block_addressing::POWER_OF_TWO ? "pow2" : "magic"); 41 | os << str.str(); 42 | } 43 | 44 | }; 45 | //===----------------------------------------------------------------------===// 46 | 47 | 48 | } // namespace cuckoofilter 49 | } // namespace dtl 50 | -------------------------------------------------------------------------------- /src/dtl/filter/cuckoofilter/cuckoofilter_table_simd.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace dtl { 4 | namespace cuckoofilter { 5 | namespace internal { 6 | 7 | 8 | template 9 | struct find_tag_in_buckets_simd { 10 | 11 | // Used to determine whether a SIMD implementation is available. 12 | static constexpr u1 vectorized = false; 13 | 14 | }; 15 | 16 | 17 | } // namespace internal 18 | } // namespace cuckoofilter 19 | } // namespace dtl 20 | -------------------------------------------------------------------------------- /src/dtl/filter/cuckoofilter/cuckoofilter_tune.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include "immintrin.h" 11 | #include "cuckoofilter_config.hpp" 12 | 13 | namespace dtl { 14 | namespace cuckoofilter { 15 | 16 | 17 | //===----------------------------------------------------------------------===// 18 | /// Provides tuning parameters to the filter instance. 19 | struct cuckoofilter_tune { 20 | 21 | /// Sets the SIMD unrolling factor for the given blocked filter config. 22 | /// Note: unrolling by 0 means -> scalar code (no SIMD) 23 | virtual void 24 | set_unroll_factor(u32 bits_per_tag, 25 | u32 tags_per_bucket, 26 | dtl::block_addressing addr_mode, 27 | u32 unroll_factor) { 28 | throw std::runtime_error("Not supported"); 29 | } 30 | 31 | 32 | /// Returns the SIMD unrolling factor for the given filter config. 33 | /// Note: unrolling by 0 means -> scalar code (no SIMD) 34 | virtual $u32 35 | get_unroll_factor(u32 bits_per_tag, 36 | u32 tags_per_bucket, 37 | dtl::block_addressing addr_mode) const { 38 | return 1; // default 39 | } 40 | 41 | 42 | /// Determines the best performing SIMD unrolling factor for the given 43 | /// filter config. 44 | virtual $u32 45 | tune_unroll_factor(u32 bits_per_tag, 46 | u32 tags_per_bucket, 47 | dtl::block_addressing addr_mode, 48 | u64 filter_size_bits) { 49 | throw std::runtime_error("Not supported"); 50 | } 51 | 52 | 53 | /// Determines the best performing SIMD unrolling factor for all valid 54 | /// filter configs. 55 | virtual void 56 | tune_unroll_factor(u64 filter_size_bits) { 57 | throw std::runtime_error("Not supported"); 58 | } 59 | 60 | }; 61 | //===----------------------------------------------------------------------===// 62 | 63 | } // namespace cuckoofilter 64 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/dynamic_blocked_bloomfilter/README.md: -------------------------------------------------------------------------------- 1 | # Blocked Bloom filter 2 | without compile-time optimizations. 3 | 4 | !!! EXPERIMENTAL CODE !!! 5 | 6 | -------------------------------------------------------------------------------- /src/dtl/filter/dynamic_blocked_bloomfilter/blocked_bloomfilter.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | 10 | namespace dtl { 11 | namespace bloomfilter_dynamic { 12 | 13 | 14 | struct blocked_bloomfilter { 15 | using key_t = uint32_t; 16 | using filter_logic_t = dtl::bloomfilter_dynamic::blocked_bloomfilter_logic; 17 | using word_t = typename filter_logic_t::word_t; 18 | 19 | //===----------------------------------------------------------------------===// 20 | const filter_logic_t filter_logic; 21 | std::vector filter_data; 22 | //===----------------------------------------------------------------------===// 23 | 24 | 25 | blocked_bloomfilter(u64 m, 26 | u32 block_size_bytes, 27 | u32 sector_size_bytes, 28 | u32 k) 29 | : filter_logic(m, block_size_bytes, sector_size_bytes, k), filter_data(filter_logic.word_cnt(), 0) {} 30 | 31 | 32 | blocked_bloomfilter(const blocked_bloomfilter&) noexcept = default; 33 | 34 | 35 | blocked_bloomfilter(blocked_bloomfilter&&) noexcept = default; 36 | //===----------------------------------------------------------------------===// 37 | 38 | 39 | __forceinline__ 40 | void 41 | insert(const key_t& key) noexcept { 42 | filter_logic.insert(&filter_data[0], key); 43 | }; 44 | //===----------------------------------------------------------------------===// 45 | 46 | 47 | __forceinline__ 48 | bool 49 | contains(const key_t& key) const noexcept { 50 | return filter_logic.contains(&filter_data[0], key); 51 | } 52 | //===----------------------------------------------------------------------===// 53 | 54 | 55 | uint64_t 56 | batch_contains(const key_t* keys, u32 key_cnt, 57 | $u32* match_positions, u32 match_offset) const { 58 | return filter_logic.batch_contains(&filter_data[0], keys, key_cnt, match_positions, match_offset); 59 | } 60 | //===----------------------------------------------------------------------===// 61 | 62 | 63 | }; 64 | //===----------------------------------------------------------------------===// 65 | 66 | 67 | } // namespace bloomfilter_dynamic 68 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/dynamic_blocked_bloomfilter/hash.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dtl { 6 | namespace bloomfilter_dynamic { 7 | 8 | struct hasher_mul32 { 9 | 10 | __forceinline__ __host__ __device__ 11 | static u32 hash(u32& key, u32 hash_no) { 12 | static constexpr u32 primes[13] { 13 | 596572387u, // Peter 1 14 | 370248451u, // Peter 2 15 | 2654435769u, // Knuth 1 16 | 1799596469u, // Knuth 2 17 | 0x9E3779B1u, // https://lowrey.me/exploring-knuths-multiplicative-hash-2/ 18 | 2284105051u, // Impala 3 19 | 1203114875u, // Impala 1 (odd, not prime) 20 | 1150766481u, // Impala 2 (odd, not prime) 21 | 2729912477u, // Impala 4 (odd, not prime) 22 | 1884591559u, // Impala 5 (odd, not prime) 23 | 770785867u, // Impala 6 (odd, not prime) 24 | 2667333959u, // Impala 7 (odd, not prime) 25 | 1550580529u, // Impala 8 (odd, not prime) 26 | }; 27 | if (hash_no > 13) { 28 | std::cerr << "hash_no out of bounds: " << hash_no << std::endl; 29 | throw "BAM"; 30 | } 31 | return key * primes[hash_no]; 32 | } 33 | }; 34 | 35 | } // namespace bloomfilter_dynamic 36 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/model/benchmark.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "timing.hpp" 12 | 13 | namespace dtl { 14 | namespace filter { 15 | namespace model { 16 | 17 | //===----------------------------------------------------------------------===// 18 | class benchmark { 19 | 20 | using key_t = $u32; 21 | 22 | std::vector> probe_keys; 23 | 24 | timing 25 | run(dtl::filter::filter& filter, $u32 thread_cnt); 26 | 27 | public: 28 | benchmark(); 29 | 30 | timing 31 | operator()(const dtl::blocked_bloomfilter_config& filter_config, u64 m, u32 thread_cnt = 0); 32 | 33 | timing 34 | operator()(const dtl::cuckoofilter::config& filter_config, u64 m, u32 thread_cnt = 0); 35 | 36 | }; 37 | //===----------------------------------------------------------------------===// 38 | 39 | } // namespace model 40 | } // namespace filter 41 | } // namespace dtl 42 | -------------------------------------------------------------------------------- /src/dtl/filter/model/benchmark_test.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "benchmark.hpp" 10 | #include "calibration_data.hpp" 11 | #include "timing.hpp" 12 | 13 | using namespace dtl::filter::model; 14 | 15 | //===----------------------------------------------------------------------===// 16 | TEST(filter_benchmark, basic_test) { 17 | benchmark benchmark; 18 | dtl::blocked_bloomfilter_config bbf_config; 19 | bbf_config.k = 4; 20 | timing bbf_timing = benchmark(bbf_config, 8ull * 1024 * 8); 21 | std::cout << "bbf: cycles=" << bbf_timing.cycles_per_lookup << ", nanos=" << bbf_timing.nanos_per_lookup << std::endl; 22 | dtl::cuckoofilter::config cf_config; 23 | timing cf_timing = benchmark(cf_config, 8ull * 1024 * 8); 24 | std::cout << "cf: cycles=" << cf_timing.cycles_per_lookup << ", nanos=" << cf_timing.nanos_per_lookup << std::endl; 25 | } 26 | //===----------------------------------------------------------------------===// 27 | 28 | -------------------------------------------------------------------------------- /src/dtl/filter/model/calibration.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "timing.hpp" 15 | #include "tuning_params.hpp" 16 | #include "calibration_data.hpp" 17 | 18 | namespace dtl { 19 | namespace filter { 20 | namespace model { 21 | 22 | 23 | //===----------------------------------------------------------------------===// 24 | // 25 | class calibration { 26 | 27 | dtl::filter::model::calibration_data& data_; 28 | 29 | void calibrate_bbf_costs(); 30 | void calibrate_cf_costs(); 31 | 32 | public: 33 | 34 | calibration(dtl::filter::model::calibration_data& data) : data_(data) { }; 35 | 36 | void calibrate_tuning_params(); 37 | void calibrate_cache_sizes(); 38 | void calibrate_filter_costs(); 39 | 40 | }; 41 | //===----------------------------------------------------------------------===// 42 | 43 | 44 | } // namespace model 45 | } // namespace filter 46 | } // namespace dtl 47 | -------------------------------------------------------------------------------- /src/dtl/filter/model/calibration_test.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "dtl/filter/model/calibration.hpp" 10 | #include "dtl/filter/model/calibration_data.hpp" 11 | #include "dtl/filter/model/timing.hpp" 12 | 13 | using namespace dtl::filter::model; 14 | 15 | //===----------------------------------------------------------------------===// 16 | TEST(model_calibration, cache_sizes) { 17 | // create a config file 18 | const std::string filename = "/tmp/calibration_data_cache_sizes"; 19 | calibration_data cd(filename); 20 | calibration c(cd); 21 | c.calibrate_tuning_params(); 22 | c.calibrate_cache_sizes(); 23 | 24 | std::remove(filename.c_str()); 25 | } 26 | //===----------------------------------------------------------------------===// 27 | -------------------------------------------------------------------------------- /src/dtl/filter/model/optimizer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peterboncz/bloomfilter-bsd/bae83545a091555e48b5495669c7adcb99fd2047/src/dtl/filter/model/optimizer.cpp -------------------------------------------------------------------------------- /src/dtl/filter/model/optimizer_test.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "dtl/filter/model/calibration_data.hpp" 10 | #include "dtl/filter/model/optimizer.hpp" 11 | #include "dtl/filter/model/timing.hpp" 12 | 13 | #include "util.hpp" 14 | 15 | using namespace dtl::filter::model; 16 | 17 | //===----------------------------------------------------------------------===// 18 | TEST(model_optimizer, basic) { 19 | const std::string filename = "/tmp/calibration_data_opt"; 20 | std::remove(filename.c_str()); 21 | 22 | const std::vector delta_timings = {{ 2.209, 0.667}, 23 | { 0.145, 0.044}, 24 | { 8.905, 2.688}, 25 | { 33.377, 10.078}}; 26 | 27 | calibration_data cd(filename); 28 | 29 | const auto configs = get_valid_bbf_configs(); 30 | for (auto c : configs) { 31 | cd.put_timings(c, delta_timings); 32 | } 33 | 34 | u64 n = 1000000; 35 | timing tw { 1000.0, 1000.0 }; 36 | u64 m_lo = 8ull * 1024 * 8; 37 | u64 m_hi = 256ull * 1024 * 1024 * 8; 38 | 39 | 40 | std::vector overheads; 41 | std::vector<$u64> ms; 42 | for (auto c : configs) { 43 | optimizer opt(n, tw, m_lo, m_hi, c, cd); 44 | while (opt.step()) { } 45 | overheads.push_back(opt.get_result_overhead()); 46 | ms.push_back(opt.get_result_m()); 47 | } 48 | 49 | std::vector rank(configs.size()); 50 | std::iota(rank.begin(), rank.end(), 0); 51 | std::sort(rank.begin(), rank.end(), [&](auto a, auto b) { 52 | return overheads[a] < overheads[b]; 53 | }); 54 | for (std::size_t i = 0; i < std::min(30ul, configs.size()); i++) { 55 | std::cout << "rank " << i 56 | << ": config=" 57 | << configs[rank[i]] 58 | << ", m=" << (ms[rank[i]] / 1024 / 8) << " [KiB]" 59 | << ", overhead=" << overheads[rank[i]].cycles_per_lookup 60 | << std::endl; 61 | } 62 | 63 | std::remove(filename.c_str()); 64 | } 65 | //===----------------------------------------------------------------------===// 66 | -------------------------------------------------------------------------------- /src/dtl/filter/model/timing.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dtl { 6 | namespace filter { 7 | namespace model { 8 | 9 | 10 | //===----------------------------------------------------------------------===// 11 | /// Timings 12 | struct timing { 13 | $f64 cycles_per_lookup = 0.0; 14 | $f64 nanos_per_lookup = 0.0; 15 | 16 | $u1 17 | operator==(const timing& other) const { 18 | return cycles_per_lookup == other.cycles_per_lookup 19 | && nanos_per_lookup == other.nanos_per_lookup; 20 | } 21 | 22 | $u1 23 | operator<(const timing& other) const { 24 | return cycles_per_lookup < other.cycles_per_lookup; 25 | } 26 | 27 | $u1 28 | operator>(const timing& other) const { 29 | return cycles_per_lookup > other.cycles_per_lookup; 30 | } 31 | 32 | timing 33 | operator*(f64 rhs) const { 34 | timing t; 35 | t.cycles_per_lookup = cycles_per_lookup * rhs; 36 | t.nanos_per_lookup = nanos_per_lookup * rhs; 37 | return t; 38 | } 39 | 40 | timing 41 | operator/(f64 rhs) const { 42 | timing t; 43 | t.cycles_per_lookup = cycles_per_lookup / rhs; 44 | t.nanos_per_lookup = nanos_per_lookup / rhs; 45 | return t; 46 | } 47 | 48 | timing 49 | operator+(f64 rhs) const { 50 | timing t; 51 | t.cycles_per_lookup = cycles_per_lookup + rhs; 52 | t.nanos_per_lookup = nanos_per_lookup + rhs; 53 | return t; 54 | } 55 | 56 | timing& 57 | operator+=(f64 rhs) { 58 | cycles_per_lookup += rhs; 59 | nanos_per_lookup += rhs; 60 | return *this; 61 | } 62 | 63 | timing 64 | operator+(const timing& rhs) const { 65 | timing t; 66 | t.cycles_per_lookup = cycles_per_lookup + rhs.cycles_per_lookup; 67 | t.nanos_per_lookup = nanos_per_lookup + rhs.nanos_per_lookup; 68 | return t; 69 | } 70 | 71 | timing& 72 | operator+=(const timing& rhs) { 73 | cycles_per_lookup += rhs.cycles_per_lookup; 74 | nanos_per_lookup += rhs.nanos_per_lookup; 75 | return *this; 76 | } 77 | 78 | timing 79 | operator-(const timing& rhs) const { 80 | timing t; 81 | t.cycles_per_lookup = cycles_per_lookup - rhs.cycles_per_lookup; 82 | t.nanos_per_lookup = nanos_per_lookup - rhs.nanos_per_lookup; 83 | return t; 84 | } 85 | 86 | void 87 | print(std::ostream& os) const { 88 | std::stringstream str; 89 | str << "[" << cycles_per_lookup << "," << nanos_per_lookup << "]"; 90 | os << str.str(); 91 | } 92 | 93 | }; 94 | //===----------------------------------------------------------------------===// 95 | 96 | 97 | } // namespace model 98 | } // namespace filter 99 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/filter/model/tuning_params.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace dtl { 6 | namespace filter { 7 | namespace model { 8 | 9 | //===----------------------------------------------------------------------===// 10 | struct tuning_params { 11 | $u32 unroll_factor = 1; 12 | 13 | tuning_params() = default; 14 | ~tuning_params() = default; 15 | tuning_params(const tuning_params& other) = default; 16 | tuning_params(tuning_params&& other) = default; 17 | 18 | tuning_params& operator=(const tuning_params& rhs) = default; 19 | tuning_params& operator=(tuning_params&& rhs) = default; 20 | 21 | $u1 22 | operator==(const tuning_params& other) const { 23 | return unroll_factor == other.unroll_factor; 24 | } 25 | 26 | void 27 | print(std::ostream& os) const { 28 | std::stringstream str; 29 | str << "u=" << unroll_factor; 30 | os << str.str(); 31 | } 32 | 33 | }; 34 | //===----------------------------------------------------------------------===// 35 | 36 | 37 | } // namespace model 38 | } // namespace filter 39 | } // namespace dtl 40 | -------------------------------------------------------------------------------- /src/dtl/filter/platform.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | 7 | namespace dtl { 8 | namespace filter { 9 | 10 | static thread_local $u1 this_thread_is_known = false; 11 | static thread_local $u32 this_thread_id = 0; 12 | 13 | 14 | //===----------------------------------------------------------------------===// 15 | class platform { 16 | 17 | // CPU affinity for the process. 18 | static const dtl::cpu_mask cpu_mask; 19 | 20 | // The number of threads to use. 21 | u32 thread_cnt; 22 | 23 | // The number of NUMA nodes. 24 | u32 numa_node_count; 25 | 26 | // Maps from a thread ID to the preferred (memory) node ID. 27 | std::vector<$u32> thread_id_to_node_id_map; 28 | 29 | platform(); 30 | 31 | public: 32 | 33 | static platform& get_instance() { 34 | static platform instance; 35 | return instance; 36 | } 37 | 38 | const dtl::cpu_mask& get_cpu_mask() const { return cpu_mask; } 39 | u32 get_numa_node_count() const { return numa_node_count; }; 40 | u32 get_thread_count() const { return thread_cnt; }; 41 | u32 get_memory_node_of_thread(u32 thread_id) const; 42 | u32 get_memory_node_of_this_thread() const; 43 | u32 get_thread_id() const; 44 | 45 | // Returns the (data) caches sizes in bytes. 46 | std::vector<$u64> get_cache_sizes() const; 47 | 48 | platform(platform const&) = delete; 49 | void operator=(platform const&) = delete; 50 | 51 | }; 52 | //===----------------------------------------------------------------------===// 53 | 54 | } // namespace filter 55 | } // namespace dtl 56 | -------------------------------------------------------------------------------- /src/dtl/filter/platform_test.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | 11 | 12 | using namespace dtl::filter; 13 | 14 | //===----------------------------------------------------------------------===// 15 | TEST(platform, read_cache_sizes) { 16 | auto sizes = platform::get_instance().get_cache_sizes(); 17 | ASSERT_TRUE(sizes.size() > 0); 18 | } 19 | //===----------------------------------------------------------------------===// 20 | -------------------------------------------------------------------------------- /src/dtl/filter/zbbf_32.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "filter_base.hpp" 5 | 6 | namespace dtl { 7 | 8 | //===----------------------------------------------------------------------===// 9 | // PImpl wrapper to reduce compilation time. 10 | //===----------------------------------------------------------------------===// 11 | class zbbf_32 : public dtl::filter::filter_base { 12 | class impl; 13 | std::unique_ptr pimpl; 14 | 15 | public: 16 | 17 | using key_t = $u32; 18 | using word_t = $u64; // internally, 32-bit words are used 19 | 20 | //===----------------------------------------------------------------------===// 21 | // The API functions. 22 | //===----------------------------------------------------------------------===// 23 | $u1 24 | insert(word_t* __restrict filter_data, key_t key); 25 | 26 | $u1 27 | batch_insert(word_t* __restrict filter_data, const key_t* keys, u32 key_cnt); 28 | 29 | $u1 30 | contains(const word_t* __restrict filter_data, key_t key) const; 31 | 32 | $u64 33 | batch_contains(const word_t* __restrict filter_data, 34 | const key_t* __restrict keys, u32 key_cnt, 35 | $u32* __restrict match_positions, u32 match_offset) const; 36 | 37 | std::string 38 | name() const; 39 | 40 | std::size_t 41 | size_in_bytes() const; 42 | 43 | std::size_t 44 | size() const; 45 | 46 | static void 47 | calibrate(u64 filter_size_bits = 4ull * 1024 * 8); 48 | 49 | static void 50 | force_unroll_factor(u32 u); 51 | //===----------------------------------------------------------------------===// 52 | 53 | zbbf_32(std::size_t m, u32 k, u32 word_cnt_per_block = 4, u32 zone_cnt = 2); 54 | ~zbbf_32() override; 55 | zbbf_32(zbbf_32&&) noexcept; 56 | zbbf_32(const zbbf_32&) = delete; 57 | zbbf_32& operator=(zbbf_32&&); 58 | zbbf_32& operator=(const zbbf_32&) = delete; 59 | 60 | }; 61 | 62 | } // namespace dtl 63 | -------------------------------------------------------------------------------- /src/dtl/filter/zbbf_64.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "zbbf_64.hpp" 4 | 5 | #include "blocked_bloomfilter/instances/zoned_blocked_bloomfilter_logic_u64_instance.hpp" // extern templates to parallelize builds 6 | #include "blocked_bloomfilter/zoned_blocked_bloomfilter.hpp" 7 | #include "blocked_bloomfilter/zoned_blocked_bloomfilter_tune_impl.hpp" 8 | 9 | namespace dtl { 10 | 11 | 12 | namespace { 13 | static dtl::zoned_blocked_bloomfilter_tune_impl<$u64> tuner; 14 | } // anonymous namespace 15 | 16 | 17 | struct zbbf_64::impl { 18 | using bbf_t = dtl::zoned_blocked_bloomfilter<$u64>; 19 | bbf_t instance; 20 | 21 | impl(const size_t m, u32 k, u32 word_cnt_per_block, u32 zone_cnt) 22 | : instance(m, k, word_cnt_per_block, zone_cnt, tuner) { }; 23 | ~impl() = default; 24 | impl(impl&&) = default; 25 | impl(const impl&) = delete; 26 | impl& operator=(impl&&) = default; 27 | impl& operator=(const impl&) = delete; 28 | }; 29 | 30 | zbbf_64::zbbf_64(const size_t m, u32 k, u32 word_cnt_per_block, u32 zone_cnt) 31 | : pimpl{ std::make_unique(m, k, word_cnt_per_block, zone_cnt) } {} 32 | zbbf_64::zbbf_64(zbbf_64&&) noexcept = default; 33 | zbbf_64::~zbbf_64() = default; 34 | zbbf_64& zbbf_64::operator=(zbbf_64&&) = default; 35 | 36 | $u1 37 | zbbf_64::insert(zbbf_64::word_t* __restrict filter_data, u32 key) { 38 | pimpl->instance.insert(filter_data, key); 39 | return true; // inserts never fail 40 | } 41 | 42 | $u1 43 | zbbf_64::batch_insert(zbbf_64::word_t* __restrict filter_data, u32* keys, u32 key_cnt) { 44 | pimpl->instance.batch_insert(filter_data, keys, key_cnt); 45 | return true; // inserts never fail 46 | } 47 | 48 | $u1 49 | zbbf_64::contains(const zbbf_64::word_t* __restrict filter_data, u32 key) const { 50 | return pimpl->instance.contains(filter_data, key); 51 | } 52 | 53 | $u64 54 | zbbf_64::batch_contains(const zbbf_64::word_t* __restrict filter_data, 55 | u32* __restrict keys, u32 key_cnt, 56 | $u32* __restrict match_positions, u32 match_offset) const { 57 | return pimpl->instance.batch_contains(filter_data, keys, key_cnt, match_positions, match_offset); 58 | } 59 | 60 | void 61 | zbbf_64::calibrate(u64 filter_size_bits) { 62 | tuner.tune_unroll_factor(filter_size_bits); 63 | } 64 | 65 | void 66 | zbbf_64::force_unroll_factor(u32 u) { 67 | tuner.set_unroll_factor(u); 68 | } 69 | 70 | std::string 71 | zbbf_64::name() const { 72 | return pimpl->instance.name(); 73 | } 74 | 75 | std::size_t 76 | zbbf_64::size_in_bytes() const { 77 | return pimpl->instance.size_in_bytes(); 78 | } 79 | 80 | std::size_t 81 | zbbf_64::size() const { 82 | return pimpl->instance.size(); 83 | } 84 | 85 | } // namespace dtl 86 | -------------------------------------------------------------------------------- /src/dtl/filter/zbbf_64.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "filter_base.hpp" 5 | 6 | namespace dtl { 7 | 8 | //===----------------------------------------------------------------------===// 9 | // PImpl wrapper to reduce compilation time. 10 | //===----------------------------------------------------------------------===// 11 | class zbbf_64 : public dtl::filter::filter_base { 12 | class impl; 13 | std::unique_ptr pimpl; 14 | 15 | public: 16 | 17 | using key_t = $u32; 18 | using word_t = $u64; 19 | 20 | //===----------------------------------------------------------------------===// 21 | // The API functions. 22 | //===----------------------------------------------------------------------===// 23 | $u1 24 | insert(word_t* __restrict filter_data, key_t key); 25 | 26 | $u1 27 | batch_insert(word_t* __restrict filter_data, const key_t* __restrict keys, u32 key_cnt); 28 | 29 | $u1 30 | contains(const word_t* __restrict filter_data, key_t key) const; 31 | 32 | $u64 33 | batch_contains(const word_t* __restrict filter_data, 34 | const key_t* __restrict keys, u32 key_cnt, 35 | $u32* __restrict match_positions, u32 match_offset) const; 36 | 37 | std::string 38 | name() const; 39 | 40 | std::size_t 41 | size_in_bytes() const; 42 | 43 | std::size_t 44 | size() const; 45 | 46 | static void 47 | calibrate(u64 filter_size_bits = 4ull * 1024 * 8); 48 | 49 | static void 50 | force_unroll_factor(u32 u); 51 | //===----------------------------------------------------------------------===// 52 | 53 | 54 | zbbf_64(std::size_t m, u32 k, u32 word_cnt_per_block = 4, u32 zone_cnt = 2); 55 | ~zbbf_64() override; 56 | zbbf_64(zbbf_64&&) noexcept; 57 | zbbf_64(const zbbf_64&) = delete; 58 | zbbf_64& operator=(zbbf_64&&); 59 | zbbf_64& operator=(const zbbf_64&) = delete; 60 | 61 | }; 62 | 63 | } // namespace dtl 64 | -------------------------------------------------------------------------------- /src/dtl/hash_fvn.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "dtl.hpp" 4 | #include "nmmintrin.h" 5 | 6 | #include 7 | 8 | namespace dtl { 9 | namespace hash { 10 | 11 | // fnv(x) = y 12 | // peter1: 2084897189 13 | // peter2: 2713107310 14 | // knuth1: 2348177672 15 | // knuth2: 931137737 16 | 17 | constexpr uint32_t FNV1_32A_INIT = 0x811c9dc5u; 18 | 19 | /// 32 bit FNV-1a 20 | template 21 | struct fnv_32a { 22 | using Ty = typename std::remove_cv::type; 23 | 24 | __host__ __device__ 25 | static inline Ty 26 | hash(const Ty& key) { 27 | const Ty byte_mask = 0b11111111; 28 | const Ty fnv_32_prime = 0x01000193u; 29 | Ty h = init; 30 | 31 | /* 32 | * FNV-1a hash each octet 33 | */ 34 | const Ty oct_3 = (key >> 24) & byte_mask; 35 | h ^= oct_3; 36 | h *= fnv_32_prime; 37 | const Ty oct_2 = (key >> 16) & byte_mask; 38 | h ^= oct_2; 39 | h *= fnv_32_prime; 40 | const Ty oct_1 = (key >> 8) & byte_mask; 41 | h ^= oct_1; 42 | h *= fnv_32_prime; 43 | const Ty oct_0 = key & byte_mask; 44 | h ^= oct_0; 45 | h *= fnv_32_prime; 46 | 47 | /* return our new hash value */ 48 | return h; 49 | } 50 | }; 51 | 52 | template 53 | struct fnv_32 { 54 | using Ty = typename std::remove_cv::type; 55 | using F = fnv_32a; 56 | 57 | __host__ __device__ 58 | static inline Ty 59 | hash(const Ty& key) { 60 | return F::hash(key); 61 | } 62 | }; 63 | 64 | template 65 | struct fnv_32_alt { 66 | using Ty = typename std::remove_cv::type; 67 | using F = fnv_32a; 68 | 69 | __host__ __device__ 70 | static inline Ty 71 | hash(const Ty& key) { 72 | return F::hash(key); 73 | } 74 | }; 75 | 76 | } // namespace hash 77 | } // namespace dtl 78 | -------------------------------------------------------------------------------- /src/dtl/lockstripe.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | namespace dtl { 13 | 14 | 15 | template 16 | struct lockstripe { 17 | static_assert(dtl::is_power_of_two(N), "Template parameter 'N' must be a power of two."); 18 | static constexpr u64 mask = N - 1; 19 | static constexpr u64 page_size = 4096; 20 | 21 | struct entry { 22 | alignas(dtl::mem::cacheline_size) std::mutex mutex; 23 | std::array<$u8, page_size - sizeof(mutex)> padding; // at least on cache-line, but we are very pessimistic 24 | }; 25 | 26 | const std::array entries; 27 | 28 | inline void 29 | lock(u64 n) { 30 | entries[n & mask].mutex.lock(); 31 | }; 32 | 33 | inline u1 34 | try_lock(u64 n) { 35 | return entries[n & mask].mutex.try_lock(); 36 | }; 37 | 38 | inline void 39 | unlock(u64 n) { 40 | entries[n & mask].mutex.unlock(); 41 | }; 42 | 43 | }; 44 | 45 | 46 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/polyfill.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #if __cplusplus < 201402L 6 | namespace std { 7 | 8 | template 9 | using enable_if_t = typename enable_if::type; 10 | 11 | } 12 | #endif -------------------------------------------------------------------------------- /src/dtl/simd.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // used generate compiler errors if native implementations are included directly 4 | #ifndef _DTL_SIMD_INCLUDED 5 | #define _DTL_SIMD_INCLUDED 6 | #endif 7 | 8 | #include "adept.hpp" 9 | #include 10 | 11 | namespace dtl { 12 | namespace simd { 13 | 14 | struct bitwidth { 15 | static const u64 16 | #ifdef __AVX512F__ 17 | value = 512; 18 | #elif __AVX2__ 19 | value = 256; 20 | #elif __SSE2__ 21 | value = 128; // TODO reset to 128 22 | #else 23 | value = 256; // emulated 24 | #endif 25 | }; 26 | 27 | 28 | 29 | template 30 | static constexpr u64 lane_count = bitwidth::value / (sizeof(T) * 8); 31 | 32 | // template 33 | // struct lane_count { 34 | // static constexpr u64 value = bitwidth::value / (sizeof(T) * 8); 35 | // }; 36 | 37 | 38 | template 39 | struct lane { 40 | enum : u64 { 41 | count = bitwidth::value / (sizeof(T) * 8) 42 | }; 43 | }; 44 | 45 | } // namespace simd 46 | } // namespace dtl 47 | 48 | 49 | #include "simd/types.hpp" 50 | #include "simd/vec.hpp" 51 | //#include "simd/extensions.hpp" 52 | 53 | 54 | // populate the dlt namespace 55 | namespace dtl { 56 | 57 | template 58 | struct super { 59 | // should work for now 60 | using type = typename std::conditional::type; 61 | }; 62 | 63 | 64 | template::count> 65 | using vec = dtl::simd::v; 66 | 67 | /// @deprecated use `dtl::vec` instead 68 | template::count> 69 | using vector = dtl::simd::v; 70 | 71 | //template 72 | //using bitset = dtl::simd::bitset; 73 | 74 | } // namespace dtl 75 | -------------------------------------------------------------------------------- /src/dtl/simd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(SOURCE_FILES ${SOURCE_FILES} 3 | ${CMAKE_CURRENT_SOURCE_DIR}/bitset.hpp 4 | ${CMAKE_CURRENT_SOURCE_DIR}/extensions.hpp 5 | ${CMAKE_CURRENT_SOURCE_DIR}/intrinsics.hpp 6 | ${CMAKE_CURRENT_SOURCE_DIR}/intrin_avx2.hpp 7 | ${CMAKE_CURRENT_SOURCE_DIR}/intrin_avx512.hpp 8 | ${CMAKE_CURRENT_SOURCE_DIR}/intrin_sse.hpp 9 | ${CMAKE_CURRENT_SOURCE_DIR}/intrin_x64.hpp 10 | ${CMAKE_CURRENT_SOURCE_DIR}/types.hpp 11 | ${CMAKE_CURRENT_SOURCE_DIR}/vec.hpp 12 | 13 | PARENT_SCOPE) 14 | -------------------------------------------------------------------------------- /src/dtl/simd/bitset.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace dtl { 10 | namespace simd { 11 | 12 | template 13 | struct bitset : public dtl::bitset { 14 | 15 | /// Returns the value of the bit at the position pos. 16 | template 17 | static inline typename v<$u64, N>::m 18 | test(const v<$u64, N>& bitset_addr, const v<$u64, N>& pos) { 19 | const auto word_idx = pos >> 6; 20 | const auto bit_idx = pos & 0b111111ull; 21 | const auto word_addr = bitset_addr + offsetof(bitset, _M_w) + (word_idx << 3); 22 | const auto word = dtl::gather<$u64>(word_addr); 23 | const auto test_mask = v<$u64, N>::make(1) << bit_idx; 24 | return (word & test_mask) != 0; 25 | } 26 | 27 | }; 28 | 29 | } // namespace simd 30 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/simd/intrin_sse.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef _DTL_SIMD_INCLUDED 4 | #error "Never use directly; include instead." 5 | #endif 6 | 7 | #include "../adept.hpp" 8 | 9 | #include "emmintrin.h" 10 | #include "smmintrin.h" 11 | #include "tmmintrin.h" 12 | #include "xmmintrin.h" 13 | 14 | namespace dtl { 15 | namespace simd { 16 | 17 | /// Define native vector type for SIMD-128: 4 x i32 18 | template<> 19 | struct vs<$i32, 4> : base<$i32, 4> { 20 | using type = __m128i; 21 | using mask_type = __m128i; 22 | type data; 23 | }; 24 | template<> 25 | struct vs<$u32, 4> : base<$u32, 4> { 26 | using type = __m128i; 27 | using mask_type = __m128i; 28 | type data; 29 | }; 30 | 31 | /// Define native vector type for SIMD-256: 4 x i64 32 | template<> 33 | struct vs<$i64, 2> : base<$i64, 2> { 34 | using type = __m128i; 35 | using mask_type = __m128i; 36 | type data; 37 | }; 38 | template<> 39 | struct vs<$u64, 2> : base<$u64, 2> { 40 | using type = __m128i; 41 | using mask_type = __m128i; 42 | type data; 43 | }; 44 | 45 | 46 | 47 | template<> 48 | struct set<$i32, __m128i, $i32> : vector_fn<$i32, __m128i, $i32> { 49 | __forceinline__ __m128i operator()(i32& a) const noexcept { 50 | return _mm_set1_epi32(a); 51 | } 52 | }; 53 | 54 | template<> 55 | struct plus<$i32, __m128i> : vector_fn<$i32, __m128i> { 56 | __forceinline__ __m128i operator()(const __m128i& lhs, const __m128i& rhs) const noexcept { 57 | return _mm_add_epi16(lhs, rhs); 58 | } 59 | }; 60 | 61 | } // namespace simd 62 | } // namespace dtl -------------------------------------------------------------------------------- /src/dtl/simd/vec_readme.md: -------------------------------------------------------------------------------- 1 | # SIMD Vectorization 2 | 3 | The header `` provides an abstraction layer for 4 | x86 SIMD intrinsics. 5 | 6 | It offers vectorized primitives which compile on any platform. 7 | 8 | At compile time the vector operations are translated to the 9 | corresponding ISA of the underlying hardware. 10 | A compatibility layer is available if SIMD is not supported 11 | on the target platform. 12 | 13 | # Glossary 14 | 15 | - **masked operation**, **zero-masking**, **merge-masking**: //TBD 16 | - 17 | 18 | 19 | ## Common functions signatures 20 | 21 | ## Special function signatures 22 | 23 | - `blend(m, a, b)`: is by definition a masked operation. Thus, it 24 | requires a `mask` but no `src` as in merge-masking operations. 25 | 26 | - `gather(...)`: requires a *base address*, a *scale* factor and an *index 27 | vector*. In general the type of the index vector is not the same as 28 | the type of the gathered elements. Especially, if 32-bit elements are 29 | gathered from 64-bit addresses, the function is considered as 30 | *type-narrowing*. 31 | 32 | # Known Issues 33 | - gather/scatter from absolute addresses works works only for 64-bit types. 34 | It is not possible to gather values of other types, such as i32 etc. 35 | -------------------------------------------------------------------------------- /src/dtl/type_traits.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //===----------------------------------------------------------------------===// 3 | #include 4 | 5 | #include 6 | #include 7 | //===----------------------------------------------------------------------===// 8 | namespace dtl { 9 | //===----------------------------------------------------------------------===// 10 | // source: https://stackoverflow.com/questions/12032771/how-to-check-if-an-arbitrary-type-is-an-iterator 11 | template 12 | struct is_iterator { 13 | static constexpr bool value = false; 14 | }; 15 | 16 | template 17 | struct is_iterator::value_type, void>::value>::type> { 18 | static constexpr bool value = true; 19 | }; 20 | //===----------------------------------------------------------------------===// 21 | // Polyfill for C++20 22 | // adapted from https://en.cppreference.com/w/cpp/experimental/is_detected 23 | struct nonesuch { 24 | ~nonesuch() = delete; 25 | nonesuch(nonesuch const&) = delete; 26 | void operator=(nonesuch const&) = delete; 27 | }; 28 | 29 | namespace detail { 30 | template class Op, class... Args> 32 | struct detector { 33 | using value_t = std::false_type; 34 | using type = Default; 35 | }; 36 | 37 | template class Op, class... Args> 38 | struct detector>, Op, Args...> { 39 | using value_t = std::true_type; 40 | using type = Op; 41 | }; 42 | 43 | } // namespace detail 44 | 45 | template class Op, class... Args> 46 | using is_detected = typename detail::detector::value_t; 47 | 48 | template class Op, class... Args> 49 | using detected_t = typename detail::detector::type; 50 | 51 | template class Op, class... Args> 52 | using detected_or = detail::detector; 53 | 54 | template 55 | using copy_assign_t = decltype(std::declval() = std::declval()); 56 | //===----------------------------------------------------------------------===// 57 | } // namespace dtl -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(dtl_tester) 3 | 4 | set(CMAKE_VERBOSE_MAKEFILE OFF) 5 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++14") 6 | 7 | # build optimized executables for the following architectures 8 | set(ARCHS 9 | core-avx2 10 | knl 11 | skx 12 | corei7 13 | ) 14 | 15 | 16 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) 17 | 18 | set(LIBS 19 | gtest 20 | gtest_main 21 | pthread 22 | numa 23 | # dtl 24 | ) 25 | 26 | # check for NUMA support 27 | #find_package(NUMA) 28 | #if (NUMA_FOUND) 29 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_NUMA") 30 | set(LIBS ${LIBS} numa) 31 | #endif (NUMA_FOUND) 32 | 33 | # check for CUDA support 34 | find_package(CUDA) 35 | if (CUDA_FOUND) 36 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_CUDA") 37 | # TODO add CUDA libs 38 | endif (CUDA_FOUND) 39 | 40 | 41 | # replacement for 'add_executable' 42 | function(add_multiarch_executable executable_name files) 43 | foreach(arch ${ARCHS}) 44 | add_executable(${executable_name}_${arch} ${files}) 45 | # workaround for older compilers which don't know the 'skx' architecture. 46 | if (arch STREQUAL "skx") 47 | set_target_properties(${executable_name}_${arch} PROPERTIES COMPILE_FLAGS "-march=knl -mavx512bw") 48 | else() 49 | set_target_properties(${executable_name}_${arch} PROPERTIES COMPILE_FLAGS "-march=${arch}") 50 | endif() 51 | target_link_libraries(${executable_name}_${arch} ${LIBS} dtl_${arch}) 52 | endforeach(arch ${ARCHS}) 53 | endfunction(add_multiarch_executable) 54 | 55 | # note for ubuntu users: gtest lib is no longer shipped as dep package (see http://askubuntu.com/questions/145887/why-no-library-files-installed-for-google-test) 56 | add_subdirectory(lib/googletest) 57 | include_directories(lib/googletest/include lib/googletest) 58 | 59 | add_subdirectory(../ dtl) 60 | include_directories(SYTEM ../thirdparty/) 61 | include_directories(SYTEM ../../) # TODO remove 62 | 63 | 64 | set(TEST_FILES 65 | bitset_test.cpp 66 | div_test.cpp 67 | mem_test.cpp 68 | vec_test.cpp 69 | cuckoofilter_test.cpp 70 | ../src/dtl/filter/filter_test.cpp 71 | ../src/dtl/filter/platform_test.cpp 72 | ../src/dtl/filter/model/benchmark_test.cpp 73 | # ../src/dtl/filter/model/calibration_test.cpp 74 | ../src/dtl/filter/model/calibration_data_test.cpp 75 | ../src/dtl/filter/model/optimizer_test.cpp 76 | 77 | ) 78 | add_multiarch_executable(dtl_tester "${TEST_FILES}") 79 | -------------------------------------------------------------------------------- /test/cuckoofilter_test.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | 3 | #include 4 | #include 5 | 6 | using namespace dtl; 7 | using namespace dtl::cuckoofilter; 8 | 9 | 10 | template 11 | void contains_test() { 12 | 13 | const uint32_t data_bitlength = sizeof(data_t) * 8; 14 | 15 | const uint32_t min_value = 1; 16 | const uint32_t max_value = (1u << bits_per_value) - 1; 17 | 18 | const uint32_t max_elements = data_bitlength / bits_per_value; 19 | 20 | for (uint32_t value = min_value; value <= max_value; value++) { 21 | data_t data = value; 22 | uint32_t match_cntr = 0; 23 | for (uint32_t i = 0; i < data_bitlength; i++) { 24 | auto element_num = i / bits_per_value; 25 | bool is_contained = packed_value::contains(data, value); 26 | if (i % bits_per_value == 0 27 | && element_num < max_elements) { 28 | ASSERT_TRUE(is_contained) << "Failed with value=" << value << ", i=" << i << ", element_num=" << element_num; 29 | match_cntr++; 30 | } 31 | else { 32 | ASSERT_FALSE(is_contained) << "Failed with value=" << value << ", i=" << i << ", element_num=" << element_num; 33 | } 34 | data <<= 1; 35 | } 36 | ASSERT_EQ(match_cntr, max_elements); 37 | } 38 | 39 | 40 | } 41 | 42 | TEST(cuckoofilter, packed_value_contains_test) { 43 | contains_test(); 44 | contains_test(); 45 | contains_test(); 46 | contains_test(); 47 | contains_test(); 48 | contains_test(); 49 | contains_test(); 50 | contains_test(); 51 | contains_test(); 52 | // contains_test(); 53 | contains_test(); 54 | contains_test(); 55 | contains_test(); 56 | contains_test(); 57 | contains_test(); 58 | contains_test(); 59 | contains_test(); 60 | contains_test(); 61 | contains_test(); 62 | contains_test(); 63 | // contains_test(); 64 | contains_test(); 65 | SUCCEED(); 66 | } 67 | 68 | -------------------------------------------------------------------------------- /test/lib/googletest/.gitignore: -------------------------------------------------------------------------------- 1 | # python 2 | *.pyc 3 | -------------------------------------------------------------------------------- /test/lib/googletest/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file contains a list of people who've made non-trivial 2 | # contribution to the Google C++ Testing Framework project. People 3 | # who commit code to the project are encouraged to add their names 4 | # here. Please keep the list sorted by first names. 5 | 6 | Ajay Joshi 7 | Balázs Dán 8 | Bharat Mediratta 9 | Chandler Carruth 10 | Chris Prince 11 | Chris Taylor 12 | Dan Egnor 13 | Eric Roman 14 | Hady Zalek 15 | Jeffrey Yasskin 16 | Jói Sigurðsson 17 | Keir Mierle 18 | Keith Ray 19 | Kenton Varda 20 | Manuel Klimek 21 | Markus Heule 22 | Mika Raento 23 | Miklós Fazekas 24 | Pasi Valminen 25 | Patrick Hanna 26 | Patrick Riley 27 | Peter Kaminski 28 | Preston Jackson 29 | Rainer Klaffenboeck 30 | Russ Cox 31 | Russ Rufer 32 | Sean Mcafee 33 | Sigurður Ásgeirsson 34 | Tracy Bialik 35 | Vadim Berman 36 | Vlad Losev 37 | Zhanyong Wan 38 | -------------------------------------------------------------------------------- /test/lib/googletest/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /test/lib/googletest/build-aux/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peterboncz/bloomfilter-bsd/bae83545a091555e48b5495669c7adcb99fd2047/test/lib/googletest/build-aux/.keep -------------------------------------------------------------------------------- /test/lib/googletest/codegear/gtest.groupproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | {c1d923e0-6cba-4332-9b6f-3420acbf5091} 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Default.Personality 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /test/lib/googletest/codegear/gtest_all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: Josh Kelley (joshkel@gmail.com) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // C++Builder's IDE cannot build a static library from files with hyphens 35 | // in their name. See http://qc.codegear.com/wc/qcmain.aspx?d=70977 . 36 | // This file serves as a workaround. 37 | 38 | #include "src/gtest-all.cc" 39 | -------------------------------------------------------------------------------- /test/lib/googletest/codegear/gtest_link.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: Josh Kelley (joshkel@gmail.com) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // Links gtest.lib and gtest_main.lib into the current project in C++Builder. 35 | // This means that these libraries can't be renamed, but it's the only way to 36 | // ensure that Debug versus Release test builds are linked against the 37 | // appropriate Debug or Release build of the libraries. 38 | 39 | #pragma link "gtest.lib" 40 | #pragma link "gtest_main.lib" 41 | -------------------------------------------------------------------------------- /test/lib/googletest/docs/Documentation.md: -------------------------------------------------------------------------------- 1 | This page lists all documentation wiki pages for Google Test **(the SVN trunk version)** 2 | -- **if you use a released version of Google Test, please read the 3 | documentation for that specific version instead.** 4 | 5 | * [Primer](Primer.md) -- start here if you are new to Google Test. 6 | * [Samples](Samples.md) -- learn from examples. 7 | * [AdvancedGuide](AdvancedGuide.md) -- learn more about Google Test. 8 | * [XcodeGuide](XcodeGuide.md) -- how to use Google Test in Xcode on Mac. 9 | * [Frequently-Asked Questions](FAQ.md) -- check here before asking a question on the mailing list. 10 | 11 | To contribute code to Google Test, read: 12 | 13 | * [DevGuide](DevGuide.md) -- read this _before_ writing your first patch. 14 | * [PumpManual](PumpManual.md) -- how we generate some of Google Test's source files. -------------------------------------------------------------------------------- /test/lib/googletest/docs/Samples.md: -------------------------------------------------------------------------------- 1 | If you're like us, you'd like to look at some Google Test sample code. The 2 | [samples folder](../samples) has a number of well-commented samples showing how to use a 3 | variety of Google Test features. 4 | 5 | * [Sample #1](../samples/sample1_unittest.cc) shows the basic steps of using Google Test to test C++ functions. 6 | * [Sample #2](../samples/sample2_unittest.cc) shows a more complex unit test for a class with multiple member functions. 7 | * [Sample #3](../samples/sample3_unittest.cc) uses a test fixture. 8 | * [Sample #4](../samples/sample4_unittest.cc) is another basic example of using Google Test. 9 | * [Sample #5](../samples/sample5_unittest.cc) teaches how to reuse a test fixture in multiple test cases by deriving sub-fixtures from it. 10 | * [Sample #6](../samples/sample6_unittest.cc) demonstrates type-parameterized tests. 11 | * [Sample #7](../samples/sample7_unittest.cc) teaches the basics of value-parameterized tests. 12 | * [Sample #8](../samples/sample8_unittest.cc) shows using `Combine()` in value-parameterized tests. 13 | * [Sample #9](../samples/sample9_unittest.cc) shows use of the listener API to modify Google Test's console output and the use of its reflection API to inspect test results. 14 | * [Sample #10](../samples/sample10_unittest.cc) shows use of the listener API to implement a primitive memory leak checker. 15 | -------------------------------------------------------------------------------- /test/lib/googletest/docs/V1_5_Documentation.md: -------------------------------------------------------------------------------- 1 | This page lists all official documentation wiki pages for Google Test **1.5.0** -- **if you use a different version of Google Test, make sure to read the documentation for that version instead.** 2 | 3 | * [Primer](V1_5_Primer.md) -- start here if you are new to Google Test. 4 | * [Samples](Samples.md) -- learn from examples. 5 | * [AdvancedGuide](V1_5_AdvancedGuide.md) -- learn more about Google Test. 6 | * [XcodeGuide](V1_5_XcodeGuide.md) -- how to use Google Test in Xcode on Mac. 7 | * [Frequently-Asked Questions](V1_5_FAQ.md) -- check here before asking a question on the mailing list. 8 | 9 | To contribute code to Google Test, read: 10 | 11 | * DevGuide -- read this _before_ writing your first patch. 12 | * [PumpManual](V1_5_PumpManual.md) -- how we generate some of Google Test's source files. -------------------------------------------------------------------------------- /test/lib/googletest/docs/V1_6_Documentation.md: -------------------------------------------------------------------------------- 1 | This page lists all documentation wiki pages for Google Test **1.6** 2 | -- **if you use a released version of Google Test, please read the 3 | documentation for that specific version instead.** 4 | 5 | * [Primer](V1_6_Primer.md) -- start here if you are new to Google Test. 6 | * [Samples](V1_6_Samples.md) -- learn from examples. 7 | * [AdvancedGuide](V1_6_AdvancedGuide.md) -- learn more about Google Test. 8 | * [XcodeGuide](V1_6_XcodeGuide.md) -- how to use Google Test in Xcode on Mac. 9 | * [Frequently-Asked Questions](V1_6_FAQ.md) -- check here before asking a question on the mailing list. 10 | 11 | To contribute code to Google Test, read: 12 | 13 | * [DevGuide](DevGuide.md) -- read this _before_ writing your first patch. 14 | * [PumpManual](V1_6_PumpManual.md) -- how we generate some of Google Test's source files. -------------------------------------------------------------------------------- /test/lib/googletest/docs/V1_6_Samples.md: -------------------------------------------------------------------------------- 1 | If you're like us, you'd like to look at some Google Test sample code. The 2 | [samples folder](../samples) has a number of well-commented samples showing how to use a 3 | variety of Google Test features. 4 | 5 | * [Sample #1](../samples/sample1_unittest.cc) shows the basic steps of using Google Test to test C++ functions. 6 | * [Sample #2](../samples/sample2_unittest.cc) shows a more complex unit test for a class with multiple member functions. 7 | * [Sample #3](../samples/sample3_unittest.cc) uses a test fixture. 8 | * [Sample #4](../samples/sample4_unittest.cc) is another basic example of using Google Test. 9 | * [Sample #5](../samples/sample5_unittest.cc) teaches how to reuse a test fixture in multiple test cases by deriving sub-fixtures from it. 10 | * [Sample #6](../samples/sample6_unittest.cc) demonstrates type-parameterized tests. 11 | * [Sample #7](../samples/sample7_unittest.cc) teaches the basics of value-parameterized tests. 12 | * [Sample #8](../samples/sample8_unittest.cc) shows using `Combine()` in value-parameterized tests. 13 | * [Sample #9](../samples/sample9_unittest.cc) shows use of the listener API to modify Google Test's console output and the use of its reflection API to inspect test results. 14 | * [Sample #10](../samples/sample10_unittest.cc) shows use of the listener API to implement a primitive memory leak checker. 15 | -------------------------------------------------------------------------------- /test/lib/googletest/docs/V1_7_Documentation.md: -------------------------------------------------------------------------------- 1 | This page lists all documentation wiki pages for Google Test **(the SVN trunk version)** 2 | -- **if you use a released version of Google Test, please read the 3 | documentation for that specific version instead.** 4 | 5 | * [Primer](V1_7_Primer.md) -- start here if you are new to Google Test. 6 | * [Samples](V1_7_Samples.md) -- learn from examples. 7 | * [AdvancedGuide](V1_7_AdvancedGuide.md) -- learn more about Google Test. 8 | * [XcodeGuide](V1_7_XcodeGuide.md) -- how to use Google Test in Xcode on Mac. 9 | * [Frequently-Asked Questions](V1_7_FAQ.md) -- check here before asking a question on the mailing list. 10 | 11 | To contribute code to Google Test, read: 12 | 13 | * [DevGuide](DevGuide.md) -- read this _before_ writing your first patch. 14 | * [PumpManual](V1_7_PumpManual.md) -- how we generate some of Google Test's source files. -------------------------------------------------------------------------------- /test/lib/googletest/docs/V1_7_Samples.md: -------------------------------------------------------------------------------- 1 | If you're like us, you'd like to look at some Google Test sample code. The 2 | [samples folder](../samples) has a number of well-commented samples showing how to use a 3 | variety of Google Test features. 4 | 5 | * [Sample #1](../samples/sample1_unittest.cc) shows the basic steps of using Google Test to test C++ functions. 6 | * [Sample #2](../samples/sample2_unittest.cc) shows a more complex unit test for a class with multiple member functions. 7 | * [Sample #3](../samples/sample3_unittest.cc) uses a test fixture. 8 | * [Sample #4](../samples/sample4_unittest.cc) is another basic example of using Google Test. 9 | * [Sample #5](../samples/sample5_unittest.cc) teaches how to reuse a test fixture in multiple test cases by deriving sub-fixtures from it. 10 | * [Sample #6](../samples/sample6_unittest.cc) demonstrates type-parameterized tests. 11 | * [Sample #7](../samples/sample7_unittest.cc) teaches the basics of value-parameterized tests. 12 | * [Sample #8](../samples/sample8_unittest.cc) shows using `Combine()` in value-parameterized tests. 13 | * [Sample #9](../samples/sample9_unittest.cc) shows use of the listener API to modify Google Test's console output and the use of its reflection API to inspect test results. 14 | * [Sample #10](../samples/sample10_unittest.cc) shows use of the listener API to implement a primitive memory leak checker. 15 | -------------------------------------------------------------------------------- /test/lib/googletest/include/gtest/gtest_prod.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Google C++ Testing Framework definitions useful in production code. 33 | 34 | #ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 35 | #define GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 36 | 37 | // When you need to test the private or protected members of a class, 38 | // use the FRIEND_TEST macro to declare your tests as friends of the 39 | // class. For example: 40 | // 41 | // class MyClass { 42 | // private: 43 | // void MyMethod(); 44 | // FRIEND_TEST(MyClassTest, MyMethod); 45 | // }; 46 | // 47 | // class MyClassTest : public testing::Test { 48 | // // ... 49 | // }; 50 | // 51 | // TEST_F(MyClassTest, MyMethod) { 52 | // // Can call MyClass::MyMethod() here. 53 | // } 54 | 55 | #define FRIEND_TEST(test_case_name, test_name)\ 56 | friend class test_case_name##_##test_name##_Test 57 | 58 | #endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_ 59 | -------------------------------------------------------------------------------- /test/lib/googletest/include/gtest/internal/custom/gtest-printers.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // This file provides an injection point for custom printers in a local 31 | // installation of gTest. 32 | // It will be included from gtest-printers.h and the overrides in this file 33 | // will be visible to everyone. 34 | // See documentation at gtest/gtest-printers.h for details on how to define a 35 | // custom printer. 36 | // 37 | // ** Custom implementation starts here ** 38 | 39 | #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 40 | #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 41 | 42 | #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PRINTERS_H_ 43 | -------------------------------------------------------------------------------- /test/lib/googletest/include/gtest/internal/custom/gtest.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Injection point for custom user configurations. 31 | // The following macros can be defined: 32 | // 33 | // GTEST_OS_STACK_TRACE_GETTER_ - The name of an implementation of 34 | // OsStackTraceGetterInterface. 35 | // 36 | // ** Custom implementation starts here ** 37 | 38 | #ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 39 | #define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 40 | 41 | #endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_ 42 | -------------------------------------------------------------------------------- /test/lib/googletest/msvc/gtest-md.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest-md", "gtest-md.vcproj", "{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_main-md", "gtest_main-md.vcproj", "{3AF54C8A-10BF-4332-9147-F68ED9862033}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_prod_test-md", "gtest_prod_test-md.vcproj", "{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | EndProjectSection 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_unittest-md", "gtest_unittest-md.vcproj", "{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}" 15 | ProjectSection(ProjectDependencies) = postProject 16 | EndProjectSection 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfiguration) = preSolution 20 | Debug = Debug 21 | Release = Release 22 | EndGlobalSection 23 | GlobalSection(ProjectConfiguration) = postSolution 24 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Debug.ActiveCfg = Debug|Win32 25 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Debug.Build.0 = Debug|Win32 26 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Release.ActiveCfg = Release|Win32 27 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Release.Build.0 = Release|Win32 28 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Debug.ActiveCfg = Debug|Win32 29 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Debug.Build.0 = Debug|Win32 30 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Release.ActiveCfg = Release|Win32 31 | {3AF54C8A-10BF-4332-9147-F68ED9862033}.Release.Build.0 = Release|Win32 32 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Debug.ActiveCfg = Debug|Win32 33 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Debug.Build.0 = Debug|Win32 34 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Release.ActiveCfg = Release|Win32 35 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Release.Build.0 = Release|Win32 36 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Debug.ActiveCfg = Debug|Win32 37 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Debug.Build.0 = Debug|Win32 38 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Release.ActiveCfg = Release|Win32 39 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Release.Build.0 = Release|Win32 40 | EndGlobalSection 41 | GlobalSection(ExtensibilityGlobals) = postSolution 42 | EndGlobalSection 43 | GlobalSection(ExtensibilityAddIns) = postSolution 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /test/lib/googletest/msvc/gtest.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest", "gtest.vcproj", "{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_main", "gtest_main.vcproj", "{3AF54C8A-10BF-4332-9147-F68ED9862032}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_unittest", "gtest_unittest.vcproj", "{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | EndProjectSection 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest_prod_test", "gtest_prod_test.vcproj", "{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}" 15 | ProjectSection(ProjectDependencies) = postProject 16 | EndProjectSection 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfiguration) = preSolution 20 | Debug = Debug 21 | Release = Release 22 | EndGlobalSection 23 | GlobalSection(ProjectConfiguration) = postSolution 24 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.ActiveCfg = Debug|Win32 25 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.Build.0 = Debug|Win32 26 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.ActiveCfg = Release|Win32 27 | {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.Build.0 = Release|Win32 28 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.ActiveCfg = Debug|Win32 29 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.Build.0 = Debug|Win32 30 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.ActiveCfg = Release|Win32 31 | {3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.Build.0 = Release|Win32 32 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.ActiveCfg = Debug|Win32 33 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.Build.0 = Debug|Win32 34 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.ActiveCfg = Release|Win32 35 | {4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.Build.0 = Release|Win32 36 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.ActiveCfg = Debug|Win32 37 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.Build.0 = Debug|Win32 38 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.ActiveCfg = Release|Win32 39 | {24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.Build.0 = Release|Win32 40 | EndGlobalSection 41 | GlobalSection(ExtensibilityGlobals) = postSolution 42 | EndGlobalSection 43 | GlobalSection(ExtensibilityAddIns) = postSolution 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /test/lib/googletest/samples/sample1.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #ifndef GTEST_SAMPLES_SAMPLE1_H_ 35 | #define GTEST_SAMPLES_SAMPLE1_H_ 36 | 37 | // Returns n! (the factorial of n). For negative n, n! is defined to be 1. 38 | int Factorial(int n); 39 | 40 | // Returns true iff n is a prime number. 41 | bool IsPrime(int n); 42 | 43 | #endif // GTEST_SAMPLES_SAMPLE1_H_ 44 | -------------------------------------------------------------------------------- /test/lib/googletest/samples/sample2.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #include "sample2.h" 35 | 36 | #include 37 | 38 | // Clones a 0-terminated C string, allocating memory using new. 39 | const char* MyString::CloneCString(const char* a_c_string) { 40 | if (a_c_string == NULL) return NULL; 41 | 42 | const size_t len = strlen(a_c_string); 43 | char* const clone = new char[ len + 1 ]; 44 | memcpy(clone, a_c_string, len + 1); 45 | 46 | return clone; 47 | } 48 | 49 | // Sets the 0-terminated C string this MyString object 50 | // represents. 51 | void MyString::Set(const char* a_c_string) { 52 | // Makes sure this works when c_string == c_string_ 53 | const char* const temp = MyString::CloneCString(a_c_string); 54 | delete[] c_string_; 55 | c_string_ = temp; 56 | } 57 | -------------------------------------------------------------------------------- /test/lib/googletest/samples/sample4.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #include 35 | 36 | #include "sample4.h" 37 | 38 | // Returns the current counter value, and increments it. 39 | int Counter::Increment() { 40 | return counter_++; 41 | } 42 | 43 | // Prints the current counter value to STDOUT. 44 | void Counter::Print() const { 45 | printf("%d", counter_); 46 | } 47 | -------------------------------------------------------------------------------- /test/lib/googletest/samples/sample4.h: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // A sample program demonstrating using Google C++ testing framework. 31 | // 32 | // Author: wan@google.com (Zhanyong Wan) 33 | 34 | #ifndef GTEST_SAMPLES_SAMPLE4_H_ 35 | #define GTEST_SAMPLES_SAMPLE4_H_ 36 | 37 | // A simple monotonic counter. 38 | class Counter { 39 | private: 40 | int counter_; 41 | 42 | public: 43 | // Creates a counter that starts at 0. 44 | Counter() : counter_(0) {} 45 | 46 | // Returns the current counter value, and increments it. 47 | int Increment(); 48 | 49 | // Prints the current counter value to STDOUT. 50 | void Print() const; 51 | }; 52 | 53 | #endif // GTEST_SAMPLES_SAMPLE4_H_ 54 | -------------------------------------------------------------------------------- /test/lib/googletest/samples/sample4_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2005, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | #include "sample4.h" 34 | 35 | // Tests the Increment() method. 36 | TEST(Counter, Increment) { 37 | Counter c; 38 | 39 | // EXPECT_EQ() evaluates its arguments exactly once, so they 40 | // can have side effects. 41 | 42 | EXPECT_EQ(0, c.Increment()); 43 | EXPECT_EQ(1, c.Increment()); 44 | EXPECT_EQ(2, c.Increment()); 45 | } 46 | -------------------------------------------------------------------------------- /test/lib/googletest/scripts/test/Makefile: -------------------------------------------------------------------------------- 1 | # A Makefile for fusing Google Test and building a sample test against it. 2 | # 3 | # SYNOPSIS: 4 | # 5 | # make [all] - makes everything. 6 | # make TARGET - makes the given target. 7 | # make check - makes everything and runs the built sample test. 8 | # make clean - removes all files generated by make. 9 | 10 | # Points to the root of fused Google Test, relative to where this file is. 11 | FUSED_GTEST_DIR = output 12 | 13 | # Paths to the fused gtest files. 14 | FUSED_GTEST_H = $(FUSED_GTEST_DIR)/gtest/gtest.h 15 | FUSED_GTEST_ALL_CC = $(FUSED_GTEST_DIR)/gtest/gtest-all.cc 16 | 17 | # Where to find the sample test. 18 | SAMPLE_DIR = ../../samples 19 | 20 | # Where to find gtest_main.cc. 21 | GTEST_MAIN_CC = ../../src/gtest_main.cc 22 | 23 | # Flags passed to the preprocessor. 24 | # We have no idea here whether pthreads is available in the system, so 25 | # disable its use. 26 | CPPFLAGS += -I$(FUSED_GTEST_DIR) -DGTEST_HAS_PTHREAD=0 27 | 28 | # Flags passed to the C++ compiler. 29 | CXXFLAGS += -g 30 | 31 | all : sample1_unittest 32 | 33 | check : all 34 | ./sample1_unittest 35 | 36 | clean : 37 | rm -rf $(FUSED_GTEST_DIR) sample1_unittest *.o 38 | 39 | $(FUSED_GTEST_H) : 40 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR) 41 | 42 | $(FUSED_GTEST_ALL_CC) : 43 | ../fuse_gtest_files.py $(FUSED_GTEST_DIR) 44 | 45 | gtest-all.o : $(FUSED_GTEST_H) $(FUSED_GTEST_ALL_CC) 46 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(FUSED_GTEST_DIR)/gtest/gtest-all.cc 47 | 48 | gtest_main.o : $(FUSED_GTEST_H) $(GTEST_MAIN_CC) 49 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_MAIN_CC) 50 | 51 | sample1.o : $(SAMPLE_DIR)/sample1.cc $(SAMPLE_DIR)/sample1.h 52 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1.cc 53 | 54 | sample1_unittest.o : $(SAMPLE_DIR)/sample1_unittest.cc \ 55 | $(SAMPLE_DIR)/sample1.h $(FUSED_GTEST_H) 56 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1_unittest.cc 57 | 58 | sample1_unittest : sample1.o sample1_unittest.o gtest-all.o gtest_main.o 59 | $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@ 60 | -------------------------------------------------------------------------------- /test/lib/googletest/src/gtest-all.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: mheule@google.com (Markus Heule) 31 | // 32 | // Google C++ Testing Framework (Google Test) 33 | // 34 | // Sometimes it's desirable to build Google Test by compiling a single file. 35 | // This file serves this purpose. 36 | 37 | // This line ensures that gtest.h can be compiled on its own, even 38 | // when it's fused. 39 | #include "gtest/gtest.h" 40 | 41 | // The following lines pull in the real gtest *.cc files. 42 | #include "src/gtest.cc" 43 | #include "src/gtest-death-test.cc" 44 | #include "src/gtest-filepath.cc" 45 | #include "src/gtest-port.cc" 46 | #include "src/gtest-printers.cc" 47 | #include "src/gtest-test-part.cc" 48 | #include "src/gtest-typed-test.cc" 49 | -------------------------------------------------------------------------------- /test/lib/googletest/src/gtest_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | #include 31 | 32 | #include "gtest/gtest.h" 33 | 34 | GTEST_API_ int main(int argc, char **argv) { 35 | printf("Running main() from gtest_main.cc\n"); 36 | testing::InitGoogleTest(&argc, argv); 37 | return RUN_ALL_TESTS(); 38 | } 39 | -------------------------------------------------------------------------------- /test/lib/googletest/test/gtest-param-test_test.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Authors: vladl@google.com (Vlad Losev) 31 | // 32 | // The Google C++ Testing Framework (Google Test) 33 | // 34 | // This header file provides classes and functions used internally 35 | // for testing Google Test itself. 36 | 37 | #ifndef GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 38 | #define GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 39 | 40 | #include "gtest/gtest.h" 41 | 42 | #if GTEST_HAS_PARAM_TEST 43 | 44 | // Test fixture for testing definition and instantiation of a test 45 | // in separate translation units. 46 | class ExternalInstantiationTest : public ::testing::TestWithParam { 47 | }; 48 | 49 | // Test fixture for testing instantiation of a test in multiple 50 | // translation units. 51 | class InstantiationInMultipleTranslaionUnitsTest 52 | : public ::testing::TestWithParam { 53 | }; 54 | 55 | #endif // GTEST_HAS_PARAM_TEST 56 | 57 | #endif // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_ 58 | -------------------------------------------------------------------------------- /test/lib/googletest/test/gtest-typed-test2_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008 Google Inc. 2 | // All Rights Reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include 33 | 34 | #include "test/gtest-typed-test_test.h" 35 | #include "gtest/gtest.h" 36 | 37 | #if GTEST_HAS_TYPED_TEST_P 38 | 39 | // Tests that the same type-parameterized test case can be 40 | // instantiated in different translation units linked together. 41 | // (ContainerTest is also instantiated in gtest-typed-test_test.cc.) 42 | INSTANTIATE_TYPED_TEST_CASE_P(Vector, ContainerTest, 43 | testing::Types >); 44 | 45 | #endif // GTEST_HAS_TYPED_TEST_P 46 | -------------------------------------------------------------------------------- /test/lib/googletest/test/gtest_all_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Tests for Google C++ Testing Framework (Google Test) 33 | // 34 | // Sometimes it's desirable to build most of Google Test's own tests 35 | // by compiling a single file. This file serves this purpose. 36 | #include "test/gtest-filepath_test.cc" 37 | #include "test/gtest-linked_ptr_test.cc" 38 | #include "test/gtest-message_test.cc" 39 | #include "test/gtest-options_test.cc" 40 | #include "test/gtest-port_test.cc" 41 | #include "test/gtest_pred_impl_unittest.cc" 42 | #include "test/gtest_prod_test.cc" 43 | #include "test/gtest-test-part_test.cc" 44 | #include "test/gtest-typed-test_test.cc" 45 | #include "test/gtest-typed-test2_test.cc" 46 | #include "test/gtest_unittest.cc" 47 | #include "test/production.cc" 48 | -------------------------------------------------------------------------------- /test/lib/googletest/test/gtest_help_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2009, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | // This program is meant to be run by gtest_help_test.py. Do not run 33 | // it directly. 34 | 35 | #include "gtest/gtest.h" 36 | 37 | // When a help flag is specified, this program should skip the tests 38 | // and exit with 0; otherwise the following test will be executed, 39 | // causing this program to exit with a non-zero code. 40 | TEST(HelpFlagTest, ShouldNotBeRun) { 41 | ASSERT_TRUE(false) << "Tests shouldn't be run when --help is specified."; 42 | } 43 | 44 | #if GTEST_HAS_DEATH_TEST 45 | TEST(DeathTest, UsedByPythonScriptToDetectSupportForDeathTestsInThisBinary) {} 46 | #endif 47 | -------------------------------------------------------------------------------- /test/lib/googletest/test/gtest_main_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | 34 | // Tests that we don't have to define main() when we link to 35 | // gtest_main instead of gtest. 36 | 37 | namespace { 38 | 39 | TEST(GTestMainTest, ShouldSucceed) { 40 | } 41 | 42 | } // namespace 43 | 44 | // We are using the main() function defined in src/gtest_main.cc, so 45 | // we don't define it here. 46 | -------------------------------------------------------------------------------- /test/lib/googletest/test/gtest_no_test_unittest.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | // Tests that a Google Test program that has no test defined can run 31 | // successfully. 32 | // 33 | // Author: wan@google.com (Zhanyong Wan) 34 | 35 | #include "gtest/gtest.h" 36 | 37 | int main(int argc, char **argv) { 38 | testing::InitGoogleTest(&argc, argv); 39 | 40 | // An ad-hoc assertion outside of all tests. 41 | // 42 | // This serves three purposes: 43 | // 44 | // 1. It verifies that an ad-hoc assertion can be executed even if 45 | // no test is defined. 46 | // 2. It verifies that a failed ad-hoc assertion causes the test 47 | // program to fail. 48 | // 3. We had a bug where the XML output won't be generated if an 49 | // assertion is executed before RUN_ALL_TESTS() is called, even 50 | // though --gtest_output=xml is specified. This makes sure the 51 | // bug is fixed and doesn't regress. 52 | EXPECT_EQ(1, 2); 53 | 54 | // The above EXPECT_EQ() should cause RUN_ALL_TESTS() to return non-zero. 55 | return RUN_ALL_TESTS() ? 0 : 1; 56 | } 57 | -------------------------------------------------------------------------------- /test/lib/googletest/test/gtest_prod_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // Unit test for include/gtest/gtest_prod.h. 33 | 34 | #include "gtest/gtest.h" 35 | #include "test/production.h" 36 | 37 | // Tests that private members can be accessed from a TEST declared as 38 | // a friend of the class. 39 | TEST(PrivateCodeTest, CanAccessPrivateMembers) { 40 | PrivateCode a; 41 | EXPECT_EQ(0, a.x_); 42 | 43 | a.set_x(1); 44 | EXPECT_EQ(1, a.x_); 45 | } 46 | 47 | typedef testing::Test PrivateCodeFixtureTest; 48 | 49 | // Tests that private members can be accessed from a TEST_F declared 50 | // as a friend of the class. 51 | TEST_F(PrivateCodeFixtureTest, CanAccessPrivateMembers) { 52 | PrivateCode a; 53 | EXPECT_EQ(0, a.x_); 54 | 55 | a.set_x(2); 56 | EXPECT_EQ(2, a.x_); 57 | } 58 | -------------------------------------------------------------------------------- /test/lib/googletest/test/gtest_sole_header_test.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: mheule@google.com (Markus Heule) 31 | // 32 | // This test verifies that it's possible to use Google Test by including 33 | // the gtest.h header file alone. 34 | 35 | #include "gtest/gtest.h" 36 | 37 | namespace { 38 | 39 | void Subroutine() { 40 | EXPECT_EQ(42, 42); 41 | } 42 | 43 | TEST(NoFatalFailureTest, ExpectNoFatalFailure) { 44 | EXPECT_NO_FATAL_FAILURE(;); 45 | EXPECT_NO_FATAL_FAILURE(SUCCEED()); 46 | EXPECT_NO_FATAL_FAILURE(Subroutine()); 47 | EXPECT_NO_FATAL_FAILURE({ SUCCEED(); }); 48 | } 49 | 50 | TEST(NoFatalFailureTest, AssertNoFatalFailure) { 51 | ASSERT_NO_FATAL_FAILURE(;); 52 | ASSERT_NO_FATAL_FAILURE(SUCCEED()); 53 | ASSERT_NO_FATAL_FAILURE(Subroutine()); 54 | ASSERT_NO_FATAL_FAILURE({ SUCCEED(); }); 55 | } 56 | 57 | } // namespace 58 | -------------------------------------------------------------------------------- /test/lib/googletest/test/gtest_uninitialized_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | 32 | #include "gtest/gtest.h" 33 | 34 | TEST(DummyTest, Dummy) { 35 | // This test doesn't verify anything. We just need it to create a 36 | // realistic stage for testing the behavior of Google Test when 37 | // RUN_ALL_TESTS() is called without testing::InitGoogleTest() being 38 | // called first. 39 | } 40 | 41 | int main() { 42 | return RUN_ALL_TESTS(); 43 | } 44 | -------------------------------------------------------------------------------- /test/lib/googletest/test/gtest_xml_outfile1_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: keith.ray@gmail.com (Keith Ray) 31 | // 32 | // gtest_xml_outfile1_test_ writes some xml via TestProperty used by 33 | // gtest_xml_outfiles_test.py 34 | 35 | #include "gtest/gtest.h" 36 | 37 | class PropertyOne : public testing::Test { 38 | protected: 39 | virtual void SetUp() { 40 | RecordProperty("SetUpProp", 1); 41 | } 42 | virtual void TearDown() { 43 | RecordProperty("TearDownProp", 1); 44 | } 45 | }; 46 | 47 | TEST_F(PropertyOne, TestSomeProperties) { 48 | RecordProperty("TestSomeProperty", 1); 49 | } 50 | -------------------------------------------------------------------------------- /test/lib/googletest/test/gtest_xml_outfile2_test_.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: keith.ray@gmail.com (Keith Ray) 31 | // 32 | // gtest_xml_outfile2_test_ writes some xml via TestProperty used by 33 | // gtest_xml_outfiles_test.py 34 | 35 | #include "gtest/gtest.h" 36 | 37 | class PropertyTwo : public testing::Test { 38 | protected: 39 | virtual void SetUp() { 40 | RecordProperty("SetUpProp", 2); 41 | } 42 | virtual void TearDown() { 43 | RecordProperty("TearDownProp", 2); 44 | } 45 | }; 46 | 47 | TEST_F(PropertyTwo, TestSomeProperties) { 48 | RecordProperty("TestSomeProperty", 2); 49 | } 50 | -------------------------------------------------------------------------------- /test/lib/googletest/test/production.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // This is part of the unit test for include/gtest/gtest_prod.h. 33 | 34 | #include "production.h" 35 | 36 | PrivateCode::PrivateCode() : x_(0) {} 37 | -------------------------------------------------------------------------------- /test/lib/googletest/test/production.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: wan@google.com (Zhanyong Wan) 31 | // 32 | // This is part of the unit test for include/gtest/gtest_prod.h. 33 | 34 | #ifndef GTEST_TEST_PRODUCTION_H_ 35 | #define GTEST_TEST_PRODUCTION_H_ 36 | 37 | #include "gtest/gtest_prod.h" 38 | 39 | class PrivateCode { 40 | public: 41 | // Declares a friend test that does not use a fixture. 42 | FRIEND_TEST(PrivateCodeTest, CanAccessPrivateMembers); 43 | 44 | // Declares a friend test that uses a fixture. 45 | FRIEND_TEST(PrivateCodeFixtureTest, CanAccessPrivateMembers); 46 | 47 | PrivateCode(); 48 | 49 | int x() const { return x_; } 50 | private: 51 | void set_x(int an_x) { x_ = an_x; } 52 | int x_; 53 | }; 54 | 55 | #endif // GTEST_TEST_PRODUCTION_H_ 56 | -------------------------------------------------------------------------------- /test/lib/googletest/xcode/Config/DebugProject.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // DebugProject.xcconfig 3 | // 4 | // These are Debug Configuration project settings for the gtest framework and 5 | // examples. It is set in the "Based On:" dropdown in the "Project" info 6 | // dialog. 7 | // This file is based on the Xcode Configuration files in: 8 | // http://code.google.com/p/google-toolbox-for-mac/ 9 | // 10 | 11 | #include "General.xcconfig" 12 | 13 | // No optimization 14 | GCC_OPTIMIZATION_LEVEL = 0 15 | 16 | // Deployment postprocessing is what triggers Xcode to strip, turn it off 17 | DEPLOYMENT_POSTPROCESSING = NO 18 | 19 | // Dead code stripping off 20 | DEAD_CODE_STRIPPING = NO 21 | 22 | // Debug symbols should be on obviously 23 | GCC_GENERATE_DEBUGGING_SYMBOLS = YES 24 | 25 | // Define the DEBUG macro in all debug builds 26 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DDEBUG=1 27 | 28 | // These are turned off to avoid STL incompatibilities with client code 29 | // // Turns on special C++ STL checks to "encourage" good STL use 30 | // GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) _GLIBCXX_DEBUG_PEDANTIC _GLIBCXX_DEBUG _GLIBCPP_CONCEPT_CHECKS 31 | -------------------------------------------------------------------------------- /test/lib/googletest/xcode/Config/FrameworkTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // FrameworkTarget.xcconfig 3 | // 4 | // These are Framework target settings for the gtest framework and examples. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Dynamic libs need to be position independent 11 | GCC_DYNAMIC_NO_PIC = NO 12 | 13 | // Dynamic libs should not have their external symbols stripped. 14 | STRIP_STYLE = non-global 15 | 16 | // Let the user install by specifying the $DSTROOT with xcodebuild 17 | SKIP_INSTALL = NO 18 | -------------------------------------------------------------------------------- /test/lib/googletest/xcode/Config/General.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // General.xcconfig 3 | // 4 | // These are General configuration settings for the gtest framework and 5 | // examples. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Build for PPC and Intel, 32- and 64-bit 11 | ARCHS = i386 x86_64 ppc ppc64 12 | 13 | // Zerolink prevents link warnings so turn it off 14 | ZERO_LINK = NO 15 | 16 | // Prebinding considered unhelpful in 10.3 and later 17 | PREBINDING = NO 18 | 19 | // Strictest warning policy 20 | WARNING_CFLAGS = -Wall -Werror -Wendif-labels -Wnewline-eof -Wno-sign-compare -Wshadow 21 | 22 | // Work around Xcode bugs by using external strip. See: 23 | // http://lists.apple.com/archives/Xcode-users/2006/Feb/msg00050.html 24 | SEPARATE_STRIP = YES 25 | 26 | // Force C99 dialect 27 | GCC_C_LANGUAGE_STANDARD = c99 28 | 29 | // not sure why apple defaults this on, but it's pretty risky 30 | ALWAYS_SEARCH_USER_PATHS = NO 31 | 32 | // Turn on position dependent code for most cases (overridden where appropriate) 33 | GCC_DYNAMIC_NO_PIC = YES 34 | 35 | // Default SDK and minimum OS version is 10.4 36 | SDKROOT = $(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk 37 | MACOSX_DEPLOYMENT_TARGET = 10.4 38 | GCC_VERSION = 4.0 39 | 40 | // VERSIONING BUILD SETTINGS (used in Info.plist) 41 | GTEST_VERSIONINFO_ABOUT = © 2008 Google Inc. 42 | -------------------------------------------------------------------------------- /test/lib/googletest/xcode/Config/ReleaseProject.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // ReleaseProject.xcconfig 3 | // 4 | // These are Release Configuration project settings for the gtest framework 5 | // and examples. It is set in the "Based On:" dropdown in the "Project" info 6 | // dialog. 7 | // This file is based on the Xcode Configuration files in: 8 | // http://code.google.com/p/google-toolbox-for-mac/ 9 | // 10 | 11 | #include "General.xcconfig" 12 | 13 | // subconfig/Release.xcconfig 14 | 15 | // Optimize for space and size (Apple recommendation) 16 | GCC_OPTIMIZATION_LEVEL = s 17 | 18 | // Deploment postprocessing is what triggers Xcode to strip 19 | DEPLOYMENT_POSTPROCESSING = YES 20 | 21 | // No symbols 22 | GCC_GENERATE_DEBUGGING_SYMBOLS = NO 23 | 24 | // Dead code strip does not affect ObjC code but can help for C 25 | DEAD_CODE_STRIPPING = YES 26 | 27 | // NDEBUG is used by things like assert.h, so define it for general compat. 28 | // ASSERT going away in release tends to create unused vars. 29 | OTHER_CFLAGS = $(OTHER_CFLAGS) -DNDEBUG=1 -Wno-unused-variable 30 | 31 | // When we strip we want to strip all symbols in release, but save externals. 32 | STRIP_STYLE = all 33 | -------------------------------------------------------------------------------- /test/lib/googletest/xcode/Config/StaticLibraryTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // StaticLibraryTarget.xcconfig 3 | // 4 | // These are static library target settings for libgtest.a. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | // This file is based on the Xcode Configuration files in: 7 | // http://code.google.com/p/google-toolbox-for-mac/ 8 | // 9 | 10 | // Static libs can be included in bundles so make them position independent 11 | GCC_DYNAMIC_NO_PIC = NO 12 | 13 | // Static libs should not have their internal globals or external symbols 14 | // stripped. 15 | STRIP_STYLE = debugging 16 | 17 | // Let the user install by specifying the $DSTROOT with xcodebuild 18 | SKIP_INSTALL = NO 19 | -------------------------------------------------------------------------------- /test/lib/googletest/xcode/Config/TestTarget.xcconfig: -------------------------------------------------------------------------------- 1 | // 2 | // TestTarget.xcconfig 3 | // 4 | // These are Test target settings for the gtest framework and examples. It 5 | // is set in the "Based On:" dropdown in the "Target" info dialog. 6 | 7 | PRODUCT_NAME = $(TARGET_NAME) 8 | HEADER_SEARCH_PATHS = ../include 9 | -------------------------------------------------------------------------------- /test/lib/googletest/xcode/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.google.${PRODUCT_NAME} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | GTEST_VERSIONINFO_LONG 21 | CFBundleShortVersionString 22 | GTEST_VERSIONINFO_SHORT 23 | CFBundleGetInfoString 24 | ${PRODUCT_NAME} GTEST_VERSIONINFO_LONG, ${GTEST_VERSIONINFO_ABOUT} 25 | NSHumanReadableCopyright 26 | ${GTEST_VERSIONINFO_ABOUT} 27 | CSResourcesFileMapped 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /test/lib/googletest/xcode/Samples/FrameworkSample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.google.gtest.${PRODUCT_NAME:identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | CSResourcesFileMapped 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /test/lib/googletest/xcode/Samples/FrameworkSample/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright 2008, Google Inc. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are 8 | # met: 9 | # 10 | # * Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # * Redistributions in binary form must reproduce the above 13 | # copyright notice, this list of conditions and the following disclaimer 14 | # in the documentation and/or other materials provided with the 15 | # distribution. 16 | # * Neither the name of Google Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived from 18 | # this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Executes the samples and tests for the Google Test Framework. 33 | 34 | # Help the dynamic linker find the path to the libraries. 35 | export DYLD_FRAMEWORK_PATH=$BUILT_PRODUCTS_DIR 36 | export DYLD_LIBRARY_PATH=$BUILT_PRODUCTS_DIR 37 | 38 | # Create some executables. 39 | test_executables=$@ 40 | 41 | # Now execute each one in turn keeping track of how many succeeded and failed. 42 | succeeded=0 43 | failed=0 44 | failed_list=() 45 | for test in ${test_executables[*]}; do 46 | "$test" 47 | result=$? 48 | if [ $result -eq 0 ]; then 49 | succeeded=$(( $succeeded + 1 )) 50 | else 51 | failed=$(( failed + 1 )) 52 | failed_list="$failed_list $test" 53 | fi 54 | done 55 | 56 | # Report the successes and failures to the console. 57 | echo "Tests complete with $succeeded successes and $failed failures." 58 | if [ $failed -ne 0 ]; then 59 | echo "The following tests failed:" 60 | echo $failed_list 61 | fi 62 | exit $failed 63 | -------------------------------------------------------------------------------- /test/lib/googletest/xcode/Samples/FrameworkSample/widget.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: preston.a.jackson@gmail.com (Preston Jackson) 31 | // 32 | // Google Test - FrameworkSample 33 | // widget.cc 34 | // 35 | 36 | // Widget is a very simple class used for demonstrating the use of gtest 37 | 38 | #include "widget.h" 39 | 40 | Widget::Widget(int number, const std::string& name) 41 | : number_(number), 42 | name_(name) {} 43 | 44 | Widget::~Widget() {} 45 | 46 | float Widget::GetFloatValue() const { 47 | return number_; 48 | } 49 | 50 | int Widget::GetIntValue() const { 51 | return static_cast(number_); 52 | } 53 | 54 | std::string Widget::GetStringValue() const { 55 | return name_; 56 | } 57 | 58 | void Widget::GetCharPtrValue(char* buffer, size_t max_size) const { 59 | // Copy the char* representation of name_ into buffer, up to max_size. 60 | strncpy(buffer, name_.c_str(), max_size-1); 61 | buffer[max_size-1] = '\0'; 62 | return; 63 | } 64 | -------------------------------------------------------------------------------- /test/lib/googletest/xcode/Samples/FrameworkSample/widget.h: -------------------------------------------------------------------------------- 1 | // Copyright 2008, Google Inc. 2 | // All rights reserved. 3 | // 4 | // Redistribution and use in source and binary forms, with or without 5 | // modification, are permitted provided that the following conditions are 6 | // met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above 11 | // copyright notice, this list of conditions and the following disclaimer 12 | // in the documentation and/or other materials provided with the 13 | // distribution. 14 | // * Neither the name of Google Inc. nor the names of its 15 | // contributors may be used to endorse or promote products derived from 16 | // this software without specific prior written permission. 17 | // 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | // 30 | // Author: preston.a.jackson@gmail.com (Preston Jackson) 31 | // 32 | // Google Test - FrameworkSample 33 | // widget.h 34 | // 35 | 36 | // Widget is a very simple class used for demonstrating the use of gtest. It 37 | // simply stores two values a string and an integer, which are returned via 38 | // public accessors in multiple forms. 39 | 40 | #import 41 | 42 | class Widget { 43 | public: 44 | Widget(int number, const std::string& name); 45 | ~Widget(); 46 | 47 | // Public accessors to number data 48 | float GetFloatValue() const; 49 | int GetIntValue() const; 50 | 51 | // Public accessors to the string data 52 | std::string GetStringValue() const; 53 | void GetCharPtrValue(char* buffer, size_t max_size) const; 54 | 55 | private: 56 | // Data members 57 | float number_; 58 | std::string name_; 59 | }; 60 | -------------------------------------------------------------------------------- /tool/calibration/src/filter-calibration-tool.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include "dtl/filter/model/calibration.hpp" 5 | #include "dtl/filter/model/calibration_data.hpp" 6 | 7 | #include "skyline_matrix_builder.hpp" 8 | #include "util.hpp" 9 | 10 | using namespace dtl::filter::model; 11 | 12 | $i32 13 | main() { 14 | auto& data = dtl::filter::model::calibration_data::get_default_instance(); 15 | dtl::filter::model::calibration calibration(data); 16 | 17 | std::cout << data << std::endl; 18 | 19 | calibration.calibrate_tuning_params(); 20 | data.persist(); 21 | 22 | calibration.calibrate_cache_sizes(); 23 | data.persist(); 24 | 25 | calibration.calibrate_filter_costs(); 26 | data.persist(); 27 | 28 | build_skyline_matrix(data); 29 | data.persist(); 30 | 31 | std::cout << data << std::endl; 32 | 33 | } 34 | -------------------------------------------------------------------------------- /tool/calibration/src/skyline_matrix_builder.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace dtl { 7 | namespace filter { 8 | namespace model { 9 | 10 | 11 | //===----------------------------------------------------------------------===// 12 | 13 | void 14 | build_skyline_matrix(dtl::filter::model::calibration_data&); 15 | 16 | //===----------------------------------------------------------------------===// 17 | 18 | 19 | } // namespace model 20 | } // namespace filter 21 | } // namespace dtl 22 | -------------------------------------------------------------------------------- /tool/calibration/src/util.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | // Read the CPU affinity for the process. 14 | static const auto cpu_mask = dtl::this_thread::get_cpu_affinity(); 15 | 16 | 17 | template 18 | void dispatch(const std::vector tasks, 19 | std::function fn) { 20 | 21 | i64 thread_cnt = dtl::env<$u64>::get("THREAD_CNT", cpu_mask.count()); 22 | i64 task_cnt = tasks.size(); 23 | i64 min_batch_size = 1; 24 | i64 max_batch_size = 16; 25 | 26 | const auto time_start = std::chrono::system_clock::now(); 27 | std::atomic<$i64> cntr { 0 }; 28 | auto thread_fn = [&](u32 thread_id) { 29 | while (true) { 30 | // Grab work. 31 | const auto inc = std::min(std::max(min_batch_size, (task_cnt - cntr) / thread_cnt), max_batch_size); 32 | const auto task_idx_begin = cntr.fetch_add(inc); 33 | const auto task_idx_end = std::min(task_idx_begin + inc, task_cnt); 34 | if (task_idx_begin >= task_cnt) break; 35 | std::stringstream s; 36 | // s << "thread " << thread_id << " got " << (task_idx_end - task_idx_begin) << " task(s)" << std::endl; 37 | std::cerr << s.str(); 38 | 39 | std::stringstream str; 40 | for ($i64 ci = task_idx_begin; ci < task_idx_end; ci++) { 41 | fn(tasks[ci], str); 42 | } 43 | std::cout << str.str(); 44 | 45 | if (thread_id == 0) { 46 | i64 i = std::min(i64(cntr), i64(task_cnt)); 47 | i64 r = std::min(task_cnt, task_cnt - i); 48 | // Estimate time until completion. 49 | const auto now = std::chrono::system_clock::now(); 50 | std::chrono::duration elapsed_seconds = now - time_start; 51 | f64 avg_sec_per_task = elapsed_seconds.count() / i; 52 | u64 remaining_sec = avg_sec_per_task * r; 53 | u64 h = (remaining_sec / 3600); 54 | u64 m = (remaining_sec % 3600) / 60; 55 | std::stringstream str; 56 | str << "Progress: [" << (i + 1) << "/" << task_cnt << "]"; 57 | str << " - estimated time until completion: " << h << "h " << m << "m" << std::endl; 58 | std::cerr << str.str(); 59 | } 60 | } 61 | }; 62 | dtl::run_in_parallel(thread_fn, cpu_mask, cpu_mask.count()); 63 | } 64 | --------------------------------------------------------------------------------