From 668146fb944359df259956bb97b96e1c34de85f6 Mon Sep 17 00:00:00 2001
From: Soeren Peters <peters@irmb.tu-bs.de>
Date: Thu, 14 Jan 2021 14:53:35 +0100
Subject: [PATCH] Add gpu options to root cmake. Add the cmake option for
 passing the path to the numerial tests. Add git clone test to the CI.

---
 .gitlab-ci.yml                                     |  4 +++-
 CMakeLists.txt                                     | 11 ++++++++++-
 .../ConfigFileReaderNT/ConfigFileReaderNT.cpp      | 14 +++++++-------
 .../gpu/tests/NumericalTests/configK15_nu10tm2.txt |  2 +-
 gpu.cmake                                          | 14 ++++++--------
 5 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 23826bce2..cef13bb5a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -244,6 +244,8 @@ gpu_numerical_tests:
     - linux
 
   before_script:
+    - mkdir /testdata && cd /testdata
+    - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@git.rz.tu-bs.de/iRMB/VirtualFluids_dev.git
     - export CCACHE_BASEDIR=$CI_PROJECT_DIR
     - export CCACHE_DIR=$CI_PROJECT_DIR/cache
     - ccache -s
@@ -253,7 +255,7 @@ gpu_numerical_tests:
     - cmake ..
       -DBUILD_VF_CPU=ON
       -DBUILD_VF_GPU=ON
-      -DVF.BUILD_NUMERIC_TESTS=ON
+      -BUILD_NUMERIC_TESTS=ON
       -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
       -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache
       -DCMAKE_C_COMPILER_LAUNCHER=ccache
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1fd7dfff1..1830f4817 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,6 +38,13 @@ set (VF_ROOT_DIR  ${CMAKE_CURRENT_SOURCE_DIR})
 option(BUILD_VF_CPU "Build VirtualFluids cpu variant" OFF)
 option(BUILD_VF_GPU "Build VirtualFluids gpu variant" OFF)
 
+# vf gpu
+option(BUILD_VF_GPU          "Build VirtualFluids GPU"     ON )
+option(BUILD_VF_GKS          "Build VirtualFluids GKS"     OFF )
+option(BUILD_VF_TRAFFIC      "Build VirtualFluids Traffic" OFF)
+option(BUILD_JSONCPP         "Builds json cpp "            OFF)
+option(BUILD_NUMERIC_TESTS   "Build numeric tests"         OFF)
+
 option(BUILD_VF_UNIT_TESTS "Build VirtualFluids unit tests" OFF)
 option(BUILD_VF_CLANG_TIDY "Add the clang tidy checks to the targets" OFF)
 option(BUILD_VF_INCLUDE_WHAT_YOU_USE "Add IWYU to the targets" OFF)
@@ -99,5 +106,7 @@ endif()
 #  3rd Party Libraries
 #################################################################################
 if(BUILD_VF_UNIT_TESTS)
-    add_subdirectory(${VF_THIRD_DIR}/googletest)
+    if(NOT BUILD_NUMERIC_TESTS) # in this case googletest is already included.
+        add_subdirectory(${VF_THIRD_DIR}/googletest)
+    endif()
 endif()
diff --git a/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.cpp b/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.cpp
index 5ad743fa1..aa2768f63 100644
--- a/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.cpp
+++ b/apps/gpu/tests/NumericalTests/Utilities/ConfigFileReaderNT/ConfigFileReaderNT.cpp
@@ -23,9 +23,9 @@ ConfigFileReader::ConfigFileReader(const std::string aFilePath) : myFilePath(aFi
     // If PATH_NUMERICAL_TESTS is not defined, the grid definitions for the tests needs to be placed in the project root
     // directories.
 #ifdef PATH_NUMERICAL_TESTS
-    pathNumericalTests = TOSTRING(PATH_NUMERICAL_TESTS);
+    pathNumericalTests = TOSTRING(PATH_NUMERICAL_TESTS) + std::string("/");
 #else
-    pathNumericalTests = "./";
+    pathNumericalTests = TOSTRING(SOURCE_ROOT) + std::string("/");
 #endif
     std::cout << pathNumericalTests << "\n";
 }
