From c12c523908c867465d89fd590f9b531c05eba933 Mon Sep 17 00:00:00 2001 From: "LEGOLAS\\lenz" <lenz@irmb.tu-bs.de> Date: Fri, 23 Nov 2018 16:47:53 +0100 Subject: [PATCH] fixes a memory leak in the Distribution struct in the Gridgenerator --- CMakeLists.txt | 4 ++++ src/GksGpu/DataBase/DataBase.cpp | 3 +++ src/GksMeshAdapter/GksMeshAdapter.cpp | 22 ++++++++++++++-------- targets/apps/GKS/gksTest/main.cpp | 6 +++--- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c200db029..a552dff40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,6 +100,10 @@ ELSE(MSVC) SET( CMAKE_CXX_FLAGS "-include ${CMAKE_BINARY_DIR}/VirtualFluidsDefinitions.h ${CMAKE_CXX_FLAGS}" ) ENDIF(MSVC) +set(CMAKE_CUDA_FLAGS " -arch=sm_60" CACHE STRING "" FORCE) + +set(CMAKE_CUDA_FLAGS_DEBUG " -G" CACHE STRING "" FORCE) + ########################################################################################################################## ### Subdirectories ### diff --git a/src/GksGpu/DataBase/DataBase.cpp b/src/GksGpu/DataBase/DataBase.cpp index e3608732e..845f6468b 100644 --- a/src/GksGpu/DataBase/DataBase.cpp +++ b/src/GksGpu/DataBase/DataBase.cpp @@ -1,6 +1,9 @@ #include "DataBase.h" #include <string> +#include <cuda.h> +#include <cuda_runtime.h> +#include <helper_cuda.h> #include "DataBaseAllocator.h" #include "DataBaseStruct.h" diff --git a/src/GksMeshAdapter/GksMeshAdapter.cpp b/src/GksMeshAdapter/GksMeshAdapter.cpp index df7f5dc8e..166e237c9 100644 --- a/src/GksMeshAdapter/GksMeshAdapter.cpp +++ b/src/GksMeshAdapter/GksMeshAdapter.cpp @@ -110,6 +110,8 @@ void GksMeshAdapter::findQuadtreeConnectivity() std::vector< SPtr<Grid> > grids = this->gridBuilder->getGrids(); + Distribution dirs = DistributionHelper::getDistribution27(); + for( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ MeshCell& cell = this->cells[ cellIdx ]; @@ -123,7 +125,6 @@ void GksMeshAdapter::findQuadtreeConnectivity() for( uint idx = 0; idx < 8; idx++ ) { - Distribution dirs = DistributionHelper::getDistribution27(); real xSign = dirs.directions[idx + 19][0]; real ySign = dirs.directions[idx + 19][1]; @@ -153,6 +154,8 @@ void GksMeshAdapter::findCellToCellConnectivity() std::vector< SPtr<Grid> > grids = this->gridBuilder->getGrids(); + Distribution dirs = DistributionHelper::getDistribution27(); + for( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ MeshCell& cell = this->cells[ cellIdx ]; @@ -166,8 +169,6 @@ void GksMeshAdapter::findCellToCellConnectivity() { if( idx == DIR_27_ZERO ) continue; - Distribution dirs = DistributionHelper::getDistribution27(); - int xSign = dirs.directions[idx][0]; int ySign = dirs.directions[idx][1]; int zSign = dirs.directions[idx][2]; @@ -190,6 +191,8 @@ void GksMeshAdapter::findCellToCellConnectivity() void GksMeshAdapter::countCells() { + *logging::out << logging::Logger::INFO_INTERMEDIATE << "countCells()" << "\n"; + this->numberOfCellsPerLevel .resize( this->numberOfLevels ); this->numberOfBulkCellsPerLevel.resize( this->numberOfLevels ); this->startOfCellsPerLevel .resize( this->numberOfLevels ); @@ -216,6 +219,8 @@ void GksMeshAdapter::countCells() void GksMeshAdapter::partitionCells() { + *logging::out << logging::Logger::INFO_INTERMEDIATE << "partitionCells()" << "\n"; + for( uint level = 0; level < this->numberOfLevels; level++ ){ std::vector<uint> idxMap( this->cells.size() ); @@ -252,6 +257,8 @@ void GksMeshAdapter::partitionCells() void GksMeshAdapter::refreshCellConnectivity(const std::vector<uint>& idxMap) { + *logging::out << logging::Logger::INFO_INTERMEDIATE << "refreshCellConnectivity()" << "\n"; + for( auto& cell : this->cells ){ for( uint idx = 0; idx < 27; idx++ ) if( cell.cellToCell[ idx ] != INVALID_INDEX ) @@ -291,6 +298,8 @@ void GksMeshAdapter::generateNodes() nodes.reserve( 2 * this->cells.size() ); + Distribution dirs = DistributionHelper::getDistribution27(); + for( uint cellIdx = 0; cellIdx < this->cells.size(); cellIdx++ ){ MeshCell& cell = this->cells[ cellIdx ]; @@ -308,7 +317,6 @@ void GksMeshAdapter::generateNodes() { if( cell.cellToNode[idx] == INVALID_INDEX ) { - Distribution dirs = DistributionHelper::getDistribution27(); real dx = dirs.directions[idx + 19][0] * d; real dy = dirs.directions[idx + 19][1] * d; @@ -321,8 +329,6 @@ void GksMeshAdapter::generateNodes() //// register new node at neighbor cells on same level for (uint idx = 0; idx < 8; idx++) { - Distribution dirs = DistributionHelper::getDistribution27(); - real dxNeighbor = -dirs.directions[idx + 19][0] * d; real dyNeighbor = -dirs.directions[idx + 19][1] * d; real dzNeighbor = -dirs.directions[idx + 19][2] * d; @@ -442,8 +448,8 @@ void GksMeshAdapter::generateFaces() ////////////////////////////////////////////////////////////////////////// - if ( cell.type == FLUID_CFF && neighborCell.type == FLUID_FCF ) newFace.negCellCoarse = cell.parent; - if ( cell.type == FLUID_FCF && neighborCell.type == FLUID_CFF ) newFace.posCellCoarse = neighborCell.parent; + //if ( cell.type == FLUID_CFF && neighborCell.type == FLUID_FCF ) newFace.negCellCoarse = cell.parent; + //if ( cell.type == FLUID_FCF && neighborCell.type == FLUID_CFF ) newFace.posCellCoarse = neighborCell.parent; ////////////////////////////////////////////////////////////////////////// diff --git a/targets/apps/GKS/gksTest/main.cpp b/targets/apps/GKS/gksTest/main.cpp index 272832154..333ae9413 100644 --- a/targets/apps/GKS/gksTest/main.cpp +++ b/targets/apps/GKS/gksTest/main.cpp @@ -41,7 +41,7 @@ void gksTest( std::string path ) real L = 1.0; - real dx = L / 64.0; + real dx = L / 128.0; real Re = 2.0e3; real U = 0.1; @@ -165,11 +165,11 @@ void gksTest( std::string path ) ////////////////////////////////////////////////////////////////////////// - for( uint iter = 1; iter < 1000000; iter++ ) + for( uint iter = 1; iter < 100000; iter++ ) { TimeStepping::nestedTimeStep(dataBase, parameters, 0); - if( iter % 10000 == 0 ) + if( iter % 1000 == 0 ) { dataBase->copyDataDeviceToHost(); -- GitLab