You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by jm...@apache.org on 2022/04/27 22:19:30 UTC

[datasketches-characterization] branch master updated: add cmake support for c++, including minor updates to support compilation from linux mint

This is an automated email from the ASF dual-hosted git repository.

jmalkin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/datasketches-characterization.git


The following commit(s) were added to refs/heads/master by this push:
     new 4d339d3  add cmake support for c++, including minor updates to support compilation from linux mint
     new ed1ba33  Merge branch 'master' of github.com:apache/datasketches-characterization
4d339d3 is described below

commit 4d339d3ad3f57612f09bfcd1d8cf81535392db97
Author: Jon <jm...@apache.org>
AuthorDate: Wed Apr 27 15:17:18 2022 -0700

    add cmake support for c++, including minor updates to support compilation from linux mint
---
 .gitignore                              |   1 -
 CMakeLists.txt                          |  81 +++++++++++++++++++++++++
 build/.gitignore                        |   7 +++
 cpp/CMakeLists.txt                      | 101 ++++++++++++++++++++++++++++++++
 cpp/src/cpc_sketch_memory_profile.cpp   |   2 +-
 cpp/src/hll_sketch_memory_profile.cpp   |   2 +-
 cpp/src/kll_merge_accuracy_profile.cpp  |   2 +-
 cpp/src/kll_sketch_accuracy_profile.cpp |   2 +-
 cpp/src/theta_sketch_memory_profile.cpp |   2 +-
 9 files changed, 194 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index d2c99ae..8641a36 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,7 +53,6 @@ bin/
 # Build artifacts
 cpp/Default/
 **/out/
