From 1c141a3adeb59593a12a81f0fc79636a1f23658f Mon Sep 17 00:00:00 2001 From: Anna Wellmann <a.wellmann@tu-bs.de> Date: Thu, 8 Dec 2022 11:50:48 +0000 Subject: [PATCH] Fix some Code Smells (Sonarqube) --- .../GridReaderGenerator/GridGeneratorTest.cpp | 4 ++-- .../GridReaderGenerator/IndexRearrangementForStreams.cpp | 2 +- .../IndexRearrangementForStreamsTest.cpp | 4 ++-- src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.h | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGeneratorTest.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGeneratorTest.cpp index 17185ef21..3009bc4ae 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGeneratorTest.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGeneratorTest.cpp @@ -22,7 +22,7 @@ private: public: uint numberOfSendIndices = 0; - LevelGridBuilderStub(SPtr<Grid> grid) : LevelGridBuilder(), grid(grid){}; + explicit LevelGridBuilderStub(SPtr<Grid> grid) : LevelGridBuilder(), grid(grid){}; uint getCommunicationProcess(int direction) override { @@ -59,7 +59,7 @@ public: class CudaMemoryManagerDouble : public CudaMemoryManager { public: - CudaMemoryManagerDouble(std::shared_ptr<Parameter> parameter) : CudaMemoryManager(parameter){}; + explicit CudaMemoryManagerDouble(std::shared_ptr<Parameter> parameter) : CudaMemoryManager(parameter){}; void cudaAllocProcessNeighborX(int lev, unsigned int processNeighbor) override{}; void cudaCopyProcessNeighborXIndex(int lev, unsigned int processNeighbor) override{}; diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.cpp index 58e753b05..4cd876940 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.cpp @@ -493,7 +493,7 @@ void IndexRearrangementForStreams::reorderRecvIndicesForCommAfterFtoC( VF_LOG_INFO("Reorder recv indices for communication after fine to coarse: level: {} direction: {}", level, direction); - if (sendIndicesForCommAfterFtoCPositions.size() <= 0) + if (sendIndicesForCommAfterFtoCPositions.size() == 0) VF_LOG_WARNING("ReorderRecvIndicesForCommAfterFtoC(): sendIndicesForCommAfterFtoCPositions is empty."); uint numberOfRecvIndices = builder->getNumberOfReceiveIndices(direction, level); diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp index 5b8bd50bd..7bf534013 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp @@ -18,7 +18,7 @@ namespace indexRearrangementTests { template <typename T> -bool vectorsAreEqual(const T *vector1, const std::vector<T> vectorExpected) +bool vectorsAreEqual(const T *vector1, const std::vector<T>& vectorExpected) { for (uint i = 0; i < vectorExpected.size(); i++) { if (vector1[i] != vectorExpected[i]) @@ -179,7 +179,7 @@ public: return 0; } - void setReceivedIndices(std::vector<uint> receivedIndices) + void setReceivedIndices(const std::vector<uint>& receivedIndices) { this->receivedIndices = receivedIndices; } diff --git a/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.h b/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.h index ca7a63244..d410340d2 100644 --- a/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.h +++ b/src/gpu/VirtualFluids_GPU/GPU/CudaMemoryManager.h @@ -99,20 +99,20 @@ public: virtual void cudaCopyProcessNeighborXIndex(int lev, unsigned int processNeighbor); void cudaFreeProcessNeighborX(int lev, unsigned int processNeighbor); // - void cudaAllocProcessNeighborY(int lev, unsigned int processNeighbor); + virtual void cudaAllocProcessNeighborY(int lev, unsigned int processNeighbor); void cudaCopyProcessNeighborYFsHD(int lev, unsigned int processNeighbor, const unsigned int &memsizeFsRecv, int streamIndex); void cudaCopyProcessNeighborYFsDH(int lev, unsigned int processNeighbor, const unsigned int &memsizeFsSend, int streamIndex); - void cudaCopyProcessNeighborYIndex(int lev, unsigned int processNeighbor); + virtual void cudaCopyProcessNeighborYIndex(int lev, unsigned int processNeighbor); void cudaFreeProcessNeighborY(int lev, unsigned int processNeighbor); // - void cudaAllocProcessNeighborZ(int lev, unsigned int processNeighbor); + virtual void cudaAllocProcessNeighborZ(int lev, unsigned int processNeighbor); void cudaCopyProcessNeighborZFsHD(int lev, unsigned int processNeighbor, const unsigned int &memsizeFsRecv, int streamIndex); void cudaCopyProcessNeighborZFsDH(int lev, unsigned int processNeighbor, const unsigned int &memsizeFsSend, int streamIndex); - void cudaCopyProcessNeighborZIndex(int lev, unsigned int processNeighbor); + virtual void cudaCopyProcessNeighborZIndex(int lev, unsigned int processNeighbor); void cudaFreeProcessNeighborZ(int lev, unsigned int processNeighbor); ////////////////////////////////////////////////////////////////////////// -- GitLab