Skip to content

Commit

Permalink
Update C++ to C++14 and Catch2 to 3.6.0 (#294)
Browse files Browse the repository at this point in the history
* Update C++ standard to C++14
* Upgrade to Catch 3.6.0
  • Loading branch information
csbnw authored Jul 22, 2024
1 parent dd4f93b commit 5098d73
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<catch2/catch.hpp|cuda.h|cuda_runtime_api.h|nvrtc.h|cudawrappers/.*\.hpp>'
- Regex: '^<cuda.h|cuda_runtime_api.h|nvrtc.h|cudawrappers/.*\.hpp>'
Priority: 3
SortPriority: 0
CaseSensitive: false
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ project adheres to [Semantic Versioning](http://semver.org/).
- `cu::Context::{getCurrent, popCurrent, getDevice}` are no longer static
- `inline_local_includes` is now more robust: it properly handles commented
includes and respects the location of an include in the original source file
- Upgrade C++ standard to C++14
- Upgrade Catch2 to version v3.6.0

## \[0.8.0\] - 2024-07-05

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ project(

include(GNUInstallDirs)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS False)
set(CMAKE_BUILD_TYPE Release)
Expand Down
6 changes: 2 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
include(FetchContent)

# We use Catch2 v2.x because it is the last version that supports C++11, see
# https://github.com/catchorg/Catch2.
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.9
GIT_TAG v3.6.0
)

FetchContent_MakeAvailable(Catch2)
Expand All @@ -28,7 +26,7 @@ foreach(component ${COMPONENTS})
catch_discover_tests(test_${component})
endforeach()

set(LINK_LIBRARIES Catch2::Catch2 cudawrappers::cu)
set(LINK_LIBRARIES Catch2::Catch2WithMain cudawrappers::cu)

target_link_libraries(test_cu PUBLIC ${LINK_LIBRARIES})

Expand Down
3 changes: 1 addition & 2 deletions tests/test_cu.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include <array>
#include <catch2/catch_test_macros.hpp>
#include <cstring>
#include <iostream>
#include <string>

#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
#include <cudawrappers/cu.hpp>

TEST_CASE("Test cu::Device", "[device]") {
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cufft.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <fstream>
#include <iostream>

#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
#include <cudawrappers/cufft.hpp>

#define FP16_EPSILON 1e-3f
Expand Down
3 changes: 1 addition & 2 deletions tests/test_nvml.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include <catch2/catch_test_macros.hpp>
#include <string>
#include <vector>

#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
#include <cudawrappers/cu.hpp>
#include <cudawrappers/nvml.hpp>

Expand Down
3 changes: 1 addition & 2 deletions tests/test_nvrtc.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include <catch2/catch_test_macros.hpp>
#include <string>
#include <vector>

#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
#include <cudawrappers/nvrtc.hpp>

TEST_CASE("Test nvrtc::Program", "[program]") {
Expand Down
6 changes: 3 additions & 3 deletions tests/test_vector_add.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#include <catch2/catch_approx.hpp>
#include <catch2/catch_test_macros.hpp>
#include <cstddef>
#include <iostream>
#include <string>
#include <vector>

#define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp>
#include <cudawrappers/cu.hpp>
#include <cudawrappers/nvrtc.hpp>

bool arrays_equal(const float *a, const float *b, size_t n) {
for (size_t i = 0; i < n; i++) {
if (a[i] != Approx(b[i]).epsilon(1e-6)) {
if (a[i] != Catch::Approx(b[i]).epsilon(1e-6)) {
return false;
}
}
Expand Down

0 comments on commit 5098d73

Please sign in to comment.