From ade549fbccde57cfd3f72f0221670ebe933b468e Mon Sep 17 00:00:00 2001 From: Benjamin Worpitz Date: Mon, 27 Apr 2020 07:50:45 +0200 Subject: [PATCH] Refactor math operations unit tests (#986) * rename `mathOps` to `math` unit test to match folder name like other tests * merge `sincos` test target into `math` test * move headers into src folder to remove relative includes --- test/unit/CMakeLists.txt | 3 +-- test/unit/math/{mathOps => }/CMakeLists.txt | 10 ++++---- test/unit/math/sincos/CMakeLists.txt | 24 ------------------- .../math/{mathOps/include => src}/Buffer.hpp | 2 ++ .../math/{mathOps/include => src}/DataGen.hpp | 1 + .../math/{mathOps/include => src}/Defines.hpp | 1 - .../math/{mathOps/include => src}/Functor.hpp | 2 ++ .../{mathOps/src/mathOps.cpp => src/math.cpp} | 9 ++++--- test/unit/math/{sincos => }/src/sincos.cpp | 1 - 9 files changed, 14 insertions(+), 39 deletions(-) rename test/unit/math/{mathOps => }/CMakeLists.txt (90%) delete mode 100644 test/unit/math/sincos/CMakeLists.txt rename test/unit/math/{mathOps/include => src}/Buffer.hpp (99%) rename test/unit/math/{mathOps/include => src}/DataGen.hpp (99%) rename test/unit/math/{mathOps/include => src}/Defines.hpp (99%) rename test/unit/math/{mathOps/include => src}/Functor.hpp (99%) rename test/unit/math/{mathOps/src/mathOps.cpp => src/math.cpp} (98%) rename test/unit/math/{sincos => }/src/sincos.cpp (99%) diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 6beec90151fa..21150e42fe6b 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -26,8 +26,7 @@ add_subdirectory("core/") add_subdirectory("event/") add_subdirectory("idx/") add_subdirectory("kernel/") -add_subdirectory("math/mathOps/") -add_subdirectory("math/sincos/") +add_subdirectory("math/") add_subdirectory("mem/buf/") add_subdirectory("mem/view/") add_subdirectory("mem/p2p/") diff --git a/test/unit/math/mathOps/CMakeLists.txt b/test/unit/math/CMakeLists.txt similarity index 90% rename from test/unit/math/mathOps/CMakeLists.txt rename to test/unit/math/CMakeLists.txt index ce1825a39d84..f6394bcd60f2 100644 --- a/test/unit/math/mathOps/CMakeLists.txt +++ b/test/unit/math/CMakeLists.txt @@ -8,13 +8,11 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # -set(_TARGET_NAME "mathOps") - +set(_TARGET_NAME "math") append_recursive_files_add_to_src_group("src/" "src/" "cpp" _FILES_SOURCE) +append_recursive_files_add_to_src_group("src/" "src/" "hpp" _FILES_HEADER) - -message(STATUS "Disabling fast math options for math operation tests only.") if(ALPAKA_ACC_GPU_CUDA_ENABLE) list(REMOVE_ITEM CUDA_NVCC_FLAGS "--ftz=true" "--prec-div=false" "--prec-sqrt=false" "--fmad=true" "--use_fast_math" "-use_fast_math") @@ -25,10 +23,10 @@ if(ALPAKA_ACC_GPU_HIP_ENABLE) HIP_NVCC_FLAGS "--ftz=true" "--prec-div=false" "--prec-sqrt=false" "--fmad=true" "--use_fast_math" "-use_fast_math") endif() - alpaka_add_executable( ${_TARGET_NAME} - ${_FILES_SOURCE}) + ${_FILES_SOURCE} + ${_FILES_HEADER}) target_include_directories( ${_TARGET_NAME} PRIVATE ${Boost_INCLUDE_DIRS}) diff --git a/test/unit/math/sincos/CMakeLists.txt b/test/unit/math/sincos/CMakeLists.txt deleted file mode 100644 index f225679a59ba..000000000000 --- a/test/unit/math/sincos/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright 2017-2020 Benjamin Worpitz, Axel Huebl, Matthias Werner, Jan Stephan -# -# This file is part of Alpaka. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -set(_TARGET_NAME "sincos") - -append_recursive_files_add_to_src_group("src/" "src/" "cpp" _FILES_SOURCE) - -alpaka_add_executable( - ${_TARGET_NAME} - ${_FILES_SOURCE}) -target_link_libraries( - ${_TARGET_NAME} - PRIVATE common) - -set_target_properties(${_TARGET_NAME} PROPERTIES FOLDER "test/unit") - -add_test(NAME ${_TARGET_NAME} COMMAND ${_TARGET_NAME} ${_ALPAKA_TEST_OPTIONS}) diff --git a/test/unit/math/mathOps/include/Buffer.hpp b/test/unit/math/src/Buffer.hpp similarity index 99% rename from test/unit/math/mathOps/include/Buffer.hpp rename to test/unit/math/src/Buffer.hpp index 710c0cc1f803..c1c49a869449 100644 --- a/test/unit/math/mathOps/include/Buffer.hpp +++ b/test/unit/math/src/Buffer.hpp @@ -10,7 +10,9 @@ #pragma once #include "Defines.hpp" + #include + #include namespace alpaka { diff --git a/test/unit/math/mathOps/include/DataGen.hpp b/test/unit/math/src/DataGen.hpp similarity index 99% rename from test/unit/math/mathOps/include/DataGen.hpp rename to test/unit/math/src/DataGen.hpp index 5ac9607b1e7f..87cd4ceedebf 100644 --- a/test/unit/math/mathOps/include/DataGen.hpp +++ b/test/unit/math/src/DataGen.hpp @@ -10,6 +10,7 @@ #pragma once #include "Defines.hpp" + #include #include #include diff --git a/test/unit/math/mathOps/include/Defines.hpp b/test/unit/math/src/Defines.hpp similarity index 99% rename from test/unit/math/mathOps/include/Defines.hpp rename to test/unit/math/src/Defines.hpp index a4bd0397ae40..9d4f1b9ef7e6 100644 --- a/test/unit/math/mathOps/include/Defines.hpp +++ b/test/unit/math/src/Defines.hpp @@ -14,7 +14,6 @@ #include #include - namespace alpaka { namespace test { namespace unit { diff --git a/test/unit/math/mathOps/include/Functor.hpp b/test/unit/math/src/Functor.hpp similarity index 99% rename from test/unit/math/mathOps/include/Functor.hpp rename to test/unit/math/src/Functor.hpp index c14716b9752e..19d095acde48 100644 --- a/test/unit/math/mathOps/include/Functor.hpp +++ b/test/unit/math/src/Functor.hpp @@ -10,7 +10,9 @@ #pragma once #include "Defines.hpp" + #include + #include namespace alpaka { diff --git a/test/unit/math/mathOps/src/mathOps.cpp b/test/unit/math/src/math.cpp similarity index 98% rename from test/unit/math/mathOps/src/mathOps.cpp rename to test/unit/math/src/math.cpp index 5efebfa2c674..20f5bb90f211 100644 --- a/test/unit/math/mathOps/src/mathOps.cpp +++ b/test/unit/math/src/math.cpp @@ -7,10 +7,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "../include/Defines.hpp" -#include "../include/Buffer.hpp" -#include "../include/Functor.hpp" -#include "../include/DataGen.hpp" +#include "Defines.hpp" +#include "Buffer.hpp" +#include "Functor.hpp" +#include "DataGen.hpp" #include #include @@ -28,7 +28,6 @@ struct TestKernel typename TResults, typename TFunctor, typename TArgs> - ALPAKA_FN_ACC auto operator()( TAcc const & acc, TResults const & results, diff --git a/test/unit/math/sincos/src/sincos.cpp b/test/unit/math/src/sincos.cpp similarity index 99% rename from test/unit/math/sincos/src/sincos.cpp rename to test/unit/math/src/sincos.cpp index abda52fafc2f..7a75c254b2e7 100644 --- a/test/unit/math/sincos/src/sincos.cpp +++ b/test/unit/math/src/sincos.cpp @@ -31,7 +31,6 @@ almost_equal(TAcc const & acc, FP x, FP y, int ulp) || alpaka::math::abs(acc, x-y) < std::numeric_limits::min(); } - class SinCosTestKernel { public: