Commit f5a3da89 authored by COULAUD Olivier's avatar COULAUD Olivier

Remove all warnings with gcc 8: memset et memcopy une now...

Remove all warnings with gcc 8: memset et memcopy une now reinterpret_cay<char*> and we remove restrict fir target and source in p2P
parent 5277ea01
...@@ -154,7 +154,8 @@ public: ...@@ -154,7 +154,8 @@ public:
* @param size the number of direct neighbors * @param size the number of direct neighbors
*/ */
virtual void P2P(const FTreeCoordinate& inLeafPosition, 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[], ContainerClass* const directNeighborsParticles[], const int neighborPositions[],
const int size) = 0; const int size) = 0;
......
...@@ -105,7 +105,8 @@ public: ...@@ -105,7 +105,8 @@ public:
/** After Downward */ /** After Downward */
void P2P(const FTreeCoordinate& , 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 { ContainerClass* const directNeighborsParticles[], const int /*positions*/[], const int inSize) override {
// Each particles targeted is impacted by the particles sources // Each particles targeted is impacted by the particles sources
long long int inc = sources->getNbParticles(); long long int inc = sources->getNbParticles();
......
...@@ -127,8 +127,15 @@ protected: ...@@ -127,8 +127,15 @@ protected:
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
/** The workload contains what a thread need to perfom its interval of work */ /** The workload contains what a thread need to perfom its interval of work */
struct Workload{ struct Workload{
typename OctreeClass::Iterator iterator; typename OctreeClass::Iterator iterator{};
int nbElements; 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 //< The work per thread for the P2M
...@@ -354,10 +361,10 @@ protected: ...@@ -354,10 +361,10 @@ protected:
#pragma omp task #pragma omp task
{ {
if(workloadBufferThread[omp_get_thread_num()] == nullptr){ 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()]; WorkloadTemp* workloadBuffer = workloadBufferThread[omp_get_thread_num()];
memset(workloadBuffer, 0, sizeof(struct WorkloadTemp)*leafsNumber); std::memset(reinterpret_cast<char*>(workloadBuffer), 0, sizeof(struct WorkloadTemp)*leafsNumber);
// Prepare the P2P // Prepare the P2P
leafsDataArray.reset(new LeafData[leafsNumber]); leafsDataArray.reset(new LeafData[leafsNumber]);
......
...@@ -58,6 +58,7 @@ public: ...@@ -58,6 +58,7 @@ public:
operator MortonIndex() const { operator MortonIndex() const {
return this->index; return this->index;
} }
// IndexedParticle & operator=(const IndexedParticle &) = default ;
// IndexedParticle(const IndexedParticle& rhs){ // IndexedParticle(const IndexedParticle& rhs){
// index = rhs.index ; // index = rhs.index ;
// particle = rhs.particle ; // particle = rhs.particle ;
...@@ -296,9 +297,9 @@ public: ...@@ -296,9 +297,9 @@ public:
<< finalParticlesNumber << " particles\n"; FLog::Controller.flush(); ); << finalParticlesNumber << " particles\n"; FLog::Controller.flush(); );
IndexedParticle* particlesWithExtension = new IndexedParticle[finalParticlesNumber]; IndexedParticle* particlesWithExtension = new IndexedParticle[finalParticlesNumber];
// Copy old data // Copy old data
memcpy(particlesWithExtension, (*workingArray), (*workingSize)*sizeof(IndexedParticle)); std::memcpy(reinterpret_cast<char*>(particlesWithExtension), (*workingArray), (*workingSize)*sizeof(IndexedParticle));
// Copy received data // Copy received data
memcpy(particlesWithExtension + (*workingSize), receivedParticles.data(), receivedParticles.size()*sizeof(IndexedParticle)); std::memcpy(reinterpret_cast<char*>(particlesWithExtension + (*workingSize)), receivedParticles.data(), receivedParticles.size()*sizeof(IndexedParticle));
// Move ptr // Move ptr
delete[] (*workingArray); delete[] (*workingArray);
(*workingArray) = particlesWithExtension; (*workingArray) = particlesWithExtension;
...@@ -316,7 +317,7 @@ public: ...@@ -316,7 +317,7 @@ public:
//Copy all the particles //Copy all the particles
(*particlesArrayInLeafOrder) = new ParticleClass[(*workingSize)]; (*particlesArrayInLeafOrder) = new ParticleClass[(*workingSize)];
for(FSize idxPart = 0 ; idxPart < (*workingSize) ; ++idxPart){ for(FSize idxPart = 0 ; idxPart < (*workingSize) ; ++idxPart){
memcpy(&(*particlesArrayInLeafOrder)[idxPart],&(*workingArray)[idxPart].particle,sizeof(ParticleClass)); std::memcpy(reinterpret_cast<char*>(&(*particlesArrayInLeafOrder)[idxPart]),&(*workingArray)[idxPart].particle,sizeof(ParticleClass));
} }
// Assign the number of leaf // Assign the number of leaf
(*leavesSize) = leavesInfo.getSize(); (*leavesSize) = leavesInfo.getSize();
...@@ -535,7 +536,7 @@ public: ...@@ -535,7 +536,7 @@ public:
const FSize sourcePosition = FMath::Max(myObjective.first, myCurrentInter.first) - myCurrentInter.first; const FSize sourcePosition = FMath::Max(myObjective.first, myCurrentInter.first) - myCurrentInter.first;
// We store from offset, and use nbPartsPerPackToRecv has the number // We store from offset, and use nbPartsPerPackToRecv has the number
// The reading position is the offset of the first leaf we own // The reading position is the offset of the first leaf we own
memcpy(&particlesRecvBuffer[offsetToRecv], &particlesArrayInLeafOrder[leavesOffsetInParticles[sourcePosition]], std::memcpy(reinterpret_cast<char*>(&particlesRecvBuffer[offsetToRecv]), &particlesArrayInLeafOrder[leavesOffsetInParticles[sourcePosition]],
nbPartsPerPackToRecv[idxPack]*sizeof(ParticleClass)); nbPartsPerPackToRecv[idxPack]*sizeof(ParticleClass));
} }
offsetToRecv += nbPartsPerPackToRecv[idxPack]; offsetToRecv += nbPartsPerPackToRecv[idxPack];
......
...@@ -192,7 +192,8 @@ public: ...@@ -192,7 +192,8 @@ public:
} }
void P2P(const FTreeCoordinate& inPosition, 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[], ContainerClass* const inNeighbors[], const int neighborPositions[],
const int inSize) override { const int inSize) override {
if(inTargets == inSources){ if(inTargets == inSources){
......
...@@ -246,8 +246,8 @@ public: ...@@ -246,8 +246,8 @@ public:
void P2P(const FTreeCoordinate& /* LeafCellCoordinate */, // needed for periodic boundary conditions void P2P(const FTreeCoordinate& /* LeafCellCoordinate */, // needed for periodic boundary conditions
ContainerClass* const FRestrict TargetParticles, ContainerClass* const /*FFRestrict */ TargetParticles,
const ContainerClass* const FRestrict SourceParticles, const ContainerClass* const /*FFRestrict */ SourceParticles,
ContainerClass* const NeighborSourceParticles[], ContainerClass* const NeighborSourceParticles[],
const int neighborPositions[], const int neighborPositions[],
const int size) override const int size) override
......
...@@ -247,7 +247,8 @@ public: ...@@ -247,7 +247,8 @@ public:
} }
void P2P(const FTreeCoordinate& inPosition, 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[], ContainerClass* const inNeighbors[], const int neighborPositions[],
const int inSize) const int inSize)
override override
......
...@@ -475,7 +475,8 @@ public: ...@@ -475,7 +475,8 @@ public:
} }
void P2P(const FTreeCoordinate& inPosition, 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[], ContainerClass* const inNeighbors[], const int neighborPositions[],
const int inSize) const int inSize)
override override
......
...@@ -195,7 +195,8 @@ public: ...@@ -195,7 +195,8 @@ public:
} }
void P2P(const FTreeCoordinate& inPosition, 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[], ContainerClass* const inNeighbors[], const int neighborPositions[],
const int inSize) override { const int inSize) override {
if(inTargets == inSources){ if(inTargets == inSources){
......
...@@ -1373,7 +1373,8 @@ public: ...@@ -1373,7 +1373,8 @@ public:
* Calling this method in multi thread should be done carrefully. * Calling this method in multi thread should be done carrefully.
*/ */
void P2P(const FTreeCoordinate& inPosition, 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[], ContainerClass* const inNeighbors[], const int neighborPositions[],
const int inSize) override { const int inSize) override {
if(inTargets == inSources){ if(inTargets == inSources){
......
...@@ -777,7 +777,8 @@ public: ...@@ -777,7 +777,8 @@ public:
* Calling this method in multi thread should be done carrefully. * Calling this method in multi thread should be done carrefully.
*/ */
void P2P(const FTreeCoordinate& inPosition, 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[], ContainerClass* const inNeighbors[], const int neighborPositions[],
const int inSize) override { const int inSize) override {
if(inTargets == inSources){ if(inTargets == inSources){
......
...@@ -229,7 +229,8 @@ public: ...@@ -229,7 +229,8 @@ public:
* Calling this method in multi thread should be done carrefully. * Calling this method in multi thread should be done carrefully.
*/ */
void P2P(const FTreeCoordinate& inPosition, 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[], ContainerClass* const inNeighbors[], const int neighborPositions[],
const int inSize) override { const int inSize) override {
if(inTargets == inSources){ if(inTargets == inSources){
......
...@@ -975,7 +975,8 @@ public: ...@@ -975,7 +975,8 @@ public:
* Calling this method in multi thread should be done carrefully. * Calling this method in multi thread should be done carrefully.
*/ */
void P2P(const FTreeCoordinate& inPosition, 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[], ContainerClass* const inNeighbors[], const int neighborPositions[],
const int inSize) override { const int inSize) override {
if(inTargets == inSources){ if(inTargets == inSources){
......
...@@ -854,7 +854,8 @@ public: ...@@ -854,7 +854,8 @@ public:
* Calling this method in multi thread should be done carrefully. * Calling this method in multi thread should be done carrefully.
*/ */
void P2P(const FTreeCoordinate& inPosition, 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[], ContainerClass* const inNeighbors[], const int neighborPositions[],
const int inSize) override { const int inSize) override {
if(inTargets == inSources){ if(inTargets == inSources){
......
...@@ -148,7 +148,8 @@ public: ...@@ -148,7 +148,8 @@ public:
} }
void P2P(const FTreeCoordinate& inPosition, 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[], ContainerClass* const inNeighbors[], const int neighborPositions[],
const int inSize) override { const int inSize) override {
if(inTargets == inSources){ if(inTargets == inSources){
......
...@@ -193,20 +193,29 @@ public: ...@@ -193,20 +193,29 @@ public:
AbstractBaseClass::Interpolator->applyL2PGradient(LeafCellCenter, leafBoxWidth, AbstractBaseClass::Interpolator->applyL2PGradient(LeafCellCenter, leafBoxWidth,
localExp, TargetParticles); 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, void P2P(const FTreeCoordinate& inPosition,
ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict inSources, ContainerClass* const /*FFRestrict */ inTargets,
ContainerClass* const inNeighbors[], const int neighborPositions[], const ContainerClass* const /*FRestrict*/ inSources, // no restrict inTargets == inSources)
ContainerClass* const inNeighbors[],
const int neighborPositions[],
const int inSize) const int inSize)
override override
{ {
this->P2P(inPosition, inTargets, inSources, inNeighbors, neighborPositions, inSize, true); this->P2P(inPosition, inTargets, inSources, inNeighbors, neighborPositions, inSize, true);
} }
void P2P(const FTreeCoordinate& inPosition, 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[], ContainerClass* const inNeighbors[], const int neighborPositions[],
const int inSize, bool do_inner) const int inSize, bool do_inner)
{ {
...@@ -225,8 +234,7 @@ public: ...@@ -225,8 +234,7 @@ public:
} }
DirectInteractionComputer<FReal, MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,inSize,MatrixKernel); DirectInteractionComputer<FReal, MatrixKernelClass::NCMP, NVALS>::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){ else if(LeafLevelSeparationCriterion==0){
DirectInteractionComputer<FReal,MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,inSize,MatrixKernel); DirectInteractionComputer<FReal,MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,inSize,MatrixKernel);
} }
......
...@@ -253,7 +253,8 @@ public: ...@@ -253,7 +253,8 @@ public:
} }
void P2P(const FTreeCoordinate& inPosition, 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[], ContainerClass* const inNeighbors[], const int neighborPositions[],
const int inSize) override { const int inSize) override {
// Standard FMM separation criterion, i.e. max 27 neighbor clusters per leaf // Standard FMM separation criterion, i.e. max 27 neighbor clusters per leaf
......
...@@ -390,8 +390,8 @@ public: ...@@ -390,8 +390,8 @@ public:
// Merge previous part and just received elements // Merge previous part and just received elements
const IndexType fullNbLowerElementsRecv = nbLowerElementsRecv + nbLowerElements; const IndexType fullNbLowerElementsRecv = nbLowerElementsRecv + nbLowerElements;
SortType* fullLowerPart = new SortType[fullNbLowerElementsRecv]; SortType* fullLowerPart = new SortType[fullNbLowerElementsRecv];
memcpy(fullLowerPart, workingArray, sizeof(SortType)* nbLowerElements); std::memcpy(reinterpret_cast<char*>(fullLowerPart), workingArray, sizeof(SortType)* nbLowerElements);
memcpy(fullLowerPart + nbLowerElements, lowerPartRecv, sizeof(SortType)* nbLowerElementsRecv); std::memcpy(reinterpret_cast<char*>(fullLowerPart + nbLowerElements), lowerPartRecv, sizeof(SortType)* nbLowerElementsRecv);
delete[] workingArray; delete[] workingArray;
delete[] lowerPartRecv; delete[] lowerPartRecv;
workingArray = fullLowerPart; workingArray = fullLowerPart;
...@@ -414,8 +414,8 @@ public: ...@@ -414,8 +414,8 @@ public:
// Merge previous part and just received elements // Merge previous part and just received elements
const IndexType fullNbGreaterElementsRecv = nbGreaterElementsRecv + nbGreaterElements; const IndexType fullNbGreaterElementsRecv = nbGreaterElementsRecv + nbGreaterElements;
SortType* fullGreaterPart = new SortType[fullNbGreaterElementsRecv]; SortType* fullGreaterPart = new SortType[fullNbGreaterElementsRecv];
memcpy(fullGreaterPart, workingArray + nbLowerElements, sizeof(SortType)* nbGreaterElements); std::memcpy(reinterpret_cast<char*>(fullGreaterPart), workingArray + nbLowerElements, sizeof(SortType)* nbGreaterElements);
memcpy(fullGreaterPart + nbGreaterElements, greaterPartRecv, sizeof(SortType)* nbGreaterElementsRecv); std::memcpy(reinterpret_cast<char*>(fullGreaterPart + nbGreaterElements), greaterPartRecv, sizeof(SortType)* nbGreaterElementsRecv);
delete[] workingArray; delete[] workingArray;
delete[] greaterPartRecv; delete[] greaterPartRecv;
workingArray = fullGreaterPart; workingArray = fullGreaterPart;
......
...@@ -66,8 +66,7 @@ class TestLagrangeMpiDirect : public FUTesterMpi<TestLagrangeMpiDirect>{ ...@@ -66,8 +66,7 @@ class TestLagrangeMpiDirect : public FUTesterMpi<TestLagrangeMpiDirect>{
}; };
FSize nbParticles = loader.getMyNumberOfParticles(); FSize nbParticles = loader.getMyNumberOfParticles();
TestParticle* const particles = new TestParticle[nbParticles]; TestParticle* const particles = new TestParticle[nbParticles]{};
memset(particles,0,sizeof(TestParticle)*nbParticles);
//idx (in file) of the first part that will be used by this proc. //idx (in file) of the first part that will be used by this proc.
FSize idxStart = loader.getStart(); FSize idxStart = loader.getStart();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment