Skip to content

Commit

Permalink
✨ New bit benchmarks to go with the paper!
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePhD committed Dec 5, 2021
1 parent 128d97e commit 89dd0e4
Show file tree
Hide file tree
Showing 37 changed files with 3,750 additions and 530 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ CMakeSettings.json

/main.cpp
/*.hex
__pycache__/
1 change: 1 addition & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
based_on_style = pep8
use_tabs = true
indent_width = 5
column_limit = 100

spaces_before_comment = 1
spaces_around_power_operator = true
Expand Down
22 changes: 6 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# ============================================================================>

cmake_minimum_required(VERSION 3.21.0)
cmake_policy(VERSION 3.16)
cmake_policy(VERSION 3.21)
# # Project kickstart
# Includes a bunch of basic flags and utilities shared across projects
# See more at the github repository link below
Expand Down Expand Up @@ -80,18 +80,13 @@ option(ZTD_IDK_DOCUMENTATION_NO_SPHINX "Turn off Sphinx usage (useful for ReadTh
option(ZTD_IDK_EXAMPLES "Enable build of examples" OFF)
option(ZTD_IDK_BENCHMARKS "Enable build of benchmarks" OFF)
option(ZTD_IDK_GENERATE_SINGLE "Enable generation of a single header and its target" OFF)
set(ZTD_IDK_BENCHMARKS_REPETITIONS 50 CACHE STRING "Number of repetitions to perform. Each repetition has a number of iterations: higher means a lot more time is spent benchmarking.")

# Modify bad flags / change defaults if we are the top level
if (ZTD_IDK_IS_TOP_LEVEL_PROJECT)
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x86/${CMAKE_BUILD_TYPE}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x86/${CMAKE_BUILD_TYPE}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x86/${CMAKE_BUILD_TYPE}/bin")
else()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x64/${CMAKE_BUILD_TYPE}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x64/${CMAKE_BUILD_TYPE}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/x64/${CMAKE_BUILD_TYPE}/bin")
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")

if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
Expand All @@ -114,17 +109,12 @@ if (ZTD_IDK_IS_TOP_LEVEL_PROJECT)
check_compiler_flag(extra-constexpr-depth MSVC /constexpr:depth2147483647 GCC -fconstexpr-depth=2147483647 CLANG -fconstexpr-depth=2147483647)
check_compiler_flag(extra-constexpr-steps MSVC /constexpr:steps2147483647 GCC -fconstexpr-ops-limit=2147483647 CLANG -fconstexpr-steps=2147483647)
check_compiler_flag(template-debugging-mode GCC -ftemplate-backtrace-limit=0)
check_compiler_diagnostic(microsoft-enum-value)
endif()
endif()

# # Main library declarations
# ztd.version
file(GLOB_RECURSE ztd.version.includes
CONFIGURE_DEPENDS
include/tag_invoke**.hpp
include/tag_invoke**.h
)

add_library(ztd.version INTERFACE)
add_library(ztd::version ALIAS ztd.version)
target_include_directories(ztd.version
Expand Down
55 changes: 55 additions & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# =============================================================================
#
# ztd.idk
# Copyright © 2021 JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC
# Contact: opensource@soasis.org
#
# Commercial License Usage
# Licensees holding valid commercial ztd.idk licenses may use this file in
# accordance with the commercial license agreement provided with the
# Software or, alternatively, in accordance with the terms contained in
# a written agreement between you and Shepherd's Oasis, LLC.
# For licensing terms and conditions see your agreement. For
# further information contact opensource@soasis.org.
#
# Apache License Version 2 Usage
# Alternatively, this file may be used under the terms of Apache License
# Version 2.0 (the "License") for non-commercial use; 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.
#
# ============================================================================>

# # Dependencies
# google benchmark
if (NOT TARGET benchmark)
FetchContent_Declare(
google_benchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG fd258bbd131552beb2483b960a5e4b69553fdacf
)
# Benchmark variables, internal setup
set(BENCHMARK_ENABLE_EXCEPTIONS ON)
set(BENCHMARK_ENABLE_TESTING OFF)
set(BENCHMARK_DOWNLOAD_DEPENDENCIES OFF)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
set(BENCHMARK_ENABLE_WERROR OFF)
set(BENCHMARK_FORCE_WERROR OFF)

FetchContent_MakeAvailable(google_benchmark)
endif()

# # Benchmarks
# Bit benchmarks
add_subdirectory(bit)
# # Benchmark Tools
add_subdirectory(tools)
59 changes: 59 additions & 0 deletions benchmarks/bit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# =============================================================================
#
# ztd.idk
# Copyright © 2021 JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC
# Contact: opensource@soasis.org
#
# Commercial License Usage
# Licensees holding valid commercial ztd.idk licenses may use this file in
# accordance with the commercial license agreement provided with the
# Software or, alternatively, in accordance with the terms contained in
# a written agreement between you and Shepherd's Oasis, LLC.
# For licensing terms and conditions see your agreement. For
# further information contact opensource@soasis.org.
#
# Apache License Version 2 Usage
# Alternatively, this file may be used under the terms of Apache License
# Version 2.0 (the "License") for non-commercial use; 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.
#
# ============================================================================>

# # Dependencies
# opaque library
add_subdirectory(opaque)

# # Benchmark Executable
file(GLOB_RECURSE ztd.idk.benchmarks.bit.sources CONFIGURE_DEPENDS source/**)

add_executable(ztd.idk.benchmarks.bit ${ztd.idk.benchmarks.bit.sources})
target_include_directories(ztd.idk.benchmarks.bit PRIVATE
include
)
target_link_libraries(ztd.idk.benchmarks.bit PRIVATE
ztd::idk
ztd::idk::benchmarks::opaque
benchmark
${CMAKE_DL_LIBS}
)

target_compile_options(ztd.idk.benchmarks.bit
PRIVATE
${--utf8-literal-encoding}
${--utf8-source-encoding}
${--disable-permissive}
${--warn-pedantic}
${--warn-default}
${--warn-extra}
${--warn-errors}
${--allow-microsoft-enum-value}
)
68 changes: 68 additions & 0 deletions benchmarks/bit/graph_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"name": "bit",
"scale": {
"type": "relative",
"to": "base"
},
"categories": [
{
"name": "find",
"pattern": "find_",
"ascending": true
},
{
"name": "count",
"pattern": "count_",
"ascending": true
},
{
"name": "is_sorted_until",
"pattern": "is_sorted_until_",
"ascending": true
},
{
"name": "is_sorted",
"pattern": "is_sorted_",
"exclude": "_until_",
"ascending": true
}
],
"data_labels": [
{
"name": "real time",
"id": "real_time",
"format": "clock",
"primary": true
},
{
"name": "cpu time",
"id": "cpu_time",
"format": "clock"
}
],
"remove_suffixes": [
",",
"_"
],
"remove_prefixes": [
",",
"_"
],
"sources": [
{
"prefix": "libc++",
"file": "libc++.ztd.idk.benchmarks.bit.json",
"required": false
},
{
"prefix": "libstdc++",
"file": "libstdc++.ztd.idk.benchmarks.bit.json",
"required": false
},
{
"prefix": "vc++",
"file": "vc++.ztd.idk.benchmarks.bit.json",
"required": false
}
]
}
62 changes: 62 additions & 0 deletions benchmarks/bit/opaque/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# =============================================================================
#
# ztd.idk
# Copyright © 2021 JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC
# Contact: opensource@soasis.org
#
# Commercial License Usage
# Licensees holding valid commercial ztd.idk licenses may use this file in
# accordance with the commercial license agreement provided with the
# Software or, alternatively, in accordance with the terms contained in
# a written agreement between you and Shepherd's Oasis, LLC.
# For licensing terms and conditions see your agreement. For
# further information contact opensource@soasis.org.
#
# Apache License Version 2 Usage
# Alternatively, this file may be used under the terms of Apache License
# Version 2.0 (the "License") for non-commercial use; 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.
#
# ============================================================================>

# # Opaque Library
file(GLOB_RECURSE ztd.idk.benchmarks.opaque.sources
CONFIGURE_DEPENDS
source/**.cpp source/**.c)

add_library(ztd.idk.benchmarks.opaque SHARED ${ztd.idk.benchmarks.opaque.sources})
add_library(ztd::idk::benchmarks::opaque ALIAS ztd.idk.benchmarks.opaque)
target_include_directories(ztd.idk.benchmarks.opaque
PUBLIC
include/
)
target_link_libraries(ztd.idk.benchmarks.opaque PRIVATE
ztd::idk
${CMAKE_DL_LIBS}
)
target_compile_definitions(ztd.idk.benchmarks.opaque
PRIVATE
ZTD_OPAQUE_BUILD=1
)
target_compile_definitions(ztd.idk.benchmarks.opaque
PUBLIC
ZTD_OPAQUE_DLL=1
)
target_compile_options(ztd.idk.benchmarks.opaque PRIVATE
${--utf8-literal-encoding}
${--utf8-source-encoding}
${--disable-permissive}
${--warn-pedantic}
${--warn-default}
${--warn-extra}
${--warn-errors}
)
48 changes: 48 additions & 0 deletions benchmarks/bit/opaque/include/opaque/opaque.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// =============================================================================
//
// ztd.idk
// Copyright © 2021 JeanHeyd "ThePhD" Meneide and Shepherd's Oasis, LLC
// Contact: opensource@soasis.org
//
// Commercial License Usage
// Licensees holding valid commercial ztd.idk licenses may use this file in
// accordance with the commercial license agreement provided with the
// Software or, alternatively, in accordance with the terms contained in
// a written agreement between you and Shepherd's Oasis, LLC.
// For licensing terms and conditions see your agreement. For
// further information contact opensource@soasis.org.
//
// Apache License Version 2 Usage
// Alternatively, this file may be used under the terms of Apache License
// Version 2.0 (the "License") for non-commercial use; 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.
//
// ============================================================================>

#ifndef ZTD_IDK_BENCHMARKS_OPAQUE_OPAQUE_HPP
#define ZTD_IDK_BENCHMARKS_OPAQUE_OPAQUE_HPP

#pragma once

#include <opaque/version.hpp>

#include <cstddef>

ZTD_OPAQUE_API_LINKAGE_I_ std::size_t opaque_benchmark_loop_limit(void) ZTD_NOEXCEPT_IF_CXX_I_;

ZTD_OPAQUE_API_LINKAGE_I_ std::size_t opaque_hardcoded_index(void) ZTD_NOEXCEPT_IF_CXX_I_;

ZTD_OPAQUE_API_LINKAGE_I_ bool opaque_true(void) ZTD_NOEXCEPT_IF_CXX_I_;

ZTD_OPAQUE_API_LINKAGE_I_ bool opaque_false(void) ZTD_NOEXCEPT_IF_CXX_I_;

#endif // ZTD_IDK_BENCHMARKS_OPAQUE_OPAQUE_HPP

0 comments on commit 89dd0e4

Please sign in to comment.