From 6ab061663c67efc10fd827186440d29623db4ee2 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Wed, 14 Oct 2020 11:03:51 -0500 Subject: [PATCH 01/19] Move nvtx3.hpp to include/nvtx3 directory. --- cpp/benchmarks/nvtx/nvtx_benchmark.cpp | 2 +- cpp/{ => include/nvtx3}/nvtx3.hpp | 0 cpp/tests/CMakeLists.txt | 2 +- cpp/tests/nvtx_tests.cpp | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename cpp/{ => include/nvtx3}/nvtx3.hpp (100%) diff --git a/cpp/benchmarks/nvtx/nvtx_benchmark.cpp b/cpp/benchmarks/nvtx/nvtx_benchmark.cpp index cf9e2ba..870926c 100644 --- a/cpp/benchmarks/nvtx/nvtx_benchmark.cpp +++ b/cpp/benchmarks/nvtx/nvtx_benchmark.cpp @@ -1,7 +1,7 @@ #include -#include +#include /** * Measure cost of not reusing the same `event_attributes` object diff --git a/cpp/nvtx3.hpp b/cpp/include/nvtx3/nvtx3.hpp similarity index 100% rename from cpp/nvtx3.hpp rename to cpp/include/nvtx3/nvtx3.hpp diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index b5df50c..ca44e45 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -41,7 +41,7 @@ endfunction(ConfigureTest) include_directories("${GTEST_INCLUDE_DIR}" "${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}" - "${CMAKE_SOURCE_DIR}") + "${CMAKE_SOURCE_DIR}/include") ################################################################################################### # - library paths --------------------------------------------------------------------------------- diff --git a/cpp/tests/nvtx_tests.cpp b/cpp/tests/nvtx_tests.cpp index f70beb3..e307b6b 100644 --- a/cpp/tests/nvtx_tests.cpp +++ b/cpp/tests/nvtx_tests.cpp @@ -16,7 +16,7 @@ #include -#include +#include struct NVTX_Test : public ::testing::Test { }; From f37ba237c5bb3f823fefae41eb1ff8f592d6dbe9 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Wed, 14 Oct 2020 11:20:25 -0500 Subject: [PATCH 02/19] Create nvtx3-cpp target and define properties. --- cpp/CMakeLists.txt | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 2875a84..7818232 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -15,9 +15,7 @@ #============================================================================= cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -project(NVTX VERSION 0.1.0 LANGUAGES C CXX CUDA) - -find_package(CUDA REQUIRED) +project(NVTX VERSION 0.1.0 LANGUAGES CXX) ################################################################################################### # - build type ------------------------------------------------------------------------------------ @@ -34,15 +32,16 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() -################################################################################################### -# - compiler options ------------------------------------------------------------------------------ - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -if(CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") -endif(CMAKE_COMPILER_IS_GNUCXX) +################################################################################################### +# - nvtx target ----------------------------------------------------------------------------------- +add_library(nvtx3-cpp INTERFACE) +target_include_directories(nvtx3-cpp INTERFACE + "$" + "$") + +target_compile_features(nvtx3-cpp INTERFACE cxx_std_11) +target_link_libraries(nvtx3-cpp INTERFACE ${CMAKE_DL_LIBS}) # Build options option(BUILD_TESTS "Configure CMake to build tests" ON) From beebc03bb8cbbecc63a77056006bc954ca993e70 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Wed, 14 Oct 2020 11:24:43 -0500 Subject: [PATCH 03/19] Link benchmarks and tests against nvtx3-cpp target. --- cpp/benchmarks/CMakeLists.txt | 7 ++----- cpp/tests/CMakeLists.txt | 5 ++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index ec48cb0..89ff5aa 100644 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -32,7 +32,7 @@ function(ConfigureBench CMAKE_BENCH_NAME CMAKE_BENCH_SRC) add_executable(${CMAKE_BENCH_NAME} ${CMAKE_BENCH_SRC}) set_target_properties(${CMAKE_BENCH_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) - target_link_libraries(${CMAKE_BENCH_NAME} benchmark benchmark_main pthread dl) + target_link_libraries(${CMAKE_BENCH_NAME} benchmark benchmark_main pthread nvtx3-cpp) set_target_properties(${CMAKE_BENCH_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/gbenchmarks") endfunction(ConfigureBench) @@ -41,10 +41,7 @@ endfunction(ConfigureBench) # - include paths --------------------------------------------------------------------------------- include_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}" - "${CMAKE_SOURCE_DIR}/include" - "${CMAKE_SOURCE_DIR}" - "${GBENCH_INCLUDE_DIR}" - "${CMAKE_CURRENT_SOURCE_DIR}") + "${GBENCH_INCLUDE_DIR}") ################################################################################################### # - library paths --------------------------------------------------------------------------------- diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index ca44e45..2c1626c 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -30,7 +30,7 @@ function(ConfigureTest CMAKE_TEST_NAME CMAKE_TEST_SRC) add_executable(${CMAKE_TEST_NAME} ${CMAKE_TEST_SRC}) set_target_properties(${CMAKE_TEST_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) target_link_libraries(${CMAKE_TEST_NAME} gmock gtest gmock_main - gtest_main pthread dl ${CUPTI_LIBRARY}) + gtest_main pthread nvtx3-cpp ) set_target_properties(${CMAKE_TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/gtests") add_test(NAME ${CMAKE_TEST_NAME} COMMAND ${CMAKE_TEST_NAME}) @@ -40,8 +40,7 @@ endfunction(ConfigureTest) # - include paths --------------------------------------------------------------------------------- include_directories("${GTEST_INCLUDE_DIR}" - "${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}" - "${CMAKE_SOURCE_DIR}/include") + "${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}") ################################################################################################### # - library paths --------------------------------------------------------------------------------- From b8c59246debbd1789a2b5f29eb827bc35e052608 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Wed, 14 Oct 2020 11:27:56 -0500 Subject: [PATCH 04/19] Remove cxx14 standard from tests/benchmark. --- cpp/benchmarks/CMakeLists.txt | 8 -------- cpp/tests/CMakeLists.txt | 6 ------ 2 files changed, 14 deletions(-) diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index 89ff5aa..fa8bf96 100644 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -17,14 +17,6 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) project(NVTX_BENCHS LANGUAGES C CXX CUDA) -################################################################################################### -# - compiler options ------------------------------------------------------------------------------ -set(CMAKE_CXX_STANDARD 14) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(CMAKE_CUDA_STANDARD 14) -set(CMAKE_CUDA_STANDARD_REQUIRED ON) - ################################################################################################### # - compiler function ----------------------------------------------------------------------------- diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index 2c1626c..cba5a6e 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -17,12 +17,6 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) project(NVTX_TESTS LANGUAGES C CXX CUDA) -set(CMAKE_CXX_STANDARD 14) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set(CMAKE_CUDA_STANDARD 14) -set(CMAKE_CUDA_STANDARD_REQUIRED ON) - ################################################################################################### # - compiler function ----------------------------------------------------------------------------- From 0e3eca184766cc470d4b49cf56af0f23dd8a8841 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Wed, 14 Oct 2020 11:29:01 -0500 Subject: [PATCH 05/19] Add CPM. --- cpp/cmake/CPM.cmake | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 cpp/cmake/CPM.cmake diff --git a/cpp/cmake/CPM.cmake b/cpp/cmake/CPM.cmake new file mode 100644 index 0000000..b342877 --- /dev/null +++ b/cpp/cmake/CPM.cmake @@ -0,0 +1,19 @@ +set(CPM_DOWNLOAD_VERSION 0.27.4) + +if(CPM_SOURCE_CACHE) + set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +elseif(DEFINED ENV{CPM_SOURCE_CACHE}) + set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +else() + set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +endif() + +if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) + message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") + file(DOWNLOAD + https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake + ${CPM_DOWNLOAD_LOCATION} + ) +endif() + +include(${CPM_DOWNLOAD_LOCATION}) From 327d8b2c1f2ee593b7259a559c5996c9eaa165a5 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Wed, 14 Oct 2020 11:39:41 -0500 Subject: [PATCH 06/19] Use CPM for gtest. --- cpp/CMakeLists.txt | 13 +++---------- cpp/tests/CMakeLists.txt | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 7818232..a7150fb 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -17,6 +17,8 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) project(NVTX VERSION 0.1.0 LANGUAGES CXX) +include(cmake/CPM.cmake) + ################################################################################################### # - build type ------------------------------------------------------------------------------------ @@ -59,17 +61,8 @@ include(CheckLibraryExists) ################################################################################################### # - add gtest ------------------------------------------------------------------------------------- -include(CTest) -include(ConfigureGoogleTest) - if(BUILD_TESTS) - if(GTEST_FOUND) - message(STATUS "Google C++ Testing Framework (Google Test) found in ${GTEST_ROOT}") - include_directories(${GTEST_INCLUDE_DIR}) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests) - else() - message(AUTHOR_WARNING "Google C++ Testing Framework (Google Test) not found: automated tests are disabled.") - endif(GTEST_FOUND) + add_subdirectory(tests) endif(BUILD_TESTS) ################################################################################################### diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index cba5a6e..ab28e0d 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -17,6 +17,18 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) project(NVTX_TESTS LANGUAGES C CXX CUDA) +include(CTest) + +CPMAddPackage( + NAME GTest + GITHUB_REPOSITORY google/googletest + GIT_TAG release-1.10.0 + VERSION 1.10.0 + GIT_SHALLOW TRUE + OPTIONS "INSTALL_GTEST OFF" + # googletest >= 1.10.0 provides a cmake config file -- use it if it exists + FIND_PACKAGE_ARGUMENTS "CONFIG") + ################################################################################################### # - compiler function ----------------------------------------------------------------------------- @@ -33,15 +45,13 @@ endfunction(ConfigureTest) ################################################################################################### # - include paths --------------------------------------------------------------------------------- -include_directories("${GTEST_INCLUDE_DIR}" - "${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}") +include_directories( "${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}") ################################################################################################### # - library paths --------------------------------------------------------------------------------- -link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}" # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported variable containing the link directories for nvcc - "${CMAKE_BINARY_DIR}/lib" - "${GTEST_LIBRARY_DIR}") +link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}" + "${CMAKE_BINARY_DIR}/lib") ################################################################################################### ### test sources ################################################################################## From 44b88f25d6e54e665728438864700982e3544857 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Wed, 14 Oct 2020 11:46:04 -0500 Subject: [PATCH 07/19] Use CPM for gbench. --- cpp/CMakeLists.txt | 9 +-------- cpp/benchmarks/CMakeLists.txt | 27 +++++++++++++++++++++------ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index a7150fb..e6be855 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -69,14 +69,7 @@ endif(BUILD_TESTS) # - add google benchmark -------------------------------------------------------------------------- if(BUILD_BENCHMARKS) - include(ConfigureGoogleBenchmark) - if(GBENCH_FOUND) - message(STATUS "Google C++ Benchmarking Framework (Google Benchmark) found in ${GBENCH_ROOT}") - include_directories(${GBENCH_INCLUDE_DIR}) - add_subdirectory(${CMAKE_SOURCE_DIR}/benchmarks) - else() - message(AUTHOR_WARNING "Google C++ Benchmarking Framework (Google Benchmark) not found: automated tests are disabled.") - endif(GBENCH_FOUND) + add_subdirectory(benchmarks) endif(BUILD_BENCHMARKS) diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index fa8bf96..4e2205d 100644 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -17,6 +17,25 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR) project(NVTX_BENCHS LANGUAGES C CXX CUDA) +CPMAddPackage( + NAME benchmark + GITHUB_REPOSITORY google/benchmark + VERSION 1.5.2 + GIT_SHALLOW TRUE + OPTIONS + "BENCHMARK_ENABLE_TESTING Off" + "BENCHMARK_ENABLE_INSTALL Off" + # The REGEX feature test fails when gbench's cmake is run under CPM w/ gcc5.4 because it doesn't assume C++11 + # Additionally, attempting to set the CMAKE_CXX_VERSION here doesn't propogate to the feature test build + # Therefore, we just disable the feature test and assume platforms we care about have a regex impl available + "RUN_HAVE_STD_REGEX 0" # +) + +if (benchmark_ADDED) + # patch google benchmark target + set_target_properties(benchmark PROPERTIES CXX_STANDARD 11) +endif() + ################################################################################################### # - compiler function ----------------------------------------------------------------------------- @@ -32,16 +51,12 @@ endfunction(ConfigureBench) ################################################################################################### # - include paths --------------------------------------------------------------------------------- -include_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}" - "${GBENCH_INCLUDE_DIR}") +include_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}") ################################################################################################### # - library paths --------------------------------------------------------------------------------- -link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}" # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported variable containing the link directories for nvcc - "${CMAKE_BINARY_DIR}/lib" - "${CMAKE_BINARY_DIR}" - "${GBENCH_LIBRARY_DIR}") +link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}") # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported variable containing the link directories for nvcc ################################################################################################### ### test sources ################################################################################## From 77ddb98b9d478a7ab2bc57b8ddbb82cfed15baf7 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Wed, 14 Oct 2020 11:49:48 -0500 Subject: [PATCH 08/19] Remove extraneous modules from parent cmake. --- cpp/CMakeLists.txt | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index e6be855..916d85e 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -49,25 +49,11 @@ target_link_libraries(nvtx3-cpp INTERFACE ${CMAKE_DL_LIBS}) option(BUILD_TESTS "Configure CMake to build tests" ON) option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" ON) -################################################################################################### -# - cmake modules --------------------------------------------------------------------------------- - -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/" ${CMAKE_MODULE_PATH}) - -include(FeatureSummary) -include(CheckIncludeFiles) -include(CheckLibraryExists) - -################################################################################################### -# - add gtest ------------------------------------------------------------------------------------- if(BUILD_TESTS) add_subdirectory(tests) endif(BUILD_TESTS) -################################################################################################### -# - add google benchmark -------------------------------------------------------------------------- - if(BUILD_BENCHMARKS) add_subdirectory(benchmarks) endif(BUILD_BENCHMARKS) From 78786f31a762be7ba1219e1091cd5c8761fbac57 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Wed, 14 Oct 2020 12:42:00 -0500 Subject: [PATCH 09/19] Add a cmake file for the NVTX C lib. --- c/CMakeLists.txt | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 c/CMakeLists.txt diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt new file mode 100644 index 0000000..01179ea --- /dev/null +++ b/c/CMakeLists.txt @@ -0,0 +1,43 @@ +#============================================================================= +# Copyright (c) 2020, NVIDIA CORPORATION. +# +# Licensed 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 FATAL_ERROR) + +project(NVTX-C VERSION 0.1.0 LANGUAGES C) + +################################################################################################### +# - build type ------------------------------------------------------------------------------------ + +# Set a default build type if none was specified +set(DEFAULT_BUILD_TYPE "Release") + +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' since none 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() + +################################################################################################### +# - nvtx target ----------------------------------------------------------------------------------- +add_library(nvtx3-c INTERFACE) +target_include_directories(nvtx3-c INTERFACE + "$" + "$") +target_link_libraries(nvtx3-c INTERFACE ${CMAKE_DL_LIBS}) + + From 3abc282b261e177b18d0b7a314d44259ba6fcd61 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Wed, 14 Oct 2020 12:42:19 -0500 Subject: [PATCH 10/19] Symlink the nvtx C directory into the cpp dir. --- cpp/nvtx-c | 1 + 1 file changed, 1 insertion(+) create mode 120000 cpp/nvtx-c diff --git a/cpp/nvtx-c b/cpp/nvtx-c new file mode 120000 index 0000000..1b271d8 --- /dev/null +++ b/cpp/nvtx-c @@ -0,0 +1 @@ +../c \ No newline at end of file From 2827367ab76046e355ca021fd0f87dbb89ea81e9 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Wed, 14 Oct 2020 12:42:43 -0500 Subject: [PATCH 11/19] Link the nvtx3-c target against the nvtx3-cpp target. --- cpp/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 916d85e..0be808b 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -15,7 +15,7 @@ #============================================================================= cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -project(NVTX VERSION 0.1.0 LANGUAGES CXX) +project(NVTX-CPP VERSION 0.1.0 LANGUAGES CXX) include(cmake/CPM.cmake) @@ -34,6 +34,8 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() +# Include the nvtx-c directory to access the nvtx-c CMake target +add_subdirectory(nvtx-c) ################################################################################################### # - nvtx target ----------------------------------------------------------------------------------- @@ -43,13 +45,12 @@ target_include_directories(nvtx3-cpp INTERFACE "$") target_compile_features(nvtx3-cpp INTERFACE cxx_std_11) -target_link_libraries(nvtx3-cpp INTERFACE ${CMAKE_DL_LIBS}) +target_link_libraries(nvtx3-cpp INTERFACE nvtx3-c) # Build options option(BUILD_TESTS "Configure CMake to build tests" ON) option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" ON) - if(BUILD_TESTS) add_subdirectory(tests) endif(BUILD_TESTS) @@ -58,7 +59,6 @@ if(BUILD_BENCHMARKS) add_subdirectory(benchmarks) endif(BUILD_BENCHMARKS) - ################################################################################################### # - build doxygen --------------------------------------------------------------------------------- add_custom_command(OUTPUT BUILD_DOXYGEN From 78187c8466a8450ca3c57f24a263d682df3925da Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Wed, 14 Oct 2020 12:46:48 -0500 Subject: [PATCH 12/19] Remove the CUDA dependency from the tests/benchmarks. --- cpp/benchmarks/CMakeLists.txt | 12 ------------ cpp/tests/CMakeLists.txt | 16 ---------------- 2 files changed, 28 deletions(-) diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index 4e2205d..1a27614 100644 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -15,8 +15,6 @@ #============================================================================= cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -project(NVTX_BENCHS LANGUAGES C CXX CUDA) - CPMAddPackage( NAME benchmark GITHUB_REPOSITORY google/benchmark @@ -48,16 +46,6 @@ function(ConfigureBench CMAKE_BENCH_NAME CMAKE_BENCH_SRC) RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/gbenchmarks") endfunction(ConfigureBench) -################################################################################################### -# - include paths --------------------------------------------------------------------------------- - -include_directories("${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}") - -################################################################################################### -# - library paths --------------------------------------------------------------------------------- - -link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}") # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported variable containing the link directories for nvcc - ################################################################################################### ### test sources ################################################################################## ################################################################################################### diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index ab28e0d..b075d2e 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -15,8 +15,6 @@ #============================================================================= cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -project(NVTX_TESTS LANGUAGES C CXX CUDA) - include(CTest) CPMAddPackage( @@ -42,20 +40,6 @@ function(ConfigureTest CMAKE_TEST_NAME CMAKE_TEST_SRC) add_test(NAME ${CMAKE_TEST_NAME} COMMAND ${CMAKE_TEST_NAME}) endfunction(ConfigureTest) -################################################################################################### -# - include paths --------------------------------------------------------------------------------- - -include_directories( "${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}") - -################################################################################################### -# - library paths --------------------------------------------------------------------------------- - -link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}" - "${CMAKE_BINARY_DIR}/lib") - -################################################################################################### -### test sources ################################################################################## -################################################################################################### ################################################################################################### # - nvtx tests ------------------------------------------------------------------------------------- From d0090e39713b0e04f026a95682e55dcd0e46d3d3 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Wed, 21 Oct 2020 16:53:12 -0500 Subject: [PATCH 13/19] pin cpm to specific commit hash --- cpp/cmake/CPM.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/cmake/CPM.cmake b/cpp/cmake/CPM.cmake index b342877..e715aa4 100644 --- a/cpp/cmake/CPM.cmake +++ b/cpp/cmake/CPM.cmake @@ -1,4 +1,4 @@ -set(CPM_DOWNLOAD_VERSION 0.27.4) +set(CPM_DOWNLOAD_VERSION aeef56ea85f050b952623a517eb484fa6697f511) if(CPM_SOURCE_CACHE) set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") From b019771ae12de55fd61b5e5a80fc7ee954045f5e Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Thu, 29 Oct 2020 10:41:45 -0500 Subject: [PATCH 14/19] Use cpm 0.27.5. --- cpp/cmake/CPM.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/cmake/CPM.cmake b/cpp/cmake/CPM.cmake index e715aa4..f069733 100644 --- a/cpp/cmake/CPM.cmake +++ b/cpp/cmake/CPM.cmake @@ -1,4 +1,4 @@ -set(CPM_DOWNLOAD_VERSION aeef56ea85f050b952623a517eb484fa6697f511) +set(CPM_DOWNLOAD_VERSION 0.27.5) if(CPM_SOURCE_CACHE) set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") From ab18349e74ba2a655b8a126f27622bcb291cd93a Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Thu, 29 Oct 2020 10:41:58 -0500 Subject: [PATCH 15/19] Require C++14 for NVTX++. --- cpp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 0be808b..b5583b6 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -44,7 +44,7 @@ target_include_directories(nvtx3-cpp INTERFACE "$" "$") -target_compile_features(nvtx3-cpp INTERFACE cxx_std_11) +target_compile_features(nvtx3-cpp INTERFACE cxx_std_14) target_link_libraries(nvtx3-cpp INTERFACE nvtx3-c) # Build options From 473d5d4bea392462e00047b71ce2e58377327223 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Thu, 29 Oct 2020 10:42:13 -0500 Subject: [PATCH 16/19] Remove the NVTX_RELAXED_CONSTEXPR since we require C++14 now. --- cpp/include/nvtx3/nvtx3.hpp | 49 +++++++++++++------------------------ 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/cpp/include/nvtx3/nvtx3.hpp b/cpp/include/nvtx3/nvtx3.hpp index 1e99373..83d8f2b 100644 --- a/cpp/include/nvtx3/nvtx3.hpp +++ b/cpp/include/nvtx3/nvtx3.hpp @@ -579,20 +579,6 @@ #define NVTX3_INLINE_IF_REQUESTED #endif -/* Enables the use of constexpr when support for C++14 relaxed constexpr - * is present. - * - * Initializing a legacy-C (i.e., no constructor) union member requires - * initializing in the constructor body. Non-empty constexpr constructors - * require C++14 relaxed constexpr. In strict C++11 compilation, fall back - * to using non-constexpr constructors for classes with union members. - */ -#if __cpp_constexpr >= 201304L -#define NVTX3_RELAXED_CONSTEXPR constexpr -#else -#define NVTX3_RELAXED_CONSTEXPR -#endif - /* Implementation sections, enclosed in guard macros for each minor version */ #ifndef NVTX3_CPP_DEFINITIONS_V1_0 @@ -1401,7 +1387,7 @@ class message { * * @param msg The contents of the message */ - NVTX3_RELAXED_CONSTEXPR message(char const* msg) noexcept : type_{NVTX_MESSAGE_TYPE_ASCII} + constexpr message(char const* msg) noexcept : type_{NVTX_MESSAGE_TYPE_ASCII} { value_.ascii = msg; } @@ -1428,7 +1414,7 @@ class message { * * @param msg The contents of the message */ - NVTX3_RELAXED_CONSTEXPR message(wchar_t const* msg) noexcept : type_{NVTX_MESSAGE_TYPE_UNICODE} + constexpr message(wchar_t const* msg) noexcept : type_{NVTX_MESSAGE_TYPE_UNICODE} { value_.unicode = msg; } @@ -1459,7 +1445,7 @@ class message { * @param msg The message that has already been registered with NVTX. */ template - NVTX3_RELAXED_CONSTEXPR message(registered_string const& msg) noexcept + constexpr message(registered_string const& msg) noexcept : type_{NVTX_MESSAGE_TYPE_REGISTERED} { value_.registered = msg.get_handle(); @@ -1469,13 +1455,13 @@ class message { * @brief Return the union holding the value of the message. * */ - NVTX3_RELAXED_CONSTEXPR value_type get_value() const noexcept { return value_; } + constexpr value_type get_value() const noexcept { return value_; } /** * @brief Return the type information about the value the union holds. * */ - NVTX3_RELAXED_CONSTEXPR nvtxMessageType_t get_type() const noexcept { return type_; } + constexpr nvtxMessageType_t get_type() const noexcept { return type_; } private: nvtxMessageType_t const type_{}; ///< message type @@ -1508,7 +1494,7 @@ class payload { * * @param value Value to use as contents of the payload */ - NVTX3_RELAXED_CONSTEXPR explicit payload(int64_t value) noexcept + constexpr explicit payload(int64_t value) noexcept : type_{NVTX_PAYLOAD_TYPE_INT64}, value_{} { value_.llValue = value; @@ -1519,7 +1505,7 @@ class payload { * * @param value Value to use as contents of the payload */ - NVTX3_RELAXED_CONSTEXPR explicit payload(int32_t value) noexcept + constexpr explicit payload(int32_t value) noexcept : type_{NVTX_PAYLOAD_TYPE_INT32}, value_{} { value_.iValue = value; @@ -1530,7 +1516,7 @@ class payload { * * @param value Value to use as contents of the payload */ - NVTX3_RELAXED_CONSTEXPR explicit payload(uint64_t value) noexcept + constexpr explicit payload(uint64_t value) noexcept : type_{NVTX_PAYLOAD_TYPE_UNSIGNED_INT64}, value_{} { value_.ullValue = value; @@ -1541,7 +1527,7 @@ class payload { * * @param value Value to use as contents of the payload */ - NVTX3_RELAXED_CONSTEXPR explicit payload(uint32_t value) noexcept + constexpr explicit payload(uint32_t value) noexcept : type_{NVTX_PAYLOAD_TYPE_UNSIGNED_INT32}, value_{} { value_.uiValue = value; @@ -1553,7 +1539,7 @@ class payload { * * @param value Value to use as contents of the payload */ - NVTX3_RELAXED_CONSTEXPR explicit payload(float value) noexcept + constexpr explicit payload(float value) noexcept : type_{NVTX_PAYLOAD_TYPE_FLOAT}, value_{} { value_.fValue = value; @@ -1565,7 +1551,7 @@ class payload { * * @param value Value to use as contents of the payload */ - NVTX3_RELAXED_CONSTEXPR explicit payload(double value) noexcept + constexpr explicit payload(double value) noexcept : type_{NVTX_PAYLOAD_TYPE_DOUBLE}, value_{} { value_.dValue = value; @@ -1575,13 +1561,13 @@ class payload { * @brief Return the union holding the value of the payload * */ - NVTX3_RELAXED_CONSTEXPR value_type get_value() const noexcept { return value_; } + constexpr value_type get_value() const noexcept { return value_; } /** * @brief Return the information about the type the union holds. * */ - NVTX3_RELAXED_CONSTEXPR nvtxPayloadType_t get_type() const noexcept { return type_; } + constexpr nvtxPayloadType_t get_type() const noexcept { return type_; } private: nvtxPayloadType_t const type_; ///< Type of the payload value @@ -1681,7 +1667,7 @@ class event_attributes { * */ template - NVTX3_RELAXED_CONSTEXPR explicit event_attributes(category const& c, Args const&... args) noexcept + constexpr explicit event_attributes(category const& c, Args const&... args) noexcept : event_attributes(args...) { attributes_.category = c.get_id(); @@ -1695,7 +1681,7 @@ class event_attributes { * */ template - NVTX3_RELAXED_CONSTEXPR explicit event_attributes(color const& c, Args const&... args) noexcept + constexpr explicit event_attributes(color const& c, Args const&... args) noexcept : event_attributes(args...) { attributes_.color = c.get_value(); @@ -1710,7 +1696,7 @@ class event_attributes { * */ template - NVTX3_RELAXED_CONSTEXPR explicit event_attributes(payload const& p, Args const&... args) noexcept + constexpr explicit event_attributes(payload const& p, Args const&... args) noexcept : event_attributes(args...) { attributes_.payload = p.get_value(); @@ -1725,7 +1711,7 @@ class event_attributes { * */ template - NVTX3_RELAXED_CONSTEXPR explicit event_attributes(message const& m, Args const&... args) noexcept + constexpr explicit event_attributes(message const& m, Args const&... args) noexcept : event_attributes(args...) { attributes_.message = m.get_value(); @@ -2261,7 +2247,6 @@ inline void mark(event_attributes const& attr) noexcept #undef NVTX3_NAMESPACE_FOR #undef NVTX3_VERSION_NAMESPACE #undef NVTX3_INLINE_IF_REQUESTED -#undef NVTX3_RELAXED_CONSTEXPR #if defined(NVTX3_INLINE_THIS_VERSION) #undef NVTX3_INLINE_THIS_VERSION From bebb3c76c6210bad5c3418c1330a44cd5d2a3f9c Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Thu, 29 Oct 2020 13:06:05 -0500 Subject: [PATCH 17/19] Require cmake 3.14 --- cpp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index b5583b6..fb6419f 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= -cmake_minimum_required(VERSION 3.12 FATAL_ERROR) +cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(NVTX-CPP VERSION 0.1.0 LANGUAGES CXX) From f8017d4f16d422e56bdf9eaa30c6a30d1548c718 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Thu, 29 Oct 2020 13:06:23 -0500 Subject: [PATCH 18/19] Remove cmake versions requirements from test/benchmark cmake files. --- cpp/benchmarks/CMakeLists.txt | 1 - cpp/tests/CMakeLists.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/cpp/benchmarks/CMakeLists.txt b/cpp/benchmarks/CMakeLists.txt index 1a27614..2decb21 100644 --- a/cpp/benchmarks/CMakeLists.txt +++ b/cpp/benchmarks/CMakeLists.txt @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= -cmake_minimum_required(VERSION 3.12 FATAL_ERROR) CPMAddPackage( NAME benchmark diff --git a/cpp/tests/CMakeLists.txt b/cpp/tests/CMakeLists.txt index b075d2e..37421ac 100644 --- a/cpp/tests/CMakeLists.txt +++ b/cpp/tests/CMakeLists.txt @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= -cmake_minimum_required(VERSION 3.12 FATAL_ERROR) include(CTest) From 719e0019fba386d955172eb20fd5762d07033759 Mon Sep 17 00:00:00 2001 From: Jake Hemstad Date: Thu, 29 Oct 2020 13:33:39 -0500 Subject: [PATCH 19/19] Use commit hash for CPM. --- cpp/cmake/CPM.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/cmake/CPM.cmake b/cpp/cmake/CPM.cmake index f069733..16e06ba 100644 --- a/cpp/cmake/CPM.cmake +++ b/cpp/cmake/CPM.cmake @@ -1,4 +1,4 @@ -set(CPM_DOWNLOAD_VERSION 0.27.5) +set(CPM_DOWNLOAD_VERSION 3b404296b539e596f39421c4e92bc803b299d964) # 0.27.5 if(CPM_SOURCE_CACHE) set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") @@ -11,7 +11,7 @@ endif() if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") file(DOWNLOAD - https://github.com/TheLartians/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake + https://raw.githubusercontent.com/TheLartians/CPM.cmake/${CPM_DOWNLOAD_VERSION}/cmake/CPM.cmake ${CPM_DOWNLOAD_LOCATION} ) endif()