-**/build/
 **/jarsIn/
 **/build.xml
 **/.idea
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..e111a26
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,81 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+cmake_minimum_required(VERSION 3.12.0)
+project(Characterization
+        LANGUAGES CXX)
+
+include(GNUInstallDirs)
+include(CMakeDependentOption)
+
+### Require out-of-source builds
+file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH)
+if(EXISTS "${LOC_PATH}")
+    message(FATAL_ERROR "You cannot build in a source directory (or any directory with a CMakeLists.txt file). Please make a build subdirectory. Feel free to remove CMakeCache.txt and CMakeFiles.")
+endif()
+
+# Ensure builds on Windows export all symbols
+set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
+
+#set(CMAKE_VERBOSE_MAKEFILE ON)
+set(CMAKE_MACOSX_RPATH ON)
+
+set(CMAKE_CXX_STANDARD 11)
+
+# enable compiler warnings globally
+# derived from https://foonathan.net/blog/2018/10/17/cmake-warnings.html
+# and https://arne-mertz.de/2018/07/cmake-properties-options/
+if (MSVC)
+  add_compile_options(/W4)
+  set(CMAKE_DEBUG_POSTFIX "d")
+else()
+  add_compile_options(-Wall -pedantic -W -Wextra)
+endif()
+
+if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0")
+  add_compile_options(-Wimplicit-fallthrough=3)
+endif()
+
+# Code generation options, to ensure shaerd libraries work and are portable
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+set(CMAKE_C_EXTENSIONS OFF)
+set(CMAKE_CXX_EXTENSIONS OFF)
+
+###### OPTIONS ######
+option(SANITIZE "Run sanitization checks (g++/clang only)" OFF)
+if(SANITIZE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
+  add_compile_options(-fsanitize=${SANITIZE})
+  add_link_options(-fsanitize=${SANITIZE})
+endif()
+
+
+# set default build type to Release
+# Derived from: https://blog.kitware.com/cmake-and-the-default-build-type/
+set(default_build_type "Release")
+if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
+  message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
+  set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
+      STRING "Choose the type of build." FORCE)
+  # Set the possible values of build type for cmake-gui
+  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
+    "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
+endif()
+
+###### TARGETS ######
+# do we need the next line since we don't actually make a library anymore?
+
+add_subdirectory(cpp)
diff --git a/build/.gitignore b/build/.gitignore
new file mode 100644
index 0000000..8928ce2
--- /dev/null
+++ b/build/.gitignore
@@ -0,0 +1,7 @@
+# build/ directory for convenience, but should remain empty
+
+# Ignore everything in here
+*
+
+# Add an exception for this file
+!.gitignore
\ No newline at end of file
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
new file mode 100644
index 0000000..5c53da1
--- /dev/null
+++ b/cpp/CMakeLists.txt
@@ -0,0 +1,101 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+add_executable(characterization)
+
+find_package(DataSketches 3.2 REQUIRED)
+target_link_libraries(characterization PUBLIC ${DATASKETCHES_LIB})
+target_include_directories(characterization PUBLIC ${DATASKETCHES_INCLUDE_DIR})
+
+target_compile_features(common INTERFACE cxx_std_11)
+
+set_target_properties(characterization PROPERTIES
+  CXX_STANDARD 11
+  CXX_STANDARD_REQUIRED YES
+)
+
+target_sources(characterization
+  PRIVATE
+    src/main.cpp
+    src/job_profile.cpp
+    src/job_profile.hpp
+    src/counting_allocator.hpp
+    src/cpc_sketch_accuracy_profile.cpp
+    src/cpc_sketch_accuracy_profile.hpp
+    src/cpc_sketch_memory_profile.cpp
+    src/cpc_sketch_memory_profile.hpp
+    src/cpc_sketch_timing_profile.cpp
+    src/cpc_sketch_timing_profile.hpp
+    src/cpc_union_accuracy_profile.cpp
+    src/cpc_union_accuracy_profile.hpp
+    src/cpc_union_timing_profile.cpp
+    src/cpc_union_timing_profile.hpp
+    src/distinct_count_accuracy_profile.cpp
+    src/distinct_count_accuracy_profile.hpp
+    src/frequent_items_merge_timing_profile.cpp
+    src/frequent_items_merge_timing_profile.hpp
+    src/frequent_items_sketch_accuracy_profile.cpp
+    src/frequent_items_sketch_accuracy_profile.hpp
+    src/frequent_items_sketch_timing_profile.cpp
+    src/frequent_items_sketch_timing_profile.hpp
+    src/hll_cross_language_profile.cpp
+    src/hll_cross_language_profile.hpp
+    src/hll_sketch_accuracy_profile.cpp
+    src/hll_sketch_accuracy_profile.hpp
+    src/hll_sketch_memory_profile.cpp
+    src/hll_sketch_memory_profile.hpp
+    src/hll_sketch_timing_profile.cpp
+    src/hll_sketch_timing_profile.hpp
+    src/hll_union_accuracy_profile.cpp
+    src/hll_union_accuracy_profile.hpp
+    src/hll_union_timing_profile.cpp
+    src/hll_union_timing_profile.hpp
+    src/kll_accuracy_profile.cpp
+    src/kll_accuracy_profile.hpp
+    src/kll_merge_accuracy_profile.cpp
+    src/kll_merge_accuracy_profile.hpp
+    src/kll_merge_timing_profile.hpp
+    src/kll_merge_timing_profile_impl.hpp
+    src/kll_sketch_accuracy_profile.cpp
+    src/kll_sketch_accuracy_profile.hpp
+    src/kll_sketch_memory_profile.hpp
+    src/kll_sketch_memory_profile_impl.hpp
+    src/kll_sketch_timing_profile.hpp
+    src/kll_sketch_timing_profile_impl.hpp
+    src/memory_usage_profile.cpp
+    src/memory_usage_profile.hpp
+    src/req_merge_timing_profile.hpp
+    src/req_merge_timing_profile_impl.hpp
+    src/req_sketch_timing_profile.hpp
+    src/req_sketch_timing_profile_impl.hpp
+    src/theta_sketch_accuracy_profile.cpp
+    src/theta_sketch_accuracy_profile.hpp
+    src/theta_sketch_memory_profile.cpp
+    src/theta_sketch_memory_profile.hpp
+    src/theta_sketch_timing_profile.cpp
+    src/theta_sketch_timing_profile.hpp
+    src/theta_union_accuracy_profile.cpp
+    src/theta_union_accuracy_profile.hpp
+    src/theta_union_timing_profile.cpp
+    src/theta_union_timing_profile.hpp
+    src/tuple_sketch_timing_profile.cpp
+    src/tuple_sketch_timing_profile.hpp
+    src/tuple_union_timing_profile.cpp
+    src/tuple_union_timing_profile.hpp
+    src/zipf_distribution.cpp
+    src/zipf_distribution.hpp
+)
diff --git a/cpp/src/cpc_sketch_memory_profile.cpp b/cpp/src/cpc_sketch_memory_profile.cpp
index 772ad4d..e2f9293 100644
--- a/cpp/src/cpc_sketch_memory_profile.cpp
+++ b/cpp/src/cpc_sketch_memory_profile.cpp
@@ -30,7 +30,7 @@ extern long long int total_allocated_memory;
 void cpc_sketch_memory_profile::run_trial(size_t lg_min_x, size_t num_points, size_t x_ppo) {
   const size_t lg_k = 26;
 
-  typedef cpc_sketch_alloc<counting_allocator<void>> cpc_sketch_a;
+  typedef cpc_sketch_alloc<counting_allocator<uint8_t>> cpc_sketch_a;
   cpc_sketch_a* s = new (counting_allocator<cpc_sketch_a>().allocate(1)) cpc_sketch_a(lg_k);
 
   size_t count = 0;
diff --git a/cpp/src/hll_sketch_memory_profile.cpp b/cpp/src/hll_sketch_memory_profile.cpp
index f6ed46f..74420f1 100644
--- a/cpp/src/hll_sketch_memory_profile.cpp
+++ b/cpp/src/hll_sketch_memory_profile.cpp
@@ -31,7 +31,7 @@ void hll_sketch_memory_profile::run_trial(size_t lg_min_x, size_t num_points, si
   const size_t lg_k = 12;
   const target_hll_type hll_type = HLL_4;
 
-  typedef hll_sketch_alloc<counting_allocator<void>> hll_sketch_a;
+  typedef hll_sketch_alloc<counting_allocator<uint8_t>> hll_sketch_a;
   hll_sketch_a* s = new (counting_allocator<hll_sketch_a>().allocate(1)) hll_sketch_a(lg_k, hll_type);
 
   size_t count = 0;
diff --git a/cpp/src/kll_merge_accuracy_profile.cpp b/cpp/src/kll_merge_accuracy_profile.cpp
index 65db044..9b9d556 100644
--- a/cpp/src/kll_merge_accuracy_profile.cpp
+++ b/cpp/src/kll_merge_accuracy_profile.cpp
@@ -51,7 +51,7 @@ double kll_merge_accuracy_profile::run_trial(float* values, unsigned stream_leng
   for (size_t i = 0; i < stream_length; i++) {
     double true_rank = static_cast<double>(i) / stream_length;
     double est_rank = sketch.get_rank(i);
-    max_rank_error = std::max(max_rank_error, abs(true_rank - est_rank));
+    max_rank_error = std::max(max_rank_error, fabs(true_rank - est_rank));
   }
 
   return max_rank_error;
diff --git a/cpp/src/kll_sketch_accuracy_profile.cpp b/cpp/src/kll_sketch_accuracy_profile.cpp
index 2caa3e2..ece5c6b 100644
--- a/cpp/src/kll_sketch_accuracy_profile.cpp
+++ b/cpp/src/kll_sketch_accuracy_profile.cpp
@@ -38,7 +38,7 @@ double kll_sketch_accuracy_profile::run_trial(float* values, unsigned stream_len
   for (size_t i = 0; i < stream_length; i++) {
     double true_rank = (double) i / stream_length;
     double est_rank = sketch.get_rank(i);
-    max_rank_error = std::max(max_rank_error, abs(true_rank - est_rank));
+    max_rank_error = std::max(max_rank_error, fabs(true_rank - est_rank));
   }
 
   return max_rank_error;
diff --git a/cpp/src/theta_sketch_memory_profile.cpp b/cpp/src/theta_sketch_memory_profile.cpp
index ee39310..dad0a36 100644
--- a/cpp/src/theta_sketch_memory_profile.cpp
+++ b/cpp/src/theta_sketch_memory_profile.cpp
@@ -30,7 +30,7 @@ extern long long int total_allocated_memory;
 void theta_sketch_memory_profile::run_trial(size_t lg_min_x, size_t num_points, size_t x_ppo) {
   const size_t lg_k = 26;
 
-  typedef update_theta_sketch_alloc<counting_allocator<void>> update_theta_sketch_a;
+  typedef update_theta_sketch_alloc<counting_allocator<uint64_t>> update_theta_sketch_a;
   update_theta_sketch_a::builder builder;
   builder.set_lg_k(lg_k);
   update_theta_sketch_a* s = new (counting_allocator<update_theta_sketch_a>().allocate(1)) update_theta_sketch_a(builder.build());


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org