@@ -413,21 +413,21 @@ int ConfigFileReader::calcNumberOfSimulations(std::shared_ptr<input::Input> inpu
     int counter = 0;
 
     int tgvCounterU0 = calcNumberOfSimulationGroup(input, "TaylorGreenVortexUx");
-    tgvCounterU0 *= StringUtil::toDoubleVector(input->getValue("ux_TGV_Ux")).size();
+    tgvCounterU0 *= int(StringUtil::toDoubleVector(input->getValue("ux_TGV_Ux")).size());
     counter += tgvCounterU0;
 
     int tgvCounterV0 = calcNumberOfSimulationGroup(input, "TaylorGreenVortexUz");
     ;
-    tgvCounterV0 *= StringUtil::toDoubleVector(input->getValue("uz_TGV_Uz")).size();
+    tgvCounterV0 *= int(StringUtil::toDoubleVector(input->getValue("uz_TGV_Uz")).size());
     counter += tgvCounterV0;
 
     int swCounter = calcNumberOfSimulationGroup(input, "ShearWave");
     ;
-    swCounter *= StringUtil::toDoubleVector(input->getValue("u0_SW")).size();
+    swCounter *= int(StringUtil::toDoubleVector(input->getValue("u0_SW")).size());
     counter += swCounter;
 
-    counter *= StringUtil::toDoubleVector(input->getValue("Viscosity")).size();
-    counter *= configData->kernelsToTest.size();
+    counter *= int(StringUtil::toDoubleVector(input->getValue("Viscosity")).size());
+    counter *= int(configData->kernelsToTest.size());
 
     return counter;
 }
diff --git a/apps/gpu/tests/NumericalTests/configK15_nu10tm2.txt b/apps/gpu/tests/NumericalTests/configK15_nu10tm2.txt
index c1592b7e0..c06068383 100644
--- a/apps/gpu/tests/NumericalTests/configK15_nu10tm2.txt
+++ b/apps/gpu/tests/NumericalTests/configK15_nu10tm2.txt
@@ -1,7 +1,7 @@
 ##################################################
 #				 GPU Mapping					 #
 ##################################################
-Devices="1"
+Devices="0"
 
 ##################################################
 #	       Basic Simulation Parameter			 #
diff --git a/gpu.cmake b/gpu.cmake
index d1d541508..bc2fab3fd 100644
--- a/gpu.cmake
+++ b/gpu.cmake
@@ -7,14 +7,6 @@
 #SET(CUDA_CUT_INCLUDE_DIR    "/cluster/cuda/9.0/include;/cluster/cuda/9.0/samples/common/inc" CACHE PATH "CUDA_CUT_INCLUDE_DIR")
 #SET(CUDA_SAMPLE_INCLUDE_DIR "/cluster/cuda/9.0/samples/common/inc" CACHE PATH "CUDA_CUT_INCLUDE_DIR")
 
-#############################################################
-###                         OPTIONS                       ###
-#############################################################
-option(VF.BUILD_VF_GPU          "Build VirtualFluids GPU"     ON )
-option(VF.BUILD_VF_GKS          "Build VirtualFluids GKS"     OFF )
-option(VF.BUILD_VF_TRAFFIC      "Build VirtualFluids Traffic" OFF)
-option(VF.BUILD_JSONCPP         "Builds json cpp "            OFF)
-option(VF.BUILD_NUMERIC_TESTS   "Build numeric tests"         OFF)
 
 #############################################################
 
@@ -135,6 +127,12 @@ ENDIF()
 #############################################################
 
 if(VF.BUILD_NUMERIC_TESTS)
+
+    # PATH_NUMERICAL_TESTS can be passed to cmake e.g. cmake .. -DPATH_NUMERICAL_TESTS=/data/
+    if(PATH_NUMERICAL_TESTS)
+        LIST(APPEND VF_COMPILER_DEFINITION "PATH_NUMERICAL_TESTS=${PATH_NUMERICAL_TESTS}")
+    endif()
+
     add_subdirectory(3rdParty/fftw/fftw-3.3.7)
     add_subdirectory(3rdParty/googletest)
     add_subdirectory(apps/gpu/tests/NumericalTests)
-- 
GitLab