From f5a3da89385e783122ed0dd661b4b197ee90e21b Mon Sep 17 00:00:00 2001 From: Olivier Coulaud Date: Wed, 13 Jun 2018 15:34:43 +0200 Subject: [PATCH] Remove all warnings with gcc 8: memset et memcopy une now reinterpret_cay and we remove restrict fir target and source in p2P --- Src/Components/FAbstractKernels.hpp | 3 ++- Src/Components/FTestKernels.hpp | 3 ++- Src/Core/FFmmAlgorithmThreadBalance.hpp | 15 ++++++++---- Src/Files/FMpiTreeBuilder.hpp | 9 +++---- Src/Kernels/Chebyshev/FChebDenseKernel.hpp | 3 ++- Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp | 4 ++-- Src/Kernels/Chebyshev/FChebKernel.hpp | 3 ++- Src/Kernels/Chebyshev/FChebSymKernel.hpp | 3 ++- .../Chebyshev/FChebTensorialKernel.hpp | 3 ++- Src/Kernels/Rotation/FRotationKernel.hpp | 3 ++- .../Rotation/FRotationOriginalKernel.hpp | 3 ++- .../Spherical/FAbstractSphericalKernel.hpp | 3 ++- Src/Kernels/Taylor/FTaylorKernel.hpp | 3 ++- Src/Kernels/Taylor/FTaylorKernelSimple.hpp | 3 ++- Src/Kernels/Uniform/FUnifDenseKernel.hpp | 3 ++- Src/Kernels/Uniform/FUnifKernel.hpp | 24 ++++++++++++------- Src/Kernels/Uniform/FUnifTensorialKernel.hpp | 3 ++- Src/Utils/FQuickSortMpi.hpp | 8 +++---- UTests/utestLagrangeMpi.cpp | 3 +-- 19 files changed, 65 insertions(+), 37 deletions(-) diff --git a/Src/Components/FAbstractKernels.hpp b/Src/Components/FAbstractKernels.hpp index 351c1117..4e34880e 100644 --- a/Src/Components/FAbstractKernels.hpp +++ b/Src/Components/FAbstractKernels.hpp @@ -154,7 +154,8 @@ public: * @param size the number of direct neighbors */ virtual void P2P(const FTreeCoordinate& inLeafPosition, - ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources, + ContainerClass* const /*FRestrict*/ targets, + const ContainerClass* const /*FRestrict*/ sources, ContainerClass* const directNeighborsParticles[], const int neighborPositions[], const int size) = 0; diff --git a/Src/Components/FTestKernels.hpp b/Src/Components/FTestKernels.hpp index 7c1416e2..c9e80aa6 100644 --- a/Src/Components/FTestKernels.hpp +++ b/Src/Components/FTestKernels.hpp @@ -105,7 +105,8 @@ public: /** After Downward */ void P2P(const FTreeCoordinate& , - ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources, + ContainerClass* const /*FRestrict*/ targets, + const ContainerClass* const /*FRestrict*/ sources, ContainerClass* const directNeighborsParticles[], const int /*positions*/[], const int inSize) override { // Each particles targeted is impacted by the particles sources long long int inc = sources->getNbParticles(); diff --git a/Src/Core/FFmmAlgorithmThreadBalance.hpp b/Src/Core/FFmmAlgorithmThreadBalance.hpp index a92ac28f..81cfc7ad 100644 --- a/Src/Core/FFmmAlgorithmThreadBalance.hpp +++ b/Src/Core/FFmmAlgorithmThreadBalance.hpp @@ -127,8 +127,15 @@ protected: ///////////////////////////////////////////////////////////////////////////// /** The workload contains what a thread need to perfom its interval of work */ struct Workload{ - typename OctreeClass::Iterator iterator; - int nbElements; + typename OctreeClass::Iterator iterator{}; + int nbElements{}; + // +// Workload(const Workload& load): iterator(load.iterator),nbElements(load.nbElements) +// {} +// Workload& operator=(const Workload& load) +// {iterator=load.iterator; nbElements=load.nbElements; +// return *this; +// } }; //< The work per thread for the P2M @@ -354,10 +361,10 @@ protected: #pragma omp task { if(workloadBufferThread[omp_get_thread_num()] == nullptr){ - workloadBufferThread[omp_get_thread_num()] = new WorkloadTemp[leafsNumber]; + workloadBufferThread[omp_get_thread_num()] = new WorkloadTemp[leafsNumber]{}; } WorkloadTemp* workloadBuffer = workloadBufferThread[omp_get_thread_num()]; - memset(workloadBuffer, 0, sizeof(struct WorkloadTemp)*leafsNumber); + std::memset(reinterpret_cast(workloadBuffer), 0, sizeof(struct WorkloadTemp)*leafsNumber); // Prepare the P2P leafsDataArray.reset(new LeafData[leafsNumber]); diff --git a/Src/Files/FMpiTreeBuilder.hpp b/Src/Files/FMpiTreeBuilder.hpp index 9db887c4..900c1cfd 100644 --- a/Src/Files/FMpiTreeBuilder.hpp +++ b/Src/Files/FMpiTreeBuilder.hpp @@ -58,6 +58,7 @@ public: operator MortonIndex() const { return this->index; } + // IndexedParticle & operator=(const IndexedParticle &) = default ; // IndexedParticle(const IndexedParticle& rhs){ // index = rhs.index ; // particle = rhs.particle ; @@ -296,9 +297,9 @@ public: << finalParticlesNumber << " particles\n"; FLog::Controller.flush(); ); IndexedParticle* particlesWithExtension = new IndexedParticle[finalParticlesNumber]; // Copy old data - memcpy(particlesWithExtension, (*workingArray), (*workingSize)*sizeof(IndexedParticle)); + std::memcpy(reinterpret_cast(particlesWithExtension), (*workingArray), (*workingSize)*sizeof(IndexedParticle)); // Copy received data - memcpy(particlesWithExtension + (*workingSize), receivedParticles.data(), receivedParticles.size()*sizeof(IndexedParticle)); + std::memcpy(reinterpret_cast(particlesWithExtension + (*workingSize)), receivedParticles.data(), receivedParticles.size()*sizeof(IndexedParticle)); // Move ptr delete[] (*workingArray); (*workingArray) = particlesWithExtension; @@ -316,7 +317,7 @@ public: //Copy all the particles (*particlesArrayInLeafOrder) = new ParticleClass[(*workingSize)]; for(FSize idxPart = 0 ; idxPart < (*workingSize) ; ++idxPart){ - memcpy(&(*particlesArrayInLeafOrder)[idxPart],&(*workingArray)[idxPart].particle,sizeof(ParticleClass)); + std::memcpy(reinterpret_cast(&(*particlesArrayInLeafOrder)[idxPart]),&(*workingArray)[idxPart].particle,sizeof(ParticleClass)); } // Assign the number of leaf (*leavesSize) = leavesInfo.getSize(); @@ -535,7 +536,7 @@ public: const FSize sourcePosition = FMath::Max(myObjective.first, myCurrentInter.first) - myCurrentInter.first; // We store from offset, and use nbPartsPerPackToRecv has the number // The reading position is the offset of the first leaf we own - memcpy(&particlesRecvBuffer[offsetToRecv], &particlesArrayInLeafOrder[leavesOffsetInParticles[sourcePosition]], + std::memcpy(reinterpret_cast(&particlesRecvBuffer[offsetToRecv]), &particlesArrayInLeafOrder[leavesOffsetInParticles[sourcePosition]], nbPartsPerPackToRecv[idxPack]*sizeof(ParticleClass)); } offsetToRecv += nbPartsPerPackToRecv[idxPack]; diff --git a/Src/Kernels/Chebyshev/FChebDenseKernel.hpp b/Src/Kernels/Chebyshev/FChebDenseKernel.hpp index 07e862bb..6a2d5274 100644 --- a/Src/Kernels/Chebyshev/FChebDenseKernel.hpp +++ b/Src/Kernels/Chebyshev/FChebDenseKernel.hpp @@ -192,7 +192,8 @@ public: } void P2P(const FTreeCoordinate& inPosition, - ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict inSources, + ContainerClass* const /*FFRestrict */ inTargets, + const ContainerClass* const /*FFRestrict */ inSources, ContainerClass* const inNeighbors[], const int neighborPositions[], const int inSize) override { if(inTargets == inSources){ diff --git a/Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp b/Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp index 32a6e9d3..ef1b688e 100644 --- a/Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp +++ b/Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp @@ -246,8 +246,8 @@ public: void P2P(const FTreeCoordinate& /* LeafCellCoordinate */, // needed for periodic boundary conditions - ContainerClass* const FRestrict TargetParticles, - const ContainerClass* const FRestrict SourceParticles, + ContainerClass* const /*FFRestrict */ TargetParticles, + const ContainerClass* const /*FFRestrict */ SourceParticles, ContainerClass* const NeighborSourceParticles[], const int neighborPositions[], const int size) override diff --git a/Src/Kernels/Chebyshev/FChebKernel.hpp b/Src/Kernels/Chebyshev/FChebKernel.hpp index 1ca9c305..5b3343c2 100644 --- a/Src/Kernels/Chebyshev/FChebKernel.hpp +++ b/Src/Kernels/Chebyshev/FChebKernel.hpp @@ -247,7 +247,8 @@ public: } void P2P(const FTreeCoordinate& inPosition, - ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict inSources, + ContainerClass* const /*FFRestrict */ inTargets, + const ContainerClass* const /*FFRestrict */ inSources, ContainerClass* const inNeighbors[], const int neighborPositions[], const int inSize) override diff --git a/Src/Kernels/Chebyshev/FChebSymKernel.hpp b/Src/Kernels/Chebyshev/FChebSymKernel.hpp index e1fbc1fe..3ac76322 100644 --- a/Src/Kernels/Chebyshev/FChebSymKernel.hpp +++ b/Src/Kernels/Chebyshev/FChebSymKernel.hpp @@ -475,7 +475,8 @@ public: } void P2P(const FTreeCoordinate& inPosition, - ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict inSources, + ContainerClass* const /*FFRestrict */ inTargets, + const ContainerClass* const /*FFRestrict */ inSources, ContainerClass* const inNeighbors[], const int neighborPositions[], const int inSize) override diff --git a/Src/Kernels/Chebyshev/FChebTensorialKernel.hpp b/Src/Kernels/Chebyshev/FChebTensorialKernel.hpp index 3c949ed8..283729e8 100644 --- a/Src/Kernels/Chebyshev/FChebTensorialKernel.hpp +++ b/Src/Kernels/Chebyshev/FChebTensorialKernel.hpp @@ -195,7 +195,8 @@ public: } void P2P(const FTreeCoordinate& inPosition, - ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict inSources, + ContainerClass* const /*FFRestrict */ inTargets, + const ContainerClass* const /*FFRestrict */ inSources, ContainerClass* const inNeighbors[], const int neighborPositions[], const int inSize) override { if(inTargets == inSources){ diff --git a/Src/Kernels/Rotation/FRotationKernel.hpp b/Src/Kernels/Rotation/FRotationKernel.hpp index aada34ef..344a48c0 100644 --- a/Src/Kernels/Rotation/FRotationKernel.hpp +++ b/Src/Kernels/Rotation/FRotationKernel.hpp @@ -1373,7 +1373,8 @@ public: * Calling this method in multi thread should be done carrefully. */ void P2P(const FTreeCoordinate& inPosition, - ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict inSources, + ContainerClass* const /*FFRestrict */ inTargets, + const ContainerClass* const /*FFRestrict */ inSources, ContainerClass* const inNeighbors[], const int neighborPositions[], const int inSize) override { if(inTargets == inSources){ diff --git a/Src/Kernels/Rotation/FRotationOriginalKernel.hpp b/Src/Kernels/Rotation/FRotationOriginalKernel.hpp index b3f79666..0273bb60 100644 --- a/Src/Kernels/Rotation/FRotationOriginalKernel.hpp +++ b/Src/Kernels/Rotation/FRotationOriginalKernel.hpp @@ -777,7 +777,8 @@ public: * Calling this method in multi thread should be done carrefully. */ void P2P(const FTreeCoordinate& inPosition, - ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict inSources, + ContainerClass* const /*FFRestrict */ inTargets, + const ContainerClass* const /*FFRestrict */ inSources, ContainerClass* const inNeighbors[], const int neighborPositions[], const int inSize) override { if(inTargets == inSources){ diff --git a/Src/Kernels/Spherical/FAbstractSphericalKernel.hpp b/Src/Kernels/Spherical/FAbstractSphericalKernel.hpp index 5c38dc8a..df1d8be6 100644 --- a/Src/Kernels/Spherical/FAbstractSphericalKernel.hpp +++ b/Src/Kernels/Spherical/FAbstractSphericalKernel.hpp @@ -229,7 +229,8 @@ public: * Calling this method in multi thread should be done carrefully. */ void P2P(const FTreeCoordinate& inPosition, - ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict inSources, + ContainerClass* const /*FFRestrict */ inTargets, + const ContainerClass* const /*FFRestrict */ inSources, ContainerClass* const inNeighbors[], const int neighborPositions[], const int inSize) override { if(inTargets == inSources){ diff --git a/Src/Kernels/Taylor/FTaylorKernel.hpp b/Src/Kernels/Taylor/FTaylorKernel.hpp index bc76487b..332cae13 100644 --- a/Src/Kernels/Taylor/FTaylorKernel.hpp +++ b/Src/Kernels/Taylor/FTaylorKernel.hpp @@ -975,7 +975,8 @@ public: * Calling this method in multi thread should be done carrefully. */ void P2P(const FTreeCoordinate& inPosition, - ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict inSources, + ContainerClass* const /*FFRestrict */ inTargets, + const ContainerClass* const /*FFRestrict */ inSources, ContainerClass* const inNeighbors[], const int neighborPositions[], const int inSize) override { if(inTargets == inSources){ diff --git a/Src/Kernels/Taylor/FTaylorKernelSimple.hpp b/Src/Kernels/Taylor/FTaylorKernelSimple.hpp index 4d46d242..c849e281 100644 --- a/Src/Kernels/Taylor/FTaylorKernelSimple.hpp +++ b/Src/Kernels/Taylor/FTaylorKernelSimple.hpp @@ -854,7 +854,8 @@ public: * Calling this method in multi thread should be done carrefully. */ void P2P(const FTreeCoordinate& inPosition, - ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict inSources, + ContainerClass* const /*FFRestrict */ inTargets, + const ContainerClass* const /*FFRestrict */ inSources, ContainerClass* const inNeighbors[], const int neighborPositions[], const int inSize) override { if(inTargets == inSources){ diff --git a/Src/Kernels/Uniform/FUnifDenseKernel.hpp b/Src/Kernels/Uniform/FUnifDenseKernel.hpp index c5a7f86f..7de7b4cb 100644 --- a/Src/Kernels/Uniform/FUnifDenseKernel.hpp +++ b/Src/Kernels/Uniform/FUnifDenseKernel.hpp @@ -148,7 +148,8 @@ public: } void P2P(const FTreeCoordinate& inPosition, - ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict inSources, + ContainerClass* const /*FFRestrict */ inTargets, + const ContainerClass* const /*FFRestrict */ inSources, ContainerClass* const inNeighbors[], const int neighborPositions[], const int inSize) override { if(inTargets == inSources){ diff --git a/Src/Kernels/Uniform/FUnifKernel.hpp b/Src/Kernels/Uniform/FUnifKernel.hpp index 58adc254..a5068aea 100644 --- a/Src/Kernels/Uniform/FUnifKernel.hpp +++ b/Src/Kernels/Uniform/FUnifKernel.hpp @@ -193,20 +193,29 @@ public: AbstractBaseClass::Interpolator->applyL2PGradient(LeafCellCenter, leafBoxWidth, localExp, TargetParticles); } - - + /// + /// \brief P2P Particle to particle operator + /// \param inPosition + /// \param inTargets + /// \param inSources + /// \param inNeighbors + /// \param neighborPositions + /// \param inSize + /// void P2P(const FTreeCoordinate& inPosition, - ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict inSources, - ContainerClass* const inNeighbors[], const int neighborPositions[], + ContainerClass* const /*FFRestrict */ inTargets, + const ContainerClass* const /*FRestrict*/ inSources, // no restrict inTargets == inSources) + ContainerClass* const inNeighbors[], + const int neighborPositions[], const int inSize) override { this->P2P(inPosition, inTargets, inSources, inNeighbors, neighborPositions, inSize, true); } - void P2P(const FTreeCoordinate& inPosition, - ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict inSources, + ContainerClass* const FRestrict inTargets, + const ContainerClass* const FRestrict inSources, // no restrict inTargets == inSources) ContainerClass* const inNeighbors[], const int neighborPositions[], const int inSize, bool do_inner) { @@ -225,8 +234,7 @@ public: } DirectInteractionComputer::P2PRemote(inTargets,inNeighbors,inSize,MatrixKernel); } - } - // Nearfield interactions are only computed within the target leaf + } // Nearfield interactions are only computed within the target leaf else if(LeafLevelSeparationCriterion==0){ DirectInteractionComputer::P2PRemote(inTargets,inNeighbors,inSize,MatrixKernel); } diff --git a/Src/Kernels/Uniform/FUnifTensorialKernel.hpp b/Src/Kernels/Uniform/FUnifTensorialKernel.hpp index 8614c43f..b206937f 100644 --- a/Src/Kernels/Uniform/FUnifTensorialKernel.hpp +++ b/Src/Kernels/Uniform/FUnifTensorialKernel.hpp @@ -253,7 +253,8 @@ public: } void P2P(const FTreeCoordinate& inPosition, - ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict inSources, + ContainerClass* const /*FFRestrict */ inTargets, + const ContainerClass* const /*FFRestrict */ inSources, ContainerClass* const inNeighbors[], const int neighborPositions[], const int inSize) override { // Standard FMM separation criterion, i.e. max 27 neighbor clusters per leaf diff --git a/Src/Utils/FQuickSortMpi.hpp b/Src/Utils/FQuickSortMpi.hpp index 6db97886..5ccd1d68 100644 --- a/Src/Utils/FQuickSortMpi.hpp +++ b/Src/Utils/FQuickSortMpi.hpp @@ -390,8 +390,8 @@ public: // Merge previous part and just received elements const IndexType fullNbLowerElementsRecv = nbLowerElementsRecv + nbLowerElements; SortType* fullLowerPart = new SortType[fullNbLowerElementsRecv]; - memcpy(fullLowerPart, workingArray, sizeof(SortType)* nbLowerElements); - memcpy(fullLowerPart + nbLowerElements, lowerPartRecv, sizeof(SortType)* nbLowerElementsRecv); + std::memcpy(reinterpret_cast(fullLowerPart), workingArray, sizeof(SortType)* nbLowerElements); + std::memcpy(reinterpret_cast(fullLowerPart + nbLowerElements), lowerPartRecv, sizeof(SortType)* nbLowerElementsRecv); delete[] workingArray; delete[] lowerPartRecv; workingArray = fullLowerPart; @@ -414,8 +414,8 @@ public: // Merge previous part and just received elements const IndexType fullNbGreaterElementsRecv = nbGreaterElementsRecv + nbGreaterElements; SortType* fullGreaterPart = new SortType[fullNbGreaterElementsRecv]; - memcpy(fullGreaterPart, workingArray + nbLowerElements, sizeof(SortType)* nbGreaterElements); - memcpy(fullGreaterPart + nbGreaterElements, greaterPartRecv, sizeof(SortType)* nbGreaterElementsRecv); + std::memcpy(reinterpret_cast(fullGreaterPart), workingArray + nbLowerElements, sizeof(SortType)* nbGreaterElements); + std::memcpy(reinterpret_cast(fullGreaterPart + nbGreaterElements), greaterPartRecv, sizeof(SortType)* nbGreaterElementsRecv); delete[] workingArray; delete[] greaterPartRecv; workingArray = fullGreaterPart; diff --git a/UTests/utestLagrangeMpi.cpp b/UTests/utestLagrangeMpi.cpp index da94dbb7..526ef43a 100644 --- a/UTests/utestLagrangeMpi.cpp +++ b/UTests/utestLagrangeMpi.cpp @@ -66,8 +66,7 @@ class TestLagrangeMpiDirect : public FUTesterMpi{ }; FSize nbParticles = loader.getMyNumberOfParticles(); - TestParticle* const particles = new TestParticle[nbParticles]; - memset(particles,0,sizeof(TestParticle)*nbParticles); + TestParticle* const particles = new TestParticle[nbParticles]{}; //idx (in file) of the first part that will be used by this proc. FSize idxStart = loader.getStart(); -- GitLab