From 90e8f721566f4cdf0b0d0c426da636260e74283b Mon Sep 17 00:00:00 2001 From: Berenger Bramas <Berenger.Bramas@inria.fr> Date: Mon, 30 Mar 2015 15:29:28 +0200 Subject: [PATCH] Use FSize when it is related to particles --- Addons/CKernelApi/Src/CKernelApi.h | 10 +- Addons/CKernelApi/Src/CScalfmmApi.h | 10 +- Addons/CKernelApi/Src/FInterEngine.hpp | 96 +-- Addons/CKernelApi/Src/FScalfmmApiInit.cpp | 16 +- Addons/CKernelApi/Src/FUserKernelEngine.hpp | 32 +- .../CKernelApi/Src/ScalfmmCKernelApiCore.cpp | 4 +- Addons/CKernelApi/Tests/testCKernelApi.c | 20 +- Addons/CKernelApi/Tests/testChebInterface.c | 14 +- Addons/CKernelApi/Tests/testUseNewApi.c | 2 +- .../Tests/testUserDefinedKernelApi.c | 20 +- Addons/FmmApi/Src/ScalfmmApiCore.cpp | 2 +- Addons/FmmApi/Src/ScalfmmApiRotation.cpp | 16 +- Addons/FmmApi/Tests/testFmmApi.cpp | 2 +- Examples/ChebyshevInterpolationFMM.cpp | 12 +- Examples/ChebyshevInterpolationMPIFMM.cpp | 16 +- Examples/DirectComputation.cpp | 2 +- Examples/LagrangeInterpolationFMM.cpp | 22 +- Examples/RotationFMM.cpp | 12 +- Examples/RotationMPIFMM.cpp | 20 +- Examples/changeFmaFormat.cpp | 8 +- Examples/compareAllPoissonKernels.cpp | 82 +-- Examples/statisticsOnOctree.cpp | 16 +- Src/Adaptive/FAdaptChebSymKernel.hpp | 400 ++++++----- Src/Adaptive/FAdaptTools.hpp | 2 +- Src/Adaptive/FAdaptUnifKernel.hpp | 660 +++++++++--------- Src/Adaptive/FAdaptiveCell.hpp | 10 +- Src/Adaptive/FAdaptiveKernelWrapper.hpp | 2 +- Src/Adaptive/FAdaptiveTestKernel.hpp | 8 +- Src/Arranger/FAbstractMover.hpp | 4 +- .../FBasicParticleContainerIndexedMover.hpp | 6 +- Src/Arranger/FBasicParticleContainerMover.hpp | 6 +- Src/Arranger/FOctreeArranger.hpp | 58 +- Src/Arranger/FOctreeArrangerProc.hpp | 29 +- Src/Arranger/FParticleTypedIndexedMover.hpp | 8 +- Src/Components/FAbstractSendable.hpp | 4 +- Src/Components/FAbstractSerializable.hpp | 2 +- Src/Components/FBasicCell.hpp | 4 +- Src/Components/FBasicParticleContainer.hpp | 44 +- Src/Components/FSimpleLeaf.hpp | 2 +- Src/Components/FTestCell.hpp | 4 +- Src/Components/FTestKernels.hpp | 8 +- Src/Containers/FAbstractBuffer.hpp | 14 +- Src/Containers/FBufferReader.hpp | 26 +- Src/Containers/FBufferWriter.hpp | 12 +- Src/Containers/FMpiBufferReader.hpp | 60 +- Src/Containers/FMpiBufferWriter.hpp | 50 +- Src/Containers/FTreeCoordinate.hpp | 4 +- Src/Containers/FVector.hpp | 62 +- Src/Core/FFmmAlgorithmPeriodic.hpp | 4 +- Src/Core/FFmmAlgorithmTask.hpp | 4 +- Src/Core/FFmmAlgorithmThreadProc.hpp | 43 +- Src/Core/FFmmAlgorithmThreadProcPeriodic.hpp | 68 +- Src/Extensions/FExtendCellType.hpp | 4 +- Src/Files/FBasicLoader.hpp | 4 +- Src/Files/FDlpolyLoader.hpp | 2 +- Src/Files/FExportWriter.hpp | 68 +- Src/Files/FFmaGenericLoader.hpp | 110 +-- Src/Files/FFmaScanfLoader.hpp | 6 +- Src/Files/FFmaTsmLoader.hpp | 4 +- Src/Files/FHLoader.hpp | 4 +- Src/Files/FIOVtk.hpp | 18 +- Src/Files/FMpiTreeBuilder.hpp | 34 +- Src/Files/FRandomLoader.hpp | 8 +- Src/Files/FTreeBuilder.hpp | 16 +- Src/Files/FTreeCsvSaver.hpp | 4 +- Src/Files/FTreeIO.hpp | 20 +- Src/Files/FTreeMpiCsvSaver.hpp | 12 +- Src/GroupTree/Core/FGroupAttachedLeaf.hpp | 10 +- Src/GroupTree/Core/FGroupOfParticles.hpp | 16 +- Src/GroupTree/Core/FGroupTree.hpp | 32 +- .../Core/FP2PGroupParticleContainer.hpp | 2 +- Src/GroupTree/Cuda/FCudaGroupAttachedLeaf.hpp | 8 +- Src/GroupTree/Cuda/FCudaGroupOfParticles.hpp | 10 +- Src/GroupTree/TestKernel/FCudaTestKernels.hpp | 6 +- .../FGroupTestParticleContainer.hpp | 2 +- Src/GroupTree/TestKernel/FTestCellPOD.hpp | 55 -- Src/GroupTree/TestKernel/FTestKernel.cl | 20 +- Src/Kernels/Chebyshev/FChebCell.hpp | 241 +++---- Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp | 116 +-- Src/Kernels/Chebyshev/FChebInterface.h | 6 +- Src/Kernels/Chebyshev/FChebInterpolator.hpp | 8 +- Src/Kernels/Interpolation/FInterpCell.hpp | 322 ++++----- Src/Kernels/P2P/FP2P.hpp | 58 +- Src/Kernels/P2P/FP2PMultiRhs.hpp | 44 +- Src/Kernels/P2P/FP2PParticleContainer.hpp | 2 +- .../P2P/FP2PParticleContainerIndexed.hpp | 12 +- Src/Kernels/P2P/FP2PR.hpp | 34 +- Src/Kernels/Rotation/FRotationCell.hpp | 16 +- Src/Kernels/Rotation/FRotationKernel.hpp | 4 +- .../Rotation/FRotationOriginalKernel.hpp | 4 +- .../Spherical/FAbstractSphericalKernel.hpp | 8 +- .../Spherical/FSphericalBlockBlasKernel.hpp | 2 +- Src/Kernels/Spherical/FSphericalCell.hpp | 14 +- Src/Kernels/Taylor/FTaylorFlopsKernel.hpp | 400 +++++------ Src/Kernels/Taylor/FTaylorKernel.hpp | 8 +- Src/Kernels/Taylor/FTaylorKernelSimple.hpp | 8 +- Src/Kernels/Uniform/FUnifCell.hpp | 333 ++++----- Src/Kernels/Uniform/FUnifInterpolator.hpp | 10 +- Src/Utils/FCompareResults.hpp | 14 +- Src/Utils/FMath.hpp | 14 +- Src/Utils/FQuickSortMpi.hpp | 4 +- Tests/Kernels/DirectAlgorithm.cpp | 4 +- Tests/Kernels/testAdaptiveChebSymFMM.cpp | 14 +- Tests/Kernels/testChebAlgorithm.cpp | 16 +- Tests/Kernels/testChebAlgorithmProc.cpp | 8 +- Tests/Kernels/testChebTensorialAlgorithm.cpp | 16 +- Tests/Kernels/testFlopsChebAlgorithm.cpp | 2 +- Tests/Kernels/testP2PEfficency.cpp | 6 +- Tests/Kernels/testRotationAlgorithm.cpp | 6 +- Tests/Kernels/testRotationPeriodicBench.cpp | 12 +- Tests/Kernels/testSphericalAlgorithm.cpp | 6 +- Tests/Kernels/testSphericalBench.cpp | 28 +- Tests/Kernels/testSphericalBlasAlgorithm.cpp | 6 +- .../testSphericalBlockBlasAlgorithm.cpp | 6 +- .../Kernels/testSphericalDlpolyAlgorithm.cpp | 16 +- Tests/Kernels/testSphericalGalaxyCsv.cpp | 10 +- Tests/Kernels/testSphericalProcAlgorithm.cpp | 12 +- .../testSphericalRotationAlgorithm.cpp | 6 +- Tests/Kernels/testTaylor.cpp | 16 +- Tests/Kernels/testTaylorSimple.cpp | 4 +- Tests/Kernels/testTsmAlgorithm.cpp | 6 +- Tests/Kernels/testTuneSphericalBlockBlas.cpp | 2 +- Tests/Kernels/testUnifAlgorithm.cpp | 16 +- Tests/Kernels/testUnifAlgorithmProc.cpp | 8 +- Tests/Kernels/testUnifTensorialAlgorithm.cpp | 16 +- Tests/Utils/testChebInterpolator.cpp | 6 +- .../testChebInterpolatorExtendedBBox.cpp | 6 +- Tests/Utils/testChebOctree.cpp | 2 +- Tests/Utils/testChebSxUCBSy.cpp | 6 +- Tests/Utils/testFmmAdaptiveAlgorithm.cpp | 4 +- .../testFmmAdaptiveAlgorithmAdvanced.cpp | 4 +- Tests/Utils/testFmmAdaptiveStats.cpp | 4 +- Tests/Utils/testFmmAlgorithm.cpp | 2 +- Tests/Utils/testFmmAlgorithmPeriodic.cpp | 4 +- Tests/Utils/testFmmAlgorithmProc.cpp | 12 +- Tests/Utils/testFmmAlgorithmProcPeriodic.cpp | 6 +- Tests/Utils/testFmmAlgorithmProcRotation.cpp | 12 +- Tests/Utils/testFmmAlgorithmTsm.cpp | 2 +- Tests/Utils/testFmmDemonstration.cpp | 14 +- Tests/Utils/testLoader.cpp | 2 +- Tests/Utils/testLoaderFMATsm.cpp | 2 +- Tests/Utils/testMemStats.cpp | 2 +- Tests/Utils/testMpiCsvSaver.cpp | 4 +- Tests/Utils/testOctree.cpp | 2 +- Tests/Utils/testOctreeFuncteur.cpp | 2 +- Tests/Utils/testOctreeParallelFuncteur.cpp | 2 +- Tests/Utils/testOctreeRearrange.cpp | 6 +- Tests/Utils/testOctreeRearrangePeriodic.cpp | 6 +- Tests/Utils/testOctreeRearrangeProc.cpp | 8 +- Tests/Utils/testOctreeRearrangeTsm.cpp | 12 +- Tests/Utils/testStatsTree.cpp | 2 +- Tests/Utils/testTreeBuilderThread.cpp | 2 +- Tests/Utils/testTreeIO.cpp | 2 +- Tests/Utils/testUnifInterpolator.cpp | 8 +- Tests/Utils/testUnifTensorialInterpolator.cpp | 8 +- Tests/noDist/ChebyshevPeriodic.cpp | 13 +- Tests/noDist/FMMnonUnitCube.cpp | 26 +- Tests/noDist/testAdaptiveChebSymFMMDebug.cpp | 22 +- Tests/noDist/testAdaptiveUnifFMM.cpp | 14 +- Tests/noDist/testBlockedAlgorithm.cpp | 8 +- Tests/noDist/testBlockedChebyshev.cpp | 10 +- Tests/noDist/testBlockedMpiAlgorithm.cpp | 10 +- Tests/noDist/testBlockedMpiChebyshev.cpp | 19 +- Tests/noDist/testBlockedRotation.cpp | 10 +- Tests/noDist/testBlockedTaylor.cpp | 10 +- Tests/noDist/testBlockedTree.cpp | 2 +- Tests/noDist/testBlockedUniform.cpp | 10 +- Tests/noDist/testBlockedWithCudaAlgorithm.cpp | 8 +- .../noDist/testBlockedWithOpenCLAlgorithm.cpp | 8 +- Tests/noDist/testChebIntFMM.cpp | 10 +- Tests/noDist/testCompareKernels.cpp | 26 +- Tests/noDist/testInsert.cpp | 158 ++--- Tests/noDist/testMpiInsert.cpp | 202 +++--- Tests/noDist/testNewCompareKernels.cpp | 92 +-- Tests/noDist/testP2PAvx.cpp | 4 +- Tests/noDist/testSmallCase.cpp | 6 +- Tests/noDist/testSphericalBlasBlockProc.cpp | 8 +- Tests/noDist/testSphericalBlasProc.cpp | 6 +- Tests/noDist/testSphericalDebug.cpp | 12 +- Tests/noDist/testTreeBuilder.cpp | 4 +- Tests/noDist/testUnifMultiRhs.cpp | 16 +- UTests/FUKernelTester.hpp | 12 +- UTests/utestChebyshevDirectPeriodic.cpp | 18 +- UTests/utestChebyshevMpi.cpp | 10 +- UTests/utestChebyshevThread.cpp | 12 +- UTests/utestFmmAlgorithmProc.cpp | 4 +- UTests/utestInterpolationMultiRhs.cpp | 12 +- UTests/utestLagrange.cpp | 12 +- UTests/utestLagrangeMpi.cpp | 10 +- UTests/utestLagrangeThread.cpp | 12 +- UTests/utestMpiTreeBuilder.cpp | 42 +- UTests/utestRotation.cpp | 12 +- UTests/utestRotationDirectPeriodic.cpp | 18 +- UTests/utestRotationDirectSeveralTime.cpp | 12 +- UTests/utestRotationDirectTsm.cpp | 12 +- UTests/utestRotationThread.cpp | 12 +- UTests/utestSpherical.cpp | 12 +- UTests/utestSphericalBlasAlgorithm.cpp | 12 +- UTests/utestSphericalDirect.cpp | 12 +- UTests/utestSphericalDirectPeriodic.cpp | 14 +- UTests/utestSphericalWithPrevious.cpp | 4 +- Utils/noDist/FmmAlgorithmTsm.cpp | 18 +- Utils/noDist/compare2Files.cpp | 6 +- Utils/noDist/removeMoment.cpp | 4 +- Utils/noDist/stamp2Fma.cpp | 14 +- Utils/noDist/testAccuracyChebFMM.cpp | 10 +- Utils/noDist/testChebOrderEpsilon.cpp | 12 +- Utils/noDist/testPrecisionAllKernel.cpp | 22 +- 208 files changed, 2831 insertions(+), 2828 deletions(-) diff --git a/Addons/CKernelApi/Src/CKernelApi.h b/Addons/CKernelApi/Src/CKernelApi.h index c6b555581..ffe528de2 100644 --- a/Addons/CKernelApi/Src/CKernelApi.h +++ b/Addons/CKernelApi/Src/CKernelApi.h @@ -48,7 +48,7 @@ void Scalfmm_dealloc_handle(Scalfmm_Handle handle, Callback_free_cell cellDestro //< The indexes are the one used on the particles operator //< The position of the particles should be composed of one triple per particle: //< xyzxyzxyz... -void Scalfmm_insert_array_of_particles(Scalfmm_Handle handle, int nbParticles, int* particleIndexes, double* particleXYZ); +void Scalfmm_insert_array_of_particles(Scalfmm_Handle handle, FSize nbParticles, int* particleIndexes, double* particleXYZ); //< To insert one particle only void Scalfmm_one_particle(Scalfmm_Handle handle, int particleIndexe, double x, double y, double z); @@ -62,13 +62,13 @@ void Scalfmm_init_cell(Scalfmm_Handle handle, Callback_init_cell cellInitializer /////////////////////////////////////////////////////////////////////////// //< These function are the callbacks of the FMM operators -typedef void (*Callback_P2M)(void* leafCell, int nbParticles, const int* particleIndexes, void* userData); +typedef void (*Callback_P2M)(void* leafCell, FSize nbParticles, const int* particleIndexes, void* userData); typedef void (*Callback_M2M)(int level, void* parentCell, int childPosition, void* childCell, void* userData); typedef void (*Callback_M2L)(int level, void* targetCell, int sourceCellPosition, void* sourceCell, void* userData); typedef void (*Callback_L2L)(int level, void* parentCell, int childPosition, void* childCell, void* userData); -typedef void (*Callback_L2P)(void* leafCell, int nbParticles, int* particleIndexes, void* userData); -typedef void (*Callback_P2P)(int nbParticles, const int* particleIndexes, int nbSourceParticles, const int* sourceParticleIndexes, void* userData); -typedef void (*Callback_P2PInner)(int nbParticles, int* particleIndexes, void* userData); +typedef void (*Callback_L2P)(void* leafCell, FSize nbParticles, int* particleIndexes, void* userData); +typedef void (*Callback_P2P)(FSize nbParticles, const int* particleIndexes, int nbSourceParticles, const int* sourceParticleIndexes, void* userData); +typedef void (*Callback_P2PInner)(FSize nbParticles, int* particleIndexes, void* userData); //< This structure should be filled (or filled with null) to call the FMM struct Scalfmm_Kernel_Descriptor { diff --git a/Addons/CKernelApi/Src/CScalfmmApi.h b/Addons/CKernelApi/Src/CScalfmmApi.h index e68d897f7..2071d0b2e 100644 --- a/Addons/CKernelApi/Src/CScalfmmApi.h +++ b/Addons/CKernelApi/Src/CScalfmmApi.h @@ -362,7 +362,7 @@ void scalfmm_algorithm_config(scalfmm_handle Handle,scalfmm_algorithm config); * @param particleIndexes indexes of particles currently computed * @param userData datas specific to the user's kernel */ -typedef void (*Callback_P2M)(void* leafCell, int nbParticles, const int* particleIndexes, void* userData); +typedef void (*Callback_P2M)(void* leafCell, FSize nbParticles, const int* particleIndexes, void* userData); /** * @brief Function to be filled by user's M2M @@ -411,7 +411,7 @@ typedef void (*Callback_L2L)(int level, void* parentCell, int childPosition, voi * @param particleIndexes indexes of particles currently computed * @param userData datas specific to the user's kernel */ -typedef void (*Callback_L2P)(void* leafCell, int nbParticles,const int* particleIndexes, void* userData); +typedef void (*Callback_L2P)(void* leafCell, FSize nbParticles,const int* particleIndexes, void* userData); /** * @brief Function to be filled by user's P2P @@ -421,7 +421,7 @@ typedef void (*Callback_L2P)(void* leafCell, int nbParticles,const int* particle * @param sourceParticleIndexes indexes of cource particles currently computed * @param userData datas specific to the user's kernel */ -typedef void (*Callback_P2P)(int nbParticles, const int* particleIndexes, int nbSourceParticles, const int* sourceParticleIndexes, void* userData); +typedef void (*Callback_P2P)(FSize nbParticles, const int* particleIndexes, int nbSourceParticles, const int* sourceParticleIndexes, void* userData); /** * @brief Function to be filled by user's P2P @@ -432,7 +432,7 @@ typedef void (*Callback_P2P)(int nbParticles, const int* particleIndexes, int nb * @param sourceNbPart array containing the number of part in each neighbors * @param userData datas specific to the user's kernel */ -typedef void (*Callback_P2PFull)(int nbParticles, const int* particleIndexes, +typedef void (*Callback_P2PFull)(FSize nbParticles, const int* particleIndexes, const int * sourceParticleIndexes[27],int sourceNbPart[27], void* userData); @@ -442,7 +442,7 @@ typedef void (*Callback_P2PFull)(int nbParticles, const int* particleIndexes, * @param particleIndexes indexes of particles currently computed * @param userData datas specific to the user's kernel */ -typedef void (*Callback_P2PInner)(int nbParticles, const int* particleIndexes, void* userData); +typedef void (*Callback_P2PInner)(FSize nbParticles, const int* particleIndexes, void* userData); diff --git a/Addons/CKernelApi/Src/FInterEngine.hpp b/Addons/CKernelApi/Src/FInterEngine.hpp index 2a427a859..e99696f45 100644 --- a/Addons/CKernelApi/Src/FInterEngine.hpp +++ b/Addons/CKernelApi/Src/FInterEngine.hpp @@ -112,9 +112,9 @@ public: void set_physical_values(int nbPhysicalValues,double * physicalValues){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ sources->getPhysicalValues()[idxPart] = physicalValues[indexes[idxPart]]; } }); @@ -126,9 +126,9 @@ public: void set_physical_values_npart( int nbPhysicalValues, int* idxOfParticles, double * physicalValues){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ int iterPart = 0; bool notFoundYet = true; while(iterPart < nbPhysicalValues && notFoundYet){ @@ -148,9 +148,9 @@ public: void get_physical_values( int nbPhysicalValues, double * physicalValues){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ physicalValues[indexes[idxPart]] = sources->getPhysicalValues()[idxPart]; } }); @@ -160,9 +160,9 @@ public: void get_physical_values_npart( int nbPhysicalValues, int* idxOfParticles, double * physicalValues){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ int iterPart = 0; bool notFoundYet = true; while(iterPart < nbPhysicalValues && notFoundYet){ @@ -181,9 +181,9 @@ public: void get_forces_xyz( int nbParts, double * forcesToFill){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ forcesToFill[indexes[idxPart]*3+0] = sources->getForcesX()[idxPart]; forcesToFill[indexes[idxPart]*3+1] = sources->getForcesY()[idxPart]; forcesToFill[indexes[idxPart]*3+2] = sources->getForcesZ()[idxPart]; @@ -194,9 +194,9 @@ public: void get_forces_xyz_npart(int nbParts, int* idxOfParticles , double * forcesToFill){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ int iterPart = 0; bool notFoundYet = true; while(iterPart < nbParts && notFoundYet){ @@ -217,9 +217,9 @@ public: void get_forces( int nbParts, double * fX, double* fY, double* fZ){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ fX[indexes[idxPart]] = sources->getForcesX()[idxPart]; fY[indexes[idxPart]] = sources->getForcesY()[idxPart]; fZ[indexes[idxPart]] = sources->getForcesZ()[idxPart]; @@ -230,9 +230,9 @@ public: void get_forces_npart(int nbParts, int* idxOfParticles ,double * fX, double* fY, double* fZ){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ int iterPart = 0; bool notFoundYet = true; while(iterPart < nbParts && notFoundYet){ @@ -254,9 +254,9 @@ public: void set_forces_xyz( int nbParts, double * forcesToRead){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ sources->getForcesX()[idxPart] = forcesToRead[indexes[idxPart]*3+0]; sources->getForcesY()[idxPart] = forcesToRead[indexes[idxPart]*3+1]; sources->getForcesZ()[idxPart] = forcesToRead[indexes[idxPart]*3+2]; @@ -266,9 +266,9 @@ public: void set_forces_xyz_npart( int nbParts, int* idxOfParticles, double * forcesToRead){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ int iterPart = 0; bool notFoundYet = true; while(iterPart < nbParts && notFoundYet){ @@ -288,9 +288,9 @@ public: void set_forces( int nbParts, double * fX, double* fY, double* fZ){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ sources->getForcesX()[idxPart] = fX[indexes[idxPart]]; sources->getForcesY()[idxPart] = fY[indexes[idxPart]]; sources->getForcesZ()[idxPart] = fZ[indexes[idxPart]]; @@ -300,9 +300,9 @@ public: void set_forces_npart( int nbParts, int* idxOfParticles, double * fX, double* fY, double* fZ){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ int iterPart = 0; bool notFoundYet = true; while(iterPart < nbParts && notFoundYet){ @@ -324,9 +324,9 @@ public: void set_potentials(int nbPotentials,double * potentialsToRead){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ sources->getPotentials()[idxPart] = potentialsToRead[indexes[idxPart]]; } }); @@ -338,9 +338,9 @@ public: void set_potentials_npart( int nbPotentials, int* idxOfParticles, double * potentialsToRead){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ int iterPart = 0; bool notFoundYet = true; while(iterPart < nbPotentials && notFoundYet){ @@ -360,9 +360,9 @@ public: void get_potentials( int nbPotentials, double * potentialsToFill){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ potentialsToFill[indexes[idxPart]] = sources->getPotentials()[idxPart]; } }); @@ -372,9 +372,9 @@ public: void get_potentials_npart( int nbPotentials, int* idxOfParticles, double * potentialsToFill){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ int iterPart = 0; bool notFoundYet = true; while(iterPart < nbPotentials && notFoundYet){ @@ -393,9 +393,9 @@ public: void get_positions_xyz(int NbPositions, double * positionsToFill){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ positionsToFill[indexes[idxPart]*3+0] = sources->getPositions()[0][idxPart]; positionsToFill[indexes[idxPart]*3+1] = sources->getPositions()[1][idxPart]; positionsToFill[indexes[idxPart]*3+2] = sources->getPositions()[2][idxPart]; @@ -406,9 +406,9 @@ public: void get_positions_xyz_npart(int NbPositions, int * idxOfParticles, double * positionsToFill){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ int iterPart = 0; bool notFoundYet = true; while(iterPart < NbPositions && notFoundYet){ @@ -429,9 +429,9 @@ public: void get_positions( int NbPositions, double * X, double * Y , double * Z){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ X[indexes[idxPart]] = sources->getPositions()[0][idxPart]; Y[indexes[idxPart]] = sources->getPositions()[1][idxPart]; Z[indexes[idxPart]] = sources->getPositions()[2][idxPart]; @@ -442,9 +442,9 @@ public: void get_positions_npart(int NbPositions, int * idxOfParticles,double * X, double * Y , double * Z){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ int iterPart = 0; bool notFoundYet = true; while(iterPart < NbPositions && notFoundYet){ @@ -468,9 +468,9 @@ public: void add_to_positions_xyz(int NbPositions,double * updatedXYZ){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ sources->getWPositions()[0][idxPart] += updatedXYZ[indexes[idxPart]*3+0]; sources->getWPositions()[1][idxPart] += updatedXYZ[indexes[idxPart]*3+1]; sources->getWPositions()[2][idxPart] += updatedXYZ[indexes[idxPart]*3+2]; @@ -481,9 +481,9 @@ public: void add_to_positions(int NbPositions,double * X, double * Y , double * Z){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ sources->getWPositions()[0][idxPart] += X[indexes[idxPart]]; sources->getWPositions()[1][idxPart] += Y[indexes[idxPart]]; sources->getWPositions()[2][idxPart] += Z[indexes[idxPart]]; @@ -495,9 +495,9 @@ public: void set_positions_xyz(int NbPositions, double * updatedXYZ){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ sources->getWPositions()[0][idxPart] = updatedXYZ[indexes[idxPart]*3+0]; sources->getWPositions()[1][idxPart] = updatedXYZ[indexes[idxPart]*3+1]; sources->getWPositions()[2][idxPart] = updatedXYZ[indexes[idxPart]*3+2]; @@ -508,9 +508,9 @@ public: void set_positions(int NbPositions, double * X, double * Y, double * Z){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ sources->getWPositions()[0][idxPart] = X[indexes[idxPart]]; sources->getWPositions()[1][idxPart] = Y[indexes[idxPart]]; sources->getWPositions()[2][idxPart] = Z[indexes[idxPart]]; diff --git a/Addons/CKernelApi/Src/FScalfmmApiInit.cpp b/Addons/CKernelApi/Src/FScalfmmApiInit.cpp index 194cc688a..72dcd1bcc 100644 --- a/Addons/CKernelApi/Src/FScalfmmApiInit.cpp +++ b/Addons/CKernelApi/Src/FScalfmmApiInit.cpp @@ -126,7 +126,7 @@ extern "C" void ChebKernelStruct_free(void *inKernel){ } -extern "C" void ChebKernel_P2M(void * leafCell, int nbParticles, const int *particleIndexes, void * inKernel){ +extern "C" void ChebKernel_P2M(void * leafCell, FSize nbParticles, const int *particleIndexes, void * inKernel){ //make temporary array of parts FP2PParticleContainerIndexed<FReal>* tempContainer = new FP2PParticleContainerIndexed<FReal>(); tempContainer->reserve(nbParticles); @@ -215,7 +215,7 @@ extern "C" void ChebKernel_L2L(int level, void* parentCell, int childPosition, v childChebCell->getLocal(0)); } -extern "C" void ChebKernel_L2P(void* leafCell, int nbParticles, const int* particleIndexes, void* inKernel){ +extern "C" void ChebKernel_L2P(void* leafCell, FSize nbParticles, const int* particleIndexes, void* inKernel){ //Create temporary FSimpleLeaf FP2PParticleContainerIndexed<FReal>* tempContainer = new FP2PParticleContainerIndexed<FReal>(); tempContainer->reserve(nbParticles); @@ -242,8 +242,8 @@ extern "C" void ChebKernel_L2P(void* leafCell, int nbParticles, const int* parti //Then retrieve the results double * forcesToFill = reinterpret_cast<UserData *>(inKernel)->forcesComputed[id_thread]; - const FVector<int>& indexes = tempContainer->getIndexes(); - for(int idxPart = 0 ; idxPart<nbParticles ; ++idxPart){ + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); + for(FSize idxPart = 0 ; idxPart<nbParticles ; ++idxPart){ forcesToFill[indexes[idxPart]*3+0] += tempContainer->getForcesX()[idxPart]; forcesToFill[indexes[idxPart]*3+1] += tempContainer->getForcesY()[idxPart]; forcesToFill[indexes[idxPart]*3+2] += tempContainer->getForcesZ()[idxPart]; @@ -254,7 +254,7 @@ extern "C" void ChebKernel_L2P(void* leafCell, int nbParticles, const int* parti } - void ChebKernel_P2P(int nbParticles, const int* particleIndexes, + void ChebKernel_P2P(FSize nbParticles, const int* particleIndexes, const int * sourceParticleIndexes[27],int sourceNbPart[27],void* inKernel){ //Create temporary FSimpleLeaf for target @@ -306,8 +306,8 @@ extern "C" void ChebKernel_L2P(void* leafCell, int nbParticles, const int* parti //get back forces double * forcesToFill = reinterpret_cast<UserData *>(inKernel)->forcesComputed[id_thread]; - const FVector<int>& indexes = tempContTarget->getIndexes(); - for(int idxPart = 0 ; idxPart<nbParticles ; ++idxPart){ + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); + for(FSize idxPart = 0 ; idxPart<nbParticles ; ++idxPart){ forcesToFill[indexes[idxPart]*3+0] += tempContTarget->getForcesX()[idxPart]; forcesToFill[indexes[idxPart]*3+1] += tempContTarget->getForcesY()[idxPart]; forcesToFill[indexes[idxPart]*3+2] += tempContTarget->getForcesZ()[idxPart]; @@ -316,7 +316,7 @@ extern "C" void ChebKernel_L2P(void* leafCell, int nbParticles, const int* parti //Note that sources are also modified. //get back sources forces for(int idSource = 0 ; idSource < 27 ; ++idSource){ - const FVector<int>& indexes = tempContSources[idSource]->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); const int nbPartInSource = sourceNbPart[idSource]; for(int idxSourcePart = 0; idxSourcePart < nbPartInSource ; ++idxSourcePart){ forcesToFill[indexes[idxSourcePart]*3+0] += tempContSources[idSource]->getForcesX()[idxSourcePart]; diff --git a/Addons/CKernelApi/Src/FUserKernelEngine.hpp b/Addons/CKernelApi/Src/FUserKernelEngine.hpp index 9b88ce6d1..4623623da 100644 --- a/Addons/CKernelApi/Src/FUserKernelEngine.hpp +++ b/Addons/CKernelApi/Src/FUserKernelEngine.hpp @@ -276,9 +276,9 @@ public: void get_positions_xyz(int NbPositions, double * positionsToFill){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ positionsToFill[indexes[idxPart]*3+0] = sources->getPositions()[0][idxPart]; positionsToFill[indexes[idxPart]*3+1] = sources->getPositions()[1][idxPart]; positionsToFill[indexes[idxPart]*3+2] = sources->getPositions()[2][idxPart]; @@ -289,9 +289,9 @@ public: void get_positions_xyz_npart(int NbPositions, int * idxOfParticles, double * positionsToFill){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ int iterPart = 0; bool notFoundYet = true; while(iterPart < NbPositions && notFoundYet){ @@ -312,9 +312,9 @@ public: void get_positions( int NbPositions, double * X, double * Y , double * Z){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ X[indexes[idxPart]] = sources->getPositions()[0][idxPart]; Y[indexes[idxPart]] = sources->getPositions()[1][idxPart]; Z[indexes[idxPart]] = sources->getPositions()[2][idxPart]; @@ -325,9 +325,9 @@ public: void get_positions_npart(int NbPositions, int * idxOfParticles,double * X, double * Y , double * Z){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ int iterPart = 0; bool notFoundYet = true; while(iterPart < NbPositions && notFoundYet){ @@ -352,9 +352,9 @@ public: void add_to_positions_xyz(int NbPositions,double * updatedXYZ){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ sources->getWPositions()[0][idxPart] += updatedXYZ[indexes[idxPart]*3+0]; sources->getWPositions()[1][idxPart] += updatedXYZ[indexes[idxPart]*3+1]; sources->getWPositions()[2][idxPart] += updatedXYZ[indexes[idxPart]*3+2]; @@ -365,9 +365,9 @@ public: void add_to_positions(int NbPositions,double * X, double * Y , double * Z){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ sources->getWPositions()[0][idxPart] += X[indexes[idxPart]]; sources->getWPositions()[1][idxPart] += Y[indexes[idxPart]]; sources->getWPositions()[2][idxPart] += Z[indexes[idxPart]]; @@ -379,9 +379,9 @@ public: void set_positions_xyz(int NbPositions, double * updatedXYZ){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ sources->getWPositions()[0][idxPart] = updatedXYZ[indexes[idxPart]*3+0]; sources->getWPositions()[1][idxPart] = updatedXYZ[indexes[idxPart]*3+1]; sources->getWPositions()[2][idxPart] = updatedXYZ[indexes[idxPart]*3+2]; @@ -392,9 +392,9 @@ public: void set_positions(int NbPositions, double * X, double * Y, double * Z){ octree->forEachLeaf([&](LeafClass* leaf){ ContainerClass * sources = leaf->getSrc(); - const FVector<int>& indexes = sources->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); int nbPartThere = sources->getNbParticles(); - for(int idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart<nbPartThere ; ++idxPart){ sources->getWPositions()[0][idxPart] = X[indexes[idxPart]]; sources->getWPositions()[1][idxPart] = Y[indexes[idxPart]]; sources->getWPositions()[2][idxPart] = Z[indexes[idxPart]]; diff --git a/Addons/CKernelApi/Src/ScalfmmCKernelApiCore.cpp b/Addons/CKernelApi/Src/ScalfmmCKernelApiCore.cpp index 9631266fc..58654050d 100644 --- a/Addons/CKernelApi/Src/ScalfmmCKernelApiCore.cpp +++ b/Addons/CKernelApi/Src/ScalfmmCKernelApiCore.cpp @@ -226,9 +226,9 @@ extern "C" void Scalfmm_dealloc_handle(Scalfmm_Handle handle, Callback_free_cell } // Insert a full array of particles. Posisions are xyz.xyz.xyz... -extern "C" void Scalfmm_insert_array_of_particles(Scalfmm_Handle handle, int nbParticles, int* particleIndexes, double* particleXYZ){ +extern "C" void Scalfmm_insert_array_of_particles(Scalfmm_Handle handle, FSize nbParticles, int* particleIndexes, double* particleXYZ){ ScalFmmCoreHandle* corehandle = (ScalFmmCoreHandle*)handle; - for(int idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ corehandle->octree->insert(FPoint<FReal>(particleXYZ[idxPart*3],particleXYZ[idxPart*3+1],particleXYZ[idxPart*3+2]), particleIndexes[idxPart]); } diff --git a/Addons/CKernelApi/Tests/testCKernelApi.c b/Addons/CKernelApi/Tests/testCKernelApi.c index 0d279eead..dc6de4024 100644 --- a/Addons/CKernelApi/Tests/testCKernelApi.c +++ b/Addons/CKernelApi/Tests/testCKernelApi.c @@ -88,13 +88,13 @@ struct MyData { // Our P2M -void my_Callback_P2M(void* cellData, int nbParticlesInLeaf, const int* particleIndexes, void* userData){ +void my_Callback_P2M(void* cellData, FSize nbParticlesInLeaf, const int* particleIndexes, void* userData){ struct MyData* my_data = (struct MyData*)userData; my_data->countP2M += 1; struct MyCellDescriptor* my_cell = (struct MyCellDescriptor*) cellData; VerbosePrint("Cell morton %lld is doing P2M with %d particles :\n", my_cell->mortonIndex, nbParticlesInLeaf); - int idxPart; + FSize idxPart; for(idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ double* position = &my_data->insertedPositions[particleIndexes[idxPart]*3]; VerbosePrint("\t particle idx %d position %e/%e%e\n", particleIndexes[idxPart], @@ -152,13 +152,13 @@ void my_Callback_L2L(int level, void* cellData, int childPosition, void* childDa // JUST-PUT-HERE: Your L2L } -void my_Callback_L2P(void* cellData, int nbParticlesInLeaf, int* particleIndexes, void* userData){ +void my_Callback_L2P(void* cellData, FSize nbParticlesInLeaf, int* particleIndexes, void* userData){ struct MyData* my_data = (struct MyData*)userData; my_data->countL2P += 1; struct MyCellDescriptor* my_cell = (struct MyCellDescriptor*) cellData; VerbosePrint("Cell morton %lld is doing L2P with %d particles :\n", my_cell->mortonIndex, nbParticlesInLeaf); - int idxPart; + FSize idxPart; for(idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ double* position = &my_data->insertedPositions[particleIndexes[idxPart]*3]; VerbosePrint("\t particle idx %d position %e/%e%e\n", particleIndexes[idxPart], @@ -167,12 +167,12 @@ void my_Callback_L2P(void* cellData, int nbParticlesInLeaf, int* particleIndexes } } -void my_Callback_P2P(int nbParticlesInLeaf, const int* particleIndexes, int nbParticlesInSrc, const int* particleIndexesSrc, void* userData){ +void my_Callback_P2P(FSize nbParticlesInLeaf, const int* particleIndexes, FSize nbParticlesInSrc, const int* particleIndexesSrc, void* userData){ struct MyData* my_data = (struct MyData*)userData; my_data->countP2P += 1; VerbosePrint("Doing P2P between two leaves of %d particles and %d particles :\n", nbParticlesInLeaf, nbParticlesInSrc); - int idxPart; + FSize idxPart; for(idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ double* position = &my_data->insertedPositions[particleIndexes[idxPart]*3]; VerbosePrint("\t Target >> particle idx %d position %e/%e%e\n", particleIndexes[idxPart], @@ -189,12 +189,12 @@ void my_Callback_P2P(int nbParticlesInLeaf, const int* particleIndexes, int nbPa // interacting with the target particles } -void my_Callback_P2PInner(int nbParticlesInLeaf, int* particleIndexes, void* userData){ +void my_Callback_P2PInner(FSize nbParticlesInLeaf, int* particleIndexes, void* userData){ struct MyData* my_data = (struct MyData*)userData; my_data->countP2PInner += 1; VerbosePrint("Doing P2P inside a leaf of %d particles :\n", nbParticlesInLeaf); - int idxPart; + FSize idxPart; for(idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ double* position = &my_data->insertedPositions[particleIndexes[idxPart]*3]; VerbosePrint("\t particle idx %d position %e/%e%e\n", particleIndexes[idxPart], @@ -217,12 +217,12 @@ int main(int argc, char ** argv){ boxCenter[0] = boxCenter[1] = boxCenter[2] = 0.0; // Create random particles - int nbParticles = 10; + FSize nbParticles = 10; int particleIndexes[nbParticles]; double particleXYZ[nbParticles*3]; { printf("Creating Particles:\n"); - int idxPart; + FSize idxPart; for(idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ particleIndexes[idxPart] = idxPart; particleXYZ[idxPart*3] = (random()/(double)(RAND_MAX))*boxWidth - boxWidth/2 + boxCenter[0]; diff --git a/Addons/CKernelApi/Tests/testChebInterface.c b/Addons/CKernelApi/Tests/testChebInterface.c index 6d8e9c66d..028f5cea7 100644 --- a/Addons/CKernelApi/Tests/testChebInterface.c +++ b/Addons/CKernelApi/Tests/testChebInterface.c @@ -34,7 +34,7 @@ void cheb_free_cell(void * inCell){ * @brief Wrapper to FMM operators (refer to CScalfmmApi.h to get the * detailed descriptions) */ -void cheb_p2m(void* cellData, int nbParticlesInLeaf, const int* particleIndexes, void* userData){ +void cheb_p2m(void* cellData, FSize nbParticlesInLeaf, const int* particleIndexes, void* userData){ ChebKernel_P2M(cellData,nbParticlesInLeaf,particleIndexes,userData); } void cheb_m2m(int level, void* parentCell, int childPosition, void* childCell, void* userData){ @@ -46,10 +46,10 @@ void cheb_m2l_full(int level, void* targetCell, void* sourceCell[343], void* use void cheb_l2l(int level, void* parentCell, int childPosition, void* childCell, void* userData){ ChebKernel_L2L( level, parentCell, childPosition, childCell, userData); } -void cheb_l2p(void* leafCell, int nbParticles, const int* particleIndexes, void* userData){ +void cheb_l2p(void* leafCell, FSize nbParticles, const int* particleIndexes, void* userData){ ChebKernel_L2P( leafCell, nbParticles, particleIndexes, userData); } -void cheb_p2pFull(int nbParticles, const int* particleIndexes, +void cheb_p2pFull(FSize nbParticles, const int* particleIndexes, const int * sourceParticleIndexes[27], int sourceNbPart[27],void* userData) { ChebKernel_P2P(nbParticles, particleIndexes, sourceParticleIndexes, sourceNbPart, userData); } @@ -131,7 +131,7 @@ int main(int argc, char ** av){ { printf("Creating Particles:\n"); - int idxPart; + FSize idxPart; for(idxPart = 0 ; idxPart < nbPart ; ++idxPart){ particleXYZ[idxPart*3] = (random()/(double)(RAND_MAX))*boxWidth - boxWidth/2 + boxCenter[0]; particleXYZ[idxPart*3+1] = (random()/(double)(RAND_MAX))*boxWidth - boxWidth/2 + boxCenter[1]; @@ -146,7 +146,7 @@ int main(int argc, char ** av){ //format in order to verify numercal results /* FILE * fd = fopen("input.fma","w"); */ /* fprintf(fd,"8\t 4\n %d\n %f\t %f\t %f\t %f\n",nbPart,boxWidth/2.0, boxCenter[0],boxCenter[1],boxCenter[2]); */ - /* int idxPart; */ + /* FSize idxPart; */ /* for(idxPart=0 ; idxPart<nbPart ; ++idxPart){ */ /* fprintf(fd,"%e\t %e\t %e\t %e \n", */ /* particleXYZ[idxPart*3], */ @@ -238,7 +238,7 @@ int main(int argc, char ** av){ //Reduction on forces array { - int idxPart; + FSize idxPart; for(idThreads=1 ; idThreads<nb_threads ; ++idThreads){ for(idxPart=0 ; idxPart<nbPart*3 ; ++idxPart){ //Everything is stored in first array @@ -265,7 +265,7 @@ int main(int argc, char ** av){ memset(forcesRef,0,sizeof(double)*3*nbPart); scalfmm_get_forces_xyz(handle_ref,nbPart,forcesRef); {//Comparison part - int idxPart; + FSize idxPart; int nbPartOkay = 0; for(idxPart=0 ; idxPart<nbPart ; ++idxPart ){ double diffX,diffY,diffZ; diff --git a/Addons/CKernelApi/Tests/testUseNewApi.c b/Addons/CKernelApi/Tests/testUseNewApi.c index 2bc5baf74..203da8dbc 100644 --- a/Addons/CKernelApi/Tests/testUseNewApi.c +++ b/Addons/CKernelApi/Tests/testUseNewApi.c @@ -37,7 +37,7 @@ int main(int argc, char ** av){ scalfmm_algorithm_config(handle,periodic); //Creation of an array of particles int nb_of_parts = 2; - int idxPart; + FSize idxPart; double * positionsXYZ = malloc(sizeof(double)*3*nb_of_parts); memset(positionsXYZ,0,sizeof(double)*3*nb_of_parts); diff --git a/Addons/CKernelApi/Tests/testUserDefinedKernelApi.c b/Addons/CKernelApi/Tests/testUserDefinedKernelApi.c index 1fd1d94cc..18b30e737 100644 --- a/Addons/CKernelApi/Tests/testUserDefinedKernelApi.c +++ b/Addons/CKernelApi/Tests/testUserDefinedKernelApi.c @@ -88,13 +88,13 @@ struct MyData { // Our P2M -void my_Callback_P2M(void* cellData, int nbParticlesInLeaf, const int* particleIndexes, void* userData){ +void my_Callback_P2M(void* cellData, FSize nbParticlesInLeaf, const int* particleIndexes, void* userData){ struct MyData* my_data = (struct MyData*)userData; my_data->countP2M += 1; struct MyCellDescriptor* my_cell = (struct MyCellDescriptor*) cellData; VerbosePrint("Cell morton %lld is doing P2M with %d particles :\n", my_cell->mortonIndex, nbParticlesInLeaf); - int idxPart; + FSize idxPart; for(idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ double* position = &my_data->insertedPositions[particleIndexes[idxPart]*3]; VerbosePrint("\t particle idx %d position %e/%e%e\n", particleIndexes[idxPart], @@ -152,13 +152,13 @@ void my_Callback_L2L(int level, void* cellData, int childPosition, void* childDa // JUST-PUT-HERE: Your L2L } -void my_Callback_L2P(void* cellData, int nbParticlesInLeaf, const int* particleIndexes, void* userData){ +void my_Callback_L2P(void* cellData, FSize nbParticlesInLeaf, const int* particleIndexes, void* userData){ struct MyData* my_data = (struct MyData*)userData; my_data->countL2P += 1; struct MyCellDescriptor* my_cell = (struct MyCellDescriptor*) cellData; VerbosePrint("Cell morton %lld is doing L2P with %d particles :\n", my_cell->mortonIndex, nbParticlesInLeaf); - int idxPart; + FSize idxPart; for(idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ double* position = &my_data->insertedPositions[particleIndexes[idxPart]*3]; VerbosePrint("\t particle idx %d position %e/%e%e\n", particleIndexes[idxPart], @@ -167,12 +167,12 @@ void my_Callback_L2P(void* cellData, int nbParticlesInLeaf, const int* particleI } } -void my_Callback_P2P(int nbParticlesInLeaf, const int* particleIndexes, int nbParticlesInSrc, const int* particleIndexesSrc, void* userData){ +void my_Callback_P2P(FSize nbParticlesInLeaf, const int* particleIndexes, FSize nbParticlesInSrc, const int* particleIndexesSrc, void* userData){ struct MyData* my_data = (struct MyData*)userData; my_data->countP2P += 1; VerbosePrint("Doing P2P between two leaves of %d particles and %d particles :\n", nbParticlesInLeaf, nbParticlesInSrc); - int idxPart; + FSize idxPart; for(idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ double* position = &my_data->insertedPositions[particleIndexes[idxPart]*3]; VerbosePrint("\t Target >> particle idx %d position %e/%e%e\n", particleIndexes[idxPart], @@ -189,12 +189,12 @@ void my_Callback_P2P(int nbParticlesInLeaf, const int* particleIndexes, int nbPa // interacting with the target particles } -void my_Callback_P2PInner(int nbParticlesInLeaf, const int* particleIndexes, void* userData){ +void my_Callback_P2PInner(FSize nbParticlesInLeaf, const int* particleIndexes, void* userData){ struct MyData* my_data = (struct MyData*)userData; my_data->countP2PInner += 1; VerbosePrint("Doing P2P inside a leaf of %d particles :\n", nbParticlesInLeaf); - int idxPart; + FSize idxPart; for(idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ double* position = &my_data->insertedPositions[particleIndexes[idxPart]*3]; VerbosePrint("\t particle idx %d position %e/%e%e\n", particleIndexes[idxPart], @@ -217,12 +217,12 @@ int main(int argc, char ** argv){ boxCenter[0] = boxCenter[1] = boxCenter[2] = 0.0; // Create random particles - int nbParticles = 10; + FSize nbParticles = 10; int particleIndexes[nbParticles]; double particleXYZ[nbParticles*3]; { printf("Creating Particles:\n"); - int idxPart; + FSize idxPart; for(idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ particleIndexes[idxPart] = idxPart; particleXYZ[idxPart*3] = (random()/(double)(RAND_MAX))*boxWidth - boxWidth/2 + boxCenter[0]; diff --git a/Addons/FmmApi/Src/ScalfmmApiCore.cpp b/Addons/FmmApi/Src/ScalfmmApiCore.cpp index 5257684f5..bd0a87cc7 100644 --- a/Addons/FmmApi/Src/ScalfmmApiCore.cpp +++ b/Addons/FmmApi/Src/ScalfmmApiCore.cpp @@ -539,7 +539,7 @@ int FmmCore_setPositions(void *fmmCore, int *nb, FReal *position) { omp_set_num_threads(corehandle->config.nbThreads); } - for(int idxPart = 0 ; idxPart < (*nb) ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < (*nb) ; ++idxPart){ const FReal* pos = &position[idxPart * 3]; corehandle->octree->insert(FPoint<FReal>(pos[0], pos[1], pos[2]),idxPart); } diff --git a/Addons/FmmApi/Src/ScalfmmApiRotation.cpp b/Addons/FmmApi/Src/ScalfmmApiRotation.cpp index b5297f5bb..b6a55a85a 100644 --- a/Addons/FmmApi/Src/ScalfmmApiRotation.cpp +++ b/Addons/FmmApi/Src/ScalfmmApiRotation.cpp @@ -216,7 +216,7 @@ int FmmKernel_P2M(void *fmmCore, void* boxId){ FmmCore_getSource(fmmCore, boxId, &positions, (void**)&physicalValues, &number); FP2PParticleContainer<FReal> sources; - for(int idxPart = 0 ; idxPart < number ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < number ; ++idxPart){ sources.push(FPoint<FReal>(positions[idxPart*3],positions[idxPart*3+1],positions[idxPart*3+2]),physicalValues[idxPart]); } @@ -251,7 +251,7 @@ int FmmKernel_L2P(void *fmmCore, void* boxId){ FmmCore_getTargetField(fmmCore, boxId, fields); FP2PParticleContainer<FReal> targets; - for(int idxPart = 0 ; idxPart < number ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < number ; ++idxPart){ targets.push(FPoint<FReal>(&positions[idxPart*3]),physicalValues[idxPart], fields[idxPart*kernelhandle->fieldDataSize], fields[idxPart*kernelhandle->fieldDataSize+1], @@ -266,7 +266,7 @@ int FmmKernel_L2P(void *fmmCore, void* boxId){ const FReal*const forcesY = targets.getForcesY(); const FReal*const forcesZ = targets.getForcesZ(); - for(int idxPart = 0 ; idxPart < number ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < number ; ++idxPart){ fields[idxPart*kernelhandle->fieldDataSize] += potentials[idxPart]; fields[idxPart*kernelhandle->fieldDataSize+1] += forcesX[idxPart]; fields[idxPart*kernelhandle->fieldDataSize+2] += forcesY[idxPart]; @@ -409,7 +409,7 @@ int FmmKernel_P2P_inner(void *fmmCore, void *boxIdSrcDest){ FTreeCoordinate treecoord(coordTargets[0], coordTargets[1], coordTargets[2]); FP2PParticleContainer<FReal> targets; - for(int idxPart = 0 ; idxPart < numberTargets ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < numberTargets ; ++idxPart){ targets.push(FPoint<FReal>(positionsTargets[idxPart*3],positionsTargets[idxPart*3+1],positionsTargets[idxPart*3+2]), potentialsTargets[idxPart], fieldsTargets[idxPart*kernelhandle->fieldDataSize], @@ -428,7 +428,7 @@ int FmmKernel_P2P_inner(void *fmmCore, void *boxIdSrcDest){ const FReal*const forcesY = targets.getForcesY(); const FReal*const forcesZ = targets.getForcesZ(); - for(int idxPart = 0 ; idxPart < numberTargets ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < numberTargets ; ++idxPart){ fieldsTargets[idxPart*kernelhandle->fieldDataSize] = potentials[idxPart]; fieldsTargets[idxPart*kernelhandle->fieldDataSize+1] = forcesX[idxPart]; fieldsTargets[idxPart*kernelhandle->fieldDataSize+2] = forcesY[idxPart]; @@ -461,7 +461,7 @@ int FmmKernel_P2P(void *fmmCore, void *boxIdSrc, void *boxIdDest){ //return FMMA FTreeCoordinate treecoord(coordTargets[0], coordTargets[1], coordTargets[2]); FP2PParticleContainer<FReal> targets; - for(int idxPart = 0 ; idxPart < numberTargets ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < numberTargets ; ++idxPart){ targets.push(FPoint<FReal>(positionsTargets[idxPart*3],positionsTargets[idxPart*3+1],positionsTargets[idxPart*3+2]), potentialsTargets[idxPart], fieldsTargets[idxPart*kernelhandle->fieldDataSize], @@ -476,7 +476,7 @@ int FmmKernel_P2P(void *fmmCore, void *boxIdSrc, void *boxIdDest){ //return FMMA FmmCore_getSource(fmmCore, boxIdSrc, &positionsSrc, (void**)&potentialsSrc, &numberSources); FP2PParticleContainer<FReal> sources; - for(int idxPart = 0 ; idxPart < numberSources ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < numberSources ; ++idxPart){ sources.push(FPoint<FReal>(positionsSrc[idxPart*3],positionsSrc[idxPart*3+1],positionsSrc[idxPart*3+2]),potentialsSrc[idxPart]); } @@ -490,7 +490,7 @@ int FmmKernel_P2P(void *fmmCore, void *boxIdSrc, void *boxIdDest){ //return FMMA const FReal*const forcesY = targets.getForcesY(); const FReal*const forcesZ = targets.getForcesZ(); - for(int idxPart = 0 ; idxPart < numberTargets ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < numberTargets ; ++idxPart){ fieldsTargets[idxPart*kernelhandle->fieldDataSize] = potentials[idxPart]; fieldsTargets[idxPart*kernelhandle->fieldDataSize+1] = forcesX[idxPart]; fieldsTargets[idxPart*kernelhandle->fieldDataSize+2] = forcesY[idxPart]; diff --git a/Addons/FmmApi/Tests/testFmmApi.cpp b/Addons/FmmApi/Tests/testFmmApi.cpp index 18b65a457..ae699f5d3 100644 --- a/Addons/FmmApi/Tests/testFmmApi.cpp +++ b/Addons/FmmApi/Tests/testFmmApi.cpp @@ -59,7 +59,7 @@ int main(int argc, char ** argv){ std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; counter.tic(); - int nbPart = (int)loader.getNumberOfParticles(); + FSize r.getNumberOfParticles(); FReal* potentials = new FReal[nbPart]; FReal* positions = new FReal[nbPart*3]; diff --git a/Examples/ChebyshevInterpolationFMM.cpp b/Examples/ChebyshevInterpolationFMM.cpp index 157fd0bd0..eeac5c1fd 100644 --- a/Examples/ChebyshevInterpolationFMM.cpp +++ b/Examples/ChebyshevInterpolationFMM.cpp @@ -129,7 +129,7 @@ int main(int argc, char* argv[]) FPoint<FReal> position; FReal physicalValue = 0.0; // - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // // Read particle per particle from file loader.fillParticle(&position,&physicalValue); @@ -172,7 +172,7 @@ int main(int argc, char* argv[]) // // { // ----------------------------------------------------- - long int N1=0, N2= loader.getNumberOfParticles()/2, N3= loader.getNumberOfParticles() -1; ; + FSize N1=0, N2= loader.getNumberOfParticles()/2, N3= loader.getNumberOfParticles() -1; ; FReal energy =0.0 ; // // Loop over all leaves @@ -190,13 +190,13 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); const FReal*const physicalValues = leaf->getTargets()->getPhysicalValues(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; if ((indexPartOrig == N1) || (indexPartOrig == N2) || (indexPartOrig == N3) ) { std::cout << "Index "<< indexPartOrig <<" potential " << potentials[idxPart] << " Pos "<<posX[idxPart]<<" "<<posY[idxPart]<<" "<<posZ[idxPart] diff --git a/Examples/ChebyshevInterpolationMPIFMM.cpp b/Examples/ChebyshevInterpolationMPIFMM.cpp index b15517244..a60d68fcd 100644 --- a/Examples/ChebyshevInterpolationMPIFMM.cpp +++ b/Examples/ChebyshevInterpolationMPIFMM.cpp @@ -133,7 +133,7 @@ int main(int argc, char* argv[]) }; TestParticle* particles = new TestParticle[loader.getMyNumberOfParticles()]; - memset(particles, 0, (unsigned int) (sizeof(TestParticle) * loader.getMyNumberOfParticles())); + memset(particles, 0, (sizeof(TestParticle) * loader.getMyNumberOfParticles())); //idx (in file) of the first part that will be used by this proc. FSize idxStart = loader.getStart(); @@ -158,10 +158,10 @@ int main(int argc, char* argv[]) tree.getBoxWidth(),tree.getHeight(), &finalParticles, &balancer); - for(int idx = 0 ; idx < finalParticles.getSize(); ++idx){ + for(FSize idx = 0 ; idx < finalParticles.getSize(); ++idx){ tree.insert(finalParticles[idx].position,finalParticles[idx].index,finalParticles[idx].physicalValue); } - printf("%d parts have been inserted in Tree \n",finalParticles.getSize()); + printf("%lld parts have been inserted in Tree \n",finalParticles.getSize()); delete[] particles; time.tac(); @@ -206,7 +206,7 @@ int main(int argc, char* argv[]) // // { // ----------------------------------------------------- - long int N1=0, N2= loader.getNumberOfParticles()/2, N3= (loader.getNumberOfParticles()-1); ; + FSize N1=0, N2= loader.getNumberOfParticles()/2, N3= (loader.getNumberOfParticles()-1); ; FReal energy =0.0 ; // // Loop over all leaves @@ -224,13 +224,13 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); const FReal*const physicalValues = leaf->getTargets()->getPhysicalValues(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; if ((indexPartOrig == N1) || (indexPartOrig == N2) || (indexPartOrig == N3) ) { std::cout << "Proc "<< app.global().processId() << " Index "<< indexPartOrig <<" potential " << potentials[idxPart] << " Pos "<<posX[idxPart]<<" "<<posY[idxPart]<<" "<<posZ[idxPart] diff --git a/Examples/DirectComputation.cpp b/Examples/DirectComputation.cpp index 6bca9422c..76790c674 100644 --- a/Examples/DirectComputation.cpp +++ b/Examples/DirectComputation.cpp @@ -76,7 +76,7 @@ int main(int argc, char ** argv){ // FFmaGenericLoader<FReal> loader(filenameIn); // - int nbParticles = static_cast<int>(loader.getNumberOfParticles()); + FSize nbParticles = static_cast<int>(loader.getNumberOfParticles()); std::cout << "Read " << nbParticles << " particles ..." << std::endl; double BoxWith=loader.getBoxWidth(); FPoint<FReal> Centre(loader.getCenterOfBox().getX(), loader.getCenterOfBox().getY() , loader.getCenterOfBox().getZ()); diff --git a/Examples/LagrangeInterpolationFMM.cpp b/Examples/LagrangeInterpolationFMM.cpp index 9282ca7f7..17192e74e 100755 --- a/Examples/LagrangeInterpolationFMM.cpp +++ b/Examples/LagrangeInterpolationFMM.cpp @@ -135,7 +135,7 @@ int main(int argc, char* argv[]) FPoint<FReal> position; FReal physicalValue = 0.0; // - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // // Read particle per particle from file loader.fillParticle(&position,&physicalValue); @@ -178,7 +178,7 @@ int main(int argc, char* argv[]) // // { // ----------------------------------------------------- - long int N1=0, N2= loader.getNumberOfParticles()/2, N3= loader.getNumberOfParticles() -1; ; + FSize N1=0, N2= loader.getNumberOfParticles()/2, N3= loader.getNumberOfParticles() -1; ; FReal energy =0.0 ; // // Loop over all leaves @@ -196,13 +196,13 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); const FReal*const physicalValues = leaf->getTargets()->getPhysicalValues(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; if ((indexPartOrig == N1) || (indexPartOrig == N2) || (indexPartOrig == N3) ) { std::cout << "Index "<< indexPartOrig <<" potential " << potentials[idxPart] << " Pos "<<posX[idxPart]<<" "<<posY[idxPart]<<" "<<posZ[idxPart] @@ -220,11 +220,11 @@ int main(int argc, char* argv[]) std::string name(FParameters::getStr(argc,argv,FParameterDefinitions::OutputFile.options, "output.fma")); FFmaGenericWriter<FReal> writer(name) ; // - int NbPoints = loader.getNumberOfParticles(); + FSize NbPoints = loader.getNumberOfParticles(); FReal * particles ; particles = new FReal[8*NbPoints] ; memset(particles,0,8*NbPoints*sizeof(FReal)); - int j = 0 ; + FSize j = 0 ; tree.forEachLeaf([&](LeafClass* leaf){ // // Input @@ -232,7 +232,7 @@ int main(int argc, char* argv[]) const FReal*const posY = leaf->getTargets()->getPositions()[1]; const FReal*const posZ = leaf->getTargets()->getPositions()[2]; const FReal*const physicalValues = leaf->getTargets()->getPhysicalValues(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); // // Computed data const FReal*const potentials = leaf->getTargets()->getPotentials(); @@ -240,8 +240,8 @@ int main(int argc, char* argv[]) const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); // - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ j = 8*indexes[idxPart]; particles[j] = posX[idxPart] ; particles[j+1] = posY[idxPart] ; diff --git a/Examples/RotationFMM.cpp b/Examples/RotationFMM.cpp index 6aa2308cd..7051c766a 100644 --- a/Examples/RotationFMM.cpp +++ b/Examples/RotationFMM.cpp @@ -134,7 +134,7 @@ int main(int argc, char* argv[]) FPoint<FReal> position; FReal physicalValue = 0.0; // - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // Read particles from file loader.fillParticle(&position,&physicalValue); @@ -169,7 +169,7 @@ int main(int argc, char* argv[]) // // { // ----------------------------------------------------- - long int N1=0, N2= loader.getNumberOfParticles()/2, N3= loader.getNumberOfParticles() -1; ; + FSize N1=0, N2= loader.getNumberOfParticles()/2, N3= loader.getNumberOfParticles() -1; ; FReal energy =0.0 ; // // Loop over all leaves @@ -183,13 +183,13 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); const FReal*const physicalValues = leaf->getTargets()->getPhysicalValues(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; if ((indexPartOrig == N1) || (indexPartOrig == N2) || (indexPartOrig == N3) ) { std::cout << "Index "<< indexPartOrig <<" potential " << potentials[idxPart] << " Forces: " << forcesX[idxPart] << " " << forcesY[idxPart] << " "<< forcesZ[idxPart] <<std::endl; diff --git a/Examples/RotationMPIFMM.cpp b/Examples/RotationMPIFMM.cpp index d267461b1..50084eb86 100644 --- a/Examples/RotationMPIFMM.cpp +++ b/Examples/RotationMPIFMM.cpp @@ -136,7 +136,7 @@ int main(int argc, char* argv[]) // struct TestParticle{ - int indexInFile; + FSize indexInFile; FPoint<FReal> position; FReal physicalValue; const FPoint<FReal>& getPosition(){ @@ -144,12 +144,12 @@ int main(int argc, char* argv[]) } }; TestParticle* particles = new TestParticle[loader->getMyNumberOfParticles()]; - memset(particles, 0, (unsigned int) (sizeof(TestParticle) * loader->getMyNumberOfParticles())); + memset(particles, 0, (sizeof(TestParticle) * loader->getMyNumberOfParticles())); //idx (in file) of the first part that will be used by this proc. - int idxStart = loader->getStart(); + FSize idxStart = loader->getStart(); - for(int idxPart = 0 ; idxPart < loader->getMyNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader->getMyNumberOfParticles() ; ++idxPart){ //Storage of the index (in the original file) of each part. particles[idxPart].indexInFile = idxPart + idxStart; @@ -164,7 +164,7 @@ int main(int argc, char* argv[]) tree.getBoxWidth(), tree.getHeight(), &finalParticles,&balancer); - for(int idx = 0 ; idx < finalParticles.getSize(); ++idx){ + for(FSize idx = 0 ; idx < finalParticles.getSize(); ++idx){ tree.insert(finalParticles[idx].position,finalParticles[idx].indexInFile,finalParticles[idx].physicalValue); } @@ -198,7 +198,7 @@ int main(int argc, char* argv[]) // { // ----------------------------------------------------- - long int N1=0, N2= loader->getNumberOfParticles()/2, N3= (loader->getNumberOfParticles()-1); ; + FSize N1=0, N2= loader->getNumberOfParticles()/2, N3= (loader->getNumberOfParticles()-1); ; FReal energy =0.0 ; // // Loop over all leaves @@ -215,13 +215,13 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); const FReal*const physicalValues = leaf->getTargets()->getPhysicalValues(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; if ((indexPartOrig == N1) || (indexPartOrig == N2) || (indexPartOrig == N3) ) { std::cout << "Proc "<< app.global().processId() << " Index "<< indexPartOrig << " potential " << potentials[idxPart] << " Pos "<<posX[idxPart]<<" "<<posY[idxPart]<<" "<<posZ[idxPart] diff --git a/Examples/changeFmaFormat.cpp b/Examples/changeFmaFormat.cpp index 4142a3b29..186718e91 100644 --- a/Examples/changeFmaFormat.cpp +++ b/Examples/changeFmaFormat.cpp @@ -60,14 +60,14 @@ int main(int argc, char ** argv){ FFmaGenericLoader<FReal> loader(filename); const FSize NbPoints = loader.getNumberOfParticles(); - const unsigned int nbData = loader.getNbRecordPerline() ; - const unsigned int arraySize =nbData*NbPoints; + const FSize nbData = loader.getNbRecordPerline() ; + const FSize arraySize =nbData*NbPoints; FReal * particles = new FReal[arraySize] ; std::memset(particles,0,arraySize*sizeof(FReal)); - int j = 0 ; - for(int idxPart = 0 ; idxPart < NbPoints ;++idxPart, j+=nbData){ + FSize j = 0 ; + for(FSize idxPart = 0 ; idxPart < NbPoints ;++idxPart, j+=nbData){ loader.fillParticle(&particles[j],nbData); } diff --git a/Examples/compareAllPoissonKernels.cpp b/Examples/compareAllPoissonKernels.cpp index b12951223..1da503f22 100644 --- a/Examples/compareAllPoissonKernels.cpp +++ b/Examples/compareAllPoissonKernels.cpp @@ -145,7 +145,7 @@ int main(int argc, char* argv[]) FReal energyD =0.0, totPhysicalValue =0.0; #pragma omp parallel for reduction(+:energyD,totPhysicalValue) - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; totPhysicalValue += particles[idx].getPhysicalValue() ; } @@ -179,7 +179,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -206,11 +206,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -254,7 +254,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -282,11 +282,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -325,7 +325,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -354,11 +354,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -396,7 +396,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -425,11 +425,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -481,7 +481,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart <nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart <nbParticles ; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -510,11 +510,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -554,7 +554,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -586,11 +586,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -626,7 +626,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -657,11 +657,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -702,7 +702,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart <nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart <nbParticles ; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -731,11 +731,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/Examples/statisticsOnOctree.cpp b/Examples/statisticsOnOctree.cpp index eb570ebc3..b82d7f5bc 100644 --- a/Examples/statisticsOnOctree.cpp +++ b/Examples/statisticsOnOctree.cpp @@ -111,7 +111,7 @@ int main(int argc, char ** argv) maxPos(0., 0., 0.); // Insertion of particles in the tree. - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // read next particle in file loader.fillParticle(&particlePosition,&physicalValue); // insert particle into tree @@ -136,8 +136,8 @@ int main(int argc, char ** argv) long int allLeaves = (1 << (3 * (TreeHeight-1) )); // maximum number of leaves FReal averageParticles = 0.0, varianceParticles = 0.0; - int nbLeafs = 0, nbPart = 0, nbTPart = 0; // number of particles, total number of particles - int minParticles = std::numeric_limits<int>::max(), + FSize nbLeafs = 0, nbPart = 0, nbTPart = 0; // number of particles, total number of particles + FSize minParticles = std::numeric_limits<FSize>::max(), maxParticles = 0; // Compute statistics on particles @@ -154,7 +154,7 @@ int main(int argc, char ** argv) ++ nbLeafs; } while(octreeIterator.moveRight()); // advancing through the level - averageParticles = nbTPart/FReal(nbLeafs); + averageParticles = FReal(nbTPart)/FReal(nbLeafs); varianceParticles = varianceParticles/FReal(nbLeafs) - averageParticles*averageParticles; @@ -175,7 +175,7 @@ int main(int argc, char ** argv) // Histogram of particles per leaf if( FParameters::existParameter(argc, argv, LocalOptionHist.options) ) { - std::vector<int> hist(maxParticles + 1, 0); + std::vector<FSize> hist(maxParticles + 1, 0); octreeIterator.gotoBottomLeft(); do { @@ -190,14 +190,14 @@ int main(int argc, char ** argv) exit(EXIT_FAILURE); } outfile << "# Particle per leaf histogram. " << hist.size() << " chunk" << std::endl; - for(unsigned int i = 0 ; i < hist.size() ; ++i){ + for(size_t i = 0 ; i < hist.size() ; ++i){ outfile << i << " " << hist[i] << std::endl; } } // Statistics on particles done FReal averageNeighbors = 0.0, varianceNeighbors = 0.0 ; - int nbBox, minBox = 100000, maxBox=0; + FSize nbBox, minBox = 100000, maxBox=0; ContainerClass* neighborsP2P[27]; octreeIterator.gotoBottomLeft(); @@ -213,7 +213,7 @@ int main(int argc, char ** argv) } while(octreeIterator.moveRight()); averageNeighbors /= FReal(nbLeafs) ; - varianceNeighbors = varianceNeighbors/nbLeafs-averageNeighbors*averageNeighbors; + varianceNeighbors = varianceNeighbors/FReal(nbLeafs)-averageNeighbors*averageNeighbors; std::cout << lhead diff --git a/Src/Adaptive/FAdaptChebSymKernel.hpp b/Src/Adaptive/FAdaptChebSymKernel.hpp index 735909803..14b3989d1 100644 --- a/Src/Adaptive/FAdaptChebSymKernel.hpp +++ b/Src/Adaptive/FAdaptChebSymKernel.hpp @@ -56,286 +56,284 @@ class FTreeCoordinate; template<class FReal, class CellClass, class ContainerClass, class MatrixKernelClass, int ORDER, int NVALS = 1> class FAdaptiveChebSymKernel : FChebSymKernel<FReal,CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS> -, public FAbstractAdaptiveKernel<CellClass, ContainerClass> { - // - typedef FChebSymKernel<FReal,CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS> KernelBaseClass; - enum {order = ORDER, - nnodes = TensorTraits<ORDER>::nnodes}; + , public FAbstractAdaptiveKernel<CellClass, ContainerClass> { + // + typedef FChebSymKernel<FReal,CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS> KernelBaseClass; + enum {order = ORDER, + nnodes = TensorTraits<ORDER>::nnodes}; - const MatrixKernelClass *const MatrixKernel; - int sminM, sminL; + const MatrixKernelClass *const MatrixKernel; + int sminM, sminL; public: - using KernelBaseClass::P2M; - using KernelBaseClass::M2M; - using KernelBaseClass::M2L; - using KernelBaseClass::finishedLevelM2L; - using KernelBaseClass::L2L; - using KernelBaseClass::L2P; - using KernelBaseClass::P2P; - using KernelBaseClass::P2PRemote; - // /** - // * The constructor initializes all constant attributes and it reads the - // * precomputed and compressed M2L operators from a binary file (an - // * runtime_error is thrown if the required file is not valid). - // */ - FAdaptiveChebSymKernel(const int inTreeHeight, const FReal inBoxWidth, - const FPoint<FReal>& inBoxCenter, const MatrixKernelClass *const inMatrixKernel, const int &minM, const int &minL) : KernelBaseClass(inTreeHeight, inBoxWidth, inBoxCenter, inMatrixKernel), MatrixKernel(inMatrixKernel),sminM(minM),sminL(minM) - {} - // /** Copy constructor */ - FAdaptiveChebSymKernel(const FAdaptiveChebSymKernel& other) - : KernelBaseClass(other), MatrixKernel(other.MatrixKernel),sminM(other.sminM),sminL(other.sminL) - { } - - // - // /** Destructor */ - ~FAdaptiveChebSymKernel() - { - //this->~KernelBaseClass() ; - } - void P2M(CellClass* const pole, const int cellLevel, const ContainerClass* const particles) override { + using KernelBaseClass::P2M; + using KernelBaseClass::M2M; + using KernelBaseClass::M2L; + using KernelBaseClass::finishedLevelM2L; + using KernelBaseClass::L2L; + using KernelBaseClass::L2P; + using KernelBaseClass::P2P; + using KernelBaseClass::P2PRemote; + // /** + // * The constructor initializes all constant attributes and it reads the + // * precomputed and compressed M2L operators from a binary file (an + // * runtime_error is thrown if the required file is not valid). + // */ + FAdaptiveChebSymKernel(const int inTreeHeight, const FReal inBoxWidth, + const FPoint<FReal>& inBoxCenter, const MatrixKernelClass *const inMatrixKernel, const int &minM, const int &minL) : KernelBaseClass(inTreeHeight, inBoxWidth, inBoxCenter, inMatrixKernel), MatrixKernel(inMatrixKernel),sminM(minM),sminL(minM) + {} + // /** Copy constructor */ + FAdaptiveChebSymKernel(const FAdaptiveChebSymKernel& other) + : KernelBaseClass(other), MatrixKernel(other.MatrixKernel),sminM(other.sminM),sminL(other.sminL) + { } + + // + // /** Destructor */ + ~FAdaptiveChebSymKernel() + { + //this->~KernelBaseClass() ; + } + void P2M(CellClass* const pole, const int cellLevel, const ContainerClass* const particles) override { const FPoint<FReal> CellCenter(KernelBaseClass::getCellCenter(pole->getCoordinate(),cellLevel)); - const FReal BoxWidth = KernelBaseClass::BoxWidth / FMath::pow(2.0,cellLevel); + const FReal BoxWidthAtLevel = KernelBaseClass::BoxWidth / FMath::pow(FReal(2.0),cellLevel); + + for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ + // 1) apply Sy + KernelBaseClass::Interpolator->applyP2M(CellCenter, BoxWidthAtLevel, + pole->getMultipole(idxRhs), particles); + } + + } - for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ - // 1) apply Sy - KernelBaseClass::Interpolator->applyP2M(CellCenter, BoxWidth, - pole->getMultipole(idxRhs), particles); - } + void M2M(CellClass* const pole, const int poleLevel, const CellClass* const subCell, const int subCellLevel) override { - } + const FPoint<FReal> subCellCenter(KernelBaseClass::getCellCenter(subCell->getCoordinate(),subCellLevel)); + const FReal subCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0,subCellLevel))); - void M2M(CellClass* const pole, const int poleLevel, const CellClass* const subCell, const int subCellLevel) override { + const FPoint<FReal> poleCellCenter(KernelBaseClass::getCellCenter(pole->getCoordinate(),poleLevel)); + const FReal poleCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, poleLevel))); - const FPoint<FReal> subCellCenter(KernelBaseClass::getCellCenter(subCell->getCoordinate(),subCellLevel)); - const FReal subCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0,subCellLevel))); + //////////////////////////////////////////////////////////////////////////// + /// p^6 version + // allocate memory + FReal* subChildParentInterpolator = new FReal [nnodes * nnodes]; - const FPoint<FReal> poleCellCenter(KernelBaseClass::getCellCenter(pole->getCoordinate(),poleLevel)); - const FReal poleCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, poleLevel))); + // set child info + FPoint<FReal> ChildRoots[nnodes], localChildRoots[nnodes]; + FChebTensor<FReal,ORDER>::setRoots(subCellCenter, subCellWidth, ChildRoots); - //////////////////////////////////////////////////////////////////////////// - /// p^6 version - // allocate memory - FReal* subChildParentInterpolator = new FReal [nnodes * nnodes]; + // map global position of roots to local position in parent cell + const map_glob_loc<FReal> map(poleCellCenter, poleCellWidth); + for (unsigned int n=0; n<nnodes; ++n) + map(ChildRoots[n], localChildRoots[n]); - // set child info - FPoint<FReal> ChildRoots[nnodes], localChildRoots[nnodes]; - FChebTensor<FReal,ORDER>::setRoots(subCellCenter, subCellWidth, ChildRoots); + // assemble child - parent - interpolator + KernelBaseClass::Interpolator->assembleInterpolator(nnodes, localChildRoots, subChildParentInterpolator); - // map global position of roots to local position in parent cell - const map_glob_loc<FReal> map(poleCellCenter, poleCellWidth); - for (unsigned int n=0; n<nnodes; ++n) - map(ChildRoots[n], localChildRoots[n]); + for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ - // assemble child - parent - interpolator - KernelBaseClass::Interpolator->assembleInterpolator(nnodes, localChildRoots, subChildParentInterpolator); + // 1) apply Sy (using tensor product M2M with an interpolator computed on the fly) - for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ + // Do NOT reset multipole expansion ! + //FBlas::scal(nnodes, FReal(0.), pole->getMultipole(idxRhs)); - // 1) apply Sy (using tensor product M2M with an interpolator computed on the fly) + /// p^6 version + FBlas::gemtva(nnodes, nnodes, FReal(1.), + subChildParentInterpolator, + const_cast<FReal*>(subCell->getMultipole(idxRhs)), pole->getMultipole(idxRhs)); - // Do NOT reset multipole expansion ! - //FBlas::scal(nnodes, FReal(0.), pole->getMultipole(idxRhs)); - /// p^6 version - FBlas::gemtva(nnodes, nnodes, FReal(1.), - subChildParentInterpolator, - const_cast<FReal*>(subCell->getMultipole(idxRhs)), pole->getMultipole(idxRhs)); + }// NVALS + } - }// NVALS + void P2L(CellClass* const local, const int localLevel, const ContainerClass* const particles) override { - } + // Target cell: local + const FReal localCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, localLevel))); + const FPoint<FReal> localCellCenter(KernelBaseClass::getCellCenter(local->getCoordinate(),localLevel)); - void P2L(CellClass* const local, const int localLevel, const ContainerClass* const particles) override { + // interpolation points of target (X) cell + FPoint<FReal> X[nnodes]; + FChebTensor<FReal,order>::setRoots(localCellCenter, localCellWidth, X); - // Target cell: local - const FReal localCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, localLevel))); - const FPoint<FReal> localCellCenter(KernelBaseClass::getCellCenter(local->getCoordinate(),localLevel)); + // read positions + const FReal*const positionsX = particles->getPositions()[0]; + const FReal*const positionsY = particles->getPositions()[1]; + const FReal*const positionsZ = particles->getPositions()[2]; - // interpolation points of target (X) cell - FPoint<FReal> X[nnodes]; - FChebTensor<FReal,order>::setRoots(localCellCenter, localCellWidth, X); + for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ - // read positions - const FReal*const positionsX = particles->getPositions()[0]; - const FReal*const positionsY = particles->getPositions()[1]; - const FReal*const positionsZ = particles->getPositions()[2]; + // read physicalValue + const FReal*const physicalValues = particles->getPhysicalValues(); - for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ + // apply P2L + for ( FSize idxPart=0; idxPart<particles->getNbParticles(); ++idxPart){ - // read physicalValue - const FReal*const physicalValues = particles->getPhysicalValues(); + const FPoint<FReal> y = FPoint<FReal>(positionsX[idxPart], + positionsY[idxPart], + positionsZ[idxPart]); - // apply P2L - for ( int idxPart=0; idxPart<particles->getNbParticles(); ++idxPart){ + for (unsigned int m=0; m<nnodes; ++m) + local->getLocal(idxRhs)[m]+=MatrixKernel->evaluate(X[m], y) * physicalValues[idxPart]; - const FPoint<FReal> y = FPoint<FReal>(positionsX[idxPart], - positionsY[idxPart], - positionsZ[idxPart]); + } - for (unsigned int m=0; m<nnodes; ++m) - local->getLocal(idxRhs)[m]+=MatrixKernel->evaluate(X[m], y) * physicalValues[idxPart]; + }// NVALS - } + } - }// NVALS + void M2L(CellClass* const local, const int localLevel, const CellClass* const pole, const int poleLevel) override { - } + // Source cell: pole + const FReal poleCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, poleLevel))); + const FPoint<FReal> poleCellCenter(KernelBaseClass::getCellCenter(pole->getCoordinate(),poleLevel)); - void M2L(CellClass* const local, const int localLevel, const CellClass* const pole, const int poleLevel) override { + // Target cell: local + const FReal localCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, localLevel))); + const FPoint<FReal> localCellCenter(KernelBaseClass::getCellCenter(local->getCoordinate(),localLevel)); - // Source cell: pole - const FReal poleCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, poleLevel))); - const FPoint<FReal> poleCellCenter(KernelBaseClass::getCellCenter(pole->getCoordinate(),poleLevel)); + // interpolation points of source (Y) and target (X) cell + FPoint<FReal> X[nnodes], Y[nnodes]; + FChebTensor<FReal,order>::setRoots(poleCellCenter, poleCellWidth, Y); + FChebTensor<FReal,order>::setRoots(localCellCenter, localCellWidth, X); - // Target cell: local - const FReal localCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, localLevel))); - const FPoint<FReal> localCellCenter(KernelBaseClass::getCellCenter(local->getCoordinate(),localLevel)); - // interpolation points of source (Y) and target (X) cell - FPoint<FReal> X[nnodes], Y[nnodes]; - FChebTensor<FReal,order>::setRoots(poleCellCenter, poleCellWidth, Y); - FChebTensor<FReal,order>::setRoots(localCellCenter, localCellWidth, X); + for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ + // Dense M2L + const FReal *const MultipoleExpansion = pole->getMultipole(idxRhs); - for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ + for (unsigned int m=0; m<nnodes; ++m) + for (unsigned int n=0; n<nnodes; ++n){ + local->getLocal(idxRhs)[m]+=MatrixKernel->evaluate(X[m], Y[n]) * MultipoleExpansion[n]; - // Dense M2L - const FReal *const MultipoleExpansion = pole->getMultipole(idxRhs); - - for (unsigned int m=0; m<nnodes; ++m) - for (unsigned int n=0; n<nnodes; ++n){ - local->getLocal(idxRhs)[m]+=MatrixKernel->evaluate(X[m], Y[n]) * MultipoleExpansion[n]; - + } } } - } - void M2P(const CellClass* const pole, const int poleLevel, ContainerClass* const particles) override { + void M2P(const CellClass* const pole, const int poleLevel, ContainerClass* const particles) override { - // Source cell: pole - const FReal poleCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, poleLevel))); - const FPoint<FReal> poleCellCenter(KernelBaseClass::getCellCenter(pole->getCoordinate(),poleLevel)); + // Source cell: pole + const FReal poleCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, poleLevel))); + const FPoint<FReal> poleCellCenter(KernelBaseClass::getCellCenter(pole->getCoordinate(),poleLevel)); - // interpolation points of source (Y) cell - FPoint<FReal> Y[nnodes]; - FChebTensor<FReal,order>::setRoots(poleCellCenter, poleCellWidth, Y); + // interpolation points of source (Y) cell + FPoint<FReal> Y[nnodes]; + FChebTensor<FReal,order>::setRoots(poleCellCenter, poleCellWidth, Y); - // read positions - const FReal*const positionsX = particles->getPositions()[0]; - const FReal*const positionsY = particles->getPositions()[1]; - const FReal*const positionsZ = particles->getPositions()[2]; + // read positions + const FReal*const positionsX = particles->getPositions()[0]; + const FReal*const positionsY = particles->getPositions()[1]; + const FReal*const positionsZ = particles->getPositions()[2]; - // get potential - FReal*const physVal = particles->getPhysicalValues(/*idxPot*/); - FReal*const potentials = particles->getPotentials(/*idxPot*/); - FReal*const fx = particles->getForcesX(/*idxPot*/); - FReal*const fy = particles->getForcesY(/*idxPot*/); - FReal*const fz = particles->getForcesZ(/*idxPot*/); + // get potential + FReal*const physVal = particles->getPhysicalValues(/*idxPot*/); + FReal*const potentials = particles->getPotentials(/*idxPot*/); + FReal*const fx = particles->getForcesX(/*idxPot*/); + FReal*const fy = particles->getForcesY(/*idxPot*/); + FReal*const fz = particles->getForcesZ(/*idxPot*/); - for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ + for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ - const FReal *const MultipoleExpansion = pole->getMultipole(idxRhs); - - // apply M2P - for (int idxPart=0; idxPart<particles->getNbParticles(); ++idxPart){ + const FReal *const MultipoleExpansion = pole->getMultipole(idxRhs); - const FPoint<FReal> x = FPoint<FReal>(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]); + // apply M2P + for (FSize idxPart=0; idxPart<particles->getNbParticles(); ++idxPart){ - for (int n=0; n<nnodes; ++n){ + const FPoint<FReal> x = FPoint<FReal>(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]); - FReal Kxy[1]; - FReal dKxy[3]; - MatrixKernel->evaluateBlockAndDerivative(x,Y[n],Kxy,dKxy); + for (int n=0; n<nnodes; ++n){ - potentials[idxPart] += Kxy[0] * MultipoleExpansion[/*idxLhs*nnodes+*/n]; - fx[idxPart] += -dKxy[0] * physVal[idxPart] * MultipoleExpansion[/*idxLhs*nnodes+*/n]; - fy[idxPart] += -dKxy[1] * physVal[idxPart] * MultipoleExpansion[/*idxLhs*nnodes+*/n]; - fz[idxPart] += -dKxy[2] * physVal[idxPart] * MultipoleExpansion[/*idxLhs*nnodes+*/n]; - - } + FReal Kxy[1]; + FReal dKxy[3]; + MatrixKernel->evaluateBlockAndDerivative(x,Y[n],Kxy,dKxy); + + potentials[idxPart] += Kxy[0] * MultipoleExpansion[/*idxLhs*nnodes+*/n]; + fx[idxPart] += -dKxy[0] * physVal[idxPart] * MultipoleExpansion[/*idxLhs*nnodes+*/n]; + fy[idxPart] += -dKxy[1] * physVal[idxPart] * MultipoleExpansion[/*idxLhs*nnodes+*/n]; + fz[idxPart] += -dKxy[2] * physVal[idxPart] * MultipoleExpansion[/*idxLhs*nnodes+*/n]; + + } - }// Particles + }// Particles - }// NVALS + }// NVALS - } + } - void L2L(const CellClass* const local, const int localLevel, CellClass* const subCell, const int subCellLevel) override { + void L2L(const CellClass* const local, const int localLevel, CellClass* const subCell, const int subCellLevel) override { - const FPoint<FReal> subCellCenter(KernelBaseClass::getCellCenter(subCell->getCoordinate(),subCellLevel)); - const FReal subCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0,subCellLevel))); + const FPoint<FReal> subCellCenter(KernelBaseClass::getCellCenter(subCell->getCoordinate(),subCellLevel)); + const FReal subCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0,subCellLevel))); - const FPoint<FReal> localCenter(KernelBaseClass::getCellCenter(local->getCoordinate(),localLevel)); - const FReal localWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0,localLevel))); + const FPoint<FReal> localCenter(KernelBaseClass::getCellCenter(local->getCoordinate(),localLevel)); + const FReal localWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0,localLevel))); - //////////////////////////////////////////////////////////////////////////// - /// p^6 version - // allocate memory - FReal* subChildParentInterpolator = new FReal [nnodes * nnodes]; + //////////////////////////////////////////////////////////////////////////// + /// p^6 version + // allocate memory + FReal* subChildParentInterpolator = new FReal [nnodes * nnodes]; - // set child info - FPoint<FReal> ChildRoots[nnodes], localChildRoots[nnodes]; - FChebTensor<FReal,ORDER>::setRoots(subCellCenter, subCellWidth, ChildRoots); + // set child info + FPoint<FReal> ChildRoots[nnodes], localChildRoots[nnodes]; + FChebTensor<FReal,ORDER>::setRoots(subCellCenter, subCellWidth, ChildRoots); - // map global position of roots to local position in parent cell - const map_glob_loc<FReal> map(localCenter, localWidth); - for (unsigned int n=0; n<nnodes; ++n) - map(ChildRoots[n], localChildRoots[n]); + // map global position of roots to local position in parent cell + const map_glob_loc<FReal> map(localCenter, localWidth); + for (unsigned int n=0; n<nnodes; ++n) + map(ChildRoots[n], localChildRoots[n]); - // assemble child - parent - interpolator - KernelBaseClass::Interpolator->assembleInterpolator(nnodes, localChildRoots, subChildParentInterpolator); + // assemble child - parent - interpolator + KernelBaseClass::Interpolator->assembleInterpolator(nnodes, localChildRoots, subChildParentInterpolator); - for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ + for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ - // 2) apply Sx + // 2) apply Sx - /// p^6 version - FBlas::gemva(nnodes, nnodes, FReal(1.), - subChildParentInterpolator, - const_cast<FReal*>(local->getLocal(idxRhs)), subCell->getLocal(idxRhs)); + /// p^6 version + FBlas::gemva(nnodes, nnodes, FReal(1.), + subChildParentInterpolator, + const_cast<FReal*>(local->getLocal(idxRhs)), subCell->getLocal(idxRhs)); - }// NVALS + }// NVALS - } + } - void L2P(const CellClass* const local, const int cellLevel, ContainerClass* const particles) override { + void L2P(const CellClass* const local, const int cellLevel, ContainerClass* const particles) override { - const FPoint<FReal> CellCenter(KernelBaseClass::getCellCenter(local->getCoordinate(),cellLevel)); - const FReal BoxWidth = KernelBaseClass::BoxWidth / FMath::pow(2.0,cellLevel); + const FPoint<FReal> CellCenter(KernelBaseClass::getCellCenter(local->getCoordinate(),cellLevel)); + const FReal LocalBoxWidth = KernelBaseClass::BoxWidth / FMath::pow(2.0,cellLevel); - for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ + for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ - // 2.a) apply Sx - KernelBaseClass::Interpolator->applyL2P(CellCenter, BoxWidth, - local->getLocal(idxRhs), particles); + // 2.a) apply Sx + KernelBaseClass::Interpolator->applyL2P(CellCenter, LocalBoxWidth, local->getLocal(idxRhs), particles); - // 2.b) apply Px (grad Sx) - KernelBaseClass::Interpolator->applyL2PGradient(CellCenter, BoxWidth, - local->getLocal(idxRhs), particles); + // 2.b) apply Px (grad Sx) + KernelBaseClass::Interpolator->applyL2PGradient(CellCenter, LocalBoxWidth, local->getLocal(idxRhs), particles); - } + } - } + } - void P2P(ContainerClass* target, const ContainerClass* sources) override { + void P2P(ContainerClass* target, const ContainerClass* sources) override { ContainerClass* sourcesArray[27] = { const_cast<ContainerClass*> (sources) }; DirectInteractionComputer<FReal, MatrixKernelClass::NCMP, NVALS>::template P2PRemote(target,sourcesArray,1,MatrixKernel); - } - - bool preferP2M(const ContainerClass* const particles) override { - return particles->getNbParticles() > this->sminM; - } - bool preferP2M(const int /*atLevel*/, const ContainerClass*const particles[], const int nbContainers) override { - int counterParticles = 0; - for(int idxContainer = 0 ; idxContainer < nbContainers ; ++idxContainer){ - counterParticles += particles[idxContainer]->getNbParticles(); - } - return counterParticles >this->sminM; - } + } + + bool preferP2M(const ContainerClass* const particles) override { + return particles->getNbParticles() > this->sminM; + } + bool preferP2M(const int /*atLevel*/, const ContainerClass*const particles[], const int nbContainers) override { + FSize counterParticles = 0; + for(FSize idxContainer = 0 ; idxContainer < nbContainers ; ++idxContainer){ + counterParticles += particles[idxContainer]->getNbParticles(); + } + return counterParticles >this->sminM; + } }; // diff --git a/Src/Adaptive/FAdaptTools.hpp b/Src/Adaptive/FAdaptTools.hpp index aefc84a70..1a196f79c 100644 --- a/Src/Adaptive/FAdaptTools.hpp +++ b/Src/Adaptive/FAdaptTools.hpp @@ -40,7 +40,7 @@ void adaptiveTreeBuilSminC(OctreeClass & tree,const int sminM, const int sminL typename OctreeClass::Iterator octreeIterator(&tree) ; int NbLevels = tree.getHeight(); - int nbPart ; + FSize nbPart ; // octreeIterator.gotoBottomLeft(); // Set s on the cells at leave level diff --git a/Src/Adaptive/FAdaptUnifKernel.hpp b/Src/Adaptive/FAdaptUnifKernel.hpp index af0f7ebdb..1b97ca665 100644 --- a/Src/Adaptive/FAdaptUnifKernel.hpp +++ b/Src/Adaptive/FAdaptUnifKernel.hpp @@ -46,7 +46,7 @@ class FTreeCoordinate; * Please read the license * * This kernels implement the Lagrange interpolation based FMM operators. - * It implements all interfaces (P2P, P2M, M2M, M2L, L2L, L2P) which are + * It implements all interfaces (P2P, P2M, M2M, M2L, L2L, L2P) which are * required by the FFmmAlgorithm and FFmmAlgorithmThread. * * @tparam CellClass Type of cell @@ -57,411 +57,409 @@ class FTreeCoordinate; template<class FReal, class CellClass, class ContainerClass, class MatrixKernelClass, int ORDER, int NVALS = 1> class FAdaptiveUnifKernel : FUnifKernel<FReal,CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS> -, public FAbstractAdaptiveKernel<CellClass, ContainerClass> { - // - typedef FUnifKernel<FReal,CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS> KernelBaseClass; - - enum {order = ORDER, - nnodes = TensorTraits<ORDER>::nnodes}; - - /// Needed for M2L operator -// // If we choose to pre-assemble adaptive M2L operators -// // then we need to provide an adaptive M2L handler -// // and the transfer in Fourier space is straightforward. -// typedef FUnifM2LHandler<ORDER,MatrixKernelClass::Type> M2LHandlerClass; -// const M2LHandlerClass M2LHandler; - - const MatrixKernelClass *const MatrixKernel; - int sminM, sminL; + , public FAbstractAdaptiveKernel<CellClass, ContainerClass> { + // + typedef FUnifKernel<FReal,CellClass, ContainerClass, MatrixKernelClass, ORDER, NVALS> KernelBaseClass; + + enum {order = ORDER, + nnodes = TensorTraits<ORDER>::nnodes}; + + /// Needed for M2L operator + // // If we choose to pre-assemble adaptive M2L operators + // // then we need to provide an adaptive M2L handler + // // and the transfer in Fourier space is straightforward. + // typedef FUnifM2LHandler<ORDER,MatrixKernelClass::Type> M2LHandlerClass; + // const M2LHandlerClass M2LHandler; + + const MatrixKernelClass *const MatrixKernel; + int sminM, sminL; public: - using KernelBaseClass::P2M; - using KernelBaseClass::M2M; - using KernelBaseClass::M2L; - using KernelBaseClass::finishedLevelM2L; - using KernelBaseClass::L2L; - using KernelBaseClass::L2P; - using KernelBaseClass::P2P; - using KernelBaseClass::P2PRemote; - // /** - // * The constructor initializes all constant attributes and it reads the - // * precomputed and compressed M2L operators from a binary file (an - // * runtime_error is thrown if the required file is not valid). - // */ - FAdaptiveUnifKernel(const int inTreeHeight, const FReal inBoxWidth, - const FPoint<FReal>& inBoxCenter, const MatrixKernelClass *const inMatrixKernel, const int &minM, const int &minL) : KernelBaseClass(inTreeHeight, inBoxWidth, inBoxCenter, inMatrixKernel) -/*, M2LHandler(inMatrixKernel, inTreeHeight, inBoxWidth)*/, MatrixKernel(inMatrixKernel),sminM(minM),sminL(minM) - {} - // /** Copy constructor */ - FAdaptiveUnifKernel(const FAdaptiveUnifKernel& other) - : KernelBaseClass(other)/*, M2LHandler(other.M2LHandler)*/, MatrixKernel(other.MatrixKernel),sminM(other.sminM),sminL(other.sminL) - { } - - // - // /** Destructor */ - ~FAdaptiveUnifKernel() - { - //this->~KernelBaseClass() ; - } - void P2M(CellClass* const pole, const int cellLevel, const ContainerClass* const particles) override { + using KernelBaseClass::P2M; + using KernelBaseClass::M2M; + using KernelBaseClass::M2L; + using KernelBaseClass::finishedLevelM2L; + using KernelBaseClass::L2L; + using KernelBaseClass::L2P; + using KernelBaseClass::P2P; + using KernelBaseClass::P2PRemote; + // /** + // * The constructor initializes all constant attributes and it reads the + // * precomputed and compressed M2L operators from a binary file (an + // * runtime_error is thrown if the required file is not valid). + // */ + FAdaptiveUnifKernel(const int inTreeHeight, const FReal inBoxWidth, + const FPoint<FReal>& inBoxCenter, const MatrixKernelClass *const inMatrixKernel, const int &minM, const int &minL) : KernelBaseClass(inTreeHeight, inBoxWidth, inBoxCenter, inMatrixKernel) + /*, M2LHandler(inMatrixKernel, inTreeHeight, inBoxWidth)*/, MatrixKernel(inMatrixKernel),sminM(minM),sminL(minM) + {} + // /** Copy constructor */ + FAdaptiveUnifKernel(const FAdaptiveUnifKernel& other) + : KernelBaseClass(other)/*, M2LHandler(other.M2LHandler)*/, MatrixKernel(other.MatrixKernel),sminM(other.sminM),sminL(other.sminL) + { } + + // + // /** Destructor */ + ~FAdaptiveUnifKernel() + { + //this->~KernelBaseClass() ; + } + void P2M(CellClass* const pole, const int cellLevel, const ContainerClass* const particles) override { const FPoint<FReal> CellCenter(KernelBaseClass::getCellCenter(pole->getCoordinate(),cellLevel)); - const FReal BoxWidth = KernelBaseClass::BoxWidth / FMath::pow(2.0,cellLevel); + const FReal BoxWidthAtLevel = KernelBaseClass::BoxWidth / FMath::pow(2.0,cellLevel); - for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ - // 1) apply Sy - KernelBaseClass::Interpolator->applyP2M(CellCenter, BoxWidth, - pole->getMultipole(idxRhs), particles); -// // 2) apply Discrete Fourier Transform -// M2LHandler.applyZeroPaddingAndDFT(pole->getMultipole(idxRhs), -// pole->getTransformedMultipole(idxRhs)); + for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ + // 1) apply Sy + KernelBaseClass::Interpolator->applyP2M(CellCenter, BoxWidthAtLevel, + pole->getMultipole(idxRhs), particles); + // // 2) apply Discrete Fourier Transform + // M2LHandler.applyZeroPaddingAndDFT(pole->getMultipole(idxRhs), + // pole->getTransformedMultipole(idxRhs)); - } + } - } + } - void M2M(CellClass* const pole, const int poleLevel, const CellClass* const subCell, const int subCellLevel) override { + void M2M(CellClass* const pole, const int poleLevel, const CellClass* const subCell, const int subCellLevel) override { + + const FPoint<FReal> subCellCenter(KernelBaseClass::getCellCenter(subCell->getCoordinate(),subCellLevel)); + const FReal subCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0,subCellLevel))); + + const FPoint<FReal> poleCellCenter(KernelBaseClass::getCellCenter(pole->getCoordinate(),poleLevel)); + const FReal poleCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, poleLevel))); + + // //////////////////////////////////////////////////////////////////////////// + // /// p^6 version + // // allocate memory + // FReal* subChildParentInterpolator = new FReal [nnodes * nnodes]; + // + // // set child info + // FPoint<FReal> ChildRoots[nnodes], localChildRoots[nnodes]; + // FUnifTensor<FReal,ORDER>::setRoots(subCellCenter, subCellWidth, ChildRoots); + // + // // map global position of roots to local position in parent cell + // const map_glob_loc<FReal> map(poleCellCenter, poleCellWidth); + // for (unsigned int n=0; n<nnodes; ++n) + // map(ChildRoots[n], localChildRoots[n]); + // + // // assemble child - parent - interpolator + // KernelBaseClass::Interpolator->assembleInterpolator(nnodes, localChildRoots, subChildParentInterpolator); + + + //////////////////////////////////////////////////////////////////////////// + /// p^4 version + + // Set sub-child coords + FReal globalChildCoords[3][ORDER]; + FUnifTensor<FReal,order>::setPolynomialsRoots(subCellCenter, subCellWidth, globalChildCoords); + + // Map global position of sub-child nodes to [-1,1] + FReal localChildCoords[3][ORDER]; + const map_glob_loc<FReal> map(poleCellCenter, poleCellWidth); + FPoint<FReal> localChildPoints; + for (unsigned int n=0; n<ORDER; ++n) { + map(FPoint<FReal>(globalChildCoords[0][n],globalChildCoords[1][n],globalChildCoords[2][n]), localChildPoints); + localChildCoords[0][n] = localChildPoints.getX(); + localChildCoords[1][n] = localChildPoints.getY(); + localChildCoords[2][n] = localChildPoints.getZ(); + } - const FPoint<FReal> subCellCenter(KernelBaseClass::getCellCenter(subCell->getCoordinate(),subCellLevel)); - const FReal subCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0,subCellLevel))); + // assemble interpolator + FReal* subChildParentInterpolator = new FReal [3 * ORDER*ORDER]; + KernelBaseClass::Interpolator->assembleInterpolator(ORDER, localChildCoords[0], subChildParentInterpolator); + KernelBaseClass::Interpolator->assembleInterpolator(ORDER, localChildCoords[1], subChildParentInterpolator + 1 * ORDER*ORDER); + KernelBaseClass::Interpolator->assembleInterpolator(ORDER, localChildCoords[2], subChildParentInterpolator + 2 * ORDER*ORDER); - const FPoint<FReal> poleCellCenter(KernelBaseClass::getCellCenter(pole->getCoordinate(),poleLevel)); - const FReal poleCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, poleLevel))); + // get permutation operators + unsigned int perm[3][nnodes]; + for (unsigned int i=0;i<3; ++i) + for (unsigned int n=0; n<nnodes; ++n) + perm[i][n] = KernelBaseClass::Interpolator->getPermutationsM2ML2L(i)[n]; -// //////////////////////////////////////////////////////////////////////////// -// /// p^6 version -// // allocate memory -// FReal* subChildParentInterpolator = new FReal [nnodes * nnodes]; -// -// // set child info -// FPoint<FReal> ChildRoots[nnodes], localChildRoots[nnodes]; -// FUnifTensor<FReal,ORDER>::setRoots(subCellCenter, subCellWidth, ChildRoots); -// -// // map global position of roots to local position in parent cell -// const map_glob_loc<FReal> map(poleCellCenter, poleCellWidth); -// for (unsigned int n=0; n<nnodes; ++n) -// map(ChildRoots[n], localChildRoots[n]); -// -// // assemble child - parent - interpolator -// KernelBaseClass::Interpolator->assembleInterpolator(nnodes, localChildRoots, subChildParentInterpolator); - - - //////////////////////////////////////////////////////////////////////////// - /// p^4 version - - // Set sub-child coords - FReal globalChildCoords[3][ORDER]; - FUnifTensor<FReal,order>::setPolynomialsRoots(subCellCenter, subCellWidth, globalChildCoords); - - // Map global position of sub-child nodes to [-1,1] - FReal localChildCoords[3][ORDER]; - const map_glob_loc<FReal> map(poleCellCenter, poleCellWidth); - FPoint<FReal> localChildPoints; - for (unsigned int n=0; n<ORDER; ++n) { - map(FPoint<FReal>(globalChildCoords[0][n],globalChildCoords[1][n],globalChildCoords[2][n]), localChildPoints); - localChildCoords[0][n] = localChildPoints.getX(); - localChildCoords[1][n] = localChildPoints.getY(); - localChildCoords[2][n] = localChildPoints.getZ(); - } + for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ - // assemble interpolator - FReal* subChildParentInterpolator = new FReal [3 * ORDER*ORDER]; - KernelBaseClass::Interpolator->assembleInterpolator(ORDER, localChildCoords[0], subChildParentInterpolator); - KernelBaseClass::Interpolator->assembleInterpolator(ORDER, localChildCoords[1], subChildParentInterpolator + 1 * ORDER*ORDER); - KernelBaseClass::Interpolator->assembleInterpolator(ORDER, localChildCoords[2], subChildParentInterpolator + 2 * ORDER*ORDER); + // 1) apply Sy (using tensor product M2M with an interpolator computed on the fly) - // get permutation operators - unsigned int perm[3][nnodes]; - for (unsigned int i=0;i<3; ++i) - for (unsigned int n=0; n<nnodes; ++n) - perm[i][n] = KernelBaseClass::Interpolator->getPermutationsM2ML2L(i)[n]; + // Do NOT reset multipole expansion ! + //FBlas::scal(nnodes, FReal(0.), pole->getMultipole(idxRhs)); - for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ + // /// p^6 version + // FBlas::gemtva(nnodes, nnodes, FReal(1.), + // subChildParentInterpolator, + // const_cast<FReal*>(subCell->getMultipole(idxRhs)), pole->getMultipole(idxRhs)); - // 1) apply Sy (using tensor product M2M with an interpolator computed on the fly) + /// p^4 version + FReal Exp[nnodes], PermExp[nnodes]; + // ORDER*ORDER*ORDER * (2*ORDER-1) + FBlas::gemtm(ORDER, ORDER, ORDER*ORDER, FReal(1.), + subChildParentInterpolator, ORDER, + const_cast<FReal*>(subCell->getMultipole(idxRhs)), ORDER, PermExp, ORDER); - // Do NOT reset multipole expansion ! - //FBlas::scal(nnodes, FReal(0.), pole->getMultipole(idxRhs)); + for (unsigned int n=0; n<nnodes; ++n) Exp[n] = PermExp[perm[1][n]]; + // ORDER*ORDER*ORDER * (2*ORDER-1) + FBlas::gemtm(ORDER, ORDER, ORDER*ORDER, FReal(1.), + subChildParentInterpolator + 2 * ORDER*ORDER, ORDER, + Exp, ORDER, PermExp, ORDER); -// /// p^6 version -// FBlas::gemtva(nnodes, nnodes, FReal(1.), -// subChildParentInterpolator, -// const_cast<FReal*>(subCell->getMultipole(idxRhs)), pole->getMultipole(idxRhs)); + for (unsigned int n=0; n<nnodes; ++n) Exp[perm[1][n]] = PermExp[perm[2][n]]; + // ORDER*ORDER*ORDER * (2*ORDER-1) + FBlas::gemtm(ORDER, ORDER, ORDER*ORDER, FReal(1.), + subChildParentInterpolator + 1 * ORDER*ORDER, ORDER, + Exp, ORDER, PermExp, ORDER); - /// p^4 version - FReal Exp[nnodes], PermExp[nnodes]; - // ORDER*ORDER*ORDER * (2*ORDER-1) - FBlas::gemtm(ORDER, ORDER, ORDER*ORDER, FReal(1.), - subChildParentInterpolator, ORDER, - const_cast<FReal*>(subCell->getMultipole(idxRhs)), ORDER, PermExp, ORDER); + for (unsigned int n=0; n<nnodes; ++n) pole->getMultipole(idxRhs)[perm[2][n]] += PermExp[n]; - for (unsigned int n=0; n<nnodes; ++n) Exp[n] = PermExp[perm[1][n]]; - // ORDER*ORDER*ORDER * (2*ORDER-1) - FBlas::gemtm(ORDER, ORDER, ORDER*ORDER, FReal(1.), - subChildParentInterpolator + 2 * ORDER*ORDER, ORDER, - Exp, ORDER, PermExp, ORDER); - for (unsigned int n=0; n<nnodes; ++n) Exp[perm[1][n]] = PermExp[perm[2][n]]; - // ORDER*ORDER*ORDER * (2*ORDER-1) - FBlas::gemtm(ORDER, ORDER, ORDER*ORDER, FReal(1.), - subChildParentInterpolator + 1 * ORDER*ORDER, ORDER, - Exp, ORDER, PermExp, ORDER); - - for (unsigned int n=0; n<nnodes; ++n) pole->getMultipole(idxRhs)[perm[2][n]] += PermExp[n]; + // // 2) Apply Discete Fourier Transform + // M2LHandler.applyZeroPaddingAndDFT(ParentCell->getMultipole(idxRhs), + // ParentCell->getTransformedMultipole(idxRhs)); + } + } + void P2L(CellClass* const local, const int localLevel, const ContainerClass* const particles) override { -// // 2) Apply Discete Fourier Transform -// M2LHandler.applyZeroPaddingAndDFT(ParentCell->getMultipole(idxRhs), -// ParentCell->getTransformedMultipole(idxRhs)); - } - } + // Target cell: local + const FReal localCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, localLevel))); + const FPoint<FReal> localCellCenter(KernelBaseClass::getCellCenter(local->getCoordinate(),localLevel)); + // std::cout << " call P2L localLevel "<< localLevel << " localCellCenter "<< localCellCenter <<std::endl; + // interpolation points of target (X) cell + FPoint<FReal> X[nnodes]; + FUnifTensor<FReal,order>::setRoots(localCellCenter, localCellWidth, X); - void P2L(CellClass* const local, const int localLevel, const ContainerClass* const particles) override { + // read positions + const FReal*const positionsX = particles->getPositions()[0]; + const FReal*const positionsY = particles->getPositions()[1]; + const FReal*const positionsZ = particles->getPositions()[2]; - // Target cell: local - const FReal localCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, localLevel))); - const FPoint<FReal> localCellCenter(KernelBaseClass::getCellCenter(local->getCoordinate(),localLevel)); - // std::cout << " call P2L localLevel "<< localLevel << " localCellCenter "<< localCellCenter <<std::endl; - // interpolation points of target (X) cell - FPoint<FReal> X[nnodes]; - FUnifTensor<FReal,order>::setRoots(localCellCenter, localCellWidth, X); + for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ - // read positions - const FReal*const positionsX = particles->getPositions()[0]; - const FReal*const positionsY = particles->getPositions()[1]; - const FReal*const positionsZ = particles->getPositions()[2]; + // read physicalValue + const FReal*const physicalValues = particles->getPhysicalValues(); - for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ + // apply P2L + for (FSize idxPart=0; idxPart<particles->getNbParticles(); ++idxPart){ - // read physicalValue - const FReal*const physicalValues = particles->getPhysicalValues(); + const FPoint<FReal> y = FPoint<FReal>(positionsX[idxPart], + positionsY[idxPart], + positionsZ[idxPart]); - // apply P2L - for (int idxPart=0; idxPart<particles->getNbParticles(); ++idxPart){ + for (unsigned int m=0; m<nnodes; ++m) + local->getLocal(idxRhs)[m]+=MatrixKernel->evaluate(X[m], y) * physicalValues[idxPart]; - const FPoint<FReal> y = FPoint<FReal>(positionsX[idxPart], - positionsY[idxPart], - positionsZ[idxPart]); + } - for (unsigned int m=0; m<nnodes; ++m) - local->getLocal(idxRhs)[m]+=MatrixKernel->evaluate(X[m], y) * physicalValues[idxPart]; + }// NVALS - } + } - }// NVALS + void M2L(CellClass* const local, const int localLevel, const CellClass* const pole, const int poleLevel) override { - } + // Source cell: pole + const FReal poleCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, poleLevel))); + const FPoint<FReal> poleCellCenter(KernelBaseClass::getCellCenter(pole->getCoordinate(),poleLevel)); - void M2L(CellClass* const local, const int localLevel, const CellClass* const pole, const int poleLevel) override { + // Target cell: local + const FReal localCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, localLevel))); + const FPoint<FReal> localCellCenter(KernelBaseClass::getCellCenter(local->getCoordinate(),localLevel)); - // Source cell: pole - const FReal poleCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, poleLevel))); - const FPoint<FReal> poleCellCenter(KernelBaseClass::getCellCenter(pole->getCoordinate(),poleLevel)); + // interpolation points of source (Y) and target (X) cell + FPoint<FReal> X[nnodes], Y[nnodes]; + FUnifTensor<FReal,order>::setRoots(poleCellCenter, poleCellWidth, Y); + FUnifTensor<FReal,order>::setRoots(localCellCenter, localCellWidth, X); - // Target cell: local - const FReal localCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, localLevel))); - const FPoint<FReal> localCellCenter(KernelBaseClass::getCellCenter(local->getCoordinate(),localLevel)); - // interpolation points of source (Y) and target (X) cell - FPoint<FReal> X[nnodes], Y[nnodes]; - FUnifTensor<FReal,order>::setRoots(poleCellCenter, poleCellWidth, Y); - FUnifTensor<FReal,order>::setRoots(localCellCenter, localCellWidth, X); + for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ + // Dense M2L + const FReal *const MultipoleExpansion = pole->getMultipole(idxRhs); - for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ + for (unsigned int m=0; m<nnodes; ++m) + for (unsigned int n=0; n<nnodes; ++n){ + local->getLocal(idxRhs)[m]+=MatrixKernel->evaluate(X[m], Y[n]) * MultipoleExpansion[n]; - // Dense M2L - const FReal *const MultipoleExpansion = pole->getMultipole(idxRhs); - - for (unsigned int m=0; m<nnodes; ++m) - for (unsigned int n=0; n<nnodes; ++n){ - local->getLocal(idxRhs)[m]+=MatrixKernel->evaluate(X[m], Y[n]) * MultipoleExpansion[n]; - + } } } - } - - void M2P(const CellClass* const pole, const int poleLevel, ContainerClass* const particles) override { - // Source cell: pole - const FReal poleCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, poleLevel))); - const FPoint<FReal> poleCellCenter(KernelBaseClass::getCellCenter(pole->getCoordinate(),poleLevel)); + void M2P(const CellClass* const pole, const int poleLevel, ContainerClass* const particles) override { - // interpolation points of source (Y) cell - FPoint<FReal> Y[nnodes]; - FUnifTensor<FReal,order>::setRoots(poleCellCenter, poleCellWidth, Y); + // Source cell: pole + const FReal poleCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0, poleLevel))); + const FPoint<FReal> poleCellCenter(KernelBaseClass::getCellCenter(pole->getCoordinate(),poleLevel)); - // read positions - const FReal*const positionsX = particles->getPositions()[0]; - const FReal*const positionsY = particles->getPositions()[1]; - const FReal*const positionsZ = particles->getPositions()[2]; + // interpolation points of source (Y) cell + FPoint<FReal> Y[nnodes]; + FUnifTensor<FReal,order>::setRoots(poleCellCenter, poleCellWidth, Y); - // get potential - FReal*const physVal = particles->getPhysicalValues(/*idxPot*/); - FReal*const potentials = particles->getPotentials(/*idxPot*/); - FReal*const fx = particles->getForcesX(/*idxPot*/); - FReal*const fy = particles->getForcesY(/*idxPot*/); - FReal*const fz = particles->getForcesZ(/*idxPot*/); + // read positions + const FReal*const positionsX = particles->getPositions()[0]; + const FReal*const positionsY = particles->getPositions()[1]; + const FReal*const positionsZ = particles->getPositions()[2]; - for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ + // get potential + FReal*const physVal = particles->getPhysicalValues(/*idxPot*/); + FReal*const potentials = particles->getPotentials(/*idxPot*/); + FReal*const fx = particles->getForcesX(/*idxPot*/); + FReal*const fy = particles->getForcesY(/*idxPot*/); + FReal*const fz = particles->getForcesZ(/*idxPot*/); - const FReal *const MultipoleExpansion = pole->getMultipole(idxRhs); - - // apply M2P - for ( int idxPart=0; idxPart<particles->getNbParticles(); ++idxPart){ + for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ - const FPoint<FReal> x = FPoint<FReal>(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]); + const FReal *const MultipoleExpansion = pole->getMultipole(idxRhs); - for (unsigned int n=0; n<nnodes; ++n){ + // apply M2P + for ( FSize idxPart=0; idxPart<particles->getNbParticles(); ++idxPart){ - FReal Kxy[1]; - FReal dKxy[3]; - MatrixKernel->evaluateBlockAndDerivative(x,Y[n],Kxy,dKxy); + const FPoint<FReal> x = FPoint<FReal>(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]); - potentials[idxPart] += Kxy[0] * MultipoleExpansion[/*idxLhs*nnodes+*/n]; - fx[idxPart] += -dKxy[0] * physVal[idxPart] * MultipoleExpansion[/*idxLhs*nnodes+*/n]; - fy[idxPart] += -dKxy[1] * physVal[idxPart] * MultipoleExpansion[/*idxLhs*nnodes+*/n]; - fz[idxPart] += -dKxy[2] * physVal[idxPart] * MultipoleExpansion[/*idxLhs*nnodes+*/n]; + for (unsigned int n=0; n<nnodes; ++n){ - } + FReal Kxy[1]; + FReal dKxy[3]; + MatrixKernel->evaluateBlockAndDerivative(x,Y[n],Kxy,dKxy); - }// Particles + potentials[idxPart] += Kxy[0] * MultipoleExpansion[/*idxLhs*nnodes+*/n]; + fx[idxPart] += -dKxy[0] * physVal[idxPart] * MultipoleExpansion[/*idxLhs*nnodes+*/n]; + fy[idxPart] += -dKxy[1] * physVal[idxPart] * MultipoleExpansion[/*idxLhs*nnodes+*/n]; + fz[idxPart] += -dKxy[2] * physVal[idxPart] * MultipoleExpansion[/*idxLhs*nnodes+*/n]; - }// NVALS + } - } + }// Particles - void L2L(const CellClass* const local, const int localLevel, CellClass* const subCell, const int subCellLevel) override { + }// NVALS - const FPoint<FReal> subCellCenter(KernelBaseClass::getCellCenter(subCell->getCoordinate(),subCellLevel)); - const FReal subCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0,subCellLevel))); + } - const FPoint<FReal> localCenter(KernelBaseClass::getCellCenter(local->getCoordinate(),localLevel)); - const FReal localWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0,localLevel))); + void L2L(const CellClass* const local, const int localLevel, CellClass* const subCell, const int subCellLevel) override { + + const FPoint<FReal> subCellCenter(KernelBaseClass::getCellCenter(subCell->getCoordinate(),subCellLevel)); + const FReal subCellWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0,subCellLevel))); + + const FPoint<FReal> localCenter(KernelBaseClass::getCellCenter(local->getCoordinate(),localLevel)); + const FReal localWidth(KernelBaseClass::BoxWidth / FReal(FMath::pow(2.0,localLevel))); + + // //////////////////////////////////////////////////////////////////////////// + // /// p^6 version + // // allocate memory + // FReal* subChildParentInterpolator = new FReal [nnodes * nnodes]; + // + // // set child info + // FPoint<FReal> ChildRoots[nnodes], localChildRoots[nnodes]; + // FUnifTensor<FReal,ORDER>::setRoots(subCellCenter, subCellWidth, ChildRoots); + // + // // map global position of roots to local position in parent cell + // const map_glob_loc<FReal> map(localCenter, localWidth); + // for (unsigned int n=0; n<nnodes; ++n) + // map(ChildRoots[n], localChildRoots[n]); + // + // // assemble child - parent - interpolator + // KernelBaseClass::Interpolator->assembleInterpolator(nnodes, localChildRoots, subChildParentInterpolator); + + //////////////////////////////////////////////////////////////////////////// + /// p^4 version + // Set sub-child coords + FReal globalChildCoords[3][ORDER]; + FUnifTensor<FReal,order>::setPolynomialsRoots(subCellCenter, subCellWidth, globalChildCoords); + + // Map global position of sub-child nodes to [-1,1] + FReal localChildCoords[3][ORDER]; + const map_glob_loc<FReal> map(localCenter, localWidth); + FPoint<FReal> localChildPoints; + for (unsigned int n=0; n<ORDER; ++n) { + map(FPoint<FReal>(globalChildCoords[0][n],globalChildCoords[1][n],globalChildCoords[2][n]), localChildPoints); + localChildCoords[0][n] = localChildPoints.getX(); + localChildCoords[1][n] = localChildPoints.getY(); + localChildCoords[2][n] = localChildPoints.getZ(); + } -// //////////////////////////////////////////////////////////////////////////// -// /// p^6 version -// // allocate memory -// FReal* subChildParentInterpolator = new FReal [nnodes * nnodes]; -// -// // set child info -// FPoint<FReal> ChildRoots[nnodes], localChildRoots[nnodes]; -// FUnifTensor<FReal,ORDER>::setRoots(subCellCenter, subCellWidth, ChildRoots); -// -// // map global position of roots to local position in parent cell -// const map_glob_loc<FReal> map(localCenter, localWidth); -// for (unsigned int n=0; n<nnodes; ++n) -// map(ChildRoots[n], localChildRoots[n]); -// -// // assemble child - parent - interpolator -// KernelBaseClass::Interpolator->assembleInterpolator(nnodes, localChildRoots, subChildParentInterpolator); - - //////////////////////////////////////////////////////////////////////////// - /// p^4 version - // Set sub-child coords - FReal globalChildCoords[3][ORDER]; - FUnifTensor<FReal,order>::setPolynomialsRoots(subCellCenter, subCellWidth, globalChildCoords); - - // Map global position of sub-child nodes to [-1,1] - FReal localChildCoords[3][ORDER]; - const map_glob_loc<FReal> map(localCenter, localWidth); - FPoint<FReal> localChildPoints; - for (unsigned int n=0; n<ORDER; ++n) { - map(FPoint<FReal>(globalChildCoords[0][n],globalChildCoords[1][n],globalChildCoords[2][n]), localChildPoints); - localChildCoords[0][n] = localChildPoints.getX(); - localChildCoords[1][n] = localChildPoints.getY(); - localChildCoords[2][n] = localChildPoints.getZ(); - } + // assemble interpolator + FReal* subChildParentInterpolator = new FReal [3 * ORDER*ORDER]; + KernelBaseClass::Interpolator->assembleInterpolator(ORDER, localChildCoords[0], subChildParentInterpolator); + KernelBaseClass::Interpolator->assembleInterpolator(ORDER, localChildCoords[1], subChildParentInterpolator + 1 * ORDER*ORDER); + KernelBaseClass::Interpolator->assembleInterpolator(ORDER, localChildCoords[2], subChildParentInterpolator + 2 * ORDER*ORDER); + + // get permutation operators + unsigned int perm[3][nnodes]; + for (unsigned int i=0;i<3; ++i) + for (unsigned int n=0; n<nnodes; ++n) + perm[i][n] = KernelBaseClass::Interpolator->getPermutationsM2ML2L(i)[n]; + + for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ + // // 1) Apply Inverse Discete Fourier Transform + // M2LHandler.unapplyZeroPaddingAndDFT(local->getTransformedLocal(idxRhs), + // const_cast<CellClass*>(local)->getLocal(idxRhs)); + + // 2) apply Sx + + // /// p^6 version + // FBlas::gemva(nnodes, nnodes, FReal(1.), + // subChildParentInterpolator, + // const_cast<FReal*>(local->getLocal(idxRhs)), subCell->getLocal(idxRhs)); + + /// p^4 version + FReal Exp[nnodes], PermExp[nnodes]; + // ORDER*ORDER*ORDER * (2*ORDER-1) + FBlas::gemm(ORDER, ORDER, ORDER*ORDER, FReal(1.), + subChildParentInterpolator, ORDER, + const_cast<FReal*>(local->getLocal(idxRhs)), ORDER, PermExp, ORDER); + + for (unsigned int n=0; n<nnodes; ++n) Exp[n] = PermExp[perm[1][n]]; + // ORDER*ORDER*ORDER * (2*ORDER-1) + FBlas::gemm(ORDER, ORDER, ORDER*ORDER, FReal(1.), + subChildParentInterpolator + 2 * ORDER*ORDER, ORDER, + Exp, ORDER, PermExp, ORDER); + + for (unsigned int n=0; n<nnodes; ++n) Exp[perm[1][n]] = PermExp[perm[2][n]]; + // ORDER*ORDER*ORDER * (2*ORDER-1) + FBlas::gemm(ORDER, ORDER, ORDER*ORDER, FReal(1.), + subChildParentInterpolator + 1 * ORDER*ORDER, ORDER, + Exp, ORDER, PermExp, ORDER); + + for (unsigned int n=0; n<nnodes; ++n) subCell->getLocal(idxRhs)[perm[2][n]] += PermExp[n]; + // total flops count: 3 * ORDER*ORDER*ORDER * (2*ORDER-1) - // assemble interpolator - FReal* subChildParentInterpolator = new FReal [3 * ORDER*ORDER]; - KernelBaseClass::Interpolator->assembleInterpolator(ORDER, localChildCoords[0], subChildParentInterpolator); - KernelBaseClass::Interpolator->assembleInterpolator(ORDER, localChildCoords[1], subChildParentInterpolator + 1 * ORDER*ORDER); - KernelBaseClass::Interpolator->assembleInterpolator(ORDER, localChildCoords[2], subChildParentInterpolator + 2 * ORDER*ORDER); - - // get permutation operators - unsigned int perm[3][nnodes]; - for (unsigned int i=0;i<3; ++i) - for (unsigned int n=0; n<nnodes; ++n) - perm[i][n] = KernelBaseClass::Interpolator->getPermutationsM2ML2L(i)[n]; - - for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ -// // 1) Apply Inverse Discete Fourier Transform -// M2LHandler.unapplyZeroPaddingAndDFT(local->getTransformedLocal(idxRhs), -// const_cast<CellClass*>(local)->getLocal(idxRhs)); - - // 2) apply Sx - -// /// p^6 version -// FBlas::gemva(nnodes, nnodes, FReal(1.), -// subChildParentInterpolator, -// const_cast<FReal*>(local->getLocal(idxRhs)), subCell->getLocal(idxRhs)); - - /// p^4 version - FReal Exp[nnodes], PermExp[nnodes]; - // ORDER*ORDER*ORDER * (2*ORDER-1) - FBlas::gemm(ORDER, ORDER, ORDER*ORDER, FReal(1.), - subChildParentInterpolator, ORDER, - const_cast<FReal*>(local->getLocal(idxRhs)), ORDER, PermExp, ORDER); - - for (unsigned int n=0; n<nnodes; ++n) Exp[n] = PermExp[perm[1][n]]; - // ORDER*ORDER*ORDER * (2*ORDER-1) - FBlas::gemm(ORDER, ORDER, ORDER*ORDER, FReal(1.), - subChildParentInterpolator + 2 * ORDER*ORDER, ORDER, - Exp, ORDER, PermExp, ORDER); - - for (unsigned int n=0; n<nnodes; ++n) Exp[perm[1][n]] = PermExp[perm[2][n]]; - // ORDER*ORDER*ORDER * (2*ORDER-1) - FBlas::gemm(ORDER, ORDER, ORDER*ORDER, FReal(1.), - subChildParentInterpolator + 1 * ORDER*ORDER, ORDER, - Exp, ORDER, PermExp, ORDER); - - for (unsigned int n=0; n<nnodes; ++n) subCell->getLocal(idxRhs)[perm[2][n]] += PermExp[n]; - // total flops count: 3 * ORDER*ORDER*ORDER * (2*ORDER-1) + } } - } + void L2P(const CellClass* const local, const int cellLevel, ContainerClass* const particles) override { - void L2P(const CellClass* const local, const int cellLevel, ContainerClass* const particles) override { + const FPoint<FReal> CellCenter(KernelBaseClass::getCellCenter(local->getCoordinate(),cellLevel)); + const FReal LocalBoxWidth = KernelBaseClass::BoxWidth / FMath::pow(2.0,cellLevel); - const FPoint<FReal> CellCenter(KernelBaseClass::getCellCenter(local->getCoordinate(),cellLevel)); - const FReal BoxWidth = KernelBaseClass::BoxWidth / FMath::pow(2.0,cellLevel); + for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ - for(int idxRhs = 0 ; idxRhs < NVALS ; ++idxRhs){ + // // 1) Apply Inverse Discete Fourier Transform + // M2LHandler.unapplyZeroPaddingAndDFT(local->getTransformedLocal(idxRhs), + // const_cast<CellClass*>(local)->getLocal(idxRhs)); -// // 1) Apply Inverse Discete Fourier Transform -// M2LHandler.unapplyZeroPaddingAndDFT(local->getTransformedLocal(idxRhs), -// const_cast<CellClass*>(local)->getLocal(idxRhs)); + // 2.a) apply Sx + KernelBaseClass::Interpolator->applyL2P(CellCenter, LocalBoxWidth, local->getLocal(idxRhs), particles); - // 2.a) apply Sx - KernelBaseClass::Interpolator->applyL2P(CellCenter, BoxWidth, - local->getLocal(idxRhs), particles); - - // 2.b) apply Px (grad Sx) - KernelBaseClass::Interpolator->applyL2PGradient(CellCenter, BoxWidth, - local->getLocal(idxRhs), particles); + // 2.b) apply Px (grad Sx) + KernelBaseClass::Interpolator->applyL2PGradient(CellCenter, LocalBoxWidth, local->getLocal(idxRhs), particles); + } } - } - void P2P(ContainerClass* target, const ContainerClass* sources) override { + void P2P(ContainerClass* target, const ContainerClass* sources) override { ContainerClass* sourcesArray[27] = { const_cast<ContainerClass*> (sources) }; DirectInteractionComputer<FReal,MatrixKernelClass::NCMP, NVALS>::template P2PRemote(target,sourcesArray,1,MatrixKernel); - } - - bool preferP2M(const ContainerClass* const particles) override { - return particles->getNbParticles() >this->sminM; - } - bool preferP2M(const int /*atLevel*/, const ContainerClass*const particles[], const int nbContainers) override { - int counterParticles = 0; - for(int idxContainer = 0 ; idxContainer < nbContainers ; ++idxContainer){ - counterParticles += particles[idxContainer]->getNbParticles(); - } -// std::cout << " Part("<<counterParticles<< ") "; - return counterParticles >this->sminM; - } + } + + bool preferP2M(const ContainerClass* const particles) override { + return particles->getNbParticles() >this->sminM; + } + bool preferP2M(const int /*atLevel*/, const ContainerClass*const particles[], const int nbContainers) override { + FSize counterParticles = 0; + for(FSize idxContainer = 0 ; idxContainer < nbContainers ; ++idxContainer){ + counterParticles += particles[idxContainer]->getNbParticles(); + } + // std::cout << " Part("<<counterParticles<< ") "; + return counterParticles >this->sminM; + } }; // diff --git a/Src/Adaptive/FAdaptiveCell.hpp b/Src/Adaptive/FAdaptiveCell.hpp index ff1e890dc..d3cbec5b7 100644 --- a/Src/Adaptive/FAdaptiveCell.hpp +++ b/Src/Adaptive/FAdaptiveCell.hpp @@ -31,7 +31,7 @@ class FAdaptiveCell : public FBasicCell { FVector<ContainerClass*> subLeaves; // // Global Index of the cell in the octree (This id is unique) - long int gID; + FSize gID; public: /** Set has not Adaptive by default */ @@ -117,7 +117,7 @@ public: } int getNbSubLeaves() const { - return subLeaves.getSize(); + return int(subLeaves.getSize()); } ContainerClass* const * getSubLeaves() { @@ -162,14 +162,14 @@ public: /// Manage a global IG DEBUG PURPOSE //////////////////////////////////////////////////////////////////////////////// //! Return the global Id of the cell in the octree - const long int getGlobalId(){ + const FSize getGlobalId(){ return this->gID ; } - const long int getGlobalId( ) const{ + const FSize getGlobalId( ) const{ return this->gID ; } //! Set he global Id of the cell in the octree to id - void setGlobalId(const long int & id){ + void setGlobalId(const FSize & id){ this->gID = id; ; } //#endif diff --git a/Src/Adaptive/FAdaptiveKernelWrapper.hpp b/Src/Adaptive/FAdaptiveKernelWrapper.hpp index bcb918b57..b688c80d9 100644 --- a/Src/Adaptive/FAdaptiveKernelWrapper.hpp +++ b/Src/Adaptive/FAdaptiveKernelWrapper.hpp @@ -90,7 +90,7 @@ public: } } // We need to aggregate if there are only particles and if the kernel says so - const bool continueToAgregate = (onlyParticlesCells && (kernel.preferP2M(inLevel, subLeaves.data(), subLeaves.getSize()) == false)); + const bool continueToAgregate = (onlyParticlesCells && (kernel.preferP2M(inLevel, subLeaves.data(), int(subLeaves.getSize())) == false)); if(nbChild == 1){ // One child means that the cell is not Adaptive pole->setAdaptive(false); diff --git a/Src/Adaptive/FAdaptiveTestKernel.hpp b/Src/Adaptive/FAdaptiveTestKernel.hpp index a338490df..44b33427e 100644 --- a/Src/Adaptive/FAdaptiveTestKernel.hpp +++ b/Src/Adaptive/FAdaptiveTestKernel.hpp @@ -39,7 +39,7 @@ public: void M2P(const CellClass* const pole, const int /*poleLevel*/, ContainerClass* const particles) override { long long int*const particlesAttributes = particles->getDataDown(); - for(int idxPart = 0 ; idxPart < particles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < particles->getNbParticles() ; ++idxPart){ particlesAttributes[idxPart] += pole->getDataUp(); } } @@ -50,14 +50,14 @@ public: void L2P(const CellClass* const local, const int /*cellLevel*/, ContainerClass* const particles) override { long long int*const particlesAttributes = particles->getDataDown(); - for(int idxPart = 0 ; idxPart < particles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < particles->getNbParticles() ; ++idxPart){ particlesAttributes[idxPart] += local->getDataDown(); } } void P2P(ContainerClass* target, const ContainerClass* sources) override { long long int*const particlesAttributes = target->getDataDown(); - for(int idxPart = 0 ; idxPart < target->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < target->getNbParticles() ; ++idxPart){ particlesAttributes[idxPart] += sources->getNbParticles(); } } @@ -66,7 +66,7 @@ public: return particles->getNbParticles() > p2mThresh; } bool preferP2M(const int /*atLevel*/, const ContainerClass*const particles[], const int nbContainers) override { - int counterParticles = 0; + FSize counterParticles = 0; for(int idxContainer = 0 ; idxContainer < nbContainers ; ++idxContainer){ counterParticles += particles[idxContainer]->getNbParticles(); } diff --git a/Src/Arranger/FAbstractMover.hpp b/Src/Arranger/FAbstractMover.hpp index ac3c35a89..8780c487b 100644 --- a/Src/Arranger/FAbstractMover.hpp +++ b/Src/Arranger/FAbstractMover.hpp @@ -19,8 +19,8 @@ template<class FReal,class OctreeClass,class ParticleClass> class FAbstractMover{ public: - virtual void getParticlePosition(ParticleClass* lf, const int idxPart, FPoint<FReal>* particlePos) = 0; - virtual void removeFromLeafAndKeep(ParticleClass* lf, const FPoint<FReal>& particlePos, const int idxPart, FParticleType type) = 0; + virtual void getParticlePosition(ParticleClass* lf, const FSize idxPart, FPoint<FReal>* particlePos) = 0; + virtual void removeFromLeafAndKeep(ParticleClass* lf, const FPoint<FReal>& particlePos, const FSize idxPart, FParticleType type) = 0; virtual void insertAllParticles(OctreeClass* tree) = 0; }; diff --git a/Src/Arranger/FBasicParticleContainerIndexedMover.hpp b/Src/Arranger/FBasicParticleContainerIndexedMover.hpp index 343e89795..90d578b28 100644 --- a/Src/Arranger/FBasicParticleContainerIndexedMover.hpp +++ b/Src/Arranger/FBasicParticleContainerIndexedMover.hpp @@ -20,12 +20,12 @@ public: } /** To get the position of the particle at idx idxPart in leaf lf */ - void getParticlePosition(ContainerClass* lf, const int idxPart, FPoint<FReal>* particlePos){ + void getParticlePosition(ContainerClass* lf, const FSize idxPart, FPoint<FReal>* particlePos){ (*particlePos) = FPoint<FReal>(lf->getPositions()[0][idxPart],lf->getPositions()[1][idxPart],lf->getPositions()[2][idxPart]); } /** Remove a particle but keep it to reinsert it later*/ - void removeFromLeafAndKeep(ContainerClass* lf, const FPoint<FReal>& particlePos, const int idxPart, FParticleType /*type*/){ + void removeFromLeafAndKeep(ContainerClass* lf, const FPoint<FReal>& particlePos, const FSize idxPart, FParticleType /*type*/){ std::array<typename ContainerClass::AttributesClass, ContainerClass::NbAttributes> particleValues; for(int idxAttr = 0 ; idxAttr < ContainerClass::NbAttributes ; ++idxAttr){ particleValues[idxAttr] = lf->getAttribute(idxAttr)[idxPart]; @@ -40,7 +40,7 @@ public: void insertAllParticles(OctreeClass* tree){ std::array<typename ContainerClass::AttributesClass, ContainerClass::NbAttributes> particleValues; - for(int idxToInsert = 0; idxToInsert<toStoreRemovedParts.getNbParticles() ; ++idxToInsert){ + for(FSize idxToInsert = 0; idxToInsert<toStoreRemovedParts.getNbParticles() ; ++idxToInsert){ for(int idxAttr = 0 ; idxAttr < ContainerClass::NbAttributes ; ++idxAttr){ particleValues[idxAttr] = toStoreRemovedParts.getAttribute(idxAttr)[idxToInsert]; } diff --git a/Src/Arranger/FBasicParticleContainerMover.hpp b/Src/Arranger/FBasicParticleContainerMover.hpp index ec0d1efac..7538c58a8 100644 --- a/Src/Arranger/FBasicParticleContainerMover.hpp +++ b/Src/Arranger/FBasicParticleContainerMover.hpp @@ -20,12 +20,12 @@ public: } /** To get the position of the particle at idx idxPart in leaf lf */ - void getParticlePosition(ContainerClass* lf, const int idxPart, FPoint<FReal>* particlePos){ + void getParticlePosition(ContainerClass* lf, const FSize idxPart, FPoint<FReal>* particlePos){ (*particlePos) = FPoint<FReal>(lf->getPositions()[0][idxPart],lf->getPositions()[1][idxPart],lf->getPositions()[2][idxPart]); } /** Remove a particle but keep it to reinsert it later*/ - void removeFromLeafAndKeep(ContainerClass* lf, const FPoint<FReal>& particlePos, const int idxPart){ + void removeFromLeafAndKeep(ContainerClass* lf, const FPoint<FReal>& particlePos, const FSize idxPart){ std::array<typename ContainerClass::AttributesClass, ContainerClass::NbAttributes> particleValues; for(int idxAttr = 0 ; idxAttr < ContainerClass::NbAttributes ; ++idxAttr){ particleValues[idxAttr] = lf->getAttribute(idxAttr)[idxPart]; @@ -40,7 +40,7 @@ public: void insertAllParticles(OctreeClass* tree){ std::array<typename ContainerClass::AttributesClass, ContainerClass::NbAttributes> particleValues; - for(int idxToInsert = 0; idxToInsert<toStoreRemovedParts.getNbParticles() ; ++idxToInsert){ + for(FSize idxToInsert = 0; idxToInsert<toStoreRemovedParts.getNbParticles() ; ++idxToInsert){ for(int idxAttr = 0 ; idxAttr < ContainerClass::NbAttributes ; ++idxAttr){ particleValues[idxAttr] = toStoreRemovedParts.getAttribute(idxAttr)[idxToInsert]; } diff --git a/Src/Arranger/FOctreeArranger.hpp b/Src/Arranger/FOctreeArranger.hpp index f906642e0..d5fdec315 100644 --- a/Src/Arranger/FOctreeArranger.hpp +++ b/Src/Arranger/FOctreeArranger.hpp @@ -71,45 +71,47 @@ public: void rearrange(){ - typename OctreeClass::Iterator octreeIterator(tree); - octreeIterator.gotoBottomLeft(); - do{ - const MortonIndex currentMortonIndex = octreeIterator.getCurrentGlobalIndex(); - //First we test sources - ContainerClass * particles = octreeIterator.getCurrentLeaf()->getSrc(); - for(int idxPart = 0 ; idxPart < particles->getNbParticles(); /*++idxPart*/){ - FPoint<FReal> currentPart; - interface->getParticlePosition(particles,idxPart,¤tPart); - checkPosition(currentPart); - const MortonIndex particuleIndex = tree->getMortonFromPosition(currentPart); - if(particuleIndex != currentMortonIndex){ - //Need to move this one - interface->removeFromLeafAndKeep(particles,currentPart,idxPart,FParticleTypeSource); - } - else{ - //Need to increment idx; - ++idxPart; - } - } - //Then we test targets - if(octreeIterator.getCurrentLeaf()->getTargets() != particles){ //Leaf is TypedLeaf - ContainerClass * particleTargets = octreeIterator.getCurrentLeaf()->getTargets(); - for(int idxPart = 0 ; idxPart < particleTargets->getNbParticles(); /*++idxPart*/){ + { + typename OctreeClass::Iterator octreeIterator(tree); + octreeIterator.gotoBottomLeft(); + do{ + const MortonIndex currentMortonIndex = octreeIterator.getCurrentGlobalIndex(); + //First we test sources + ContainerClass * particles = octreeIterator.getCurrentLeaf()->getSrc(); + for(FSize idxPart = 0 ; idxPart < particles->getNbParticles(); /*++idxPart*/){ FPoint<FReal> currentPart; - interface->getParticlePosition(particleTargets,idxPart,¤tPart); + interface->getParticlePosition(particles,idxPart,¤tPart); checkPosition(currentPart); const MortonIndex particuleIndex = tree->getMortonFromPosition(currentPart); if(particuleIndex != currentMortonIndex){ //Need to move this one - interface->removeFromLeafAndKeep(particleTargets,currentPart,idxPart, FParticleTypeTarget); + interface->removeFromLeafAndKeep(particles,currentPart,idxPart,FParticleTypeSource); } else{ //Need to increment idx; ++idxPart; } } - } - }while(octreeIterator.moveRight()); + //Then we test targets + if(octreeIterator.getCurrentLeaf()->getTargets() != particles){ //Leaf is TypedLeaf + ContainerClass * particleTargets = octreeIterator.getCurrentLeaf()->getTargets(); + for(FSize idxPart = 0 ; idxPart < particleTargets->getNbParticles(); /*++idxPart*/){ + FPoint<FReal> currentPart; + interface->getParticlePosition(particleTargets,idxPart,¤tPart); + checkPosition(currentPart); + const MortonIndex particuleIndex = tree->getMortonFromPosition(currentPart); + if(particuleIndex != currentMortonIndex){ + //Need to move this one + interface->removeFromLeafAndKeep(particleTargets,currentPart,idxPart, FParticleTypeTarget); + } + else{ + //Need to increment idx; + ++idxPart; + } + } + } + }while(octreeIterator.moveRight()); + } printf("Insert back particles\n"); //Insert back the parts that have been removed interface->insertAllParticles(tree); diff --git a/Src/Arranger/FOctreeArrangerProc.hpp b/Src/Arranger/FOctreeArrangerProc.hpp index 73bc7b694..b0a5b61f2 100644 --- a/Src/Arranger/FOctreeArrangerProc.hpp +++ b/Src/Arranger/FOctreeArrangerProc.hpp @@ -107,7 +107,7 @@ public: const FPoint<FReal> min(tree->getBoxCenter(),-boxWidth/2); const FPoint<FReal> max(tree->getBoxCenter(),boxWidth/2); - FVector<int> indexesToExtract; + FVector<FSize> indexesToExtract; typename OctreeClass::Iterator octreeIterator(tree); octreeIterator.gotoBottomLeft(); @@ -115,7 +115,7 @@ public: const MortonIndex currentIndex = octreeIterator.getCurrentGlobalIndex(); ContainerClass* particles = octreeIterator.getCurrentLeaf()->getSrc(); //IdxPart is incremented at the end of the loop - for(int idxPart = 0 ; idxPart < particles->getNbParticles(); /*++idxPart*/){ + for(FSize idxPart = 0 ; idxPart < particles->getNbParticles(); /*++idxPart*/){ FPoint<FReal> partPos( particles->getPositions()[0][idxPart], particles->getPositions()[1][idxPart], particles->getPositions()[2][idxPart] ); @@ -205,26 +205,27 @@ public: ParticleClass* toReceive = nullptr; MPI_Request*const requests = new MPI_Request[comm.processCount()*2]; memset(requests, 0, sizeof(MPI_Request) * comm.processCount() * 2); - long long int*const indexToReceive = new long long int[comm.processCount() + 1]; - memset(indexToReceive, 0, sizeof(long long int) * comm.processCount() + 1); + FSize*const indexToReceive = new FSize[comm.processCount() + 1]; + memset(indexToReceive, 0, sizeof(FSize) * comm.processCount() + 1); int iterRequests = 0; int limitRecvSend = 0; int hasToRecvFrom = 0; { // gather what to send to who + isend data - int*const counter = new int[comm.processCount()]; - memset(counter, 0, sizeof(int) * comm.processCount()); + FSize*const counter = new FSize[comm.processCount()]; + memset(counter, 0, sizeof(FSize) * comm.processCount()); for(int idxProc = 0 ; idxProc < comm.processCount() ; ++idxProc){ counter[idxProc] = toMove[idxProc].getSize(); } // say who send to who - int*const allcounter = new int[comm.processCount()*comm.processCount()]; - FMpi::MpiAssert( MPI_Allgather( counter, comm.processCount(), MPI_INT, allcounter, comm.processCount(), MPI_INT, comm.getComm()), __LINE__ ); + FSize*const allcounter = new FSize[comm.processCount()*comm.processCount()]; + FMpi::MpiAssert( MPI_Allgather( counter, comm.processCount(), FMpi::GetType(*counter), allcounter, comm.processCount(), + FMpi::GetType(*counter), comm.getComm()), __LINE__ ); // prepare buffer to receive - long long int sumToRecv = 0; + FSize sumToRecv = 0; indexToReceive[0] = 0; for(int idxProc = 0 ; idxProc < comm.processCount() ; ++idxProc){ if( idxProc != comm.processId()){ @@ -237,7 +238,8 @@ public: // send for(int idxProc = 0 ; idxProc < comm.processCount() ; ++idxProc){ if(idxProc != comm.processId() && allcounter[idxProc * comm.processCount() + comm.processId()]){ - FMpi::MpiAssert( MPI_Irecv(&toReceive[indexToReceive[idxProc]], allcounter[idxProc * comm.processCount() + comm.processId()] * int(sizeof(ParticleClass)), MPI_BYTE, + FAssertLF( allcounter[idxProc * comm.processCount() + comm.processId()] * sizeof(ParticleClass) < std::numeric_limits<int>::max()); + FMpi::MpiAssert( MPI_Irecv(&toReceive[indexToReceive[idxProc]], int(allcounter[idxProc * comm.processCount() + comm.processId()] * sizeof(ParticleClass)), MPI_BYTE, idxProc, 0, comm.getComm(), &requests[iterRequests++]), __LINE__ ); hasToRecvFrom += 1; } @@ -248,7 +250,8 @@ public: // recv for(int idxProc = 0 ; idxProc < comm.processCount() ; ++idxProc){ if(idxProc != comm.processId() && toMove[idxProc].getSize()){ - FMpi::MpiAssert( MPI_Isend(toMove[idxProc].data(), toMove[idxProc].getSize() * int(sizeof(ParticleClass)), MPI_BYTE, + FAssertLF( toMove[idxProc].getSize() * sizeof(ParticleClass) < std::numeric_limits<int>::max()); + FMpi::MpiAssert( MPI_Isend(toMove[idxProc].data(), int(toMove[idxProc].getSize() * sizeof(ParticleClass)), MPI_BYTE, idxProc, 0, comm.getComm(), &requests[iterRequests++]), __LINE__ ); } } @@ -258,7 +261,7 @@ public: } { // insert particles that moved - for(int idxPart = 0 ; idxPart < toMove[comm.processId()].getSize() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < toMove[comm.processId()].getSize() ; ++idxPart){ ConverterClass::Insert( tree , toMove[comm.processId()][idxPart]); } } @@ -271,7 +274,7 @@ public: FMpi::MpiAssert( MPI_Waitany( iterRequests, requests, &done, &status ), __LINE__ ); if( done < limitRecvSend ){ const int source = status.MPI_SOURCE; - for(long long int idxPart = indexToReceive[source] ; idxPart < indexToReceive[source+1] ; ++idxPart){ + for(FSize idxPart = indexToReceive[source] ; idxPart < indexToReceive[source+1] ; ++idxPart){ ConverterClass::Insert( tree , toReceive[idxPart]); } hasToRecvFrom -= 1; diff --git a/Src/Arranger/FParticleTypedIndexedMover.hpp b/Src/Arranger/FParticleTypedIndexedMover.hpp index c1504df13..e4e1b8a55 100644 --- a/Src/Arranger/FParticleTypedIndexedMover.hpp +++ b/Src/Arranger/FParticleTypedIndexedMover.hpp @@ -23,12 +23,12 @@ public: } /** To get the position of the particle at idx idxPart in leaf lf */ - void getParticlePosition(ContainerClass* lf, const int idxPart, FPoint<FReal>* particlePos){ + void getParticlePosition(ContainerClass* lf, const FSize idxPart, FPoint<FReal>* particlePos){ (*particlePos) = FPoint<FReal>(lf->getPositions()[0][idxPart],lf->getPositions()[1][idxPart],lf->getPositions()[2][idxPart]); } /** Remove a particle but keep it to reinsert it later*/ - void removeFromLeafAndKeep(ContainerClass* lf, const FPoint<FReal>& particlePos, const int idxPart, FParticleType type){ + void removeFromLeafAndKeep(ContainerClass* lf, const FPoint<FReal>& particlePos, const FSize idxPart, FParticleType type){ std::array<typename ContainerClass::AttributesClass, ContainerClass::NbAttributes> particleValues; for(int idxAttr = 0 ; idxAttr < ContainerClass::NbAttributes ; ++idxAttr){ particleValues[idxAttr] = lf->getAttribute(idxAttr)[idxPart]; @@ -46,7 +46,7 @@ public: void insertAllParticles(OctreeClass* tree){ std::array<typename ContainerClass::AttributesClass, ContainerClass::NbAttributes> particleValues; - for(int idxToInsert = 0; idxToInsert<toStoreRemovedSourceParts.getNbParticles() ; ++idxToInsert){ + for(FSize idxToInsert = 0; idxToInsert<toStoreRemovedSourceParts.getNbParticles() ; ++idxToInsert){ for(int idxAttr = 0 ; idxAttr < ContainerClass::NbAttributes ; ++idxAttr){ particleValues[idxAttr] = toStoreRemovedSourceParts.getAttribute(idxAttr)[idxToInsert]; } @@ -56,7 +56,7 @@ public: tree->insert(particlePos, FParticleTypeSource, toStoreRemovedSourceParts.getIndexes()[idxToInsert], particleValues); } - for(int idxToInsert = 0; idxToInsert<toStoreRemovedTargetParts.getNbParticles() ; ++idxToInsert){ + for(FSize idxToInsert = 0; idxToInsert<toStoreRemovedTargetParts.getNbParticles() ; ++idxToInsert){ for(int idxAttr = 0 ; idxAttr < ContainerClass::NbAttributes ; ++idxAttr){ particleValues[idxAttr] = toStoreRemovedTargetParts.getAttribute(idxAttr)[idxToInsert]; } diff --git a/Src/Components/FAbstractSendable.hpp b/Src/Components/FAbstractSendable.hpp index f43ee2b8a..cb419af8a 100644 --- a/Src/Components/FAbstractSendable.hpp +++ b/Src/Components/FAbstractSendable.hpp @@ -43,7 +43,7 @@ protected: static_assert(sizeof(BufferWriterClass) == 0 , "Your class should implement deserializeUp"); } - virtual int getSavedSizeUp() = 0; + virtual FSize getSavedSizeUp() = 0; /////////////////////////////////////////////// // For Downward pass @@ -60,7 +60,7 @@ protected: static_assert(sizeof(BufferWriterClass) == 0 , "Your class should implement deserializeDown"); } - virtual int getSavedSizeDown() = 0; + virtual FSize getSavedSizeDown() = 0; }; diff --git a/Src/Components/FAbstractSerializable.hpp b/Src/Components/FAbstractSerializable.hpp index f11b3e3c3..3fc3ca3bf 100644 --- a/Src/Components/FAbstractSerializable.hpp +++ b/Src/Components/FAbstractSerializable.hpp @@ -45,7 +45,7 @@ protected: static_assert(sizeof(BufferReaderClass) == 0 , "Your class should implement restore"); } - virtual int getSavedSize() const = 0; + virtual FSize getSavedSize() const = 0; }; #endif // FABSTRACTSERIALIZABLE_HPP diff --git a/Src/Components/FBasicCell.hpp b/Src/Components/FBasicCell.hpp index c24a4d22c..37d6aed15 100644 --- a/Src/Components/FBasicCell.hpp +++ b/Src/Components/FBasicCell.hpp @@ -86,8 +86,8 @@ public: coordinate.restore(buffer); } - int getSavedSize() const { - return int(sizeof(mortonIndex)) + coordinate.getSavedSize(); + FSize getSavedSize() const { + return FSize(sizeof(mortonIndex)) + coordinate.getSavedSize(); } /** Do nothing */ diff --git a/Src/Components/FBasicParticleContainer.hpp b/Src/Components/FBasicParticleContainer.hpp index 515295c4b..1eccdc21f 100644 --- a/Src/Components/FBasicParticleContainer.hpp +++ b/Src/Components/FBasicParticleContainer.hpp @@ -48,36 +48,36 @@ template <class FReal, unsigned NbAttributesPerParticle, class AttributeClass > class FBasicParticleContainer : public FAbstractParticleContainer<FReal>, public FAbstractSerializable { protected: - static const int MemoryAlignement = FP2PDefaultAlignement; - static const int DefaultNbParticles = int(MemoryAlignement/sizeof(FReal)); + static const FSize MemoryAlignement = FP2PDefaultAlignement; + static const FSize DefaultNbParticles = FSize(MemoryAlignement/sizeof(FReal)); /** The number of particles in the container */ - int nbParticles; + FSize nbParticles; /** 3 pointers to 3 arrays of real to store the position */ FReal* positions[3]; /** The attributes requested by the user */ AttributeClass* attributes[NbAttributesPerParticle]; /** The allocated memory */ - int allocatedParticles; + FSize allocatedParticles; ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// /** Ending call for pushing the attributes */ template<int index> - void addParticleValue(const int /*insertPosition*/){ + void addParticleValue(const FSize /*insertPosition*/){ } /** Ending call for pushing array of attributes */ template<int index> - void addParticleValueS(const int /*insertPosition*/,const int /*nbParticles*/){ + void addParticleValueS(const FSize /*insertPosition*/,const FSize /*nbParticles*/){ } /** Filling call for each attributes values */ template<int index, typename... Args> - void addParticleValue(const int insertPosition, const AttributeClass value, Args... args){ + void addParticleValue(const FSize insertPosition, const AttributeClass value, Args... args){ // Compile test to ensure indexing static_assert(index < NbAttributesPerParticle, "Index to get attributes is out of scope."); // insert the value @@ -90,10 +90,10 @@ protected: * add multiples attributes from arrays */ template<int index, typename... Args> - void addParticleValueS(const int insertPosition, const int nbParts, const AttributeClass* value, Args... args){ + void addParticleValueS(const FSize insertPosition, const FSize nbParts, const AttributeClass* value, Args... args){ // Compile test to ensure indexing static_assert(index < NbAttributesPerParticle, "Index to get attributes is out of scope."); - for(int idxPart = 0; idxPart<nbParts ; ++idxPart){ + for(FSize idxPart = 0; idxPart<nbParts ; ++idxPart){ // insert the value attributes[index][insertPosition+idxPart] = value[idxPart]; // Continue for reamining values @@ -109,8 +109,8 @@ protected: void increaseSizeIfNeeded(FSize sizeInput = 1){ if( nbParticles+(sizeInput-1) >= allocatedParticles ){ // allocate memory - const int moduloParticlesNumber = (MemoryAlignement/sizeof(FReal)); - allocatedParticles = (FMath::Max(DefaultNbParticles,int(FReal(nbParticles+sizeInput)*1.5)) + moduloParticlesNumber - 1) & ~(moduloParticlesNumber-1); + const FSize moduloParticlesNumber = (MemoryAlignement/sizeof(FReal)); + allocatedParticles = (FMath::Max(DefaultNbParticles,FSize(FReal(nbParticles+sizeInput)*1.5)) + moduloParticlesNumber - 1) & ~(moduloParticlesNumber-1); // init with 0 const size_t allocatedBytes = (sizeof(FReal)*3 + sizeof(AttributeClass)*NbAttributesPerParticle)*allocatedParticles; FReal* newData = reinterpret_cast<FReal*>(FAlignedMemory::AllocateBytes<MemoryAlignement>(allocatedBytes)); @@ -158,7 +158,7 @@ public: * @brief getNbParticles * @return the number of particles */ - int getNbParticles() const{ + FSize getNbParticles() const{ return nbParticles; } /** @@ -232,10 +232,10 @@ public: */ template<typename... Args> void pushArray(const FPoint<FReal> * inParticlePosition, FSize numberOfParts, Args... args){ - const int positionToInsert = nbParticles; + const FSize positionToInsert = nbParticles; //Tests if enough space increaseSizeIfNeeded(numberOfParts); - for(int idxPart = 0; idxPart<numberOfParts ; ++idxPart){ + for(FSize idxPart = 0; idxPart<numberOfParts ; ++idxPart){ // insert particle data positions[0][positionToInsert + idxPart] = inParticlePosition[idxPart].getX(); positions[1][positionToInsert + idxPart] = inParticlePosition[idxPart].getY(); @@ -322,10 +322,10 @@ public: * indexesToRemove must be sorted * it removes all the particles at position indexesToRemove */ - void removeParticles(const int indexesToRemove[], const int nbParticlesToRemove){ - int offset = 1; - int idxIndexes = 1; - int idxIns = indexesToRemove[0] + 1; + void removeParticles(const FSize indexesToRemove[], const FSize nbParticlesToRemove){ + FSize offset = 1; + FSize idxIndexes = 1; + FSize idxIns = indexesToRemove[0] + 1; for( ; idxIns < nbParticles && idxIndexes < nbParticlesToRemove ; ++idxIns){ if( idxIns == indexesToRemove[idxIndexes] ){ idxIndexes += 1; @@ -362,7 +362,7 @@ public: return reinterpret_cast<AttributeClass*>(positions[2] + allocatedParticles); } - int getLeadingRawData() const { + FSize getLeadingRawData() const { return allocatedParticles; } @@ -370,8 +370,8 @@ public: ///////////////////////////////////////////////////// /** The size to send a leaf */ - int getSavedSize() const{ - return int(sizeof(nbParticles) + nbParticles * (3 * sizeof(FReal) + NbAttributesPerParticle * sizeof(AttributeClass))); + FSize getSavedSize() const{ + return FSize(sizeof(nbParticles) + nbParticles * (3 * sizeof(FReal) + NbAttributesPerParticle * sizeof(AttributeClass))); } /** Save the current cell in a buffer */ @@ -391,7 +391,7 @@ public: buffer >> nbParticles; if( nbParticles >= allocatedParticles ){ // allocate memory - const int moduloParticlesNumber = (MemoryAlignement/sizeof(FReal)); + const FSize moduloParticlesNumber = (MemoryAlignement/sizeof(FReal)); allocatedParticles = (nbParticles + moduloParticlesNumber - 1) & ~(moduloParticlesNumber-1); // init with 0 const size_t allocatedBytes = (sizeof(FReal)*3 + sizeof(AttributeClass)*NbAttributesPerParticle)*allocatedParticles; diff --git a/Src/Components/FSimpleLeaf.hpp b/Src/Components/FSimpleLeaf.hpp index 7f382146e..7913a4c35 100644 --- a/Src/Components/FSimpleLeaf.hpp +++ b/Src/Components/FSimpleLeaf.hpp @@ -51,7 +51,7 @@ public: * and the other parameters given by the user */ template<typename... Args> - void pushArray(const FPoint<FReal>* inParticlePosition, int numberOfParts, Args ... args){ + void pushArray(const FPoint<FReal>* inParticlePosition, FSize numberOfParts, Args ... args){ // We pass every thing to the container and let it manage this->particles.pushArray(inParticlePosition,numberOfParts, args...); } diff --git a/Src/Components/FTestCell.hpp b/Src/Components/FTestCell.hpp index 6e922fe92..527ff7a74 100644 --- a/Src/Components/FTestCell.hpp +++ b/Src/Components/FTestCell.hpp @@ -76,8 +76,8 @@ public: buffer >> dataDown >> dataUp; } - int getSavedSize() const { - return int(sizeof(long long int))*2 + FBasicCell::getSavedSize(); + FSize getSavedSize() const { + return FSize(sizeof(long long int))*2 + FBasicCell::getSavedSize(); } ///////////////////////////////////////////////// diff --git a/Src/Components/FTestKernels.hpp b/Src/Components/FTestKernels.hpp index c705f0a1b..5e3533aa5 100644 --- a/Src/Components/FTestKernels.hpp +++ b/Src/Components/FTestKernels.hpp @@ -87,7 +87,7 @@ public: void L2P(const CellClass* const local, ContainerClass*const particles){ // The particles is impacted by the parent cell long long int*const particlesAttributes = particles->getDataDown(); - for(int idxPart = 0 ; idxPart < particles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < particles->getNbParticles() ; ++idxPart){ particlesAttributes[idxPart] += local->getDataDown(); } } @@ -109,7 +109,7 @@ public: } long long int*const particlesAttributes = targets->getDataDown(); - for(int idxPart = 0 ; idxPart < targets->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < targets->getNbParticles() ; ++idxPart){ particlesAttributes[idxPart] += inc; } } @@ -127,7 +127,7 @@ public: } long long int*const particlesAttributes = targets->getDataDown(); - for(int idxPart = 0 ; idxPart < targets->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < targets->getNbParticles() ; ++idxPart){ particlesAttributes[idxPart] += inc; } } @@ -183,7 +183,7 @@ void ValidateFMMAlgo(OctreeClass* const tree){ do{ const bool isUsingTsm = (octreeIterator.getCurrentListTargets() != octreeIterator.getCurrentListSrc()); const long long int* dataDown = octreeIterator.getCurrentListTargets()->getDataDown(); - for(int idxPart = 0 ; idxPart < octreeIterator.getCurrentListTargets()->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < octreeIterator.getCurrentListTargets()->getNbParticles() ; ++idxPart){ if( (!isUsingTsm && dataDown[idxPart] != NbPart - 1) || (isUsingTsm && dataDown[idxPart] != NbPart) ){ std::cout << "Problem L2P + P2P : " << dataDown[idxPart] << ", " << diff --git a/Src/Containers/FAbstractBuffer.hpp b/Src/Containers/FAbstractBuffer.hpp index 2dfc43f0d..b3a37167a 100644 --- a/Src/Containers/FAbstractBuffer.hpp +++ b/Src/Containers/FAbstractBuffer.hpp @@ -27,9 +27,9 @@ public: virtual char* data() = 0; virtual const char* data() const = 0; - virtual int getSize() const = 0; - virtual void seek(const int inIndex) = 0; - virtual int tell() const = 0; + virtual FSize getSize() const = 0; + virtual void seek(const FSize inIndex) = 0; + virtual FSize tell() const = 0; template <class ClassType> ClassType getValue(){ @@ -41,7 +41,7 @@ public: static_assert(sizeof(ClassType) == 0, "Your Buffer should implement fillValue."); } template <class ClassType> - void fillArray(ClassType* const , const int ){ + void fillArray(ClassType* const , const FSize ){ static_assert(sizeof(ClassType) == 0, "Your Buffer should implement fillArray."); } template <class ClassType> @@ -63,7 +63,7 @@ public: virtual char* data() = 0; virtual const char* data() const = 0; - virtual int getSize() const = 0; + virtual FSize getSize() const = 0; virtual void reset() = 0; template <class ClassType> @@ -71,11 +71,11 @@ public: static_assert(sizeof(ClassType) == 0, "Your Buffer should implement write."); } template <class ClassType> - void writeAt(const int position, const ClassType& object){ + void writeAt(const FSize position, const ClassType& object){ static_assert(sizeof(ClassType) == 0, "Your Buffer should implement writeAt."); } template <class ClassType> - void write(const ClassType* const objects, const int inSize){ + void write(const ClassType* const objects, const FSize inSize){ static_assert(sizeof(ClassType) == 0, "Your Buffer should implement write."); } template <class ClassType> diff --git a/Src/Containers/FBufferReader.hpp b/Src/Containers/FBufferReader.hpp index 15041f274..a948b4af1 100644 --- a/Src/Containers/FBufferReader.hpp +++ b/Src/Containers/FBufferReader.hpp @@ -28,47 +28,47 @@ */ class FBufferReader : public FAbstractBufferReader { FVector<char> buffer; //< The memory buffer - int index; //< The current index reading position + FSize index; //< The current index reading position public: /** Construct with a memory size init to 0 */ - explicit FBufferReader(const int inCapacity = 0) : buffer(inCapacity), index(0) { + explicit FBufferReader(const FSize inCapacity = 0) : buffer(inCapacity), index(0) { if(inCapacity){ reserve(inCapacity); } } /** Destructor */ - virtual ~FBufferReader(){ + virtual ~FBufferReader() override { } /** Get the memory area */ - char* data(){ + char* data() override { return buffer.data(); } /** Get the memory area */ - const char* data() const { + const char* data() const override { return buffer.data(); } /** Size of the meomry initialzed */ - int getSize() const{ + FSize getSize() const override { return buffer.getSize(); } /** Move the read index to a position */ - void seek(const int inIndex){ + void seek(const FSize inIndex) override { index = inIndex; } /** Get the read position */ - int tell() const { + FSize tell() const override { return index; } /** Reset and allocate nbBytes memory filled with 0 */ - void reserve(const int nbBytes){ + void reserve(const FSize nbBytes){ reset(); buffer.set( 0, nbBytes); } @@ -83,7 +83,7 @@ public: template <class ClassType> ClassType getValue(){ ClassType value = (*reinterpret_cast<ClassType*>(&buffer[index])); - index += int(sizeof(ClassType)); + index += FSize(sizeof(ClassType)); return value; } @@ -91,14 +91,14 @@ public: template <class ClassType> void fillValue(ClassType* const inValue){ (*inValue) = (*reinterpret_cast<ClassType*>(&buffer[index])); - index += int(sizeof(ClassType)); + index += FSize(sizeof(ClassType)); } /** Fill one/many value(s) with memcpy */ template <class ClassType> - void fillArray(ClassType* const inArray, const int inSize){ + void fillArray(ClassType* const inArray, const FSize inSize){ memcpy( inArray, &buffer[index], sizeof(ClassType) * inSize); - index += int(sizeof(ClassType) * inSize); + index += FSize(sizeof(ClassType) * inSize); } /** Same as fillValue */ diff --git a/Src/Containers/FBufferWriter.hpp b/Src/Containers/FBufferWriter.hpp index 17fb48e57..f44b9b482 100644 --- a/Src/Containers/FBufferWriter.hpp +++ b/Src/Containers/FBufferWriter.hpp @@ -32,7 +32,7 @@ private: public: /** Constructor with a default capacity of 512 bytes */ - explicit FBufferWriter(const int inCapacity = 512) : buffer(inCapacity) { + explicit FBufferWriter(const FSize inCapacity = 512) : buffer(inCapacity) { } /** Destructor */ @@ -50,26 +50,26 @@ public: } /** Get the filled space */ - int getSize() const { + FSize getSize() const { return buffer.getSize(); } /** Write data by mem cpy */ template <class ClassType> void write(const ClassType& object){ - buffer.memocopy(reinterpret_cast<const char*>(&object), int(sizeof(ClassType))); + buffer.memocopy(reinterpret_cast<const char*>(&object), FSize(sizeof(ClassType))); } /** Write back, position + sizeof(object) has to be < size */ template <class ClassType> - void writeAt(const int position, const ClassType& object){ + void writeAt(const FSize position, const ClassType& object){ (*reinterpret_cast<ClassType*>(&buffer[position])) = object; } /** Write an array */ template <class ClassType> - void write(const ClassType* const objects, const int inSize){ - buffer.memocopy(reinterpret_cast<const char*>(objects), int(sizeof(ClassType)) * inSize); + void write(const ClassType* const objects, const FSize inSize){ + buffer.memocopy(reinterpret_cast<const char*>(objects), FSize(sizeof(ClassType)) * inSize); } /** Equivalent to write */ diff --git a/Src/Containers/FMpiBufferReader.hpp b/Src/Containers/FMpiBufferReader.hpp index 82ed256e9..8382985c8 100644 --- a/Src/Containers/FMpiBufferReader.hpp +++ b/Src/Containers/FMpiBufferReader.hpp @@ -30,13 +30,13 @@ */ class FMpiBufferReader : public FAbstractBufferReader { MPI_Comm comm; //< Communicator needed by MPI_Pack functions - int arrayCapacity; //< Allocated space + FSize arrayCapacity; //< Allocated space std::unique_ptr<char[]> array; //< Allocated Array - int currentIndex; + FSize currentIndex; public : /*Constructor with a default arrayCapacity of 512 bytes */ - explicit FMpiBufferReader(const MPI_Comm inComm = MPI_COMM_WORLD, const int inDefaultCapacity = 512): + explicit FMpiBufferReader(const MPI_Comm inComm = MPI_COMM_WORLD, const FSize inDefaultCapacity = 512): comm(inComm), arrayCapacity(inDefaultCapacity), array(new char[inDefaultCapacity]), @@ -50,7 +50,7 @@ public : } /** To change the capacity (but reset the head to 0) */ - void cleanAndResize(const int newCapacity){ + void cleanAndResize(const FSize newCapacity){ if(newCapacity != arrayCapacity){ arrayCapacity = newCapacity; array.reset(new char[newCapacity]); @@ -64,71 +64,79 @@ public : } /** Get allocated memory pointer */ - char* data(){ + char* data() override { return array.get(); } /** Get allocated memory pointer */ - const char* data() const { + const char* data() const override { return array.get(); } /** get the filled space */ - int getSize() const{ + FSize getSize() const override { return currentIndex; } /** Size of the memory initialized */ - int getCapacity() const{ + FSize getCapacity() const{ return arrayCapacity; } /** Move the read index to a position */ - void seek(const int inIndex){ - - FAssertLF(inIndex <= arrayCapacity, "FMpiBufferReader :: Aborting :: Can't move index because buffer isn't long enough ",inIndex," ",arrayCapacity); + void seek(const FSize inIndex) override { + FAssertLF(inIndex <= arrayCapacity, "FMpiBufferReader :: Aborting :: Can't move index because buffer isn't long enough ",inIndex," ",arrayCapacity); currentIndex = inIndex; } /** Get the read position */ - int tell() const { + FSize tell() const override { return currentIndex; } /** Get a value with memory cast */ template <class ClassType> ClassType getValue(){ + FAssertLF(arrayCapacity < std::numeric_limits<int>::max()); + FAssertLF(currentIndex < std::numeric_limits<int>::max()); + int previousIndex = int(currentIndex); ClassType value; - int previousIndex = currentIndex; - seek(int(sizeof(value) + previousIndex)); - FMpi::Assert(MPI_Unpack(array.get(),arrayCapacity,&previousIndex,&value,1,FMpi::GetType(value),comm), __LINE__); + FMpi::Assert(MPI_Unpack(array.get(),int(arrayCapacity),&previousIndex,&value,1,FMpi::GetType(value),comm), __LINE__); + seek(FSize(sizeof(value) + previousIndex)); return value; } /** Get a value with memory cast at a specified index */ template <class ClassType> - ClassType getValue(const int ind){ + ClassType getValue(const FSize ind){ ClassType value; - int previousIndex = ind; - seek(int(sizeof(value)+ind)); - FMpi::Assert(MPI_Unpack(array.get(),arrayCapacity,&previousIndex,&value,1,FMpi::GetType(value),comm), __LINE__); + FAssertLF(arrayCapacity < std::numeric_limits<int>::max()); + FAssertLF(ind < std::numeric_limits<int>::max()); + int previousIndex = int(ind); + FMpi::Assert(MPI_Unpack(array.get(),int(arrayCapacity),&previousIndex,&value,1,FMpi::GetType(value),comm), __LINE__); + seek(FSize(sizeof(value)+ind)); return value; } /** Fill a value with memory cast */ template <class ClassType> void fillValue(ClassType* const inValue){ - int previousIndex = currentIndex; - seek(int(sizeof(ClassType) + previousIndex)); - FMpi::Assert(MPI_Unpack(array.get(),arrayCapacity,&previousIndex,inValue,1,FMpi::GetType(*inValue),comm), __LINE__); + FAssertLF(arrayCapacity < std::numeric_limits<int>::max()); + FAssertLF(currentIndex < std::numeric_limits<int>::max()); + int previousIndex = int(currentIndex); + FMpi::Assert(MPI_Unpack(array.get(),int(arrayCapacity),&previousIndex,inValue,1,FMpi::GetType(*inValue),comm), __LINE__); + seek(FSize(sizeof(ClassType) + previousIndex)); } /** Fill one/many value(s) with memcpy */ template <class ClassType> - void fillArray(ClassType* const inArray, const int inSize){ - int previousIndex = currentIndex; - seek(int(sizeof(ClassType) * inSize + previousIndex)); - FMpi::Assert(MPI_Unpack(array.get(),arrayCapacity,&previousIndex,inArray,inSize,FMpi::GetType(*inArray),comm), __LINE__); + void fillArray(ClassType* const inArray, const FSize inSize){ + FAssertLF(arrayCapacity < std::numeric_limits<int>::max()); + FAssertLF(currentIndex < std::numeric_limits<int>::max()); + FAssertLF(inSize < std::numeric_limits<int>::max()); + int previousIndex = int(currentIndex); + FMpi::Assert(MPI_Unpack(array.get(),int(arrayCapacity),&previousIndex,inArray,int(inSize),FMpi::GetType(*inArray),comm), __LINE__); + seek(FSize(sizeof(ClassType) * inSize + previousIndex)); } /** Same as fillValue */ diff --git a/Src/Containers/FMpiBufferWriter.hpp b/Src/Containers/FMpiBufferWriter.hpp index 6d3eb4333..1e5a29597 100644 --- a/Src/Containers/FMpiBufferWriter.hpp +++ b/Src/Containers/FMpiBufferWriter.hpp @@ -30,14 +30,14 @@ */ class FMpiBufferWriter : public FAbstractBufferWriter { MPI_Comm mpiComm; //< Communicator needed by MPI_Pack functions - int arrayCapacity; //< Allocated Space + FSize arrayCapacity; //< Allocated Space std::unique_ptr<char[]> array; //< Allocated Array - int currentIndex; //< Currently filled space + FSize currentIndex; //< Currently filled space /** Test and exit if not enought space */ void expandIfNeeded(const size_t requestedSpace) { - if( arrayCapacity < int(currentIndex + requestedSpace) ){ - arrayCapacity = int(double(currentIndex + requestedSpace + 1) * 1.5); + if( arrayCapacity < FSize(currentIndex + requestedSpace) ){ + arrayCapacity = FSize(double(currentIndex + requestedSpace + 1) * 1.5); char* arrayTmp = new char[arrayCapacity]; memcpy(arrayTmp, array.get(), sizeof(char)*currentIndex); array.reset(arrayTmp); @@ -46,7 +46,7 @@ class FMpiBufferWriter : public FAbstractBufferWriter { public: /** Constructor with a default arrayCapacity of 512 bytes */ - explicit FMpiBufferWriter(const MPI_Comm inComm, const int inDefaultCapacity = 1024): + explicit FMpiBufferWriter(const MPI_Comm inComm, const FSize inDefaultCapacity = 1024): mpiComm(inComm), arrayCapacity(inDefaultCapacity), array(new char[inDefaultCapacity]), @@ -60,7 +60,7 @@ public: } /** To change the capacity (but reset the head to 0 if size if lower) */ - void resize(const int newCapacity){ + void resize(const FSize newCapacity){ if(newCapacity != arrayCapacity){ arrayCapacity = newCapacity; char* arrayTmp = new char[arrayCapacity]; @@ -75,22 +75,22 @@ public: } /** Get allocated memory pointer */ - char* data(){ + char* data() override { return array.get(); } /** Get allocated memory pointer */ - const char* data() const { + const char* data() const override { return array.get(); } /** Get the filled space */ - int getSize() const { + FSize getSize() const override { return currentIndex; } /** Get the allocated space */ - int getCapacity() const { + FSize getCapacity() const { return arrayCapacity; } @@ -98,7 +98,10 @@ public: template <class ClassType> void write(const ClassType& object){ expandIfNeeded(sizeof(ClassType)); - FMpi::Assert(MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), arrayCapacity, ¤tIndex, mpiComm), __LINE__); + FAssertLF(arrayCapacity < std::numeric_limits<int>::max()); + int intCurrentIndex = int(currentIndex); + FMpi::Assert(MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), int(arrayCapacity), &intCurrentIndex, mpiComm), __LINE__); + currentIndex = intCurrentIndex; } /** @@ -107,24 +110,33 @@ public: template <class ClassType> void write(const ClassType&& object){ expandIfNeeded(sizeof(ClassType)); - FMpi::Assert(MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), arrayCapacity, ¤tIndex, mpiComm), __LINE__); + FAssertLF(arrayCapacity < std::numeric_limits<int>::max()); + int intCurrentIndex = int(currentIndex); + FMpi::Assert(MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), int(arrayCapacity), &intCurrentIndex, mpiComm), __LINE__); + currentIndex = intCurrentIndex; } /** Write back, position + sizeof(object) has to be < size */ template <class ClassType> - void writeAt(const int position, const ClassType& object){ - FAssertLF(int(position + sizeof(ClassType)) <= currentIndex) - int noConstPosition = position; - FMpi::Assert(MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), arrayCapacity, &noConstPosition, mpiComm), __LINE__); + void writeAt(const FSize position, const ClassType& object){ + FAssertLF(FSize(position + sizeof(ClassType)) <= currentIndex); + FAssertLF(arrayCapacity < std::numeric_limits<int>::max()); + FAssertLF(position < std::numeric_limits<int>::max()); + int noConstPosition = int(position); + FMpi::Assert(MPI_Pack(const_cast<ClassType*>(&object), 1, FMpi::GetType(object), array.get(), int(arrayCapacity), &noConstPosition, mpiComm), __LINE__); } /** Write an array * Warning : inSize is a number of ClassType object to write, not a size in bytes */ template <class ClassType> - void write(const ClassType* const objects, const int inSize){ + void write(const ClassType* const objects, const FSize inSize){ expandIfNeeded(sizeof(ClassType) * inSize); - FMpi::Assert(MPI_Pack( const_cast<ClassType*>(objects), inSize, FMpi::GetType(*objects), array.get(), arrayCapacity, ¤tIndex, mpiComm), __LINE__); + FAssertLF(arrayCapacity < std::numeric_limits<int>::max()); + FAssertLF(inSize < std::numeric_limits<int>::max()); + int intCurrentIndex = int(currentIndex); + FMpi::Assert(MPI_Pack( const_cast<ClassType*>(objects), int(inSize), FMpi::GetType(*objects), array.get(), int(arrayCapacity), &intCurrentIndex, mpiComm), __LINE__); + currentIndex = intCurrentIndex; } /** Equivalent to write */ @@ -135,7 +147,7 @@ public: } /** Reset the writing index, but do not change the arrayCapacity */ - void reset(){ + void reset() override { currentIndex = 0; } }; diff --git a/Src/Containers/FTreeCoordinate.hpp b/Src/Containers/FTreeCoordinate.hpp index 04b772bba..f84fc8e1e 100644 --- a/Src/Containers/FTreeCoordinate.hpp +++ b/Src/Containers/FTreeCoordinate.hpp @@ -259,8 +259,8 @@ public: } /** To know the size when we save it */ - int getSavedSize() const { - return int(sizeof(data[0]) + sizeof(data[1]) + sizeof(data[2])); + FSize getSavedSize() const { + return FSize(sizeof(data[0]) + sizeof(data[1]) + sizeof(data[2])); } diff --git a/Src/Containers/FVector.hpp b/Src/Containers/FVector.hpp index a4982cbb2..dec190002 100644 --- a/Src/Containers/FVector.hpp +++ b/Src/Containers/FVector.hpp @@ -34,12 +34,12 @@ template<class ObjectType> class FVector { protected: - static const int DefaultSize = 10; /**< Default size */ + static const FSize DefaultSize = 10; /**< Default size */ ObjectType* array; /**< memory area*/ - int capacity; /**< memory capacity, the size of array */ - int index; /**< index in array, the current position to insert */ + FSize capacity; /**< memory capacity, the size of array */ + FSize index; /**< index in array, the current position to insert */ public: typedef ObjectType ValueType; /**< data type of data in FVector */ @@ -56,7 +56,7 @@ public: * @brief Constructor * @param inCapacity the memory to allocate */ - explicit FVector(const int inCapacity): array(nullptr), capacity(inCapacity), index(0) { + explicit FVector(const FSize inCapacity): array(nullptr), capacity(inCapacity), index(0) { if( inCapacity ){ array = reinterpret_cast< ObjectType* >( new char[sizeof(ObjectType) * inCapacity]); } @@ -71,7 +71,7 @@ public: if( other.capacity ){ array = reinterpret_cast< ObjectType* >( new char[sizeof(ObjectType) * other.capacity]); // Copy each element - for(int idx = 0 ; idx < other.index ; ++idx){ + for(FSize idx = 0 ; idx < other.index ; ++idx){ new((void*)&array[idx]) ObjectType(other.array[idx]); } } @@ -105,12 +105,12 @@ public: // alloc bigger if needed if(capacity < other.getSize()){ delete [] reinterpret_cast< char* >(array); - capacity = int(other.getSize() * 1.5); + capacity = FSize(double(other.getSize()) * 1.5); array = reinterpret_cast< ObjectType* >( new char[sizeof(ObjectType) * capacity]); } index = other.index; - for(int idx = 0 ; idx < other.index ; ++idx){ + for(FSize idx = 0 ; idx < other.index ; ++idx){ new((void*)&array[idx]) ObjectType(other.array[idx]); } } @@ -147,7 +147,7 @@ public: * @return the buffer capacity * The capacity is the current memory size allocated. */ - int getCapacity() const{ + FSize getCapacity() const{ return capacity; } @@ -156,7 +156,7 @@ public: *@param inCapacity to change the capacity * If capacity given is lower than size elements after capacity are removed */ - void setCapacity(const int inCapacity) { + void setCapacity(const FSize inCapacity) { if( inCapacity != capacity ){ while(inCapacity < index){ (&array[--index])->~ObjectType(); @@ -164,7 +164,7 @@ public: // Copy elements ObjectType* const nextArray = reinterpret_cast< ObjectType* >( inCapacity ? new char[sizeof(ObjectType) * inCapacity] : nullptr); - for(int idx = 0 ; idx < index ; ++idx){ + for(FSize idx = 0 ; idx < index ; ++idx){ new((void*)&nextArray[idx]) ObjectType(std::move(array[idx])); (&array[idx])->~ObjectType(); } @@ -177,10 +177,10 @@ public: /** Resize the vector (and change the capacity if needed) */ template <typename... Args> - void resize(const int newSize, Args... args){ + void resize(const FSize newSize, Args... args){ if(index < newSize){ if(capacity < newSize){ - setCapacity(int(newSize*1.5)); + setCapacity(FSize(double(newSize)*1.5)); } while(index != newSize){ new((void*)&array[index]) ObjectType(args...); @@ -221,7 +221,7 @@ public: * @return The number of element added into the vector * This is not the capcity */ - int getSize() const{ + FSize getSize() const{ return index; } @@ -241,7 +241,7 @@ public: void push( const ObjectType & inValue ){ // if needed, increase the vector if( index == capacity ){ - setCapacity(int((capacity+1) * 1.5)); + setCapacity(static_cast<FSize>(double(capacity+1) * 1.5)); } // add the new element new((void*)&array[index++]) ObjectType(inValue); @@ -254,7 +254,7 @@ public: void pushNew(Args... args){ // if needed, increase the vector if( index == capacity ){ - setCapacity(int((capacity+1) * 1.5)); + setCapacity(static_cast<FSize>(double(capacity+1) * 1.5)); } // add the new element new((void*)&array[index++]) ObjectType(args...); @@ -265,13 +265,13 @@ public: * @param inValue the new value * @param inRepeat the number of time the value is inserted */ - void set( const ObjectType & inValue, const int inRepeat){ + void set( const ObjectType & inValue, const FSize inRepeat){ // if needed, increase the vector if( capacity < index + inRepeat ){ - setCapacity(int((index + inRepeat) * 1.5)); + setCapacity(FSize(double(index + inRepeat) * 1.5)); } // add the new element - for( int idx = 0 ; idx < inRepeat ; ++idx){ + for( FSize idx = 0 ; idx < inRepeat ; ++idx){ new((void*)&array[index++]) ObjectType(inValue); } } @@ -281,7 +281,7 @@ public: *@param inPosition the query position *@return the value */ - ObjectType& operator[](const int inPosition ) { + ObjectType& operator[](const FSize inPosition ) { return array[inPosition]; } @@ -290,7 +290,7 @@ public: * @param inPosition the query position * @return the value */ - const ObjectType& operator[](const int inPosition ) const { + const ObjectType& operator[](const FSize inPosition ) const { return array[inPosition]; } @@ -312,13 +312,13 @@ public: * @param inArray the array to copy values * @param inSize the size of the array */ - void extractValues(const ObjectType*const inArray, const int inSize){ + void extractValues(const ObjectType*const inArray, const FSize inSize){ // Check available memory if(capacity < index + inSize){ - setCapacity( int((index + inSize) * 1.5) ); + setCapacity( FSize(double(index + inSize) * 1.5) ); } // Copy values - for(int idx = 0 ; idx < inSize ; ++idx){ + for(FSize idx = 0 ; idx < inSize ; ++idx){ new((void*)&array[index++]) ObjectType(inArray[idx]); } } @@ -327,10 +327,10 @@ public: * @param inArray the array to copie values * @param inSize the size of the array */ - void memocopy(const ObjectType*const inArray, const int inSize){ + void memocopy(const ObjectType*const inArray, const FSize inSize){ // Check available memory if(capacity < index + inSize){ - setCapacity( int((index + inSize) * 1.5) ); + setCapacity( FSize(double(index + inSize) * 1.5) ); } // Copy values memcpy(&array[index], inArray, inSize * sizeof(ObjectType)); @@ -338,8 +338,8 @@ public: } /** Remove a values by shifting all the next values */ - void removeOne(const int idxToRemove){ - for(int idxMove = idxToRemove + 1; idxMove < index ; ++idxMove){ + void removeOne(const FSize idxToRemove){ + for(FSize idxMove = idxToRemove + 1; idxMove < index ; ++idxMove){ array[idxMove - 1] = array[idxMove]; } index -= 1; @@ -347,7 +347,7 @@ public: /** This class is a basic iterator * <code> - * typename FVector<int>::ConstBasicIterator iter(myVector);<br> + * typename FVector<FSize>::ConstBasicIterator iter(myVector);<br> * while( iter.hasNotFinished() ){<br> * printf("%d\n",iter.data());<br> * iter.gotoNext();<br> @@ -357,7 +357,7 @@ public: class BasicIterator { protected: FVector* const vector; /**< the vector to work on*/ - int index; /**< the current node*/ + FSize index; /**< the current node*/ public: /** Empty destructor */ @@ -398,7 +398,7 @@ public: */ void remove(){ if( hasNotFinished() ){ - for(int idxMove = index + 1; idxMove < vector->index ; ++idxMove){ + for(FSize idxMove = index + 1; idxMove < vector->index ; ++idxMove){ vector->array[idxMove - 1] = vector->array[idxMove]; } vector->index -= 1; @@ -414,7 +414,7 @@ public: class ConstBasicIterator { protected: const FVector* const vector; /**< the vector to work on*/ - int index; /**< the current node*/ + FSize index; /**< the current node*/ public: /** Empty destructor */ diff --git a/Src/Core/FFmmAlgorithmPeriodic.hpp b/Src/Core/FFmmAlgorithmPeriodic.hpp index 119a6d3e1..e82dfce6a 100644 --- a/Src/Core/FFmmAlgorithmPeriodic.hpp +++ b/Src/Core/FFmmAlgorithmPeriodic.hpp @@ -358,7 +358,7 @@ protected: FReal*const positionsY = periodicNeighbors[idxNeig]->getWPositions()[1]; FReal*const positionsZ = periodicNeighbors[idxNeig]->getWPositions()[2]; - for(int idxPart = 0; idxPart < periodicNeighbors[idxNeig]->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0; idxPart < periodicNeighbors[idxNeig]->getNbParticles() ; ++idxPart){ positionsX[idxPart] += boxWidth * FReal(offsets[idxNeig].getX()); positionsY[idxPart] += boxWidth * FReal(offsets[idxNeig].getY()); positionsZ[idxPart] += boxWidth * FReal(offsets[idxNeig].getZ()); @@ -377,7 +377,7 @@ protected: FReal*const positionsY = periodicNeighbors[idxNeig]->getWPositions()[1]; FReal*const positionsZ = periodicNeighbors[idxNeig]->getWPositions()[2]; - for(int idxPart = 0; idxPart < periodicNeighbors[idxNeig]->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0; idxPart < periodicNeighbors[idxNeig]->getNbParticles() ; ++idxPart){ positionsX[idxPart] -= boxWidth * FReal(offsets[idxNeig].getX()); positionsY[idxPart] -= boxWidth * FReal(offsets[idxNeig].getY()); positionsZ[idxPart] -= boxWidth * FReal(offsets[idxNeig].getZ()); diff --git a/Src/Core/FFmmAlgorithmTask.hpp b/Src/Core/FFmmAlgorithmTask.hpp index 23a5e69e3..010c30a85 100644 --- a/Src/Core/FFmmAlgorithmTask.hpp +++ b/Src/Core/FFmmAlgorithmTask.hpp @@ -330,8 +330,8 @@ protected: FLOG( computationCounter.tic() ); for( int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){ - const int nbLeaf = shapes[idxShape].getSize(); - for(int iterLeaf = 0 ; iterLeaf < nbLeaf ; ++iterLeaf ){ + const FSize nbLeaf = (shapes[idxShape].getSize()); + for(FSize iterLeaf = 0 ; iterLeaf < nbLeaf ; ++iterLeaf ){ typename OctreeClass::Iterator toWork = shapes[idxShape][iterLeaf]; #pragma omp task firstprivate(neighbors, toWork, l2pEnabled, p2pEnabled) { diff --git a/Src/Core/FFmmAlgorithmThreadProc.hpp b/Src/Core/FFmmAlgorithmThreadProc.hpp index 6df2d0c05..e36e3a733 100644 --- a/Src/Core/FFmmAlgorithmThreadProc.hpp +++ b/Src/Core/FFmmAlgorithmThreadProc.hpp @@ -356,10 +356,10 @@ protected: MPI_Request requestsSize[8]; MPI_Status statusSize[8]; - int bufferSize; + FSize bufferSize; FMpiBufferWriter sendBuffer(comm.getComm(), 1);// Max = 1 + sizeof(cell)*7 std::unique_ptr<FMpiBufferReader[]> recvBuffer(new FMpiBufferReader[7]); - int recvBufferSize[7]; + FSize recvBufferSize[7]; CellClass recvBufferCells[7]; // The first proc that send to me a cell @@ -447,7 +447,8 @@ protected: bufferSize = sendBuffer.getSize(); MPI_Isend(&bufferSize, 1, MPI_INT, currentProcIdToSendTo, FMpi::TagFmmM2MSize + idxLevel, comm.getComm(), &requestsSize[iterMpiRequestsSize++]); - MPI_Isend(sendBuffer.data(), sendBuffer.getSize(), MPI_PACKED, currentProcIdToSendTo, + FAssertLF(sendBuffer.getSize() < std::numeric_limits<int>::max()); + MPI_Isend(sendBuffer.data(), int(sendBuffer.getSize()), MPI_PACKED, currentProcIdToSendTo, FMpi::TagFmmM2M + idxLevel, comm.getComm(), &requests[iterMpiRequests++]); } } @@ -487,7 +488,8 @@ protected: && ( !procHasWorkAtLevel(idxLevel+1, idProcSource) || procCoversMyRightBorderCell(idxLevel, idProcSource) )){ if(procHasWorkAtLevel(idxLevel+1, idProcSource) && procCoversMyRightBorderCell(idxLevel, idProcSource)){ recvBuffer[nbProcThatSendToMe].cleanAndResize(recvBufferSize[nbProcThatSendToMe]); - MPI_Irecv(recvBuffer[nbProcThatSendToMe].data(), recvBufferSize[nbProcThatSendToMe], MPI_PACKED, + FAssertLF(recvBufferSize[nbProcThatSendToMe] < std::numeric_limits<int>::max()); + MPI_Irecv(recvBuffer[nbProcThatSendToMe].data(), int(recvBufferSize[nbProcThatSendToMe]), MPI_PACKED, idProcSource, FMpi::TagFmmM2M + idxLevel, comm.getComm(), &requests[iterMpiRequests++]); nbProcThatSendToMe += 1; FAssertLF(nbProcThatSendToMe <= 7); @@ -725,8 +727,9 @@ protected: FAssertLF(sendBuffer[idxLevel * nbProcess + idxProc]->getSize() == toSendAtProcAtLevel); + FAssertLF(sendBuffer[idxLevel * nbProcess + idxProc]->getSize() < std::numeric_limits<int>::max()); FMpi::MpiAssert( MPI_Isend( sendBuffer[idxLevel * nbProcess + idxProc]->data(), - sendBuffer[idxLevel * nbProcess + idxProc]->getSize(),MPI_PACKED, idxProc, + int(sendBuffer[idxLevel * nbProcess + idxProc]->getSize()),MPI_PACKED, idxProc, FMpi::TagLast + idxLevel, comm.getComm(), &requests[iterRequest++]) , __LINE__ ); } @@ -734,8 +737,9 @@ protected: if(toReceiveFromProcAtLevel){ recvBuffer[idxLevel * nbProcess + idxProc] = new FMpiBufferReader(comm.getComm(),int(toReceiveFromProcAtLevel)); + FAssertLF(recvBuffer[idxLevel * nbProcess + idxProc]->getCapacity() < std::numeric_limits<int>::max()); FMpi::MpiAssert( MPI_Irecv(recvBuffer[idxLevel * nbProcess + idxProc]->data(), - recvBuffer[idxLevel * nbProcess + idxProc]->getCapacity(), MPI_PACKED,idxProc, + int(recvBuffer[idxLevel * nbProcess + idxProc]->getCapacity()), MPI_PACKED,idxProc, FMpi::TagLast + idxLevel, comm.getComm(), &requests[iterRequest++]) , __LINE__ ); } } @@ -1027,8 +1031,8 @@ protected: FLOG(prepareCounter.tic()); int iterRequests = 0; int iterRequestsSize = 0; - int recvBufferSize = 0; - int sendBufferSize; + FSize recvBufferSize = 0; + FSize sendBufferSize; // Post the receive if(hasToReceive){ FMpi::MpiAssert( MPI_Irecv( &recvBufferSize, 1, MPI_INT, idxProcToReceive, @@ -1053,7 +1057,8 @@ protected: // Post the send message FMpi::MpiAssert( MPI_Isend(&sendBufferSize, 1, MPI_INT, idxProcSend, FMpi::TagFmmL2LSize + idxLevel, comm.getComm(), &requestsSize[iterRequestsSize++]), __LINE__); - FMpi::MpiAssert( MPI_Isend(sendBuffer.data(), sendBuffer.getSize(), MPI_PACKED, idxProcSend, + FAssertLF(sendBuffer.getSize() < std::numeric_limits<int>::max()); + FMpi::MpiAssert( MPI_Isend(sendBuffer.data(), int(sendBuffer.getSize()), MPI_PACKED, idxProcSend, FMpi::TagFmmL2L + idxLevel, comm.getComm(), &requests[iterRequests++]), __LINE__); // Inc and check the counter nbMessageSent += 1; @@ -1075,7 +1080,8 @@ protected: if(hasToReceive){ recvBuffer.cleanAndResize(recvBufferSize); - FMpi::MpiAssert( MPI_Irecv( recvBuffer.data(), recvBuffer.getCapacity(), MPI_PACKED, idxProcToReceive, + FAssertLF(recvBuffer.getCapacity() < std::numeric_limits<int>::max()); + FMpi::MpiAssert( MPI_Irecv( recvBuffer.data(), int(recvBuffer.getCapacity()), MPI_PACKED, idxProcToReceive, FMpi::TagFmmL2L + idxLevel, comm.getComm(), &requests[iterRequests++]), __LINE__ ); } @@ -1165,8 +1171,8 @@ protected: * let U and V be id of processes : * globalReceiveMap[U*nbProcess + V] == size of information needed by V and own by U */ - int*const globalReceiveMap = new int[nbProcess * nbProcess]; - memset(globalReceiveMap, 0, sizeof(int) * nbProcess * nbProcess); + FSize*const globalReceiveMap = new FSize[nbProcess * nbProcess]; + memset(globalReceiveMap, 0, sizeof(FSize) * nbProcess * nbProcess); FBoolArray leafsNeedOther(this->numberOfLeafs); int countNeedOther = 0; @@ -1186,8 +1192,8 @@ protected: FVector<LeafData> leafsNeedOtherData(countNeedOther); FVector<typename OctreeClass::Iterator>*const toSend = new FVector<typename OctreeClass::Iterator>[nbProcess]; - int partsToSend[nbProcess]; - memset(partsToSend, 0, sizeof(int) * nbProcess); + FSize partsToSend[nbProcess]; + memset(partsToSend, 0, sizeof(FSize) * nbProcess); #pragma omp parallel { @@ -1267,7 +1273,8 @@ protected: if(globalReceiveMap[idxProc * nbProcess + idProcess]){ //if idxProc has sth for me. //allocate buffer of right size recvBuffer[idxProc] = new FMpiBufferReader(comm.getComm(),globalReceiveMap[idxProc * nbProcess + idProcess]); - FMpi::MpiAssert( MPI_Irecv(recvBuffer[idxProc]->data(), recvBuffer[idxProc]->getCapacity(), MPI_PACKED, + FAssertLF(recvBuffer[idxProc]->getCapacity() < std::numeric_limits<int>::max()); + FMpi::MpiAssert( MPI_Irecv(recvBuffer[idxProc]->data(), int(recvBuffer[idxProc]->getCapacity()), MPI_PACKED, idxProc, FMpi::TagFmmP2P, comm.getComm(), &requests[iterRequest++]) , __LINE__ ); } } @@ -1284,7 +1291,8 @@ protected: toSend[idxProc][idxLeaf].getCurrentListSrc()->save(*sendBuffer[idxProc]); } - FMpi::MpiAssert( MPI_Isend( sendBuffer[idxProc]->data(), sendBuffer[idxProc]->getSize() , MPI_PACKED , + FAssertLF(sendBuffer[idxProc]->getSize() < std::numeric_limits<int>::max()); + FMpi::MpiAssert( MPI_Isend( sendBuffer[idxProc]->data(), int(sendBuffer[idxProc]->getSize()) , MPI_PACKED , idxProc, FMpi::TagFmmP2P, comm.getComm(), &requests[iterRequest++]) , __LINE__ ); } @@ -1428,7 +1436,8 @@ protected: MortonIndex indexesNeighbors[27]; int indexArray[26]; // Box limite - const int nbLeafToProceed = leafsNeedOtherData.getSize(); + FAssertLF(leafsNeedOtherData.getSize() < std::numeric_limits<int>::max()); + const int nbLeafToProceed = int(leafsNeedOtherData.getSize()); #pragma omp for schedule(static) for(int idxLeafs = 0 ; idxLeafs < nbLeafToProceed ; ++idxLeafs){ diff --git a/Src/Core/FFmmAlgorithmThreadProcPeriodic.hpp b/Src/Core/FFmmAlgorithmThreadProcPeriodic.hpp index c2e5e3dca..622fd17d5 100644 --- a/Src/Core/FFmmAlgorithmThreadProcPeriodic.hpp +++ b/Src/Core/FFmmAlgorithmThreadProcPeriodic.hpp @@ -397,10 +397,10 @@ protected: MPI_Request requestsSize[8]; MPI_Status statusSize[8]; - int bufferSize; + FSize bufferSize; FMpiBufferWriter sendBuffer(comm.getComm(), 1);// Max = 1 + sizeof(cell)*7 std::unique_ptr<FMpiBufferReader[]> recvBuffer(new FMpiBufferReader[7]); - int recvBufferSize[7]; + FSize recvBufferSize[7]; CellClass recvBufferCells[7]; // The first proc that send to me a cell @@ -489,7 +489,8 @@ protected: bufferSize = sendBuffer.getSize(); MPI_Isend(&bufferSize, 1, MPI_INT, currentProcIdToSendTo, FMpi::TagFmmM2MSize + idxLevel, comm.getComm(), &requestsSize[iterMpiRequestsSize++]); - MPI_Isend(sendBuffer.data(), sendBuffer.getSize(), MPI_PACKED, currentProcIdToSendTo, + FAssertLF(sendBuffer.getSize() < std::numeric_limits<int>::max()); + MPI_Isend(sendBuffer.data(), int(sendBuffer.getSize()), MPI_PACKED, currentProcIdToSendTo, FMpi::TagFmmM2M + idxLevel, comm.getComm(), &requests[iterMpiRequests++]); } } @@ -529,7 +530,8 @@ protected: && ( !procHasWorkAtLevel(idxLevel+1, idProcSource) || procCoversMyRightBorderCell(idxLevel, idProcSource) )){ if(procHasWorkAtLevel(idxLevel+1, idProcSource) && procCoversMyRightBorderCell(idxLevel, idProcSource)){ recvBuffer[nbProcThatSendToMe].cleanAndResize(recvBufferSize[nbProcThatSendToMe]); - MPI_Irecv(recvBuffer[nbProcThatSendToMe].data(), recvBufferSize[nbProcThatSendToMe], MPI_PACKED, + FAssertLF(recvBufferSize[nbProcThatSendToMe] < std::numeric_limits<int>::max()); + MPI_Irecv(recvBuffer[nbProcThatSendToMe].data(), int(recvBufferSize[nbProcThatSendToMe]), MPI_PACKED, idProcSource, FMpi::TagFmmM2M + idxLevel, comm.getComm(), &requests[iterMpiRequests++]); nbProcThatSendToMe += 1; FAssertLF(nbProcThatSendToMe <= 7); @@ -608,7 +610,7 @@ protected: for(int idxProc = 1 ; idxProc < nbProcess ; ++idxProc ){ if( procHasWorkAtLevel(1,idxProc) ){ - MPI_Irecv(&recvBufferSize[iterRequestsSize], 1, MPI_INT, idxProc, + MPI_Irecv(&recvBufferSize[iterRequestsSize], 1, FMpi::GetType(recvBufferSize[iterRequestsSize]), idxProc, FMpi::TagFmmM2MSize, comm.getComm(), &requests[iterRequestsSize]); iterRequestsSize += 1; FAssertLF(iterRequestsSize <= 7); @@ -624,7 +626,8 @@ protected: for(int idxProc = 1 ; idxProc < nbProcess ; ++idxProc ){ if( procHasWorkAtLevel(1,idxProc) ){ recvBuffer[iterRequests].cleanAndResize(recvBufferSize[iterRequests]); - MPI_Irecv(recvBuffer[iterRequests].data(), recvBufferSize[iterRequests], MPI_BYTE, idxProc, + FAssertLF(recvBufferSize[iterRequests] < std::numeric_limits<int>::max()); + MPI_Irecv(recvBuffer[iterRequests].data(), int(recvBufferSize[iterRequests]), MPI_BYTE, idxProc, FMpi::TagFmmM2M, comm.getComm(), &requests[iterRequests]); iterRequests += 1; FAssertLF(iterRequests <= 7); @@ -682,9 +685,9 @@ protected: } } sendBuffer.writeAt(0,state); - int sizeToSend = sendBuffer.getSize(); - MPI_Send(&sizeToSend, 1, MPI_INT, 0, FMpi::TagFmmM2MSize, comm.getComm()); - MPI_Send(sendBuffer.data(), sendBuffer.getSize(), MPI_BYTE, 0, FMpi::TagFmmM2M, comm.getComm()); + FSize sizeToSend = sendBuffer.getSize(); + MPI_Send(&sizeToSend, 1, FMpi::GetType(sizeToSend), 0, FMpi::TagFmmM2MSize, comm.getComm()); + MPI_Send(sendBuffer.data(), int(sendBuffer.getSize()), MPI_BYTE, 0, FMpi::TagFmmM2M, comm.getComm()); } } } @@ -841,7 +844,7 @@ protected: for(int idxProc = 0 ; idxProc < nbProcess ; ++idxProc){ const long long int toSendAtProcAtLevel = indexToSend[idxLevel * nbProcess + idxProc]; if(toSendAtProcAtLevel != 0){ - sendBuffer[idxLevel * nbProcess + idxProc] = new FMpiBufferWriter(comm.getComm(),toSendAtProcAtLevel); + sendBuffer[idxLevel * nbProcess + idxProc] = new FMpiBufferWriter(comm.getComm(),int(toSendAtProcAtLevel)); sendBuffer[idxLevel * nbProcess + idxProc]->write(int(toSend[idxLevel * nbProcess + idxProc].getSize())); @@ -853,17 +856,19 @@ protected: FAssertLF(sendBuffer[idxLevel * nbProcess + idxProc]->getSize() == toSendAtProcAtLevel); + FAssertLF(sendBuffer[idxLevel * nbProcess + idxProc]->getSize() < std::numeric_limits<int>::max()); FMpi::MpiAssert( MPI_Isend( sendBuffer[idxLevel * nbProcess + idxProc]->data(), - sendBuffer[idxLevel * nbProcess + idxProc]->getSize(),MPI_PACKED, idxProc, + int(sendBuffer[idxLevel * nbProcess + idxProc]->getSize()),MPI_PACKED, idxProc, FMpi::TagLast + idxLevel, comm.getComm(), &requests[iterRequest++]) , __LINE__ ); } const long long int toReceiveFromProcAtLevel = globalReceiveMap[(idxProc * nbProcess * OctreeHeight) + idxLevel * nbProcess + idProcess]; if(toReceiveFromProcAtLevel){ - recvBuffer[idxLevel * nbProcess + idxProc] = new FMpiBufferReader(comm.getComm(),toReceiveFromProcAtLevel); + recvBuffer[idxLevel * nbProcess + idxProc] = new FMpiBufferReader(comm.getComm(),int(toReceiveFromProcAtLevel)); + FAssertLF(recvBuffer[idxLevel * nbProcess + idxProc]->getCapacity() < std::numeric_limits<int>::max()); FMpi::MpiAssert( MPI_Irecv(recvBuffer[idxLevel * nbProcess + idxProc]->data(), - recvBuffer[idxLevel * nbProcess + idxProc]->getCapacity(), MPI_PACKED,idxProc, + int(recvBuffer[idxLevel * nbProcess + idxProc]->getCapacity()), MPI_PACKED,idxProc, FMpi::TagLast + idxLevel, comm.getComm(), &requests[iterRequest++]) , __LINE__ ); } } @@ -1106,9 +1111,10 @@ protected: // Periodic if( idProcess == 0){ rootCellFromProc.serializeDown(sendBuffer); - int sizeOfSerialization = sendBuffer.getSize(); + FAssertLF(sendBuffer.getSize() < std::numeric_limits<int>::max()); + int sizeOfSerialization = int(sendBuffer.getSize()); FMpi::MpiAssert( MPI_Bcast( &sizeOfSerialization, 1, MPI_INT, 0, comm.getComm() ), __LINE__ ); - FMpi::MpiAssert( MPI_Bcast( sendBuffer.data(), sendBuffer.getSize(), MPI_BYTE, 0, comm.getComm() ), __LINE__ ); + FMpi::MpiAssert( MPI_Bcast( sendBuffer.data(), int(sendBuffer.getSize()), MPI_BYTE, 0, comm.getComm() ), __LINE__ ); sendBuffer.reset(); } else{ @@ -1169,8 +1175,8 @@ protected: FLOG(prepareCounter.tic()); int iterRequests = 0; int iterRequestsSize = 0; - int recvBufferSize = 0; - int sendBufferSize; + FSize recvBufferSize = 0; + FSize sendBufferSize; // Post the receive if(hasToReceive){ FMpi::MpiAssert( MPI_Irecv( &recvBufferSize, 1, MPI_INT, idxProcToReceive, @@ -1195,7 +1201,8 @@ protected: // Post the send message FMpi::MpiAssert( MPI_Isend(&sendBufferSize, 1, MPI_INT, idxProcSend, FMpi::TagFmmL2LSize + idxLevel, comm.getComm(), &requestsSize[iterRequestsSize++]), __LINE__); - FMpi::MpiAssert( MPI_Isend(sendBuffer.data(), sendBuffer.getSize(), MPI_PACKED, idxProcSend, + FAssertLF(sendBuffer.getSize() < std::numeric_limits<int>::max()); + FMpi::MpiAssert( MPI_Isend(sendBuffer.data(), int(sendBuffer.getSize()), MPI_PACKED, idxProcSend, FMpi::TagFmmL2L + idxLevel, comm.getComm(), &requests[iterRequests++]), __LINE__); // Inc and check the counter nbMessageSent += 1; @@ -1216,7 +1223,9 @@ protected: } if(hasToReceive){ - FMpi::MpiAssert( MPI_Irecv( recvBuffer.data(), recvBuffer.getCapacity(), MPI_PACKED, idxProcToReceive, + recvBuffer.cleanAndResize(recvBufferSize); + FAssertLF(recvBuffer.getCapacity() < std::numeric_limits<int>::max()); + FMpi::MpiAssert( MPI_Irecv( recvBuffer.data(), int(recvBuffer.getCapacity()), MPI_PACKED, idxProcToReceive, FMpi::TagFmmL2L + idxLevel, comm.getComm(), &requests[iterRequests++]), __LINE__ ); } @@ -1306,8 +1315,8 @@ protected: * let U and V be id of processes : * globalReceiveMap[U*nbProcess + V] == size of information needed by V and own by U */ - int*const globalReceiveMap = new int[nbProcess * nbProcess]; - memset(globalReceiveMap, 0, sizeof(int) * nbProcess * nbProcess); + FSize*const globalReceiveMap = new FSize[nbProcess * nbProcess]; + memset(globalReceiveMap, 0, sizeof(FSize) * nbProcess * nbProcess); FBoolArray leafsNeedOther(this->numberOfLeafs); int countNeedOther = 0; @@ -1327,8 +1336,8 @@ protected: FVector<LeafData> leafsNeedOtherData(countNeedOther); FVector<typename OctreeClass::Iterator>*const toSend = new FVector<typename OctreeClass::Iterator>[nbProcess]; - int partsToSend[nbProcess]; - memset(partsToSend, 0, sizeof(int) * nbProcess); + FSize partsToSend[nbProcess]; + memset(partsToSend, 0, sizeof(FSize) * nbProcess); #pragma omp parallel { @@ -1410,7 +1419,8 @@ protected: if(globalReceiveMap[idxProc * nbProcess + idProcess]){ //if idxProc has sth for me. //allocate buffer of right size recvBuffer[idxProc] = new FMpiBufferReader(comm.getComm(),globalReceiveMap[idxProc * nbProcess + idProcess]); - FMpi::MpiAssert( MPI_Irecv(recvBuffer[idxProc]->data(), recvBuffer[idxProc]->getCapacity(), MPI_PACKED, + FAssertLF(recvBuffer[idxProc]->getCapacity() < std::numeric_limits<int>::max()); + FMpi::MpiAssert( MPI_Irecv(recvBuffer[idxProc]->data(), int(recvBuffer[idxProc]->getCapacity()), MPI_PACKED, idxProc, FMpi::TagFmmP2P, comm.getComm(), &requests[iterRequest++]) , __LINE__ ); } } @@ -1427,7 +1437,8 @@ protected: toSend[idxProc][idxLeaf].getCurrentListSrc()->save(*sendBuffer[idxProc]); } - FMpi::MpiAssert( MPI_Isend( sendBuffer[idxProc]->data(), sendBuffer[idxProc]->getSize() , MPI_PACKED , + FAssertLF(sendBuffer[idxProc]->getSize() < std::numeric_limits<int>::max()); + FMpi::MpiAssert( MPI_Isend( sendBuffer[idxProc]->data(), int(sendBuffer[idxProc]->getSize()) , MPI_PACKED , idxProc, FMpi::TagFmmP2P, comm.getComm(), &requests[iterRequest++]) , __LINE__ ); } @@ -1561,7 +1572,7 @@ protected: FReal*const positionsY = periodicNeighbors[idxNeig]->getWPositions()[1]; FReal*const positionsZ = periodicNeighbors[idxNeig]->getWPositions()[2]; - for(int idxPart = 0; idxPart < periodicNeighbors[idxNeig]->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0; idxPart < periodicNeighbors[idxNeig]->getNbParticles() ; ++idxPart){ positionsX[idxPart] += boxWidth * FReal(offsets[idxNeig].getX()); positionsY[idxPart] += boxWidth * FReal(offsets[idxNeig].getY()); positionsZ[idxPart] += boxWidth * FReal(offsets[idxNeig].getZ()); @@ -1578,7 +1589,7 @@ protected: FReal*const positionsY = periodicNeighbors[idxNeig]->getWPositions()[1]; FReal*const positionsZ = periodicNeighbors[idxNeig]->getWPositions()[2]; - for(int idxPart = 0; idxPart < periodicNeighbors[idxNeig]->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0; idxPart < periodicNeighbors[idxNeig]->getNbParticles() ; ++idxPart){ positionsX[idxPart] -= boxWidth * FReal(offsets[idxNeig].getX()); positionsY[idxPart] -= boxWidth * FReal(offsets[idxNeig].getY()); positionsZ[idxPart] -= boxWidth * FReal(offsets[idxNeig].getZ()); @@ -1621,7 +1632,8 @@ protected: int indexArray[26]; // Box limite const int limite = 1 << (this->OctreeHeight - 1); - const int nbLeafToProceed = leafsNeedOtherData.getSize(); + FAssertLF(leafsNeedOtherData.getSize() < std::numeric_limits<int>::max()); + const int nbLeafToProceed = int(leafsNeedOtherData.getSize()); #pragma omp for schedule(static) for(int idxLeafs = 0 ; idxLeafs < nbLeafToProceed ; ++idxLeafs){ diff --git a/Src/Extensions/FExtendCellType.hpp b/Src/Extensions/FExtendCellType.hpp index c1c3ac36c..5f32aead2 100644 --- a/Src/Extensions/FExtendCellType.hpp +++ b/Src/Extensions/FExtendCellType.hpp @@ -87,8 +87,8 @@ public: containsSources = false; } - int getSavedSize() const { - return sizeof(containsTargets) + sizeof(containsSources); + FSize getSavedSize() const { + return FSize(sizeof(containsTargets) + sizeof(containsSources)); } }; diff --git a/Src/Files/FBasicLoader.hpp b/Src/Files/FBasicLoader.hpp index 7b8c94bd8..63283bc86 100644 --- a/Src/Files/FBasicLoader.hpp +++ b/Src/Files/FBasicLoader.hpp @@ -42,7 +42,7 @@ * <br> * FOctree<FBasicParticle, TestCell, FSimpleLeaf> tree(loader.getBoxWidth(),loader.getCenterOfBox()); <br> * <br> -* for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ <br> +* for(FSize r.getNumberOfParticles() ; ++idx){ <br> * FBasicParticle* const part = new FBasicParticle(); <br> * loader.fillParticle(part); <br> * tree.insert(part); <br> @@ -55,7 +55,7 @@ protected: std::ifstream file; //< The file to read FPoint<FReal> centerOfBox; //< The center of box read from file FReal boxWidth; //< the box width read from file - int nbParticles; //< the number of particles read from file + FSize nbParticles; //< the number of particles read from file public: /** diff --git a/Src/Files/FDlpolyLoader.hpp b/Src/Files/FDlpolyLoader.hpp index ba46fdbd3..b34cdc3fb 100644 --- a/Src/Files/FDlpolyLoader.hpp +++ b/Src/Files/FDlpolyLoader.hpp @@ -265,7 +265,7 @@ protected: FILE* const file; //< The file to read // FPoint<FReal> centerOfBox; //< The center of box read from file // double boxWidth; //< the box width read from file -// int nbParticles; //< the number of particles read from file +// FSize nbParticles; //< the number of particles read from file // double energy; size_t removeWarning; diff --git a/Src/Files/FExportWriter.hpp b/Src/Files/FExportWriter.hpp index 00b1878c1..c7a15cb2d 100644 --- a/Src/Files/FExportWriter.hpp +++ b/Src/Files/FExportWriter.hpp @@ -23,7 +23,7 @@ #include <fstream> #include <string> -//! \fn void exportCVS(std::ofstream& file, const FReal * particles , const int N, const int nbDataPerParticle=4) +//! \fn void exportCVS(std::ofstream& file, const FReal * particles , const FSize N, const FSize nbDataPerParticle=4) //! \brief Export particles in CVS Format //! @@ -37,24 +37,24 @@ //! @param nbDataPerParticle number of values per particles (default value 4) //! template <class FReal> -void exportCVS(std::ofstream& file, const FReal * particles , const int N, const int nbDataPerParticle=4){ - int j = 0; +void exportCVS(std::ofstream& file, const FReal * particles , const FSize N, const FSize nbDataPerParticle=4){ + FSize j = 0; if (nbDataPerParticle==4){ file << " x , y , z, q " <<std::endl; } else { file << " x , y , z, q P FX FY FZ" <<std::endl; } - for(int i = 0 ; i< N; ++i, j+=nbDataPerParticle){ + for(FSize i = 0 ; i< N; ++i, j+=nbDataPerParticle){ file << particles[j] ; - for (int k = 1 ; k< nbDataPerParticle ; ++k) { + for (FSize k = 1 ; k< nbDataPerParticle ; ++k) { file << " , " << particles[j+k] ; } file << std::endl; } } // -//! \fn void exportCOSMOS(std::ofstream& file, const FReal * particles, const int N ) +//! \fn void exportCOSMOS(std::ofstream& file, const FReal * particles, const FSize N ) //! \brief Export particles in COSMOS Format //! @@ -66,16 +66,16 @@ void exportCVS(std::ofstream& file, const FReal * particles , const int N, const //! @param N number of particles //! template <class FReal> -void exportCOSMOS(std::ofstream& file, const FReal * particles , const int N){ - int j = 0; +void exportCOSMOS(std::ofstream& file, const FReal * particles , const FSize N){ + FSize j = 0; file << " x , y , z, q " <<std::endl; - for(int i = 0 ; i< N; ++i, j+=4){ + for(FSize i = 0 ; i< N; ++i, j+=4){ file << particles[j] << " " << particles[j+1] << " " << particles[j+2] << " 0.0 0.0 0.0 " << particles[j+3] <<" " << i << std::endl; } } // // -//! \fn void exportVTK(std::ofstream& file, const FReal * particles, const int N ) +//! \fn void exportVTK(std::ofstream& file, const FReal * particles, const FSize N ) //! \brief Export particles in CVS Format //! @@ -87,8 +87,8 @@ void exportCOSMOS(std::ofstream& file, const FReal * particles , const int N){ //! @param particles array of particles of type FReal (float or double) Its size is 4*N (X,Y,Z,M) //! @param N number of particles template <class FReal> -void exportVTK(std::ofstream& VTKfile, const FReal * particles, const int N, const int nbDataPerParticle=4 ){ - int j = 0; +void exportVTK(std::ofstream& VTKfile, const FReal * particles, const FSize N, const FSize nbDataPerParticle=4 ){ + FSize j = 0; //--------------------------- // print generic information //--------------------------- @@ -103,27 +103,27 @@ void exportVTK(std::ofstream& VTKfile, const FReal * particles, const int N, con //--------------------------------- VTKfile << "POINTS " << N << " float" << "\n"; // - for(int i = 0 ; i< N; ++i, j+=nbDataPerParticle){ + for(FSize i = 0 ; i< N; ++i, j+=nbDataPerParticle){ VTKfile << particles[j] << " " << particles[j+1] << " " << particles[j+2] <<std::endl; } // ------------------------------------------ VTKfile << "\n"; VTKfile << "VERTICES " << N << " " << 2*N << "\n"; - for(int i = 0 ; i< N; ++i){ + for(FSize i = 0 ; i< N; ++i){ VTKfile << " 1 " << " " <<i<<std::endl; } VTKfile << "POINT_DATA " << N << "\n"; VTKfile << "SCALARS PhysicalValue float 1" << "\n" << "LOOKUP_TABLE default" << "\n" ; j = 0 ; - for(int i = 0 ; i< N; ++i, j+=nbDataPerParticle){ + for(FSize i = 0 ; i< N; ++i, j+=nbDataPerParticle){ VTKfile << particles[j+3] << " " <<std::endl; } VTKfile << "\n"; }; // // -//! \fn void exportVTKxml(std::ofstream& file, const FReal * particles, const int N ) +//! \fn void exportVTKxml(std::ofstream& file, const FReal * particles, const FSize N ) //! \brief Export particles in xml polydata VTK Format //! @@ -135,8 +135,8 @@ void exportVTK(std::ofstream& VTKfile, const FReal * particles, const int N, con //! @param particles array of particles of type FReal (float or double) Its size is 4*N (X,Y,Z,M) //! @param N number of particles template <class FReal> -void exportVTKxml(std::ofstream& VTKfile, const FReal * particles, const int N ){ - int j = 0; +void exportVTKxml(std::ofstream& VTKfile, const FReal * particles, const FSize N ){ + FSize j = 0; VTKfile << "<?xml version=\"1.0\"?>" <<std::endl << "<VTKFile type=\"PolyData\" version=\"0.1\" byte_order=\"LittleEndian\"> "<<std::endl @@ -145,7 +145,7 @@ void exportVTKxml(std::ofstream& VTKfile, const FReal * particles, const int N ) << "<Points>"<<std::endl << "<DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\"> "<<std::endl ; j = 0 ; - for(int i = 0 ; i< N; ++i, j+=4){ + for(FSize i = 0 ; i< N; ++i, j+=4){ VTKfile << particles[j] << " " << particles[j+1] << " " << particles[j+2] << " " ; } VTKfile <<std::endl<< "</DataArray> "<<std::endl @@ -153,7 +153,7 @@ void exportVTKxml(std::ofstream& VTKfile, const FReal * particles, const int N ) << "<PointData Scalars=\"PhysicalValue\" > "<<std::endl << "<DataArray type=\"Float64\" Name=\"PhysicalValue\" format=\"ascii\">"<<std::endl ; j = 0 ; - for(int i = 0 ; i< N; ++i, j+=4){ + for(FSize i = 0 ; i< N; ++i, j+=4){ VTKfile << particles[j+3] << " " ; } VTKfile <<std::endl << "</DataArray>"<<std::endl @@ -161,12 +161,12 @@ void exportVTKxml(std::ofstream& VTKfile, const FReal * particles, const int N ) << " <CellData>"<<" </CellData>"<<std::endl << " <Verts>"<<std::endl << " <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">"<<std::endl ; - for(int i = 0 ; i< N; ++i){ + for(FSize i = 0 ; i< N; ++i){ VTKfile << i << " " ; } VTKfile<<std::endl << "</DataArray>" <<std::endl << "<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">"<<std::endl ; - for(int i = 1 ; i< N+1; ++i){ + for(FSize i = 1 ; i< N+1; ++i){ VTKfile << i << " " ; } VTKfile<<std::endl << "</DataArray>"<<std::endl @@ -181,7 +181,7 @@ void exportVTKxml(std::ofstream& VTKfile, const FReal * particles, const int N ) // // // -//! \fn void exportVTKxml(std::ofstream& file, const FReal * particles, const int N, const int nbDataPerParticle ) +//! \fn void exportVTKxml(std::ofstream& file, const FReal * particles, const FSize N, const FSize nbDataPerParticle ) //! \brief Export particles in CVS Format //! @@ -194,8 +194,8 @@ void exportVTKxml(std::ofstream& VTKfile, const FReal * particles, const int N ) //! @param N number of particles //! @param nbDataPerParticle number of values per particles (default value 4) template <class FReal> -void exportVTKxml(std::ofstream& VTKfile, const FReal * particles, const int N, const int nbDataPerParticle ){ - int j = 0; +void exportVTKxml(std::ofstream& VTKfile, const FReal * particles, const FSize N, const FSize nbDataPerParticle ){ + FSize j = 0; VTKfile << "<?xml version=\"1.0\"?>" <<std::endl << "<VTKFile type=\"PolyData\" version=\"0.1\" byte_order=\"LittleEndian\"> "<<std::endl @@ -204,7 +204,7 @@ void exportVTKxml(std::ofstream& VTKfile, const FReal * particles, const int N, << "<Points>"<<std::endl << "<DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\"> "<<std::endl ; j = 0 ; - for(int i = 0 ; i< N; ++i, j+=nbDataPerParticle){ + for(FSize i = 0 ; i< N; ++i, j+=nbDataPerParticle){ VTKfile << particles[j] << " " << particles[j+1] << " " << particles[j+2] << " " ; } VTKfile <<std::endl<< "</DataArray> "<<std::endl @@ -213,19 +213,19 @@ void exportVTKxml(std::ofstream& VTKfile, const FReal * particles, const int N, VTKfile<< "<PointData Scalars=\"PhysicalValue\" > "<<std::endl << "<DataArray type=\"Float64\" Name=\"PhysicalValue\" format=\"ascii\">"<<std::endl ; j = 0 ; - for(int i = 0 ; i< N; ++i, j+=nbDataPerParticle){ + for(FSize i = 0 ; i< N; ++i, j+=nbDataPerParticle){ VTKfile << particles[j+3] << " " ; } VTKfile <<std::endl << "</DataArray>"<<std::endl ; VTKfile << "<DataArray type=\"Float64\" Name=\"Potential\" format=\"ascii\">"<<std::endl ; j = 0 ; - for(int i = 0 ; i< N; ++i, j+=nbDataPerParticle){ + for(FSize i = 0 ; i< N; ++i, j+=nbDataPerParticle){ VTKfile << particles[j+4] << " " ; } VTKfile <<std::endl << "</DataArray>"<<std::endl ; VTKfile<< "<DataArray type=\"Float64\" Name=\"Force\" NumberOfComponents=\"3\" format=\"ascii\"> "<<std::endl ; j = 0 ; - for(int i = 0 ; i< N; ++i, j+=nbDataPerParticle){ + for(FSize i = 0 ; i< N; ++i, j+=nbDataPerParticle){ VTKfile << particles[j+5] << " " << particles[j+6] << " " << particles[j+7] << " " ; } VTKfile <<std::endl<< "</DataArray> "<<std::endl; @@ -234,7 +234,7 @@ void exportVTKxml(std::ofstream& VTKfile, const FReal * particles, const int N, VTKfile << "<PointData Scalars=\"PhysicalValue\" > "<<std::endl << "<DataArray type=\"Float64\" Name=\"PhysicalValue\" format=\"ascii\">"<<std::endl ; j = 0 ; - for(int i = 0 ; i< N; ++i, j+=nbDataPerParticle){ + for(FSize i = 0 ; i< N; ++i, j+=nbDataPerParticle){ VTKfile << particles[j+3] << " " ; } VTKfile <<std::endl << "</DataArray>"<<std::endl ; @@ -244,12 +244,12 @@ void exportVTKxml(std::ofstream& VTKfile, const FReal * particles, const int N, << " <CellData>"<<" </CellData>"<<std::endl << " <Verts>"<<std::endl << " <DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\">"<<std::endl ; - for(int i = 0 ; i< N; ++i){ + for(FSize i = 0 ; i< N; ++i){ VTKfile << i << " " ; } VTKfile<<std::endl << "</DataArray>" <<std::endl << "<DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\">"<<std::endl ; - for(int i = 1 ; i< N+1; ++i){ + for(FSize i = 1 ; i< N+1; ++i){ VTKfile << i << " " ; } VTKfile<<std::endl << "</DataArray>"<<std::endl @@ -266,7 +266,7 @@ void exportVTKxml(std::ofstream& VTKfile, const FReal * particles, const int N, // The Driver //////////////////////////////////////////////////////////////////////////////////////////////////// // -//! \fn void driverExportData(std::ofstream& file, const FReal * particles , const int N, const int nbDataPerParticle=4) +//! \fn void driverExportData(std::ofstream& file, const FReal * particles , const FSize N, const FSize nbDataPerParticle=4) //! \brief The driver to select the right format to write the data //! //! The driver select the right format (CVS, COSMOS, VTK, VTP,, ...) according to the extention of the filename @@ -281,7 +281,7 @@ void exportVTKxml(std::ofstream& VTKfile, const FReal * particles, const int N, //! @param particles array of particles of type FReal (float or double) Its size is N*nbDataPerParticle //! @param nbDataPerParticle number of values per particles (default value 4) template <class FReal> -void driverExportData(std::string & filename, const FReal * particles , const int NbPoints, const int nbDataPerParticle=4){ +void driverExportData(std::string & filename, const FReal * particles , const FSize NbPoints, const FSize nbDataPerParticle=4){ // std::ofstream file( filename.c_str(), std::ofstream::out); // open particle file diff --git a/Src/Files/FFmaGenericLoader.hpp b/Src/Files/FFmaGenericLoader.hpp index 2f70bb144..2d3e33af5 100644 --- a/Src/Files/FFmaGenericLoader.hpp +++ b/Src/Files/FFmaGenericLoader.hpp @@ -44,7 +44,7 @@ * \tparam READ number of items to read (UNUSED, see WRITE) * \tparam WRITE number of items to write (must be >= 4) */ -template<class FReal, int READ, int WRITE> +template<class FReal, FSize READ, FSize WRITE> class FmaRWParticle { /// Data stored FReal data[WRITE]; @@ -135,22 +135,22 @@ public: } /// Get READ - unsigned int getReadDataNumber() const{ - return (unsigned int) (READ); + FSize getReadDataNumber() const{ + return FSize(READ); } /// Get WRITE - unsigned int getWriteDataNumber() const{ + FSize getWriteDataNumber() const{ return WRITE; } /// Get size of Class Particle - unsigned int getWriteDataSize() const { + FSize getWriteDataSize() const { return sizeof(FmaRWParticle<FReal, READ,WRITE>); } /// Get Size of array (should be same as above...) - long unsigned int getClassSize() const { + FSize getClassSize() const { return WRITE*sizeof(FReal); } }; @@ -178,7 +178,7 @@ public: * memset(particles, 0, sizeof(FmaRParticle) * nbParticles) ; * * // Read the file via the loader. - * for(int idx = 0 ; idx < nbParticles ; ++idx){ + * for(FSize idx = 0 ; idx < nbParticles ; ++idx){ * loader.fillParticle(particles[idx]); * } * \endcode @@ -209,10 +209,10 @@ protected: FPoint<FReal> centerOfBox; ///< The center of box (read from file) FReal boxWidth; ///< the box width (read from file) FSize nbParticles; ///< the number of particles (read from file) - unsigned int typeData[2]; ///< Size of the data to read, number of data on 1 line + FSize typeData[2]; ///< Size of the data to read, number of data on 1 line private: FReal *tmpVal ; ///< Temporary array to read data - int otherDataToRead ; ///< number of other data (>4) to read in a particle record + FSize otherDataToRead ; ///< number of other data (>4) to read in a particle record public: /** * This constructor opens a file using the given mode and reads its @@ -321,13 +321,13 @@ public: * The box width from the simulation file opened by the loader * @return the number of data per record (Particle) */ - unsigned int getNbRecordPerline(){ + FSize getNbRecordPerline(){ return typeData[1]; } /** * To know if the data are in float or in double type * @return the type of the values float (4) or double (8) */ - unsigned int getDataType(){ + FSize getDataType(){ return typeData[0]; } /** @@ -349,7 +349,7 @@ public: outParticlePositions->setPosition(x,y,z); if(otherDataToRead> 0){ - for (int i = 0 ; i <otherDataToRead; ++i){ + for (FSize i = 0 ; i <otherDataToRead; ++i){ (*this->file) >> x ; } } @@ -364,7 +364,7 @@ public: * * @param nbDataToRead number of value to read (I.e. size of the array) */ - void fillParticle(FReal* dataToRead, const unsigned int nbDataToRead){ + void fillParticle(FReal* dataToRead, const FSize nbDataToRead){ if(binaryFile){ file->read((char*)(dataToRead), sizeof(FReal)*nbDataToRead); if(nbDataToRead< typeData[1]){ @@ -373,12 +373,12 @@ public: } else{ - for (unsigned int i = 0 ; i <nbDataToRead; ++i){ + for (FSize i = 0 ; i <nbDataToRead; ++i){ (*this->file) >>dataToRead[i]; } if(nbDataToRead< typeData[1]){ FReal x; - for (unsigned int i = 0 ; i <typeData[1]-nbDataToRead; ++i){ + for (FSize i = 0 ; i <typeData[1]-nbDataToRead; ++i){ (*this->file) >> x ; } } @@ -395,7 +395,7 @@ public: */ template <class dataPart> void fillParticle(dataPart& dataToRead){ - int otherDataRead = typeData[1] - dataToRead.getReadDataNumber() ; + FSize otherDataRead = typeData[1] - dataToRead.getReadDataNumber() ; if(binaryFile){ file->read((char*)(dataToRead.getPtrFirstData()), sizeof(FReal)*(dataToRead.getReadDataNumber())); if( otherDataRead > 0){ @@ -404,13 +404,13 @@ public: } else{ FReal * val = dataToRead.getPtrFirstData(); - for (unsigned int i = 0 ; i <dataToRead.getReadDataNumber(); ++i){ + for (FSize i = 0 ; i <dataToRead.getReadDataNumber(); ++i){ (*this->file) >>*val; ++val; } if( otherDataRead > 0){ FReal x; - for (int i = 0 ; i <otherDataRead ;++i){ + for (FSize i = 0 ; i <otherDataRead ;++i){ (*this->file) >>x; } } @@ -430,10 +430,10 @@ public: * @param N the number of particles. */ template <class dataPart> - void fillParticle(dataPart *dataToRead, const int N){ - int otherDataRead = typeData[1] - (*dataToRead).getReadDataNumber() ; + void fillParticle(dataPart *dataToRead, const FSize N){ + FSize otherDataRead = typeData[1] - (*dataToRead).getReadDataNumber() ; if (otherDataRead < 0){ - std::cerr << "Error in fFFmaGenericLoader::fillParticle(dataPart *dataToRead, const int N)." + std::cerr << "Error in fFFmaGenericLoader::fillParticle(dataPart *dataToRead, const FSize N)." << std::endl << "Wrong number of values to read:" << std::endl << "expected " << typeData[1] << " from file\n" @@ -446,7 +446,7 @@ public: sizeof(FReal)*(N*(*dataToRead).getReadDataNumber())); } else { - for (int i = 0 ; i <N; ++i) { + for (FSize i = 0 ; i <N; ++i) { this->fillParticle(dataToRead[i]) ; } } @@ -478,7 +478,7 @@ private: void readBinaryHeader(){ std::cout << " File open in binary mode "<< std::endl; file->seekg (std::ios::beg); - file->read((char*)&typeData,2*sizeof(unsigned int)); + file->read((char*)&typeData,2*sizeof(FSize)); std::cout << " Datatype "<< typeData[0] << " "<< typeData[1] << std::endl; if(typeData[0] != sizeof(FReal)){ std::cerr << "Size of elements in part file " << typeData[0] << " is different from size of FReal " << sizeof(FReal)<<std::endl; @@ -625,8 +625,8 @@ public: */ template <class typePart> void writeHeader(const FPoint<FReal> ¢erOfBox,const FReal &boxWidth, const FSize &nbParticles, const typePart data) { - unsigned int typeFReal[2] = {sizeof(FReal) , sizeof(typePart) / sizeof(FReal) }; - const unsigned int ndata = data.getWriteDataNumber(); + FSize typeFReal[2] = {sizeof(FReal) , sizeof(typePart) / sizeof(FReal) }; + const FSize ndata = data.getWriteDataNumber(); std::cout <<" WriteHeader: typeFReal: " << typeFReal[0] << " nb Elts: " << typeFReal[1] <<" NData to write "<< ndata<< "\n"; if (ndata != typeFReal[1]){ typeFReal[1] = ndata; @@ -652,8 +652,8 @@ public: * @param nbDataPerRecord Number of record/value per particle */ void writeHeader(const FPoint<FReal> ¢erOfBox,const FReal &boxWidth, const FSize &nbParticles, - const unsigned int dataType, const unsigned int nbDataPerRecord) { - unsigned int typeFReal[2] = {dataType , nbDataPerRecord }; + const FSize dataType, const FSize nbDataPerRecord) { + FSize typeFReal[2] = {dataType , nbDataPerRecord }; FReal x = boxWidth *0.5; if(this->binaryFile) { this->writerBinaryHeader(centerOfBox,x,nbParticles,typeFReal); @@ -698,21 +698,21 @@ public: void writeArrayOfParticles(const dataPart *dataToWrite, const FSize N){ // std::cout << "NB points to write: "<< N <<std::endl; if(binaryFile){ - unsigned int recordSize= dataToWrite[0].getWriteDataSize() ; - unsigned int typeFReal[2] = {sizeof(FReal) , sizeof(dataPart) / sizeof(FReal) }; + FSize recordSize= dataToWrite[0].getWriteDataSize() ; + FSize typeFReal[2] = {sizeof(FReal) , sizeof(dataPart) / sizeof(FReal) }; // std::cout << "typeData "<< typeFReal[0] << " "<< typeFReal[1] <<" "<< std::endl; if (sizeof(dataPart) == recordSize){ // std::cout << "Size to write: "<<N*dataToWrite[0].getWriteDataSize() <<std::endl; - file->write((char*)(dataToWrite[0].getPtrFirstData()), N*recordSize); + file->write((const char*)(dataToWrite[0].getPtrFirstData()), N*recordSize); } else { - file->write((char* )&typeFReal[0],2*sizeof(unsigned int)); + file->write((const char* )&typeFReal[0],2*sizeof(FSize)); // std::cout << "Size to write: N* "<<typeFReal[0] *typeFReal[1] <<std::endl; - for (int i = 0 ; i <N ; ++i){ - file->write((char*)(dataToWrite[i].getPtrFirstData()), recordSize ); + for (FSize i = 0 ; i <N ; ++i){ + file->write((const char*)(dataToWrite[i].getPtrFirstData()), recordSize ); // const FReal * val = dataToWrite[i].getPtrFirstData() ; // std::cout << i <<" "; - // for( int j=0; j<typeFReal[1] ; ++j){ + // for( FSize j=0; j<typeFReal[1] ; ++j){ // std::cout << *val << " ";++val; // } // std::cout <<std::endl; @@ -720,13 +720,13 @@ public: } } else{ // ASCII part - const int ndata = dataToWrite[0].getWriteDataNumber(); + const FSize ndata = dataToWrite[0].getWriteDataNumber(); // std::cout << "typeData "<< sizeof(FReal) << " "<<ndata << std::endl; this->file->precision(10); - for (int i = 0 ; i <N ; ++i){ + for (FSize i = 0 ; i <N ; ++i){ const FReal * val = dataToWrite[i].getPtrFirstData() ; - for (int j= 0 ; j <ndata ; ++j){ + for (FSize j= 0 ; j <ndata ; ++j){ (*this->file) << *val << " "; ++val; } (*this->file) <<std::endl; @@ -753,18 +753,18 @@ public: * Fwriter.writeArrayOfReal(particles, nbParticles); * \endcode */ - void writeArrayOfReal(const FReal *dataToWrite, const unsigned int nbData, const FSize N){ + void writeArrayOfReal(const FReal *dataToWrite, const FSize nbData, const FSize N){ if(binaryFile){ - file->write((char*)(dataToWrite), N*nbData*sizeof(FReal)); + file->write((const char*)(dataToWrite), N*nbData*sizeof(FReal)); } else{ this->file->precision(10); // std::cout << "N "<< N << " nbData "<< nbData<<std::endl; // exit(-1); - int k = 0; - for (int i = 0 ; i <N ; ++i){ + FSize k = 0; + for (FSize i = 0 ; i <N ; ++i){ // std::cout << "i "<< i << " "; - for (unsigned int jj= 0 ; jj<nbData ; ++jj, ++k){ + for (FSize jj= 0 ; jj<nbData ; ++jj, ++k){ (*this->file) << dataToWrite[k] << " "; // std::cout << dataToWrite[k]<< " "; } @@ -777,7 +777,7 @@ public: private: void writerAscciHeader( const FPoint<FReal> ¢erOfBox,const FReal &boxWidth, - const FSize &nbParticles, const unsigned int *typeFReal) { + const FSize &nbParticles, const FSize *typeFReal) { this->file->precision(10); (*this->file) << typeFReal[0] <<" "<<typeFReal[1]<<std::endl; (*this->file) << nbParticles << " "<< boxWidth << " " @@ -785,18 +785,18 @@ private: << std::endl; } void writerBinaryHeader(const FPoint<FReal> ¢erOfBox,const FReal &boxWidth, - const FSize &nbParticles, const unsigned int *typeFReal) { + const FSize &nbParticles, const FSize *typeFReal) { file->seekg (std::ios::beg); - file->write((char*)typeFReal,2*sizeof(unsigned int)); + file->write((const char*)typeFReal,2*sizeof(FSize)); if(typeFReal[0] != sizeof(FReal)){ std::cout << "Size of elements in part file " << typeFReal[0] << " is different from size of FReal " << sizeof(FReal)<<std::endl; std::exit( EXIT_FAILURE); } else{ - file->write( (char*)&(nbParticles), sizeof(FSize) ); + file->write( (const char*)&(nbParticles), sizeof(FSize) ); // std::cout << "nbParticles "<< nbParticles<<std::endl; - file->write( (char*)&(boxWidth) ,sizeof(boxWidth) ); - file->write( (char*)(centerOfBox.getDataValue()),sizeof(FReal)*3); + file->write( (const char*)&(boxWidth) ,sizeof(boxWidth) ); + file->write( (const char*)(centerOfBox.getDataValue()),sizeof(FReal)*3); } } }; @@ -827,17 +827,17 @@ private: // /** // * return The number of data to read. it is used in FMAGenericLoader (here 4) // */ -// int getReadDataNumber() +// FSize getReadDataNumber() // { return 4;} // /** // * return The number of data to write. it is used in FMAGenericWriter (here 4) // */ -// int getWriteDataNumber() const +// FSize getWriteDataNumber() const // { return 4;} // /** // * return size in byte of the structure. it is used in FMAGenericWriter // */ -// unsigned int getWriteDataSize() const +// FSize getWriteDataSize() const // { return sizeof(FmaR4W4Particle);} // }; @@ -866,17 +866,17 @@ private: // /** // * return The number of data to read. it is used in FMAGenericLoader (here 4) // */ -// int getReadDataNumber() +// FSize getReadDataNumber() // { return 4;} // /** // * return The number of data to write. it is used in FMAGenericWriter (here 8) // */ -// int getWriteDataNumber() const +// FSize getWriteDataNumber() const // { return 8;} // /** // * return size in byte of the structure. it is used in FMAGenericWriter // */ -// unsigned int getWriteDataSize() const +// FSize getWriteDataSize() const // { return sizeof(FmaR4W8Particle);} // }; // @@ -895,7 +895,7 @@ private: // * Useful to read the result of the output of DirectComputation and to compare the potential and the force // * with the FMM computation // */ -// int getReadDataNumber() +// FSize getReadDataNumber() // { return 8;} // }; //\typedef FmaBasicParticle an alias of FmaR4W4Particle diff --git a/Src/Files/FFmaScanfLoader.hpp b/Src/Files/FFmaScanfLoader.hpp index 6514b4e10..f51ca18a5 100644 --- a/Src/Files/FFmaScanfLoader.hpp +++ b/Src/Files/FFmaScanfLoader.hpp @@ -42,7 +42,7 @@ * <br> * FOctree<FBasicParticle, TestCell, FSimpleLeaf> tree(loader.getBoxWidth(),loader.getCenterOfBox()); <br> * <br> -* for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ <br> +* for(FSize r.getNumberOfParticles() ; ++idx){ <br> * FBasicParticle* const part = new FBasicParticle(); <br> * loader.fillParticle(part); <br> * tree.insert(part); <br> @@ -57,7 +57,7 @@ protected: FILE* file; //< The file to read FPoint<FReal> centerOfBox; //< The center of box read from file FReal boxWidth; //< the box width read from file - int nbParticles; //< the number of particles read from file + FSize nbParticles; //< the number of particles read from file public: /** @@ -70,7 +70,7 @@ public: // test if open if(this->file){ float x,y,z, fBoxWidth; - const int nbReadElements = fscanf(file,"%d %f %f %f %f",&this->nbParticles,&fBoxWidth,&x,&y,&z); + const int nbReadElements = fscanf(file,"%lld %f %f %f %f",&this->nbParticles,&fBoxWidth,&x,&y,&z); if(nbReadElements == 5){ this->boxWidth = fBoxWidth * 2; this->centerOfBox.setPosition(x,y,z); diff --git a/Src/Files/FFmaTsmLoader.hpp b/Src/Files/FFmaTsmLoader.hpp index 6b588ff16..eadf1137f 100644 --- a/Src/Files/FFmaTsmLoader.hpp +++ b/Src/Files/FFmaTsmLoader.hpp @@ -43,7 +43,7 @@ * <br> * FOctree<FBasicParticle, TestCell, FSimpleLeaf> tree(loader.getBoxWidth(),loader.getCenterOfBox()); <br> * <br> -* for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ <br> +* for(FSize r.getNumberOfParticles() ; ++idx){ <br> * FBasicParticle* const part = new FBasicParticle(); <br> * loader.fillParticle(part); <br> * tree.insert(part); <br> @@ -58,7 +58,7 @@ protected: std::ifstream file; //< The file to read FPoint<FReal> centerOfBox; //< The center of box read from file FReal boxWidth; //< the box width read from file - int nbParticles; //< the number of particles read from file + FSize nbParticles; //< the number of particles read from file public: /** diff --git a/Src/Files/FHLoader.hpp b/Src/Files/FHLoader.hpp index 0c39dfb86..1eaed6d4e 100644 --- a/Src/Files/FHLoader.hpp +++ b/Src/Files/FHLoader.hpp @@ -42,7 +42,7 @@ * <br> * FOctree<FBasicParticle, TestCell, FSimpleLeaf> tree(loader.getBoxWidth(),loader.getCenterOfBox()); <br> * <br> -* for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ <br> +* for(FSize r.getNumberOfParticles() ; ++idx){ <br> * FBasicParticle* const part = new FBasicParticle(); <br> * loader.fillParticle(part); <br> * tree.insert(part); <br> @@ -57,7 +57,7 @@ protected: FILE* file; //< The file to read FPoint<FReal> centerOfBox; //< The center of box read from file FReal boxWidth; //< the box width read from file - int nbParticles; //< the number of particles read from file + FSize nbParticles; //< the number of particles read from file public: /** diff --git a/Src/Files/FIOVtk.hpp b/Src/Files/FIOVtk.hpp index bd97068e1..982672e00 100644 --- a/Src/Files/FIOVtk.hpp +++ b/Src/Files/FIOVtk.hpp @@ -217,7 +217,7 @@ void FIOVtk<FReal>::writeXMLParticles( const std::string& VTKname,const std::str VTKfile << " <PolyData>" << std::endl; // typename OctreeClass::Iterator octreeIterator(&tree); - int nbNodes=0; + FSize nbNodes=0; octreeIterator.gotoBottomLeft(); do{ //ContainerClass* const FRestrict segments = octreeIterator.getCurrentListTargets(); @@ -237,8 +237,8 @@ void FIOVtk<FReal>::writeXMLParticles( const std::string& VTKname,const std::str do{ auto * leaf = octreeIterator.getCurrentLeaf() ; auto * const physicalValues = leaf->getTargets()->getPhysicalValues(); - int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ VTKfile << " " << physicalValues[idxPart] ; } } while(octreeIterator.moveRight()); @@ -248,8 +248,8 @@ void FIOVtk<FReal>::writeXMLParticles( const std::string& VTKname,const std::str do{ auto * leaf = octreeIterator.getCurrentLeaf() ; auto * const potentials = leaf->getTargets()->getPotentials(); - int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ VTKfile << " " << potentials[idxPart] ; } } while(octreeIterator.moveRight()); @@ -261,8 +261,8 @@ void FIOVtk<FReal>::writeXMLParticles( const std::string& VTKname,const std::str FReal*const forcesX = leaf->getTargets()->getForcesX(); FReal*const forcesY = leaf->getTargets()->getForcesY(); FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ VTKfile << " " << forcesX[idxPart] << " " << forcesY[idxPart] << " " << forcesZ[idxPart] ; } } while(octreeIterator.moveRight()); @@ -277,8 +277,8 @@ void FIOVtk<FReal>::writeXMLParticles( const std::string& VTKname,const std::str const FReal* const positionsX = leaf->getTargets()->getPositions()[0]; const FReal* const positionsY = leaf->getTargets()->getPositions()[1]; const FReal* const positionsZ = leaf->getTargets()->getPositions()[2]; - int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ VTKfile << " " << positionsX[idxPart] << " " << positionsY[idxPart] << " " << positionsZ[idxPart] ; } } while(octreeIterator.moveRight()); diff --git a/Src/Files/FMpiTreeBuilder.hpp b/Src/Files/FMpiTreeBuilder.hpp index f5a7326c4..9a15113d8 100644 --- a/Src/Files/FMpiTreeBuilder.hpp +++ b/Src/Files/FMpiTreeBuilder.hpp @@ -43,7 +43,7 @@ private: /** To keep the leaves information after the sort */ struct LeafInfo { MortonIndex mindex; - int nbParts; + FSize nbParts; FSize startingPoint; }; @@ -88,7 +88,7 @@ public: const FReal boxWidthAtLeafLevel = loader.getBoxWidth() / FReal(1 << (TreeHeight - 1) ); // Fill the array and compute the morton index - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(originalParticlesUnsorted[idxPart].particle); host.setX( FCoordinateComputer::GetTreeCoordinate<FReal>( originalParticlesUnsorted[idxPart].particle.getPosition().getX() - boxCorner.getX(), loader.getBoxWidth(), boxWidthAtLeafLevel, TreeHeight )); @@ -125,7 +125,7 @@ public: const FReal boxWidthAtLeafLevel = boxWidth / FReal(1 << (TreeHeight - 1) ); // Fill the array and compute the morton index - for(int idxPart = 0 ; idxPart < originalNbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < originalNbParticles ; ++idxPart){ originalParticlesUnsorted[idxPart].particle = inOriginalParticles[idxPart]; host.setX( FCoordinateComputer::GetTreeCoordinate<FReal>( originalParticlesUnsorted[idxPart].particle.getPosition().getX() - boxCorner.getX(), boxWidth, boxWidthAtLeafLevel, TreeHeight )); @@ -205,7 +205,8 @@ public: if(idProcToSendTo != myRank && allProcFirstLeafStates[(idProcToSendTo)*2 + 1].mindex == borderLeavesState[0].mindex){ // Post and send message for the first leaf requests.push((MPI_Request)0); - FMpi::MpiAssert(MPI_Isend(&workingArray[0], borderLeavesState[0].nbParts, MPI_BYTE, idProcToSendTo, + FAssertLF(borderLeavesState[0].nbParts < std::numeric_limits<int>::max()); + FMpi::MpiAssert(MPI_Isend(&workingArray[0], int(borderLeavesState[0].nbParts), MPI_BYTE, idProcToSendTo, FMpi::TagExchangeIndexs, communicator.getComm(), &requests[0]),__LINE__); hasSentFirstLeaf = true; } @@ -234,7 +235,8 @@ public: // If there are some on this proc if(allProcFirstLeafStates[(postRecvIdx)*2].mindex != noDataFlag){ requests.push((MPI_Request)0); - FMpi::MpiAssert(MPI_Irecv(&receivedParticles[postPositionRecv], allProcFirstLeafStates[(postRecvIdx)*2].nbParts, MPI_BYTE, postRecvIdx, + FAssertLF(allProcFirstLeafStates[(postRecvIdx)*2].nbParts < std::numeric_limits<int>::max()); + FMpi::MpiAssert(MPI_Irecv(&receivedParticles[postPositionRecv], int(allProcFirstLeafStates[(postRecvIdx)*2].nbParts), MPI_BYTE, postRecvIdx, FMpi::TagExchangeIndexs, communicator.getComm(), &requests[0]),__LINE__); // Inc the write position postPositionRecv += allProcFirstLeafStates[(postRecvIdx)*2].nbParts; @@ -245,13 +247,13 @@ public: } // Finalize communication - FMpi::MpiAssert(MPI_Waitall(requests.getSize(), requests.data(), MPI_STATUSES_IGNORE),__LINE__); + FMpi::MpiAssert(MPI_Waitall(int(requests.getSize()), requests.data(), MPI_STATUSES_IGNORE),__LINE__); // IF we sent we need to remove the first leaf if(hasSentFirstLeaf){ - const int offsetParticles = borderLeavesState[0].nbParts; + const FSize offsetParticles = borderLeavesState[0].nbParts; // Move all the particles - for(int idxPart = offsetParticles ; idxPart < (*workingSize) ; ++idxPart){ + for(FSize idxPart = offsetParticles ; idxPart < (*workingSize) ; ++idxPart){ workingArray[idxPart - offsetParticles] = workingArray[idxPart]; } // Move all the leaf @@ -485,20 +487,22 @@ public: #ifdef SCALFMM_USE_LOG /** To produce stats after the Equalize phase */ { - const int finalNbParticles = particleSaver->getSize(); + const FSize finalNbParticles = particleSaver->getSize(); if(communicator.processId() != 0){ - FMpi::MpiAssert(MPI_Gather(const_cast<int*>(&finalNbParticles),1,MPI_INT,nullptr,1,MPI_INT,0,communicator.getComm()), __LINE__); + FMpi::MpiAssert(MPI_Gather(const_cast<FSize*>(&finalNbParticles),1,FMpi::GetType(finalNbParticles),nullptr, + 1,FMpi::GetType(finalNbParticles),0,communicator.getComm()), __LINE__); } else{ const int nbProcs = communicator.processCount(); - std::unique_ptr<int[]> nbPartsPerProc(new int[nbProcs]); + std::unique_ptr<FSize[]> nbPartsPerProc(new FSize[nbProcs]); - FMpi::MpiAssert(MPI_Gather(const_cast<int*>(&finalNbParticles),1,MPI_INT,nbPartsPerProc.get(),1,MPI_INT,0,communicator.getComm()), __LINE__); + FMpi::MpiAssert(MPI_Gather(const_cast<FSize*>(&finalNbParticles),1,FMpi::GetType(finalNbParticles),nbPartsPerProc.get(), + 1,FMpi::GetType(finalNbParticles),0,communicator.getComm()), __LINE__); FReal averageNbParticles = 0; - int minNbParticles = finalNbParticles; - int maxNbParticles = finalNbParticles; + FSize minNbParticles = finalNbParticles; + FSize maxNbParticles = finalNbParticles; for(int idxProc = 0 ; idxProc < nbProcs ; ++idxProc){ maxNbParticles = FMath::Max(maxNbParticles, nbPartsPerProc[idxProc]); @@ -507,7 +511,7 @@ public: } averageNbParticles /= float(nbProcs); - printf("End of Equalize Phase : \n \t Min number of parts : %d \n \t Max number of parts : %d \n \t Average number of parts : %e \n", + printf("End of Equalize Phase : \n \t Min number of parts : %lld \n \t Max number of parts : %lld \n \t Average number of parts : %e \n", minNbParticles,maxNbParticles,averageNbParticles); } } diff --git a/Src/Files/FRandomLoader.hpp b/Src/Files/FRandomLoader.hpp index 89f2f8b33..d53417c08 100644 --- a/Src/Files/FRandomLoader.hpp +++ b/Src/Files/FRandomLoader.hpp @@ -35,7 +35,7 @@ template <class FReal> class FRandomLoader : public FAbstractLoader<FReal> { protected: - const size_t nbParticles; //< the number of particles + const FSize nbParticles; //< the number of particles const FReal boxWidth; //< the box width const FPoint<FReal> centerOfBox; //< The center of box @@ -48,9 +48,9 @@ public: * @param inSeed The seed for the random generator (default value time(nullptr)) * */ - FRandomLoader(const size_t inNbParticles, const FReal inBoxWidth = 1.0, + FRandomLoader(const FSize inNbParticles, const FReal inBoxWidth = 1.0, const FPoint<FReal>& inCenterOfBox = FPoint<FReal>(0,0,0), - const unsigned int inSeed = static_cast<long int>(time(nullptr))) + const unsigned int inSeed = static_cast<unsigned int>(time(nullptr))) : nbParticles(inNbParticles), boxWidth(inBoxWidth), centerOfBox(inCenterOfBox) { srand48(inSeed); } @@ -116,7 +116,7 @@ public: template <class FReal> class FRandomLoaderTsm : public FRandomLoader<FReal> { public: - FRandomLoaderTsm(const size_t inNbParticles, const FReal inBoxWidth = 1.0, + FRandomLoaderTsm(const FSize inNbParticles, const FReal inBoxWidth = 1.0, const FPoint<FReal>& inCenterOfBox = FPoint<FReal>(0,0,0), const unsigned int inSeed = static_cast<unsigned int>(time(nullptr))) : FRandomLoader<FReal>(inNbParticles,inBoxWidth,inCenterOfBox,inSeed) { } diff --git a/Src/Files/FTreeBuilder.hpp b/Src/Files/FTreeBuilder.hpp index f3127e918..b8db4ac54 100644 --- a/Src/Files/FTreeBuilder.hpp +++ b/Src/Files/FTreeBuilder.hpp @@ -51,7 +51,7 @@ private: /** This class is the relation between particles and their morton idx */ struct IndexedParticle{ MortonIndex mindex; - int particlePositionInArray; + FSize particlePositionInArray; // To sort according to the mindex bool operator<=(const IndexedParticle& rhs) const { @@ -63,7 +63,7 @@ private: struct LeafDescriptor{ LeafClass* leafPtr; FSize offsetInArray; - int nbParticlesInLeaf; + FSize nbParticlesInLeaf; }; public: @@ -96,7 +96,7 @@ public: std::unique_ptr<IndexedParticle[]> particleIndexes(new IndexedParticle[numberOfParticle]); FLOG(copyTimer.tic()); - for(int idxParts=0; idxParts<numberOfParticle ; ++idxParts ){ + for(FSize idxParts=0; idxParts<numberOfParticle ; ++idxParts ){ // Get the Morton Index const FTreeCoordinate host( FCoordinateComputer::GetTreeCoordinate<FReal>(particlesContainers.getPositions()[0][idxParts] - boxCorner.getX(), @@ -138,7 +138,7 @@ public: { MortonIndex previousIndex = -1; - for(int idxParts = 0 ; idxParts < numberOfParticle ; ++idxParts){ + for(FSize idxParts = 0 ; idxParts < numberOfParticle ; ++idxParts){ // If not the same leaf, inc the counter if(particleIndexes[idxParts].mindex != previousIndex){ previousIndex = particleIndexes[idxParts].mindex; @@ -166,7 +166,7 @@ public: int currentLeafIndex = -1; MortonIndex currentMortonIndex = -1; - for(int idxParts = 0 ; idxParts < numberOfParticle ; ++idxParts){ + for(FSize idxParts = 0 ; idxParts < numberOfParticle ; ++idxParts){ // If not the same leaf if(particleIndexes[idxParts].mindex != currentMortonIndex){ FAssertLF(FSize(currentLeafIndex) < numberOfLeaves); @@ -205,14 +205,14 @@ public: #pragma omp for schedule(static) for(FSize idxLeaf = 0 ; idxLeaf < numberOfLeaves ; ++idxLeaf ){ - const int nbParticlesAlreadyInLeaf = leavesDescriptor[idxLeaf].leafPtr->getSrc()->getNbParticles(); + const FSize nbParticlesAlreadyInLeaf = leavesDescriptor[idxLeaf].leafPtr->getSrc()->getNbParticles(); // Reserve the space needed for the new particles leavesDescriptor[idxLeaf].leafPtr->getSrc()->reserve(nbParticlesAlreadyInLeaf + leavesDescriptor[idxLeaf].nbParticlesInLeaf); // For all particles - for(int idxPart = 0 ; idxPart < leavesDescriptor[idxLeaf].nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < leavesDescriptor[idxLeaf].nbParticlesInLeaf ; ++idxPart){ // Get position in the original container - const int particleOriginalPos = particleIndexes[leavesDescriptor[idxLeaf].offsetInArray + idxPart].particlePositionInArray; + const FSize particleOriginalPos = particleIndexes[leavesDescriptor[idxLeaf].offsetInArray + idxPart].particlePositionInArray; // Get the original position FPoint<FReal> particlePos( partX[particleOriginalPos], partY[particleOriginalPos], diff --git a/Src/Files/FTreeCsvSaver.hpp b/Src/Files/FTreeCsvSaver.hpp index e9f80ac1a..ba1904b94 100644 --- a/Src/Files/FTreeCsvSaver.hpp +++ b/Src/Files/FTreeCsvSaver.hpp @@ -69,7 +69,7 @@ public: FReal values[4]; { const ContainerClass* container = octreeIterator.getCurrentListTargets(); - for(int idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){ container->fillToCsv(idxPart, values); file << values[0] << "," << values[1] << "," << values[2] << "," << values[3] << "\n"; @@ -79,7 +79,7 @@ public: const bool isUsingTsm = (octreeIterator.getCurrentListTargets() != octreeIterator.getCurrentListSrc()); if( isUsingTsm ){ const ContainerClass* container = octreeIterator.getCurrentListSrc(); - for(int idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){ container->fillToCsv(idxPart, values); file << values[0] << "," << values[1] << "," << values[2] << "," << values[3] << "\n"; diff --git a/Src/Files/FTreeIO.hpp b/Src/Files/FTreeIO.hpp index dc9a6d678..615a8b1e3 100644 --- a/Src/Files/FTreeIO.hpp +++ b/Src/Files/FTreeIO.hpp @@ -89,8 +89,8 @@ public: octreeIterator.getCurrentListSrc()->save(buffer); octreeIterator.getCurrentListTargets()->save(buffer); - const int sizeOfLeaf = buffer.getSize(); - file.write((const char*) &sizeOfLeaf, sizeof(int)); + const FSize sizeOfLeaf = buffer.getSize(); + file.write((const char*) &sizeOfLeaf, sizeof(FSize)); file.write(buffer.data(), buffer.getSize()); ++nbLeaf; @@ -106,8 +106,8 @@ public: buffer.reset(); octreeIterator.getCurrentListSrc()->save(buffer); - const int sizeOfLeaf = buffer.getSize(); - file.write((const char*) &sizeOfLeaf, sizeof(int)); + const FSize sizeOfLeaf = buffer.getSize(); + file.write((const char*) &sizeOfLeaf, sizeof(FSize)); file.write(buffer.data(), buffer.getSize()); ++nbLeaf; @@ -138,8 +138,8 @@ public: buffer.reset(); octreeIterator.getCurrentCell()->save(buffer); - const int sizeOfCell = buffer.getSize(); - file.write((const char*) &sizeOfCell, sizeof(int)); + const FSize sizeOfCell = buffer.getSize(); + file.write((const char*) &sizeOfCell, sizeof(FSize)); file.write(buffer.data(), buffer.getSize()); ++nbCells; @@ -203,8 +203,8 @@ public: MortonIndex mindex = 0; file.read((char*)&mindex, sizeof(mindex)); - int sizeOfLeaf = 0; - file.read((char*)&sizeOfLeaf, sizeof(int)); + FSize sizeOfLeaf = 0; + file.read((char*)&sizeOfLeaf, sizeof(FSize)); buffer.reserve(sizeOfLeaf); file.read((char*)buffer.data(), sizeOfLeaf); @@ -237,8 +237,8 @@ public: return false; } - int sizeOfCell = 0; - file.read((char*)&sizeOfCell, sizeof(int)); + FSize sizeOfCell = 0; + file.read((char*)&sizeOfCell, sizeof(FSize)); buffer.reserve(sizeOfCell); file.read((char*)buffer.data(), sizeOfCell); diff --git a/Src/Files/FTreeMpiCsvSaver.hpp b/Src/Files/FTreeMpiCsvSaver.hpp index ad0ad50b8..01dec35fd 100644 --- a/Src/Files/FTreeMpiCsvSaver.hpp +++ b/Src/Files/FTreeMpiCsvSaver.hpp @@ -92,7 +92,7 @@ public: MPI_Offset disp = 0; { // Each procs count its particles - int mypart = 0; + FSize mypart = 0; typename OctreeClass::Iterator octreeIterator(tree); octreeIterator.gotoBottomLeft(); do{ @@ -102,9 +102,9 @@ public: } while(octreeIterator.moveRight()); // Gather particles number - int*const particlesPerProcs = new int[comm.processCount()]; - MPI_Allgather(&mypart, 1, MPI_INT, particlesPerProcs, 1, MPI_INT, comm.getComm()); - int previousPart = 0; + FSize*const particlesPerProcs = new FSize[comm.processCount()]; + FMpi::Assert( MPI_Allgather(&mypart, 1, FMpi::GetType(mypart), particlesPerProcs, 1, FMpi::GetType(mypart), comm.getComm()), __LINE__); + FSize previousPart = 0; for(int idxProc = 0 ; idxProc < comm.processId() ; ++idxProc){ previousPart += particlesPerProcs[idxProc]; } @@ -134,7 +134,7 @@ public: do{ { const ContainerClass* container = octreeIterator.getCurrentListTargets(); - for(int idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){ FReal values[4]; container->fillToCsv(idxPart, values); sprintf(line, lineFormat, values[0],values[1], @@ -149,7 +149,7 @@ public: const bool isUsingTsm = (octreeIterator.getCurrentListTargets() != octreeIterator.getCurrentListSrc()); if( isUsingTsm ){ const ContainerClass* container = octreeIterator.getCurrentListSrc(); - for(int idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){ FReal values[4]; container->fillToCsv(idxPart, values); sprintf(line, lineFormat, values[0],values[1], diff --git a/Src/GroupTree/Core/FGroupAttachedLeaf.hpp b/Src/GroupTree/Core/FGroupAttachedLeaf.hpp index a9c78804c..ab2df0e04 100644 --- a/Src/GroupTree/Core/FGroupAttachedLeaf.hpp +++ b/Src/GroupTree/Core/FGroupAttachedLeaf.hpp @@ -17,7 +17,7 @@ template <class FReal, unsigned NbSymbAttributes, unsigned NbAttributesPerPartic class FGroupAttachedLeaf { protected: //< Nb of particles in the current leaf - int nbParticles; + FSize nbParticles; //< Pointers to the positions of the particles FReal* positionsPointers[3]; //< Pointers to the attributes of the particles @@ -38,7 +38,7 @@ public: * @param inAttributesBuffer the memory address of the first attribute * @param inLeadingAttributes each attribute is access by inAttributesBuffer + in bytes inLeadingAttributes*idx */ - FGroupAttachedLeaf(const int inNbParticles, FReal* inPositionBuffer, const size_t inLeadingPosition, + FGroupAttachedLeaf(const FSize inNbParticles, FReal* inPositionBuffer, const size_t inLeadingPosition, AttributeClass* inAttributesBuffer, const size_t inLeadingAttributes) : nbParticles(inNbParticles){ // Redirect pointers to position @@ -93,7 +93,7 @@ public: * @brief getNbParticles * @return the number of particles in the leaf */ - int getNbParticles() const{ + FSize getNbParticles() const{ return nbParticles; } @@ -156,7 +156,7 @@ public: /** Allocate a new leaf by calling its constructor */ template<class ParticleClassContainer> - void copyFromContainer(const ParticleClassContainer* particles, const int offsetInSrcContainer){ + void copyFromContainer(const ParticleClassContainer* particles, const FSize offsetInSrcContainer){ FAssertLF(isAttachedToSomething()); // Copy position memcpy(positionsPointers[0], particles->getPositions()[0] + offsetInSrcContainer, nbParticles*sizeof(FReal)); @@ -172,7 +172,7 @@ public: /** Copy data for one particle (from the ParticleClassContainer into the attached buffer) */ template<class ParticleClassContainer> - void setParticle(const int destPartIdx, const int srcPartIdx, const ParticleClassContainer* particles){ + void setParticle(const FSize destPartIdx, const FSize srcPartIdx, const ParticleClassContainer* particles){ // Copy position positionsPointers[0][destPartIdx] = particles->getPositions()[0][srcPartIdx]; positionsPointers[1][destPartIdx] = particles->getPositions()[1][srcPartIdx]; diff --git a/Src/GroupTree/Core/FGroupOfParticles.hpp b/Src/GroupTree/Core/FGroupOfParticles.hpp index 88c00de25..70d277108 100644 --- a/Src/GroupTree/Core/FGroupOfParticles.hpp +++ b/Src/GroupTree/Core/FGroupOfParticles.hpp @@ -28,18 +28,18 @@ class FGroupOfParticles { int blockIndexesTableSize; //< The real number of particles allocated - int nbParticlesAllocatedInGroup; + FSize nbParticlesAllocatedInGroup; //< Bytes difference/offset between position size_t positionOffset; //< Bytes difference/offset between attributes size_t attributeOffset; //< The total number of particles in the group - int nbParticlesInGroup; + FSize nbParticlesInGroup; }; /** Information about a leaf */ struct alignas(FStarPUDefaultAlign::StructAlign) LeafHeader { - int nbParticles; + FSize nbParticles; size_t offSet; }; @@ -73,7 +73,7 @@ protected: //< Pointer to leaves information LeafHeader* leafHeader; //< The total number of particles in the group - const int nbParticlesInGroup; + const FSize nbParticlesInGroup; //< Pointers to particle position x, y, z FReal* particlePosition[3]; @@ -129,13 +129,13 @@ public: * @param inEndingIndex last leaf morton index + 1 * @param inNumberOfLeaves total number of leaves in the interval (should be <= inEndingIndex-inEndingIndex) */ - FGroupOfParticles(const MortonIndex inStartingIndex, const MortonIndex inEndingIndex, const int inNumberOfLeaves, const int inNbParticles) + FGroupOfParticles(const MortonIndex inStartingIndex, const MortonIndex inEndingIndex, const int inNumberOfLeaves, const FSize inNbParticles) : allocatedMemoryInByte(0), memoryBuffer(nullptr), blockHeader(nullptr), blockIndexesTable(nullptr), leafHeader(nullptr), nbParticlesInGroup(inNbParticles), deleteBuffer(true){ memset(particlePosition, 0, sizeof(particlePosition)); memset(particleAttributes, 0, sizeof(particleAttributes)); - const int nbParticlesAllocatedInGroup = RoundToUpperParticles(nbParticlesInGroup+(MemoryAlignementParticles-1)*inNumberOfLeaves); + const FSize nbParticlesAllocatedInGroup = RoundToUpperParticles(nbParticlesInGroup+(MemoryAlignementParticles-1)*inNumberOfLeaves); // Find the number of leaf to allocate in the blocks const int blockIndexesTableSize = int(inEndingIndex-inStartingIndex); @@ -248,7 +248,7 @@ public: } /** Get the total number of particles in the group */ - int getNbParticlesInGroup() const { + FSize getNbParticlesInGroup() const { return nbParticlesInGroup; } @@ -268,7 +268,7 @@ public: } /** Allocate a new leaf by calling its constructor */ - size_t newLeaf(const MortonIndex inIndex, const int id, const int nbParticles, const size_t offsetInGroup){ + size_t newLeaf(const MortonIndex inIndex, const int id, const FSize nbParticles, const size_t offsetInGroup){ FAssertLF(isInside(inIndex)); FAssertLF(!exists(inIndex)); FAssertLF(id < blockHeader->blockIndexesTableSize); diff --git a/Src/GroupTree/Core/FGroupTree.hpp b/Src/GroupTree/Core/FGroupTree.hpp index b3b3e0ceb..de532642a 100644 --- a/Src/GroupTree/Core/FGroupTree.hpp +++ b/Src/GroupTree/Core/FGroupTree.hpp @@ -77,7 +77,7 @@ public: typename OctreeClass::Iterator blockIteratorInOctree = octreeIterator; // Move the iterator per nbElementsPerBlock (or until it cannot move right) int sizeOfBlock = 1; - int nbParticlesInGroup = octreeIterator.getCurrentLeaf()->getSrc()->getNbParticles(); + FSize nbParticlesInGroup = octreeIterator.getCurrentLeaf()->getSrc()->getNbParticles(); while(sizeOfBlock < nbElementsPerBlock && octreeIterator.moveRight()){ sizeOfBlock += 1; nbParticlesInGroup += octreeIterator.getCurrentLeaf()->getSrc()->getNbParticles(); @@ -192,18 +192,18 @@ public: { // Build morton index for particles struct ParticleSortingStruct{ - int originalIndex; + FSize originalIndex; MortonIndex mindex; }; // Convert position to morton index - const int nbParticles = inParticlesContainer->getNbParticles(); + const FSize nbParticles = inParticlesContainer->getNbParticles(); ParticleSortingStruct* particlesToSort = new ParticleSortingStruct[nbParticles]; { const FReal* xpos = inParticlesContainer->getPositions()[0]; const FReal* ypos = inParticlesContainer->getPositions()[1]; const FReal* zpos = inParticlesContainer->getPositions()[2]; - for(int idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ const FTreeCoordinate host = FCoordinateComputer::GetCoordinateFromPositionAndCorner<FReal>(this->boxCorner, this->boxWidth, treeHeight, FPoint<FReal>(xpos[idxPart], ypos[idxPart], zpos[idxPart]) ); @@ -215,7 +215,7 @@ public: // Sort if needed if(particlesAreSorted == false){ - FQuickSort<ParticleSortingStruct, int>::QsOmp(particlesToSort, nbParticles, [](const ParticleSortingStruct& v1, const ParticleSortingStruct& v2){ + FQuickSort<ParticleSortingStruct, FSize>::QsOmp(particlesToSort, nbParticles, [](const ParticleSortingStruct& v1, const ParticleSortingStruct& v2){ return v1.mindex <= v2.mindex; }); } @@ -224,12 +224,12 @@ public: // Convert to block const int idxLevel = (treeHeight - 1); - int* nbParticlesPerLeaf = new int[nbElementsPerBlock]; - int firstParticle = 0; + FSize* nbParticlesPerLeaf = new FSize[nbElementsPerBlock]; + FSize firstParticle = 0; // We need to proceed each group in sub level while(firstParticle != nbParticles){ int sizeOfBlock = 0; - int lastParticle = firstParticle; + FSize lastParticle = firstParticle; // Count until end of sub group is reached or we have enough cells while(sizeOfBlock < nbElementsPerBlock && lastParticle < nbParticles){ if(sizeOfBlock == 0 || currentBlockIndexes[sizeOfBlock-1] != particlesToSort[lastParticle].mindex){ @@ -257,7 +257,7 @@ public: // Init cells size_t nbParticlesOffsetBeforeLeaf = 0; - int offsetParticles = firstParticle; + FSize offsetParticles = firstParticle; for(int cellIdInBlock = 0; cellIdInBlock != sizeOfBlock ; ++cellIdInBlock){ newBlock->newCell(currentBlockIndexes[cellIdInBlock], cellIdInBlock); @@ -273,7 +273,7 @@ public: BasicAttachedClass attachedLeaf = newParticleBlock->template getLeaf<BasicAttachedClass>(currentBlockIndexes[cellIdInBlock]); // Copy each particle from the original position - for(int idxPart = 0 ; idxPart < nbParticlesPerLeaf[cellIdInBlock] ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesPerLeaf[cellIdInBlock] ; ++idxPart){ attachedLeaf.setParticle(idxPart, particlesToSort[idxPart + offsetParticles].originalIndex, inParticlesContainer); } offsetParticles += nbParticlesPerLeaf[cellIdInBlock]; @@ -394,18 +394,18 @@ public: { // Build morton index for particles struct ParticleSortingStruct{ - int originalIndex; + FSize originalIndex; MortonIndex mindex; }; // Convert position to morton index - const int nbParticles = inParticlesContainer->getNbParticles(); + const FSize nbParticles = inParticlesContainer->getNbParticles(); ParticleSortingStruct* particlesToSort = new ParticleSortingStruct[nbParticles]; { const FReal* xpos = inParticlesContainer->getPositions()[0]; const FReal* ypos = inParticlesContainer->getPositions()[1]; const FReal* zpos = inParticlesContainer->getPositions()[2]; - for(int idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ const FTreeCoordinate host = FCoordinateComputer::GetCoordinateFromPositionAndCorner<FReal>(this->boxCorner, this->boxWidth, treeHeight, FPoint<FReal>(xpos[idxPart], ypos[idxPart], zpos[idxPart]) ); @@ -417,7 +417,7 @@ public: // Sort if needed if(particlesAreSorted == false){ - FQuickSort<ParticleSortingStruct, int>::QsOmp(particlesToSort, nbParticles, [](const ParticleSortingStruct& v1, const ParticleSortingStruct& v2){ + FQuickSort<ParticleSortingStruct, FSize>::QsOmp(particlesToSort, nbParticles, [](const ParticleSortingStruct& v1, const ParticleSortingStruct& v2){ return v1.mindex <= v2.mindex; }); } @@ -479,7 +479,7 @@ public: BasicAttachedClass attachedLeaf = newParticleBlock->template getLeaf<BasicAttachedClass>(currentBlockIndexes[cellIdInBlock]); // Copy each particle from the original position - for(int idxPart = 0 ; idxPart < nbParticlesPerLeaf[cellIdInBlock] ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesPerLeaf[cellIdInBlock] ; ++idxPart){ attachedLeaf.setParticle(idxPart, particlesToSort[idxPart + offsetParticles].originalIndex, inParticlesContainer); } offsetParticles += nbParticlesPerLeaf[cellIdInBlock]; @@ -733,7 +733,7 @@ public: std::cout << "There are " << particleBlocks.size() << " leaf-groups.\n"; int idxGroup = 0; - int totalNbParticles = 0; + FSize totalNbParticles = 0; for (const ParticleGroupClass* block: particleBlocks){ std::cout << "\t Group " << (idxGroup++); std::cout << "\t Size = " << block->getNumberOfLeavesInBlock(); diff --git a/Src/GroupTree/Core/FP2PGroupParticleContainer.hpp b/Src/GroupTree/Core/FP2PGroupParticleContainer.hpp index ab79b3bfb..b02a8dbcf 100644 --- a/Src/GroupTree/Core/FP2PGroupParticleContainer.hpp +++ b/Src/GroupTree/Core/FP2PGroupParticleContainer.hpp @@ -12,7 +12,7 @@ class FP2PGroupParticleContainer : public FGroupAttachedLeaf<FReal, NVALS*NRHS, public: FP2PGroupParticleContainer(){} - FP2PGroupParticleContainer(const int inNbParticles, FReal* inPositionBuffer, const size_t inLeadingPosition, + FP2PGroupParticleContainer(const FSize inNbParticles, FReal* inPositionBuffer, const size_t inLeadingPosition, FReal* inAttributesBuffer, const size_t inLeadingAttributes) : Parent(inNbParticles, inPositionBuffer, inLeadingPosition, inAttributesBuffer, inLeadingAttributes) { diff --git a/Src/GroupTree/Cuda/FCudaGroupAttachedLeaf.hpp b/Src/GroupTree/Cuda/FCudaGroupAttachedLeaf.hpp index 89c92dd2f..1daa5404d 100644 --- a/Src/GroupTree/Cuda/FCudaGroupAttachedLeaf.hpp +++ b/Src/GroupTree/Cuda/FCudaGroupAttachedLeaf.hpp @@ -8,7 +8,7 @@ template <class FReal, unsigned NbSymbAttributes, unsigned NbAttributesPerPartic class FCudaGroupAttachedLeaf { protected: //< Nb of particles in the current leaf - int nbParticles; + FSize nbParticles; //< Pointers to the positions of the particles FReal* positionsPointers[3]; //< Pointers to the attributes of the particles @@ -29,7 +29,7 @@ public: * @param inAttributesBuffer the memory address of the first attribute * @param inLeadingAttributes each attribute is access by inAttributesBuffer + in bytes inLeadingAttributes*idx */ - __device__ FCudaGroupAttachedLeaf(const int inNbParticles, FReal* inPositionBuffer, const size_t inLeadingPosition, + __device__ FCudaGroupAttachedLeaf(const FSize inNbParticles, FReal* inPositionBuffer, const size_t inLeadingPosition, AttributeClass* inAttributesBuffer, const size_t inLeadingAttributes) : nbParticles(inNbParticles){ // Redirect pointers to position @@ -84,7 +84,7 @@ public: * @brief getNbParticles * @return the number of particles in the leaf */ - __device__ int getNbParticles() const{ + __device__ FSize getNbParticles() const{ return nbParticles; } @@ -147,7 +147,7 @@ public: /** Copy data for one particle (from the ParticleClassContainer into the attached buffer) */ template<class ParticleClassContainer> - __device__ void setParticle(const int destPartIdx, const int srcPartIdx, const ParticleClassContainer* particles){ + __device__ void setParticle(const FSize destPartIdx, const FSize srcPartIdx, const ParticleClassContainer* particles){ // Copy position positionsPointers[0][destPartIdx] = particles->getPositions()[0][srcPartIdx]; positionsPointers[1][destPartIdx] = particles->getPositions()[1][srcPartIdx]; diff --git a/Src/GroupTree/Cuda/FCudaGroupOfParticles.hpp b/Src/GroupTree/Cuda/FCudaGroupOfParticles.hpp index 0191ea7db..140f1efdb 100644 --- a/Src/GroupTree/Cuda/FCudaGroupOfParticles.hpp +++ b/Src/GroupTree/Cuda/FCudaGroupOfParticles.hpp @@ -16,18 +16,18 @@ class FCudaGroupOfParticles { int blockIndexesTableSize; //< The real number of particles allocated - int nbParticlesAllocatedInGroup; + FSize nbParticlesAllocatedInGroup; //< Bytes difference/offset between position size_t positionOffset; //< Bytes difference/offset between attributes size_t attributeOffset; //< The total number of particles in the group - int nbParticlesInGroup; + FSize nbParticlesInGroup; }; /** Information about a leaf */ struct alignas(FStarPUDefaultAlign::StructAlign) LeafHeader { - int nbParticles; + FSize nbParticles; size_t offSet; }; @@ -61,7 +61,7 @@ protected: //< Pointer to leaves information LeafHeader* leafHeader; //< The total number of particles in the group - const int nbParticlesInGroup; + const FSize nbParticlesInGroup; //< Pointers to particle position x, y, z FReal* particlePosition[3]; @@ -124,7 +124,7 @@ public: } /** Get the total number of particles in the group */ - __device__ int getNbParticlesInGroup() const { + __device__ FSize getNbParticlesInGroup() const { return nbParticlesInGroup; } diff --git a/Src/GroupTree/TestKernel/FCudaTestKernels.hpp b/Src/GroupTree/TestKernel/FCudaTestKernels.hpp index 21d56ae66..d9317f354 100644 --- a/Src/GroupTree/TestKernel/FCudaTestKernels.hpp +++ b/Src/GroupTree/TestKernel/FCudaTestKernels.hpp @@ -63,7 +63,7 @@ public: if(threadIdx.x == 0) { // The particles is impacted by the parent cell long long int*const particlesAttributes = particles->template getAttribute<0>(); - for(int idxPart = 0 ; idxPart < particles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < particles->getNbParticles() ; ++idxPart){ particlesAttributes[idxPart] += *local.down; } } @@ -87,7 +87,7 @@ public: } long long int*const particlesAttributes = targets->template getAttribute<0>(); - for(int idxPart = 0 ; idxPart < targets->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < targets->getNbParticles() ; ++idxPart){ particlesAttributes[idxPart] += inc; } } @@ -107,7 +107,7 @@ public: } long long int*const particlesAttributes = targets->template getAttribute<0>(); - for(int idxPart = 0 ; idxPart < targets->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < targets->getNbParticles() ; ++idxPart){ particlesAttributes[idxPart] += inc; } } diff --git a/Src/GroupTree/TestKernel/FGroupTestParticleContainer.hpp b/Src/GroupTree/TestKernel/FGroupTestParticleContainer.hpp index b3dae24d1..9896f077f 100644 --- a/Src/GroupTree/TestKernel/FGroupTestParticleContainer.hpp +++ b/Src/GroupTree/TestKernel/FGroupTestParticleContainer.hpp @@ -12,7 +12,7 @@ class FGroupTestParticleContainer : public FGroupAttachedLeaf<FReal, 0, 1, long public: FGroupTestParticleContainer(){} - FGroupTestParticleContainer(const int inNbParticles, FReal* inPositionBuffer, const size_t inLeadingPosition, + FGroupTestParticleContainer(const FSize inNbParticles, FReal* inPositionBuffer, const size_t inLeadingPosition, long long int* inAttributesBuffer, const size_t inLeadingAttributes) : Parent(inNbParticles, inPositionBuffer, inLeadingPosition, inAttributesBuffer, inLeadingAttributes) { diff --git a/Src/GroupTree/TestKernel/FTestCellPOD.hpp b/Src/GroupTree/TestKernel/FTestCellPOD.hpp index f6381db42..fe3cdfff9 100644 --- a/Src/GroupTree/TestKernel/FTestCellPOD.hpp +++ b/Src/GroupTree/TestKernel/FTestCellPOD.hpp @@ -78,61 +78,6 @@ public: (*up) = 0; } - ///////////////////////////////////////////////// - - /** Save the current cell in a buffer */ - template <class BufferWriterClass> - void save(BufferWriterClass& buffer) const{ - buffer << symb->mortonIndex << symb->coordinates[0] - << symb->coordinates[1] << symb->coordinates[2]; - buffer << (*down) << (*up); - } - - /** Restore the current cell from a buffer */ - template <class BufferReaderClass> - void restore(BufferReaderClass& buffer){ - buffer >> symb->mortonIndex >> symb->coordinates[0] - >> symb->coordinates[1] >> symb->coordinates[2]; - buffer >> (*down) >> (*up); - } - - int getSavedSize() const { - return int(sizeof(symb->mortonIndex) + sizeof(symb->coordinates[0]) + - sizeof(symb->coordinates[1]) + sizeof(symb->coordinates[2]) + - sizeof((*down)) + sizeof((*up))); - } - - ///////////////////////////////////////////////// - - /** Serialize only up data in a buffer */ - template <class BufferWriterClass> - void serializeUp(BufferWriterClass& buffer) const { - buffer << (*up); - } - /** Deserialize only up data in a buffer */ - template <class BufferReaderClass> - void deserializeUp(BufferReaderClass& buffer){ - buffer >> (*up); - } - - /** Serialize only down data in a buffer */ - template <class BufferWriterClass> - void serializeDown(BufferWriterClass& buffer) const { - buffer << (*down); - } - /** Deserialize only up data in a buffer */ - template <class BufferReaderClass> - void deserializeDown(BufferReaderClass& buffer){ - buffer >> (*down); - } - - int getSavedSizeDown() { - return int(sizeof(FTestCellPODData)); - } - - int getSavedSizeUp() { - return int(sizeof(FTestCellPODData)); - } }; diff --git a/Src/GroupTree/TestKernel/FTestKernel.cl b/Src/GroupTree/TestKernel/FTestKernel.cl index dfa30b433..81711a970 100644 --- a/Src/GroupTree/TestKernel/FTestKernel.cl +++ b/Src/GroupTree/TestKernel/FTestKernel.cl @@ -200,14 +200,14 @@ void FSetToNullptr343(struct FWrappeCell ptrs[343]){ struct FOpenCLGroupAttachedLeaf { //< Nb of particles in the current leaf - int nbParticles; + FSize nbParticles; //< Pointers to the positions of the particles __global FReal* positionsPointers[3]; //< Pointers to the attributes of the particles __global FParticleValueClass* attributes[NbSymbAttributes+NbAttributesPerParticle]; }; -struct FOpenCLGroupAttachedLeaf BuildFOpenCLGroupAttachedLeaf(const int inNbParticles, __global FReal* inPositionBuffer, const size_t inLeadingPosition, +struct FOpenCLGroupAttachedLeaf BuildFOpenCLGroupAttachedLeaf(const FSize inNbParticles, __global FReal* inPositionBuffer, const size_t inLeadingPosition, __global FParticleValueClass* inAttributesBuffer, const size_t inLeadingAttributes){ struct FOpenCLGroupAttachedLeaf leaf; leaf.nbParticles = (inNbParticles); @@ -265,18 +265,18 @@ struct FOpenCLGroupOfParticlesBlockHeader{ int blockIndexesTableSize; //< The real number of particles allocated - int nbParticlesAllocatedInGroup; + FSize nbParticlesAllocatedInGroup; //< Bytes difference/offset between position size_t positionOffset; //< Bytes difference/offset between attributes size_t attributeOffset; //< The total number of particles in the group - int nbParticlesInGroup; + FSize nbParticlesInGroup; }__attribute__ ((aligned (DefaultStructAlign))); /** Information about a leaf */ struct FOpenCLGroupOfParticlesLeafHeader { - int nbParticles; + FSize nbParticles; size_t offSet; }__attribute__ ((aligned (DefaultStructAlign))); @@ -294,7 +294,7 @@ struct FOpenCLGroupOfParticles { //< Pointer to leaves information __global struct FOpenCLGroupOfParticlesLeafHeader* leafHeader; //< The total number of particles in the group - const int nbParticlesInGroup; + const FSize nbParticlesInGroup; //< Pointers to particle position x, y, z __global FReal* particlePosition[3]; @@ -384,7 +384,7 @@ struct FOpenCLGroupOfCellsBlockHeader{ struct FOpenCLGroupOfCells { //< The size of the memoryBuffer - int allocatedMemoryInByte; + size_t allocatedMemoryInByte; //< Pointer to a block memory __global unsigned char* memoryBuffer; @@ -509,7 +509,7 @@ void L2L(const struct FWrappeCell localCell, struct FWrappeCell child[8], const void L2P(const struct FWrappeCell localCell, struct FOpenCLGroupAttachedLeaf particles, __global void* user_data){ __global long long* partdown = particles.attributes[0]; - for(int idxPart = 0 ; idxPart < particles.nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < particles.nbParticles ; ++idxPart){ partdown[idxPart] += *localCell.down; } } @@ -526,7 +526,7 @@ void P2P(const int3 pos, } __global long long* partdown = targets.attributes[0]; - for(int idxPart = 0 ; idxPart < targets.nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < targets.nbParticles ; ++idxPart){ partdown[idxPart] += cumul; } } @@ -535,7 +535,7 @@ void P2PRemote(const int3 pos, struct FOpenCLGroupAttachedLeaf targets, const struct FOpenCLGroupAttachedLeaf sources, struct FOpenCLGroupAttachedLeaf directNeighborsParticles, const int position, __global void* user_data){ __global long long* partdown = targets.attributes[0]; - for(int idxPart = 0 ; idxPart < targets.nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < targets.nbParticles ; ++idxPart){ partdown[idxPart] += directNeighborsParticles.nbParticles; } } diff --git a/Src/Kernels/Chebyshev/FChebCell.hpp b/Src/Kernels/Chebyshev/FChebCell.hpp index 94328a349..88be11a4d 100644 --- a/Src/Kernels/Chebyshev/FChebCell.hpp +++ b/Src/Kernels/Chebyshev/FChebCell.hpp @@ -33,137 +33,142 @@ template <class FReal, int ORDER, int NRHS = 1, int NLHS = 1, int NVALS = 1> class FChebCell : public FBasicCell { - // nnodes = ORDER^3 - // we multiply by 2 because we store the Multipole expansion end the compressed one. - static const int VectorSize = TensorTraits<ORDER>::nnodes * 2; + // nnodes = ORDER^3 + // we multiply by 2 because we store the Multipole expansion end the compressed one. + static const int VectorSize = TensorTraits<ORDER>::nnodes * 2; - FReal multipole_exp[NRHS * NVALS * VectorSize]; //< Multipole expansion - FReal local_exp[NLHS * NVALS * VectorSize]; //< Local expansion + FReal multipole_exp[NRHS * NVALS * VectorSize]; //< Multipole expansion + FReal local_exp[NLHS * NVALS * VectorSize]; //< Local expansion public: - FChebCell(){ - memset(multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize); - memset(local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize); - } - - ~FChebCell() {} - - /** Get Multipole */ - const FReal* getMultipole(const int inRhs) const - { return this->multipole_exp + inRhs*VectorSize; - } - /** Get Local */ - const FReal* getLocal(const int inRhs) const{ - return this->local_exp + inRhs*VectorSize; - } - - /** Get Multipole */ - FReal* getMultipole(const int inRhs){ - return this->multipole_exp + inRhs*VectorSize; - } - /** Get Local */ - FReal* getLocal(const int inRhs){ - return this->local_exp + inRhs*VectorSize; - } - - /** To get the leading dim of a vec */ - int getVectorSize() const{ - return VectorSize; - } - - /** Make it like the begining */ - void resetToInitialState(){ - memset(multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize); - memset(local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize); - } - - /////////////////////////////////////////////////////// - // to extend FAbstractSendable - /////////////////////////////////////////////////////// - template <class BufferWriterClass> - void serializeUp(BufferWriterClass& buffer) const{ - buffer.write(multipole_exp, VectorSize*NVALS*NRHS); - } - template <class BufferReaderClass> - void deserializeUp(BufferReaderClass& buffer){ - buffer.fillArray(multipole_exp, VectorSize*NVALS*NRHS); - } - - template <class BufferWriterClass> - void serializeDown(BufferWriterClass& buffer) const{ - buffer.write(local_exp, VectorSize*NVALS*NLHS); - } - template <class BufferReaderClass> - void deserializeDown(BufferReaderClass& buffer){ - buffer.fillArray(local_exp, VectorSize*NVALS*NLHS); - } - - /////////////////////////////////////////////////////// - // to extend Serializable - /////////////////////////////////////////////////////// - template <class BufferWriterClass> - void save(BufferWriterClass& buffer) const{ - FBasicCell::save(buffer); - buffer.write(multipole_exp, VectorSize*NVALS*NRHS); - buffer.write(local_exp, VectorSize*NVALS*NLHS); - } - template <class BufferReaderClass> - void restore(BufferReaderClass& buffer){ - FBasicCell::restore(buffer); - buffer.fillArray(multipole_exp, VectorSize*NVALS*NRHS); - buffer.fillArray(local_exp, VectorSize*NVALS*NLHS); - } - - int getSavedSize() const { - return int(sizeof(FReal)) * VectorSize*(NRHS+NLHS)*NVALS + FBasicCell::getSavedSize(); - } - - int getSavedSizeUp() const { - return int(sizeof(FReal)) * VectorSize*(NRHS)*NVALS; - } - - int getSavedSizeDown() const { - return int(sizeof(FReal)) * VectorSize*(NLHS)*NVALS; - } - -// template <class StreamClass> -// const void print(StreamClass& output) const{ - template <class StreamClass> + FChebCell(){ + memset(multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize); + memset(local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize); + } + + ~FChebCell() {} + + /** Get Multipole */ + const FReal* getMultipole(const int inRhs) const + { return this->multipole_exp + inRhs*VectorSize; + } + /** Get Local */ + const FReal* getLocal(const int inRhs) const{ + return this->local_exp + inRhs*VectorSize; + } + + /** Get Multipole */ + FReal* getMultipole(const int inRhs){ + return this->multipole_exp + inRhs*VectorSize; + } + /** Get Local */ + FReal* getLocal(const int inRhs){ + return this->local_exp + inRhs*VectorSize; + } + + /** To get the leading dim of a vec */ + int getVectorSize() const{ + return VectorSize; + } + + /** Make it like the begining */ + void resetToInitialState(){ + memset(multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize); + memset(local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize); + } + + /////////////////////////////////////////////////////// + // to extend FAbstractSendable + /////////////////////////////////////////////////////// + template <class BufferWriterClass> + void serializeUp(BufferWriterClass& buffer) const{ + buffer.write(multipole_exp, VectorSize*NVALS*NRHS); + } + template <class BufferReaderClass> + void deserializeUp(BufferReaderClass& buffer){ + buffer.fillArray(multipole_exp, VectorSize*NVALS*NRHS); + } + + template <class BufferWriterClass> + void serializeDown(BufferWriterClass& buffer) const{ + buffer.write(local_exp, VectorSize*NVALS*NLHS); + } + template <class BufferReaderClass> + void deserializeDown(BufferReaderClass& buffer){ + buffer.fillArray(local_exp, VectorSize*NVALS*NLHS); + } + + /////////////////////////////////////////////////////// + // to extend Serializable + /////////////////////////////////////////////////////// + template <class BufferWriterClass> + void save(BufferWriterClass& buffer) const{ + FBasicCell::save(buffer); + buffer.write(multipole_exp, VectorSize*NVALS*NRHS); + buffer.write(local_exp, VectorSize*NVALS*NLHS); + } + template <class BufferReaderClass> + void restore(BufferReaderClass& buffer){ + FBasicCell::restore(buffer); + buffer.fillArray(multipole_exp, VectorSize*NVALS*NRHS); + buffer.fillArray(local_exp, VectorSize*NVALS*NLHS); + } + + FSize getSavedSize() const { + return FSize(sizeof(FReal)) * VectorSize*(NRHS+NLHS)*NVALS + FBasicCell::getSavedSize(); + } + + FSize getSavedSizeUp() const { + return FSize(sizeof(FReal)) * VectorSize*(NRHS)*NVALS; + } + + FSize getSavedSizeDown() const { + return FSize(sizeof(FReal)) * VectorSize*(NLHS)*NVALS; + } + + // template <class StreamClass> + // const void print(StreamClass& output) const{ + template <class StreamClass> friend StreamClass& operator<<(StreamClass& output, const FChebCell<FReal, ORDER, NRHS, NLHS, NVALS>& cell){ -// const void print() const{ - output <<" Multipole exp NRHS " <<NRHS <<" NVALS " <<NVALS << " VectorSize/2 " << cell.getVectorSize() *0.5<< std::endl; - for (int rhs= 0 ; rhs < NRHS ; ++rhs) { - const FReal* pole = cell.getMultipole(rhs); - for (int val= 0 ; val < NVALS ; ++val) { - output<< " val : " << val << " exp: " ; - for (int i= 0 ; i < cell.getVectorSize()/2 ; ++i) { - output<< pole[i] << " "; - } - output << std::endl; - } - } - return output; - } + // const void print() const{ + output <<" Multipole exp NRHS " <<NRHS <<" NVALS " <<NVALS << " VectorSize/2 " << cell.getVectorSize() *0.5<< std::endl; + for (int rhs= 0 ; rhs < NRHS ; ++rhs) { + const FReal* pole = cell.getMultipole(rhs); + for (int val= 0 ; val < NVALS ; ++val) { + output<< " val : " << val << " exp: " ; + for (int i= 0 ; i < cell.getVectorSize()/2 ; ++i) { + output<< pole[i] << " "; + } + output << std::endl; + } + } + return output; + } }; template <class FReal, int ORDER, int NRHS = 1, int NLHS = 1, int NVALS = 1> class FTypedChebCell : public FChebCell<FReal, ORDER,NRHS,NLHS,NVALS>, public FExtendCellType { public: - template <class BufferWriterClass> - void save(BufferWriterClass& buffer) const{ + template <class BufferWriterClass> + void save(BufferWriterClass& buffer) const{ FChebCell<FReal,ORDER,NRHS,NLHS,NVALS>::save(buffer); - FExtendCellType::save(buffer); - } - template <class BufferReaderClass> - void restore(BufferReaderClass& buffer){ + FExtendCellType::save(buffer); + } + template <class BufferReaderClass> + void restore(BufferReaderClass& buffer){ FChebCell<FReal,ORDER,NRHS,NLHS,NVALS>::restore(buffer); - FExtendCellType::restore(buffer); - } - void resetToInitialState(){ + FExtendCellType::restore(buffer); + } + void resetToInitialState(){ FChebCell<FReal,ORDER,NRHS,NLHS,NVALS>::resetToInitialState(); - FExtendCellType::resetToInitialState(); - } + FExtendCellType::resetToInitialState(); + } + + + FSize getSavedSize() const { + return FExtendCellType::getSavedSize() + FChebCell<FReal, ORDER,NRHS,NLHS,NVALS>::getSavedSize(); + } }; #endif //FCHEBCELL_HPP diff --git a/Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp b/Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp index fa50fa13a..0c9b2dac3 100644 --- a/Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp +++ b/Src/Kernels/Chebyshev/FChebFlopsSymKernel.hpp @@ -62,38 +62,38 @@ public: const FSmartPointer<SymmetryHandler, FSmartPointerMemory> SymHandler; /// tree height - const unsigned int inTreeHeight; + const unsigned int inTreeHeight; // count permuted local and multipole expansions - unsigned int* countExp; + unsigned int* countExp; - unsigned long long flopsP2M, flopsM2M, flopsM2L, flopsL2L, flopsL2P, flopsP2P; + unsigned long long flopsP2M, flopsM2M, flopsM2L, flopsL2L, flopsL2P, flopsP2P; - unsigned long long *flopsPerLevelM2M, *flopsPerLevelM2L, *flopsPerLevelL2L; + unsigned long long *flopsPerLevelM2M, *flopsPerLevelM2L, *flopsPerLevelL2L; // start flop counters - unsigned int countFlopsM2MorL2L() const + unsigned int countFlopsM2MorL2L() const { return 3 * nnodes * (2*ORDER-1); } - unsigned int countFlopsM2L(const unsigned int nexp, const unsigned int rank) const + unsigned int countFlopsM2L(const unsigned int nexp, const unsigned int rank) const { return nexp * (4*nnodes*rank - rank - nnodes); } - unsigned int countFlopsP2P() const + unsigned int countFlopsP2P() const { return 34; } - unsigned int countFlopsP2Pmutual() const + unsigned int countFlopsP2Pmutual() const { return 39; } - unsigned int countFlopsP2M(const unsigned int N) const { - const unsigned first = N * (18 + (ORDER-2) * 6 + (ORDER-1) * (6 + (ORDER-1) * (6 + (ORDER-1) * 2))); - const unsigned W2 = 3 * ORDER*(2*(ORDER-1)-1); - const unsigned W4 = 3 * (ORDER*(ORDER-1)*(2*(ORDER-1)-1) + ORDER*ORDER*(2*(ORDER-1)-1)); - const unsigned W8 = 3 * (2*(ORDER-1)-1) * (ORDER*(ORDER-1)*(ORDER-1) + ORDER*ORDER*(ORDER-1) + nnodes); + unsigned int countFlopsP2M(const unsigned int N) const { + const unsigned first = N * (18 + (ORDER-2) * 6 + (ORDER-1) * (6 + (ORDER-1) * (6 + (ORDER-1) * 2))); + const unsigned W2 = 3 * ORDER*(2*(ORDER-1)-1); + const unsigned W4 = 3 * (ORDER*(ORDER-1)*(2*(ORDER-1)-1) + ORDER*ORDER*(2*(ORDER-1)-1)); + const unsigned W8 = 3 * (2*(ORDER-1)-1) * (ORDER*(ORDER-1)*(ORDER-1) + ORDER*ORDER*(ORDER-1) + nnodes); return first + W2 + W4 + W8 + nnodes*11; } - unsigned int countFlopsL2PTotal(const unsigned int N) const { - const unsigned W0 = nnodes; - const unsigned W2 = 3 * (ORDER-1)*ORDER*ORDER * 2*ORDER; - const unsigned W4 = 3 * ORDER*(ORDER-1)*(ORDER-1) * 2*ORDER; - const unsigned W8 = (ORDER-1)*(ORDER-1)*(ORDER-1) * (2*ORDER-1); - const unsigned second = N * (38 + (ORDER-2)*15 + (ORDER-1)*((ORDER-1) * (27 + (ORDER-1) * 16))) + 6; + unsigned int countFlopsL2PTotal(const unsigned int N) const { + const unsigned W0 = nnodes; + const unsigned W2 = 3 * (ORDER-1)*ORDER*ORDER * 2*ORDER; + const unsigned W4 = 3 * ORDER*(ORDER-1)*(ORDER-1) * 2*ORDER; + const unsigned W8 = (ORDER-1)*(ORDER-1)*(ORDER-1) * (2*ORDER-1); + const unsigned second = N * (38 + (ORDER-2)*15 + (ORDER-1)*((ORDER-1) * (27 + (ORDER-1) * 16))) + 6; return W0 + W2 + W4 + W8 + second; } // end flop counters @@ -113,11 +113,11 @@ public: flopsP2M(0), flopsM2M(0), flopsM2L(0), flopsL2L(0), flopsL2P(0), flopsP2P(0), flopsPerLevelM2M(nullptr), flopsPerLevelM2L(nullptr), flopsPerLevelL2L(nullptr) { - countExp = new unsigned int [343]; - flopsPerLevelM2M = new unsigned long long [inTreeHeight]; - flopsPerLevelM2L = new unsigned long long [inTreeHeight]; - flopsPerLevelL2L = new unsigned long long [inTreeHeight]; - for (unsigned int level = 0; level<inTreeHeight; ++level) + countExp = new unsigned int [343]; + flopsPerLevelM2M = new unsigned long long [inTreeHeight]; + flopsPerLevelM2L = new unsigned long long [inTreeHeight]; + flopsPerLevelL2L = new unsigned long long [inTreeHeight]; + for (unsigned int level = 0; level<inTreeHeight; ++level) flopsPerLevelM2M[level] = flopsPerLevelM2L[level] = flopsPerLevelL2L[level] = 0; } @@ -127,7 +127,7 @@ public: FChebFlopsSymKernel(const FChebFlopsSymKernel& other) : SymHandler(other.SymHandler), flopsP2M(0), flopsM2M(0), flopsM2L(0), flopsL2L(0), flopsL2P(0), flopsP2P(0) - { countExp = new unsigned int [343]; } + { countExp = new unsigned int [343]; } @@ -149,18 +149,18 @@ public: std::cout << "\n==================================================" << "\n- Flops for P2M/M2M" << std::endl; - for (unsigned int level=0; level<inTreeHeight; ++level) + for (unsigned int level=0; level<inTreeHeight; ++level) if (level < inTreeHeight-1) std::cout << " |- at level " << level << " flops = " << flopsPerLevelM2M[level] << std::endl; else std::cout << " |- at level " << level << " flops = " << flopsP2M << std::endl; std::cout << "==================================================" << "\n- Flops for M2L" << std::endl; - for (unsigned int level=0; level<inTreeHeight; ++level) + for (unsigned int level=0; level<inTreeHeight; ++level) std::cout << " |- at level " << level << " flops = " << flopsPerLevelM2L[level] << std::endl; std::cout << "==================================================" << "\n- Flops for L2L/L2P" << std::endl; - for (unsigned int level=0; level<inTreeHeight; ++level) + for (unsigned int level=0; level<inTreeHeight; ++level) if (level < inTreeHeight-1) std::cout << " |- at level " << level << " flops = " << flopsPerLevelL2L[level] << std::endl; else @@ -177,7 +177,7 @@ public: void P2M(CellClass* const /* not needed */, const ContainerClass* const SourceParticles) { - flopsP2M += countFlopsP2M(SourceParticles->getNbParticles()); + flopsP2M += countFlopsP2M(int(SourceParticles->getNbParticles())); } @@ -186,8 +186,8 @@ public: const CellClass*const FRestrict *const FRestrict ChildCells, const int TreeLevel) { - unsigned int flops = 0; - for (unsigned int ChildIndex=0; ChildIndex < 8; ++ChildIndex) + unsigned int flops = 0; + for (unsigned int ChildIndex=0; ChildIndex < 8; ++ChildIndex) if (ChildCells[ChildIndex]) flops += countFlopsM2MorL2L(); flopsM2M += flops; flopsPerLevelM2M[TreeLevel] += flops; @@ -201,13 +201,13 @@ public: const int /* not needed */, const int TreeLevel) { - unsigned int flops = 0; + unsigned int flops = 0; // count how ofter each of the 16 interactions is used memset(countExp, 0, sizeof(int) * 343); - for (unsigned int idx=0; idx<343; ++idx) + for (unsigned int idx=0; idx<343; ++idx) if (SourceCells[idx]) countExp[SymHandler->pindices[idx]]++; // multiply (mat-mat-mul) - for (unsigned int pidx=0; pidx<343; ++pidx) + for (unsigned int pidx=0; pidx<343; ++pidx) if (countExp[pidx]) flops += countFlopsM2L(countExp[pidx], SymHandler->LowRank[pidx]) + countExp[pidx]*nnodes; flopsM2L += flops; @@ -219,8 +219,8 @@ public: CellClass* FRestrict *const FRestrict ChildCells, const int TreeLevel) { - unsigned int flops = 0; - for (unsigned int ChildIndex=0; ChildIndex < 8; ++ChildIndex) + unsigned int flops = 0; + for (unsigned int ChildIndex=0; ChildIndex < 8; ++ChildIndex) if (ChildCells[ChildIndex]) flops += countFlopsM2MorL2L() + nnodes; flopsL2L += flops; flopsPerLevelL2L[TreeLevel] += flops; @@ -239,7 +239,7 @@ public: // or // 2) apply Sx and Px (grad Sx) - flopsL2P += countFlopsL2PTotal(TargetParticles->getNbParticles()) + 4 * TargetParticles->getNbParticles(); + flopsL2P += countFlopsL2PTotal(int(TargetParticles->getNbParticles())) + 4 * int(TargetParticles->getNbParticles()); } @@ -252,12 +252,12 @@ public: { if (TargetParticles != SourceParticles) { flopsP2P += countFlopsP2P() * TargetParticles->getNbParticles() * SourceParticles->getNbParticles(); - for (unsigned int idx=0; idx<27; ++idx) + for (unsigned int idx=0; idx<27; ++idx) if (NeighborSourceParticles[idx]) flopsP2P += countFlopsP2P() * TargetParticles->getNbParticles() * NeighborSourceParticles[idx]->getNbParticles(); } else { flopsP2P += countFlopsP2Pmutual() * ((TargetParticles->getNbParticles()*TargetParticles->getNbParticles()+TargetParticles->getNbParticles()) / 2); - for (unsigned int idx=0; idx<=13; ++idx) + for (unsigned int idx=0; idx<=13; ++idx) if (NeighborSourceParticles[idx]) flopsP2P += countFlopsP2Pmutual() * TargetParticles->getNbParticles() * NeighborSourceParticles[idx]->getNbParticles(); } @@ -291,19 +291,19 @@ struct FChebFlopsSymKernel<FReal, CellClass, ContainerClass, MatrixKernelClass, int LowRank[343]; // permutation vectors and permutated indices - unsigned int pvectors[343][nnodes]; - unsigned int pindices[343]; + unsigned int pvectors[343][nnodes]; + unsigned int pindices[343]; // compute rank - unsigned int getRank(const FReal singular_values[], const double eps) + unsigned int getRank(const FReal singular_values[], const double eps) { FReal nrm2(0.); - for (unsigned int k=0; k<nnodes; ++k) + for (unsigned int k=0; k<nnodes; ++k) nrm2 += singular_values[k] * singular_values[k]; FReal nrm2k(0.); - for (unsigned int k=nnodes; k>0; --k) { + for (unsigned int k=nnodes; k>0; --k) { nrm2k += singular_values[k-1] * singular_values[k-1]; if (nrm2k > eps*eps * nrm2) return k; } @@ -316,7 +316,7 @@ struct FChebFlopsSymKernel<FReal, CellClass, ContainerClass, MatrixKernelClass, SymmetryHandler(const MatrixKernelClass *const MatrixKernel, const double Epsilon) { // init all 343 item to zero, because effectively only 16 exist - for (unsigned int t=0; t<343; ++t) { + for (unsigned int t=0; t<343; ++t) { K[t] = nullptr; LowRank[t] = 0; } @@ -327,7 +327,7 @@ struct FChebFlopsSymKernel<FReal, CellClass, ContainerClass, MatrixKernelClass, for (int j=-3; j<=3; ++j) for (int k=-3; k<=3; ++k) if (abs(i)>1 || abs(j)>1 || abs(k)>1) { - const unsigned int idx = ((i+3) * 7 + (j+3)) * 7 + (k+3); + const unsigned int idx = ((i+3) * 7 + (j+3)) * 7 + (k+3); pindices[idx] = Symmetries.getPermutationArrayAndIndex(i,j,k, pvectors[idx]); } @@ -340,7 +340,7 @@ struct FChebFlopsSymKernel<FReal, CellClass, ContainerClass, MatrixKernelClass, /** Destructor */ ~SymmetryHandler() { - for (unsigned int t=0; t<343; ++t) + for (unsigned int t=0; t<343; ++t) if (K[ t]!=nullptr) delete [] K[ t]; } @@ -357,12 +357,12 @@ private: FReal* U = new FReal [nnodes*nnodes]; // needed for the SVD - const unsigned int LWORK = 2 * (3*nnodes + nnodes); + const unsigned int LWORK = 2 * (3*nnodes + nnodes); FReal *const WORK = new FReal [LWORK]; FReal *const VT = new FReal [nnodes*nnodes]; FReal *const S = new FReal [nnodes]; - unsigned int counter = 0; + unsigned int counter = 0; for (int i=2; i<=3; ++i) { for (int j=0; j<=i; ++j) { for (int k=0; k<=j; ++k) { @@ -370,37 +370,37 @@ private: // assemble matrix const FPoint<FReal> cy(FReal(2.*i), FReal(2.*j), FReal(2.*k)); FChebTensor<FReal,ORDER>::setRoots(cy, FReal(2.), Y); - for (unsigned int n=0; n<nnodes; ++n) - for (unsigned int m=0; m<nnodes; ++m) + for (unsigned int n=0; n<nnodes; ++n) + for (unsigned int m=0; m<nnodes; ++m) U[n*nnodes + m] = MatrixKernel->evaluate(X[m], Y[n]); // applying weights //////////////////////////////////////// FReal weights[nnodes]; FChebTensor<FReal,ORDER>::setRootOfWeights(weights); - for (unsigned int n=0; n<nnodes; ++n) { + for (unsigned int n=0; n<nnodes; ++n) { FBlas::scal(nnodes, weights[n], U + n, nnodes); // scale rows FBlas::scal(nnodes, weights[n], U + n * nnodes); // scale cols } ////////////////////////////////////////////////////////// // truncated singular value decomposition of matrix - const unsigned int info = FBlas::gesvd(nnodes, nnodes, U, S, VT, nnodes, LWORK, WORK); + const unsigned int info = FBlas::gesvd(nnodes, nnodes, U, S, VT, nnodes, LWORK, WORK); if (info!=0) throw std::runtime_error("SVD did not converge with " + std::to_string(info)); - const unsigned int rank = this->getRank(S, Epsilon); + const unsigned int rank = this->getRank(S, Epsilon); // store - const unsigned int idx = (i+3)*7*7 + (j+3)*7 + (k+3); + const unsigned int idx = (i+3)*7*7 + (j+3)*7 + (k+3); assert(K[idx]==nullptr); K[idx] = new FReal [2*rank*nnodes]; LowRank[idx] = rank; - for (unsigned int r=0; r<rank; ++r) + for (unsigned int r=0; r<rank; ++r) FBlas::scal(nnodes, S[r], U + r*nnodes); FBlas::copy(rank*nnodes, U, K[idx]); - for (unsigned int r=0; r<rank; ++r) + for (unsigned int r=0; r<rank; ++r) FBlas::copy(nnodes, VT + r, nnodes, K[idx] + rank*nnodes + r*nnodes, 1); // un-weighting //////////////////////////////////////////// - for (unsigned int n=0; n<nnodes; ++n) { + for (unsigned int n=0; n<nnodes; ++n) { FBlas::scal(rank, FReal(1.) / weights[n], K[idx] + n, nnodes); // scale rows FBlas::scal(rank, FReal(1.) / weights[n], K[idx] + rank*nnodes + n, nnodes); // scale rows } diff --git a/Src/Kernels/Chebyshev/FChebInterface.h b/Src/Kernels/Chebyshev/FChebInterface.h index 6e7495f4d..78d8e6baf 100644 --- a/Src/Kernels/Chebyshev/FChebInterface.h +++ b/Src/Kernels/Chebyshev/FChebInterface.h @@ -48,12 +48,12 @@ ChebKernelStruct * ChebKernelStruct_create(int inTreeHeight, void ChebKernelStruct_free(void * kernel); //To access kernel member function -void ChebKernel_P2M(void * leafCell, int nbParticles,const int* particleIndexes, void* kernel); +void ChebKernel_P2M(void * leafCell, FSize nbParticles,const int* particleIndexes, void* kernel); void ChebKernel_M2M(int level, void* parentCell, int childPosition, void* childCell, void* kernel); void ChebKernel_M2L(int level, void* targetCell, void* sourceCell[343], void* kernel); void ChebKernel_L2L(int level, void* parentCell, int childPosition, void* childCell, void* kernel); -void ChebKernel_L2P(void* leafCell, int nbParticles, const int* particleIndexes, void* kernel); -void ChebKernel_P2P(int nbParticles, const int* particleIndexes, +void ChebKernel_L2P(void* leafCell, FSize nbParticles, const int* particleIndexes, void* kernel); +void ChebKernel_P2P(FSize nbParticles, const int* particleIndexes, const int * sourceParticleIndexes[27], int sourceNbPart[27],void* userData); typedef struct myUserDatas{ diff --git a/Src/Kernels/Chebyshev/FChebInterpolator.hpp b/Src/Kernels/Chebyshev/FChebInterpolator.hpp index fea298cbd..3ecd3e258 100644 --- a/Src/Kernels/Chebyshev/FChebInterpolator.hpp +++ b/Src/Kernels/Chebyshev/FChebInterpolator.hpp @@ -669,7 +669,7 @@ inline void FChebInterpolator<FReal, ORDER,MatrixKernelClass,NVALS>::applyP2M(co const FReal*const positionsY = inParticles->getPositions()[1]; const FReal*const positionsZ = inParticles->getPositions()[2]; - for(int idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++idxPart){ // map global position to [-1,1] map(FPoint<FReal>(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]), localPosition); // 15 flops @@ -913,7 +913,7 @@ inline void FChebInterpolator<FReal, ORDER,MatrixKernelClass,NVALS>::applyL2P(co const FReal*const positionsY = inParticles->getPositions()[1]; const FReal*const positionsZ = inParticles->getPositions()[2]; - for(int idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++ idxPart){ + for(FSize idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++ idxPart){ // map global position to [-1,1] map(FPoint<FReal>(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]), localPosition); // 15 flops @@ -1108,7 +1108,7 @@ inline void FChebInterpolator<FReal, ORDER,MatrixKernelClass,NVALS>::applyL2PGra const FReal*const positionsY = inParticles->getPositions()[1]; const FReal*const positionsZ = inParticles->getPositions()[2]; - for(int idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++ idxPart){ + for(FSize idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++ idxPart){ // map global position to [-1,1] map(FPoint<FReal>(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]), localPosition); @@ -1321,7 +1321,7 @@ inline void FChebInterpolator<FReal, ORDER,MatrixKernelClass,NVALS>::applyL2PTot const FReal*const positionsY = inParticles->getPositions()[1]; const FReal*const positionsZ = inParticles->getPositions()[2]; - for(int idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++ idxPart){ + for(FSize idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++ idxPart){ // map global position to [-1,1] map(FPoint<FReal>(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]), localPosition); // 15 flops diff --git a/Src/Kernels/Interpolation/FInterpCell.hpp b/Src/Kernels/Interpolation/FInterpCell.hpp index 161214948..01185658e 100644 --- a/Src/Kernels/Interpolation/FInterpCell.hpp +++ b/Src/Kernels/Interpolation/FInterpCell.hpp @@ -28,13 +28,13 @@ * @class FInterpCell * Please read the license * - * This class defines a cell that can be used in both Chebyshev and + * This class defines a cell that can be used in both Chebyshev and * Lagrange based FMM. - * - * PB: This class provides the storage and accessors for the transformed + * + * PB: This class provides the storage and accessors for the transformed * expansion used in the Uniform FMM (in Fourier space, i.e. complex valued). * - * PB: Beware! This class does not support yet the storage of the compressed + * PB: Beware! This class does not support yet the storage of the compressed * expansions used in the low rank version of the Chebyshev FMM algorithm. * * @param NVALS is the number of right hand side. @@ -42,170 +42,174 @@ template <class FReal, int ORDER, int NRHS = 1, int NLHS = 1, int NVALS = 1> class FInterpCell : public FBasicCell { - static const int VectorSize = TensorTraits<ORDER>::nnodes; - static const int TransformedVectorSize = (2*ORDER-1)*(2*ORDER-1)*(2*ORDER-1); + static const int VectorSize = TensorTraits<ORDER>::nnodes; + static const int TransformedVectorSize = (2*ORDER-1)*(2*ORDER-1)*(2*ORDER-1); - FReal multipole_exp[NRHS * NVALS * VectorSize]; //< Multipole expansion - FReal local_exp[NLHS * NVALS * VectorSize]; //< Local expansion - // PB: Store multipole and local expansion in Fourier space - FComplex<FReal> transformed_multipole_exp[NRHS * NVALS * TransformedVectorSize]; - FComplex<FReal> transformed_local_exp[NLHS * NVALS * TransformedVectorSize]; + FReal multipole_exp[NRHS * NVALS * VectorSize]; //< Multipole expansion + FReal local_exp[NLHS * NVALS * VectorSize]; //< Local expansion + // PB: Store multipole and local expansion in Fourier space + FComplex<FReal> transformed_multipole_exp[NRHS * NVALS * TransformedVectorSize]; + FComplex<FReal> transformed_local_exp[NLHS * NVALS * TransformedVectorSize]; public: - FInterpCell(){ - memset(multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize); - memset(local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize); - memset(transformed_multipole_exp, 0, - sizeof(FComplex<FReal>) * NRHS * NVALS * TransformedVectorSize); - memset(transformed_local_exp, 0, - sizeof(FComplex<FReal>) * NLHS * NVALS * TransformedVectorSize); - } - - ~FInterpCell() {} - - /** Get Multipole */ - const FReal* getMultipole(const int inRhs) const - { return this->multipole_exp + inRhs*VectorSize; - } - /** Get Local */ - const FReal* getLocal(const int inRhs) const{ - return this->local_exp + inRhs*VectorSize; - } - - /** Get Multipole */ - FReal* getMultipole(const int inRhs){ - return this->multipole_exp + inRhs*VectorSize; - } - /** Get Local */ - FReal* getLocal(const int inRhs){ - return this->local_exp + inRhs*VectorSize; - } - - /** To get the leading dim of a vec */ - int getVectorSize() const{ - return VectorSize; - } - - /** Get Transformed Multipole */ - const FComplex<FReal>* getTransformedMultipole(const int inRhs) const{ - return this->transformed_multipole_exp + inRhs*TransformedVectorSize; - } - /** Get Transformed Local */ - const FComplex<FReal>* getTransformedLocal(const int inRhs) const{ - return this->transformed_local_exp + inRhs*TransformedVectorSize; - } - - /** Get Transformed Multipole */ - FComplex<FReal>* getTransformedMultipole(const int inRhs){ - return this->transformed_multipole_exp + inRhs*TransformedVectorSize; - } - /** Get Transformed Local */ - FComplex<FReal>* getTransformedLocal(const int inRhs){ - return this->transformed_local_exp + inRhs*TransformedVectorSize; - } - - /** To get the leading dim of a vec */ - int getTransformedVectorSize() const{ - return TransformedVectorSize; - } - - /** Make it like the begining */ - void resetToInitialState(){ - memset(multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize); - memset(local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize); - memset(transformed_multipole_exp, 0, - sizeof(FComplex<FReal>) * NRHS * NVALS * TransformedVectorSize); - memset(transformed_local_exp, 0, - sizeof(FComplex<FReal>) * NLHS * NVALS * TransformedVectorSize); - } - - /////////////////////////////////////////////////////// - // to extend FAbstractSendable - /////////////////////////////////////////////////////// - template <class BufferWriterClass> - void serializeUp(BufferWriterClass& buffer) const{ - buffer.write(multipole_exp, VectorSize*NVALS*NRHS); - buffer.write(transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS); - } - - template <class BufferReaderClass> - void deserializeUp(BufferReaderClass& buffer){ - buffer.fillArray(multipole_exp, VectorSize*NVALS*NRHS); - buffer.fillArray(transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS); - } - - template <class BufferWriterClass> - void serializeDown(BufferWriterClass& buffer) const{ - buffer.write(local_exp, VectorSize*NVALS*NLHS); - buffer.write(transformed_local_exp, TransformedVectorSize*NVALS*NLHS); - } - - template <class BufferReaderClass> - void deserializeDown(BufferReaderClass& buffer){ - buffer.fillArray(local_exp, VectorSize*NVALS*NLHS); - buffer.fillArray(transformed_local_exp, TransformedVectorSize*NVALS*NLHS); - } - - /////////////////////////////////////////////////////// - // to extend Serializable - /////////////////////////////////////////////////////// - template <class BufferWriterClass> - void save(BufferWriterClass& buffer) const{ - FBasicCell::save(buffer); - buffer.write(multipole_exp, VectorSize*NVALS*NRHS); - buffer.write(transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS); - buffer.write(local_exp, VectorSize*NVALS*NLHS); - buffer.write(transformed_local_exp, TransformedVectorSize*NVALS*NLHS); - } - - template <class BufferReaderClass> - void restore(BufferReaderClass& buffer){ - FBasicCell::restore(buffer); - buffer.fillArray(multipole_exp, VectorSize*NVALS*NRHS); - buffer.fillArray(transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS); - buffer.fillArray(local_exp, VectorSize*NVALS*NLHS); - buffer.fillArray(transformed_local_exp, TransformedVectorSize*NVALS*NLHS); - } - - static constexpr int GetSize(){ - return (NRHS+NLHS)*NVALS*VectorSize * (int) sizeof(FReal) + (NRHS+NLHS)*NVALS*TransformedVectorSize * (int) sizeof(FComplex<FReal>); - } - - int getSavedSize() const { - return (NRHS+NLHS)*NVALS*VectorSize * (int) sizeof(FReal) - + (NRHS+NLHS)*NVALS*TransformedVectorSize * (int) sizeof(FComplex<FReal>) - + FBasicCell::getSavedSize(); - } - - int getSavedSizeUp() const { - return (NRHS)*NVALS*VectorSize * (int) sizeof(FReal) - + (NRHS)*NVALS*TransformedVectorSize * (int) sizeof(FComplex<FReal>); - } - - int getSavedSizeDown() const { - return (NLHS)*NVALS*VectorSize * (int) sizeof(FReal) - + (NLHS)*NVALS*TransformedVectorSize * (int) sizeof(FComplex<FReal>); - } + FInterpCell(){ + memset(multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize); + memset(local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize); + memset(transformed_multipole_exp, 0, + sizeof(FComplex<FReal>) * NRHS * NVALS * TransformedVectorSize); + memset(transformed_local_exp, 0, + sizeof(FComplex<FReal>) * NLHS * NVALS * TransformedVectorSize); + } + + ~FInterpCell() {} + + /** Get Multipole */ + const FReal* getMultipole(const int inRhs) const + { return this->multipole_exp + inRhs*VectorSize; + } + /** Get Local */ + const FReal* getLocal(const int inRhs) const{ + return this->local_exp + inRhs*VectorSize; + } + + /** Get Multipole */ + FReal* getMultipole(const int inRhs){ + return this->multipole_exp + inRhs*VectorSize; + } + /** Get Local */ + FReal* getLocal(const int inRhs){ + return this->local_exp + inRhs*VectorSize; + } + + /** To get the leading dim of a vec */ + int getVectorSize() const{ + return VectorSize; + } + + /** Get Transformed Multipole */ + const FComplex<FReal>* getTransformedMultipole(const int inRhs) const{ + return this->transformed_multipole_exp + inRhs*TransformedVectorSize; + } + /** Get Transformed Local */ + const FComplex<FReal>* getTransformedLocal(const int inRhs) const{ + return this->transformed_local_exp + inRhs*TransformedVectorSize; + } + + /** Get Transformed Multipole */ + FComplex<FReal>* getTransformedMultipole(const int inRhs){ + return this->transformed_multipole_exp + inRhs*TransformedVectorSize; + } + /** Get Transformed Local */ + FComplex<FReal>* getTransformedLocal(const int inRhs){ + return this->transformed_local_exp + inRhs*TransformedVectorSize; + } + + /** To get the leading dim of a vec */ + int getTransformedVectorSize() const{ + return TransformedVectorSize; + } + + /** Make it like the begining */ + void resetToInitialState(){ + memset(multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize); + memset(local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize); + memset(transformed_multipole_exp, 0, + sizeof(FComplex<FReal>) * NRHS * NVALS * TransformedVectorSize); + memset(transformed_local_exp, 0, + sizeof(FComplex<FReal>) * NLHS * NVALS * TransformedVectorSize); + } + + /////////////////////////////////////////////////////// + // to extend FAbstractSendable + /////////////////////////////////////////////////////// + template <class BufferWriterClass> + void serializeUp(BufferWriterClass& buffer) const{ + buffer.write(multipole_exp, VectorSize*NVALS*NRHS); + buffer.write(transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS); + } + + template <class BufferReaderClass> + void deserializeUp(BufferReaderClass& buffer){ + buffer.fillArray(multipole_exp, VectorSize*NVALS*NRHS); + buffer.fillArray(transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS); + } + + template <class BufferWriterClass> + void serializeDown(BufferWriterClass& buffer) const{ + buffer.write(local_exp, VectorSize*NVALS*NLHS); + buffer.write(transformed_local_exp, TransformedVectorSize*NVALS*NLHS); + } + + template <class BufferReaderClass> + void deserializeDown(BufferReaderClass& buffer){ + buffer.fillArray(local_exp, VectorSize*NVALS*NLHS); + buffer.fillArray(transformed_local_exp, TransformedVectorSize*NVALS*NLHS); + } + + /////////////////////////////////////////////////////// + // to extend Serializable + /////////////////////////////////////////////////////// + template <class BufferWriterClass> + void save(BufferWriterClass& buffer) const{ + FBasicCell::save(buffer); + buffer.write(multipole_exp, VectorSize*NVALS*NRHS); + buffer.write(transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS); + buffer.write(local_exp, VectorSize*NVALS*NLHS); + buffer.write(transformed_local_exp, TransformedVectorSize*NVALS*NLHS); + } + + template <class BufferReaderClass> + void restore(BufferReaderClass& buffer){ + FBasicCell::restore(buffer); + buffer.fillArray(multipole_exp, VectorSize*NVALS*NRHS); + buffer.fillArray(transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS); + buffer.fillArray(local_exp, VectorSize*NVALS*NLHS); + buffer.fillArray(transformed_local_exp, TransformedVectorSize*NVALS*NLHS); + } + + static constexpr int GetSize(){ + return (NRHS+NLHS)*NVALS*VectorSize * (int) sizeof(FReal) + (NRHS+NLHS)*NVALS*TransformedVectorSize * (int) sizeof(FComplex<FReal>); + } + + FSize getSavedSize() const { + return FSize((NRHS+NLHS)*NVALS*VectorSize * (int) sizeof(FReal) + + (NRHS+NLHS)*NVALS*TransformedVectorSize * (int) sizeof(FComplex<FReal>) + + FBasicCell::getSavedSize()); + } + + int getSavedSizeUp() const { + return FSize((NRHS)*NVALS*VectorSize * (int) sizeof(FReal) + + (NRHS)*NVALS*TransformedVectorSize * (int) sizeof(FComplex<FReal>)); + } + + int getSavedSizeDown() const { + return FSize((NLHS)*NVALS*VectorSize * (int) sizeof(FReal) + + (NLHS)*NVALS*TransformedVectorSize * (int) sizeof(FComplex<FReal>)); + } }; template <int ORDER, int NRHS = 1, int NLHS = 1, int NVALS = 1> class FTypedInterpCell : public FInterpCell<ORDER,NRHS,NLHS,NVALS>, public FExtendCellType { public: - template <class BufferWriterClass> - void save(BufferWriterClass& buffer) const{ - FInterpCell<ORDER,NRHS,NLHS,NVALS>::save(buffer); - FExtendCellType::save(buffer); - } - template <class BufferReaderClass> - void restore(BufferReaderClass& buffer){ - FInterpCell<ORDER,NRHS,NLHS,NVALS>::restore(buffer); - FExtendCellType::restore(buffer); - } - void resetToInitialState(){ - FInterpCell<ORDER,NRHS,NLHS,NVALS>::resetToInitialState(); - FExtendCellType::resetToInitialState(); - } + template <class BufferWriterClass> + void save(BufferWriterClass& buffer) const{ + FInterpCell<ORDER,NRHS,NLHS,NVALS>::save(buffer); + FExtendCellType::save(buffer); + } + template <class BufferReaderClass> + void restore(BufferReaderClass& buffer){ + FInterpCell<ORDER,NRHS,NLHS,NVALS>::restore(buffer); + FExtendCellType::restore(buffer); + } + void resetToInitialState(){ + FInterpCell<ORDER,NRHS,NLHS,NVALS>::resetToInitialState(); + FExtendCellType::resetToInitialState(); + } + + FSize getSavedSize() const { + return FExtendCellType::getSavedSize() + FInterpCell<FReal, ORDER,NRHS,NLHS,NVALS>::getSavedSize(); + } }; #endif //FINTERPCELL_HPP diff --git a/Src/Kernels/P2P/FP2P.hpp b/Src/Kernels/P2P/FP2P.hpp index a96a94e04..4117a6df4 100644 --- a/Src/Kernels/P2P/FP2P.hpp +++ b/Src/Kernels/P2P/FP2P.hpp @@ -205,20 +205,20 @@ inline void FullMutualKIJ(ContainerClass* const FRestrict inTargets, ContainerCl 1,3,4, 2,4,5}; - const int nbParticlesTargets = inTargets->getNbParticles(); + const FSize nbParticlesTargets = inTargets->getNbParticles(); const FReal*const targetsX = inTargets->getPositions()[0]; const FReal*const targetsY = inTargets->getPositions()[1]; const FReal*const targetsZ = inTargets->getPositions()[2]; - for(int idxNeighbors = 0 ; idxNeighbors < limiteNeighbors ; ++idxNeighbors){ - for(int idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ + for(FSize idxNeighbors = 0 ; idxNeighbors < limiteNeighbors ; ++idxNeighbors){ + for(FSize idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ if( inNeighbors[idxNeighbors] ){ - const int nbParticlesSources = inNeighbors[idxNeighbors]->getNbParticles(); + const FSize nbParticlesSources = inNeighbors[idxNeighbors]->getNbParticles(); const FReal*const sourcesX = inNeighbors[idxNeighbors]->getPositions()[0]; const FReal*const sourcesY = inNeighbors[idxNeighbors]->getPositions()[1]; const FReal*const sourcesZ = inNeighbors[idxNeighbors]->getPositions()[2]; - for(int idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){ + for(FSize idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){ // evaluate kernel and its partial derivatives const FPoint<FReal> sourcePoint(sourcesX[idxSource],sourcesY[idxSource],sourcesZ[idxSource]); @@ -264,8 +264,8 @@ inline void FullMutualKIJ(ContainerClass* const FRestrict inTargets, ContainerCl } } - for(int idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ - for(int idxSource = idxTarget + 1 ; idxSource < nbParticlesTargets ; ++idxSource){ + for(FSize idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ + for(FSize idxSource = idxTarget + 1 ; idxSource < nbParticlesTargets ; ++idxSource){ // evaluate kernel and its partial derivatives const FPoint<FReal> sourcePoint(targetsX[idxSource],targetsY[idxSource],targetsZ[idxSource]); @@ -318,20 +318,20 @@ inline void FullRemoteKIJ(ContainerClass* const FRestrict inTargets, ContainerCl 1,3,4, 2,4,5}; - const int nbParticlesTargets = inTargets->getNbParticles(); + const FSize nbParticlesTargets = inTargets->getNbParticles(); const FReal*const targetsX = inTargets->getPositions()[0]; const FReal*const targetsY = inTargets->getPositions()[1]; const FReal*const targetsZ = inTargets->getPositions()[2]; - for(int idxNeighbors = 0 ; idxNeighbors < limiteNeighbors ; ++idxNeighbors){ - for(int idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ + for(FSize idxNeighbors = 0 ; idxNeighbors < limiteNeighbors ; ++idxNeighbors){ + for(FSize idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ if( inNeighbors[idxNeighbors] ){ - const int nbParticlesSources = inNeighbors[idxNeighbors]->getNbParticles(); + const FSize nbParticlesSources = inNeighbors[idxNeighbors]->getNbParticles(); const FReal*const sourcesX = inNeighbors[idxNeighbors]->getPositions()[0]; const FReal*const sourcesY = inNeighbors[idxNeighbors]->getPositions()[1]; const FReal*const sourcesZ = inNeighbors[idxNeighbors]->getPositions()[2]; - for(int idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){ + for(FSize idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){ // evaluate kernel and its partial derivatives const FPoint<FReal> sourcePoint(sourcesX[idxSource],sourcesY[idxSource],sourcesZ[idxSource]); @@ -375,7 +375,7 @@ template <class FReal, class ContainerClass, class MatrixKernelClass, class Comp static void GenericFullMutual(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[], const int limiteNeighbors, const MatrixKernelClass *const MatrixKernel){ - const int nbParticlesTargets = inTargets->getNbParticles(); + const FSize nbParticlesTargets = inTargets->getNbParticles(); const FReal*const targetsPhysicalValues = inTargets->getPhysicalValues(); const FReal*const targetsX = inTargets->getPositions()[0]; const FReal*const targetsY = inTargets->getPositions()[1]; @@ -385,9 +385,9 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain FReal*const targetsForcesZ = inTargets->getForcesZ(); FReal*const targetsPotentials = inTargets->getPotentials(); - for(int idxNeighbors = 0 ; idxNeighbors < limiteNeighbors ; ++idxNeighbors){ + for(FSize idxNeighbors = 0 ; idxNeighbors < limiteNeighbors ; ++idxNeighbors){ if( inNeighbors[idxNeighbors] ){ - const int nbParticlesSources = (inNeighbors[idxNeighbors]->getNbParticles()+NbFRealInComputeClass-1)/NbFRealInComputeClass; + const FSize nbParticlesSources = (inNeighbors[idxNeighbors]->getNbParticles()+NbFRealInComputeClass-1)/NbFRealInComputeClass; const ComputeClass*const sourcesPhysicalValues = (const ComputeClass*)inNeighbors[idxNeighbors]->getPhysicalValues(); const ComputeClass*const sourcesX = (const ComputeClass*)inNeighbors[idxNeighbors]->getPositions()[0]; const ComputeClass*const sourcesY = (const ComputeClass*)inNeighbors[idxNeighbors]->getPositions()[1]; @@ -397,7 +397,7 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain ComputeClass*const sourcesForcesZ = (ComputeClass*)inNeighbors[idxNeighbors]->getForcesZ(); ComputeClass*const sourcesPotentials = (ComputeClass*)inNeighbors[idxNeighbors]->getPotentials(); - for(int idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ + for(FSize idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ const ComputeClass tx = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsX[idxTarget]); const ComputeClass ty = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsY[idxTarget]); const ComputeClass tz = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsZ[idxTarget]); @@ -407,7 +407,7 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain ComputeClass tfz = FMath::Zero<ComputeClass>(); ComputeClass tpo = FMath::Zero<ComputeClass>(); - for(int idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){ + for(FSize idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){ ComputeClass Kxy[1]; ComputeClass dKxy[3]; MatrixKernel->evaluateBlockAndDerivative(sourcesX[idxSource],sourcesY[idxSource],sourcesZ[idxSource], @@ -440,7 +440,7 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain {//In this part, we compute (vectorially) the interaction //within the target leaf. - const int nbParticlesSources = (nbParticlesTargets+NbFRealInComputeClass-1)/NbFRealInComputeClass; + const FSize nbParticlesSources = (nbParticlesTargets+NbFRealInComputeClass-1)/NbFRealInComputeClass; const ComputeClass*const sourcesPhysicalValues = (const ComputeClass*)targetsPhysicalValues; const ComputeClass*const sourcesX = (const ComputeClass*)targetsX; const ComputeClass*const sourcesY = (const ComputeClass*)targetsY; @@ -450,7 +450,7 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain ComputeClass*const sourcesForcesZ = (ComputeClass*)targetsForcesZ; ComputeClass*const sourcesPotentials = (ComputeClass*)targetsPotentials; - for(int idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ + for(FSize idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ const ComputeClass tx = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsX[idxTarget]); const ComputeClass ty = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsY[idxTarget]); const ComputeClass tz = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsZ[idxTarget]); @@ -460,7 +460,7 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain ComputeClass tfz = FMath::Zero<ComputeClass>(); ComputeClass tpo = FMath::Zero<ComputeClass>(); - for(int idxSource = (idxTarget+NbFRealInComputeClass)/NbFRealInComputeClass ; idxSource < nbParticlesSources ; ++idxSource){ + for(FSize idxSource = (idxTarget+NbFRealInComputeClass)/NbFRealInComputeClass ; idxSource < nbParticlesSources ; ++idxSource){ ComputeClass Kxy[1]; ComputeClass dKxy[3]; MatrixKernel->evaluateBlockAndDerivative(sourcesX[idxSource],sourcesY[idxSource],sourcesZ[idxSource], @@ -489,10 +489,10 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain } } - for(int idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ - const int limitForTarget = NbFRealInComputeClass-(idxTarget%NbFRealInComputeClass); - for(int idxS = 1 ; idxS < limitForTarget ; ++idxS){ - const int idxSource = idxTarget + idxS; + for(FSize idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ + const FSize limitForTarget = NbFRealInComputeClass-(idxTarget%NbFRealInComputeClass); + for(FSize idxS = 1 ; idxS < limitForTarget ; ++idxS){ + const FSize idxSource = idxTarget + idxS; FReal Kxy[1]; FReal dKxy[3]; MatrixKernel->evaluateBlockAndDerivative(targetsX[idxSource],targetsY[idxSource],targetsZ[idxSource], @@ -520,7 +520,7 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain template <class FReal, class ContainerClass, class MatrixKernelClass, class ComputeClass, int NbFRealInComputeClass> static void GenericFullRemote(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[], const int limiteNeighbors, const MatrixKernelClass *const MatrixKernel){ - const int nbParticlesTargets = inTargets->getNbParticles(); + const FSize nbParticlesTargets = inTargets->getNbParticles(); const FReal*const targetsPhysicalValues = inTargets->getPhysicalValues(); const FReal*const targetsX = inTargets->getPositions()[0]; const FReal*const targetsY = inTargets->getPositions()[1]; @@ -530,15 +530,15 @@ static void GenericFullRemote(ContainerClass* const FRestrict inTargets, Contain FReal*const targetsForcesZ = inTargets->getForcesZ(); FReal*const targetsPotentials = inTargets->getPotentials(); - for(int idxNeighbors = 0 ; idxNeighbors < limiteNeighbors ; ++idxNeighbors){ + for(FSize idxNeighbors = 0 ; idxNeighbors < limiteNeighbors ; ++idxNeighbors){ if( inNeighbors[idxNeighbors] ){ - const int nbParticlesSources = (inNeighbors[idxNeighbors]->getNbParticles()+NbFRealInComputeClass-1)/NbFRealInComputeClass; + const FSize nbParticlesSources = (inNeighbors[idxNeighbors]->getNbParticles()+NbFRealInComputeClass-1)/NbFRealInComputeClass; const ComputeClass*const sourcesPhysicalValues = (const ComputeClass*)inNeighbors[idxNeighbors]->getPhysicalValues(); const ComputeClass*const sourcesX = (const ComputeClass*)inNeighbors[idxNeighbors]->getPositions()[0]; const ComputeClass*const sourcesY = (const ComputeClass*)inNeighbors[idxNeighbors]->getPositions()[1]; const ComputeClass*const sourcesZ = (const ComputeClass*)inNeighbors[idxNeighbors]->getPositions()[2]; - for(int idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ + for(FSize idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ const ComputeClass tx = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsX[idxTarget]); const ComputeClass ty = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsY[idxTarget]); const ComputeClass tz = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsZ[idxTarget]); @@ -548,7 +548,7 @@ static void GenericFullRemote(ContainerClass* const FRestrict inTargets, Contain ComputeClass tfz = FMath::Zero<ComputeClass>(); ComputeClass tpo = FMath::Zero<ComputeClass>(); - for(int idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){ + for(FSize idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){ ComputeClass Kxy[1]; ComputeClass dKxy[3]; MatrixKernel->evaluateBlockAndDerivative(sourcesX[idxSource],sourcesY[idxSource],sourcesZ[idxSource], diff --git a/Src/Kernels/P2P/FP2PMultiRhs.hpp b/Src/Kernels/P2P/FP2PMultiRhs.hpp index 8583ae2ed..1c118839d 100644 --- a/Src/Kernels/P2P/FP2PMultiRhs.hpp +++ b/Src/Kernels/P2P/FP2PMultiRhs.hpp @@ -25,7 +25,7 @@ namespace FP2P { inline void FullMutualMultiRhs(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[], const int limiteNeighbors, const MatrixKernelClass *const MatrixKernel){ - const int nbParticlesTargets = inTargets->getNbParticles(); + const FSize nbParticlesTargets = inTargets->getNbParticles(); const FReal*const targetsPhysicalValues = inTargets->getPhysicalValuesArray(); const FReal*const targetsX = inTargets->getPositions()[0]; const FReal*const targetsY = inTargets->getPositions()[1]; @@ -35,12 +35,12 @@ namespace FP2P { FReal*const targetsForcesZ = inTargets->getForcesZArray(); FReal*const targetsPotentials = inTargets->getPotentialsArray(); const int NVALS = inTargets->getNVALS(); - const int targetsLD = inTargets->getLeadingDimension(); + const FSize targetsLD = inTargets->getLeadingDimension(); - for(int idxNeighbors = 0 ; idxNeighbors < limiteNeighbors ; ++idxNeighbors){ - for(int idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ + for(FSize idxNeighbors = 0 ; idxNeighbors < limiteNeighbors ; ++idxNeighbors){ + for(FSize idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ if( inNeighbors[idxNeighbors] ){ - const int nbParticlesSources = inNeighbors[idxNeighbors]->getNbParticles(); + const FSize nbParticlesSources = inNeighbors[idxNeighbors]->getNbParticles(); const FReal*const sourcesPhysicalValues = inNeighbors[idxNeighbors]->getPhysicalValuesArray(); const FReal*const sourcesX = inNeighbors[idxNeighbors]->getPositions()[0]; const FReal*const sourcesY = inNeighbors[idxNeighbors]->getPositions()[1]; @@ -49,9 +49,9 @@ namespace FP2P { FReal*const sourcesForcesY = inNeighbors[idxNeighbors]->getForcesYArray(); FReal*const sourcesForcesZ = inNeighbors[idxNeighbors]->getForcesZArray(); FReal*const sourcesPotentials = inNeighbors[idxNeighbors]->getPotentialsArray(); - const int sourcesLD = inNeighbors[idxNeighbors]->getLeadingDimension(); + const FSize sourcesLD = inNeighbors[idxNeighbors]->getLeadingDimension(); - for(int idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){ + for(FSize idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){ // Compute kernel of interaction and its derivative const FPoint<FReal> sourcePoint(sourcesX[idxSource],sourcesY[idxSource],sourcesZ[idxSource]); @@ -63,8 +63,8 @@ namespace FP2P { for(int idxVals = 0 ; idxVals < NVALS ; ++idxVals){ - const int idxTargetValue = idxVals*targetsLD+idxTarget; - const int idxSourceValue = idxVals*sourcesLD+idxSource; + const FSize idxTargetValue = idxVals*targetsLD+idxTarget; + const FSize idxSourceValue = idxVals*sourcesLD+idxSource; FReal coef = (targetsPhysicalValues[idxTargetValue] * sourcesPhysicalValues[idxSourceValue]); @@ -85,8 +85,8 @@ namespace FP2P { } } - for(int idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ - for(int idxSource = idxTarget + 1 ; idxSource < nbParticlesTargets ; ++idxSource){ + for(FSize idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ + for(FSize idxSource = idxTarget + 1 ; idxSource < nbParticlesTargets ; ++idxSource){ // Compute kernel of interaction... const FPoint<FReal> sourcePoint(targetsX[idxSource],targetsY[idxSource],targetsZ[idxSource]); @@ -98,8 +98,8 @@ namespace FP2P { for(int idxVals = 0 ; idxVals < NVALS ; ++idxVals){ - const int idxTargetValue = idxVals*targetsLD+idxTarget; - const int idxSourceValue = idxVals*targetsLD+idxSource; + const FSize idxTargetValue = idxVals*targetsLD+idxTarget; + const FSize idxSourceValue = idxVals*targetsLD+idxSource; FReal coef = (targetsPhysicalValues[idxTargetValue] * targetsPhysicalValues[idxSourceValue]); @@ -127,7 +127,7 @@ template <class FReal, class ContainerClass, typename MatrixKernelClass> inline void FullRemoteMultiRhs(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[], const int limiteNeighbors, const MatrixKernelClass *const MatrixKernel){ - const int nbParticlesTargets = inTargets->getNbParticles(); + const FSize nbParticlesTargets = inTargets->getNbParticles(); const FReal*const targetsPhysicalValues = inTargets->getPhysicalValuesArray(); const FReal*const targetsX = inTargets->getPositions()[0]; const FReal*const targetsY = inTargets->getPositions()[1]; @@ -137,19 +137,19 @@ inline void FullRemoteMultiRhs(ContainerClass* const FRestrict inTargets, Contai FReal*const targetsForcesZ = inTargets->getForcesZArray(); FReal*const targetsPotentials = inTargets->getPotentialsArray(); const int NVALS = inTargets->getNVALS(); - const int targetsLD = inTargets->getLeadingDimension(); + const FSize targetsLD = inTargets->getLeadingDimension(); - for(int idxNeighbors = 0 ; idxNeighbors < limiteNeighbors ; ++idxNeighbors){ - for(int idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ + for(FSize idxNeighbors = 0 ; idxNeighbors < limiteNeighbors ; ++idxNeighbors){ + for(FSize idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ if( inNeighbors[idxNeighbors] ){ - const int nbParticlesSources = inNeighbors[idxNeighbors]->getNbParticles(); + const FSize nbParticlesSources = inNeighbors[idxNeighbors]->getNbParticles(); const FReal*const sourcesPhysicalValues = inNeighbors[idxNeighbors]->getPhysicalValuesArray(); const FReal*const sourcesX = inNeighbors[idxNeighbors]->getPositions()[0]; const FReal*const sourcesY = inNeighbors[idxNeighbors]->getPositions()[1]; const FReal*const sourcesZ = inNeighbors[idxNeighbors]->getPositions()[2]; - const int sourcesLD = inNeighbors[idxNeighbors]->getLeadingDimension(); + const FSize sourcesLD = inNeighbors[idxNeighbors]->getLeadingDimension(); - for(int idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){ + for(FSize idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){ // Compute kernel of interaction... const FPoint<FReal> sourcePoint(sourcesX[idxSource],sourcesY[idxSource],sourcesZ[idxSource]); @@ -161,8 +161,8 @@ inline void FullRemoteMultiRhs(ContainerClass* const FRestrict inTargets, Contai for(int idxVals = 0 ; idxVals < NVALS ; ++idxVals){ - const int idxTargetValue = idxVals*targetsLD+idxTarget; - const int idxSourceValue = idxVals*sourcesLD+idxSource; + const FSize idxTargetValue = idxVals*targetsLD+idxTarget; + const FSize idxSourceValue = idxVals*sourcesLD+idxSource; FReal coef = (targetsPhysicalValues[idxTargetValue] * sourcesPhysicalValues[idxSourceValue]); diff --git a/Src/Kernels/P2P/FP2PParticleContainer.hpp b/Src/Kernels/P2P/FP2PParticleContainer.hpp index 18b2413b8..d6cb2ac75 100644 --- a/Src/Kernels/P2P/FP2PParticleContainer.hpp +++ b/Src/Kernels/P2P/FP2PParticleContainer.hpp @@ -42,7 +42,7 @@ public: return Parent::getRawData() + ((0+idxRhs)*NVALS+idxVals)*Parent::getLeadingRawData(); } - int getLeadingDimension(){ + FSize getLeadingDimension(){ return Parent::getLeadingRawData(); } diff --git a/Src/Kernels/P2P/FP2PParticleContainerIndexed.hpp b/Src/Kernels/P2P/FP2PParticleContainerIndexed.hpp index 7d4b421a6..668543e41 100644 --- a/Src/Kernels/P2P/FP2PParticleContainerIndexed.hpp +++ b/Src/Kernels/P2P/FP2PParticleContainerIndexed.hpp @@ -25,22 +25,22 @@ template<class FReal, int NRHS = 1, int NLHS = 1, int NVALS = 1> class FP2PParticleContainerIndexed : public FP2PParticleContainer<FReal, NRHS,NLHS,NVALS> { typedef FP2PParticleContainer<FReal, NRHS,NLHS,NVALS> Parent; - FVector<int> indexes; + FVector<FSize> indexes; public: template<typename... Args> - void push(const FPoint<FReal>& inParticlePosition, const int index, Args... args){ + void push(const FPoint<FReal>& inParticlePosition, const FSize index, Args... args){ Parent::push(inParticlePosition, args... ); indexes.push(index); } template<typename... Args> - void push(const FPoint<FReal>& inParticlePosition, const FParticleType particleType, const int index, Args... args){ + void push(const FPoint<FReal>& inParticlePosition, const FParticleType particleType, const FSize index, Args... args){ Parent::push(inParticlePosition, particleType, args... ); indexes.push(index); } - const FVector<int>& getIndexes() const{ + const FVector<FSize>& getIndexes() const{ return indexes; } @@ -49,14 +49,14 @@ public: Parent::clear(); } - void removeParticles(const int indexesToRemove[], const int nbParticlesToRemove){ + void removeParticles(const FSize indexesToRemove[], const FSize nbParticlesToRemove){ if(nbParticlesToRemove == 0 || indexesToRemove == nullptr){ return; } int offset = 1; int idxIndexes = 1; - int idxIns = indexesToRemove[0] + 1; + FSize idxIns = indexesToRemove[0] + 1; for( ; idxIns < indexes.getSize() && idxIndexes < nbParticlesToRemove ; ++idxIns){ if( idxIns == indexesToRemove[idxIndexes] ){ idxIndexes += 1; diff --git a/Src/Kernels/P2P/FP2PR.hpp b/Src/Kernels/P2P/FP2PR.hpp index 252b5a3ab..651700685 100644 --- a/Src/Kernels/P2P/FP2PR.hpp +++ b/Src/Kernels/P2P/FP2PR.hpp @@ -84,7 +84,7 @@ template <class FReal, class ContainerClass, class ComputeClass, int NbFRealInCo static void GenericFullMutual(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[], const int limiteNeighbors){ - const int nbParticlesTargets = inTargets->getNbParticles(); + const FSize nbParticlesTargets = inTargets->getNbParticles(); const FReal*const targetsPhysicalValues = inTargets->getPhysicalValues(); const FReal*const targetsX = inTargets->getPositions()[0]; const FReal*const targetsY = inTargets->getPositions()[1]; @@ -96,9 +96,9 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain const ComputeClass mOne = FMath::One<ComputeClass>(); - for(int idxNeighbors = 0 ; idxNeighbors < limiteNeighbors ; ++idxNeighbors){ + for(FSize idxNeighbors = 0 ; idxNeighbors < limiteNeighbors ; ++idxNeighbors){ if( inNeighbors[idxNeighbors] ){ - const int nbParticlesSources = (inNeighbors[idxNeighbors]->getNbParticles()+NbFRealInComputeClass-1)/NbFRealInComputeClass; + const FSize nbParticlesSources = (inNeighbors[idxNeighbors]->getNbParticles()+NbFRealInComputeClass-1)/NbFRealInComputeClass; const ComputeClass*const sourcesPhysicalValues = (const ComputeClass*)inNeighbors[idxNeighbors]->getPhysicalValues(); const ComputeClass*const sourcesX = (const ComputeClass*)inNeighbors[idxNeighbors]->getPositions()[0]; const ComputeClass*const sourcesY = (const ComputeClass*)inNeighbors[idxNeighbors]->getPositions()[1]; @@ -108,7 +108,7 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain ComputeClass*const sourcesForcesZ = (ComputeClass*)inNeighbors[idxNeighbors]->getForcesZ(); ComputeClass*const sourcesPotentials = (ComputeClass*)inNeighbors[idxNeighbors]->getPotentials(); - for(int idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ + for(FSize idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ const ComputeClass tx = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsX[idxTarget]); const ComputeClass ty = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsY[idxTarget]); const ComputeClass tz = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsZ[idxTarget]); @@ -118,7 +118,7 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain ComputeClass tfz = FMath::Zero<ComputeClass>(); ComputeClass tpo = FMath::Zero<ComputeClass>(); - for(int idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){ + for(FSize idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){ ComputeClass dx = sourcesX[idxSource] - tx; ComputeClass dy = sourcesY[idxSource] - ty; ComputeClass dz = sourcesZ[idxSource] - tz; @@ -155,7 +155,7 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain {//In this part, we compute (vectorially) the interaction //within the target leaf. - const int nbParticlesSources = (nbParticlesTargets+NbFRealInComputeClass-1)/NbFRealInComputeClass; + const FSize nbParticlesSources = (nbParticlesTargets+NbFRealInComputeClass-1)/NbFRealInComputeClass; const ComputeClass*const sourcesPhysicalValues = (const ComputeClass*)targetsPhysicalValues; const ComputeClass*const sourcesX = (const ComputeClass*)targetsX; const ComputeClass*const sourcesY = (const ComputeClass*)targetsY; @@ -165,7 +165,7 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain ComputeClass*const sourcesForcesZ = (ComputeClass*)targetsForcesZ; ComputeClass*const sourcesPotentials = (ComputeClass*)targetsPotentials; - for(int idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ + for(FSize idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ const ComputeClass tx = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsX[idxTarget]); const ComputeClass ty = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsY[idxTarget]); const ComputeClass tz = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsZ[idxTarget]); @@ -175,7 +175,7 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain ComputeClass tfz = FMath::Zero<ComputeClass>(); ComputeClass tpo = FMath::Zero<ComputeClass>(); - for(int idxSource = (idxTarget+NbFRealInComputeClass)/NbFRealInComputeClass ; idxSource < nbParticlesSources ; ++idxSource){ + for(FSize idxSource = (idxTarget+NbFRealInComputeClass)/NbFRealInComputeClass ; idxSource < nbParticlesSources ; ++idxSource){ ComputeClass dx = sourcesX[idxSource] - tx; ComputeClass dy = sourcesY[idxSource] - ty; @@ -208,10 +208,10 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain } } - for(int idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ - const int limitForTarget = NbFRealInComputeClass-(idxTarget%NbFRealInComputeClass); - for(int idxS = 1 ; idxS < limitForTarget ; ++idxS){ - const int idxSource = idxTarget + idxS; + for(FSize idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ + const FSize limitForTarget = NbFRealInComputeClass-(idxTarget%NbFRealInComputeClass); + for(FSize idxS = 1 ; idxS < limitForTarget ; ++idxS){ + const FSize idxSource = idxTarget + idxS; FReal dx = targetsX[idxSource] - targetsX[idxTarget]; FReal dy = targetsY[idxSource] - targetsY[idxTarget]; FReal dz = targetsZ[idxSource] - targetsZ[idxTarget]; @@ -242,7 +242,7 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain template <class FReal, class ContainerClass, class ComputeClass, int NbFRealInComputeClass> static void GenericFullRemote(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[], const int limiteNeighbors){ - const int nbParticlesTargets = inTargets->getNbParticles(); + const FSize nbParticlesTargets = inTargets->getNbParticles(); const FReal*const targetsPhysicalValues = inTargets->getPhysicalValues(); const FReal*const targetsX = inTargets->getPositions()[0]; const FReal*const targetsY = inTargets->getPositions()[1]; @@ -254,15 +254,15 @@ static void GenericFullRemote(ContainerClass* const FRestrict inTargets, Contain const ComputeClass mOne = FMath::One<ComputeClass>(); - for(int idxNeighbors = 0 ; idxNeighbors < limiteNeighbors ; ++idxNeighbors){ + for(FSize idxNeighbors = 0 ; idxNeighbors < limiteNeighbors ; ++idxNeighbors){ if( inNeighbors[idxNeighbors] ){ - const int nbParticlesSources = (inNeighbors[idxNeighbors]->getNbParticles()+NbFRealInComputeClass-1)/NbFRealInComputeClass; + const FSize nbParticlesSources = (inNeighbors[idxNeighbors]->getNbParticles()+NbFRealInComputeClass-1)/NbFRealInComputeClass; const ComputeClass*const sourcesPhysicalValues = (const ComputeClass*)inNeighbors[idxNeighbors]->getPhysicalValues(); const ComputeClass*const sourcesX = (const ComputeClass*)inNeighbors[idxNeighbors]->getPositions()[0]; const ComputeClass*const sourcesY = (const ComputeClass*)inNeighbors[idxNeighbors]->getPositions()[1]; const ComputeClass*const sourcesZ = (const ComputeClass*)inNeighbors[idxNeighbors]->getPositions()[2]; - for(int idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ + for(FSize idxTarget = 0 ; idxTarget < nbParticlesTargets ; ++idxTarget){ const ComputeClass tx = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsX[idxTarget]); const ComputeClass ty = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsY[idxTarget]); const ComputeClass tz = FMath::ConvertTo<ComputeClass, const FReal*>(&targetsZ[idxTarget]); @@ -272,7 +272,7 @@ static void GenericFullRemote(ContainerClass* const FRestrict inTargets, Contain ComputeClass tfz = FMath::Zero<ComputeClass>(); ComputeClass tpo = FMath::Zero<ComputeClass>(); - for(int idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){ + for(FSize idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){ ComputeClass dx = sourcesX[idxSource] - tx; ComputeClass dy = sourcesY[idxSource] - ty; ComputeClass dz = sourcesZ[idxSource] - tz; diff --git a/Src/Kernels/Rotation/FRotationCell.hpp b/Src/Kernels/Rotation/FRotationCell.hpp index 8a29deaa1..4f4c28db2 100644 --- a/Src/Kernels/Rotation/FRotationCell.hpp +++ b/Src/Kernels/Rotation/FRotationCell.hpp @@ -145,17 +145,17 @@ public: buffer.fillArray(local_exp, LocalSize); } - int getSavedSize() const { - return ((int) sizeof(FComplex<FReal>)) * (MultipoleSize + LocalSize) - + FBasicCell::getSavedSize(); + FSize getSavedSize() const { + return FSize(((int) sizeof(FComplex<FReal>)) * (MultipoleSize + LocalSize) + + FBasicCell::getSavedSize()); } - int getSavedSizeUp() const { - return ((int) sizeof(FComplex<FReal>)) * (MultipoleSize); + FSize getSavedSizeUp() const { + return ((FSize) sizeof(FComplex<FReal>)) * (MultipoleSize); } - int getSavedSizeDown() const { - return ((int) sizeof(FComplex<FReal>)) * (LocalSize); + FSize getSavedSizeDown() const { + return ((FSize) sizeof(FComplex<FReal>)) * (LocalSize); } }; @@ -177,7 +177,7 @@ public: FExtendCellType::resetToInitialState(); } - int getSavedSize() const { + FSize getSavedSize() const { return FExtendCellType::getSavedSize() + FRotationCell<FReal, P>::getSavedSize(); } }; diff --git a/Src/Kernels/Rotation/FRotationKernel.hpp b/Src/Kernels/Rotation/FRotationKernel.hpp index 68d06a9ce..24db97d1e 100644 --- a/Src/Kernels/Rotation/FRotationKernel.hpp +++ b/Src/Kernels/Rotation/FRotationKernel.hpp @@ -926,7 +926,7 @@ public: const FReal*const positionsY = inParticles->getPositions()[1]; const FReal*const positionsZ = inParticles->getPositions()[2]; - for(int idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++ idxPart){ + for(FSize idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++ idxPart){ // P2M const FPoint<FReal> position(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]); const FSpherical<FReal> sph(position - cellPosition); @@ -1165,7 +1165,7 @@ public: FReal*const forcesZ = inParticles->getForcesZ(); FReal*const potentials = inParticles->getPotentials(); - for(int idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++ idxPart){ + for(FSize idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++ idxPart){ // L2P const FPoint<FReal> position(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]); const FSpherical<FReal> sph(position - cellPosition); diff --git a/Src/Kernels/Rotation/FRotationOriginalKernel.hpp b/Src/Kernels/Rotation/FRotationOriginalKernel.hpp index 5db94ccfe..1b3985ac1 100644 --- a/Src/Kernels/Rotation/FRotationOriginalKernel.hpp +++ b/Src/Kernels/Rotation/FRotationOriginalKernel.hpp @@ -460,7 +460,7 @@ public: const FReal*const positionsY = inParticles->getPositions()[1]; const FReal*const positionsZ = inParticles->getPositions()[2]; - for(int idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++ idxPart){ + for(FSize idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++ idxPart){ // P2M const FPoint<FReal> position(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]); const FSpherical<FReal> sph(position - cellPosition); @@ -675,7 +675,7 @@ public: FReal*const forcesZ = inParticles->getForcesZ(); FReal*const potentials = inParticles->getPotentials(); - for(int idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++ idxPart){ + for(FSize idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++ idxPart){ // L2P const FPoint<FReal> position(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]); const FSpherical<FReal> sph(position - cellPosition); diff --git a/Src/Kernels/Spherical/FAbstractSphericalKernel.hpp b/Src/Kernels/Spherical/FAbstractSphericalKernel.hpp index cdc23a49d..611b158c3 100644 --- a/Src/Kernels/Spherical/FAbstractSphericalKernel.hpp +++ b/Src/Kernels/Spherical/FAbstractSphericalKernel.hpp @@ -153,7 +153,7 @@ public: const FReal*const positionsX = inParticles->getPositions()[0]; const FReal*const positionsY = inParticles->getPositions()[1]; const FReal*const positionsZ = inParticles->getPositions()[2]; - for(int idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++idxPart){ // P2M particleToMultiPole(cellMultiPole, polePosition, FPoint<FReal>(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]), @@ -202,7 +202,7 @@ public: FReal*const forcesX = inParticles->getForcesX(); FReal*const forcesY = inParticles->getForcesY(); FReal*const forcesZ = inParticles->getForcesZ(); - for(int idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++idxPart){ // L2P localToParticle(localPosition, cellLocal, FPoint<FReal>(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]), @@ -636,7 +636,7 @@ public: FReal*const forcesZ = inParticles->getForcesZ(); FVector<FPoint<FReal>>& velocities = inParticles->getVelocities(); - for(int idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++idxPart){ const FReal physicalValue = physicalValues[idxPart]; // Coef = 1/m * time/2 const FReal coef = (FReal(1.0)/physicalValue) * (DT/FReal(2.0)); @@ -657,7 +657,7 @@ public: FReal*const positionsZ = inParticles->getWPositions()[2]; FVector<FPoint<FReal>>& velocities = inParticles->getVelocities(); - for(int idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++idxPart){ FPoint<FReal> velocity_dt( velocities[idxPart] ); velocity_dt *= DT; positionsX[idxPart] += velocity_dt.getX(); diff --git a/Src/Kernels/Spherical/FSphericalBlockBlasKernel.hpp b/Src/Kernels/Spherical/FSphericalBlockBlasKernel.hpp index b782e2566..9efc19599 100644 --- a/Src/Kernels/Spherical/FSphericalBlockBlasKernel.hpp +++ b/Src/Kernels/Spherical/FSphericalBlockBlasKernel.hpp @@ -266,7 +266,7 @@ public: FBlas::c_gemm( FF_MATRIX_ROW_DIM, FF_MATRIX_COLUMN_DIM, - interactions[interactionIndex].getSize(), + int(interactions[interactionIndex].getSize()), one, FComplex<FReal>::ToFReal(preM2LTransitions[inLevel][interactionIndex]), FF_MATRIX_ROW_DIM, diff --git a/Src/Kernels/Spherical/FSphericalCell.hpp b/Src/Kernels/Spherical/FSphericalCell.hpp index dcd9d6d8f..21c5bebb0 100644 --- a/Src/Kernels/Spherical/FSphericalCell.hpp +++ b/Src/Kernels/Spherical/FSphericalCell.hpp @@ -153,17 +153,17 @@ public: buffer.fillArray(local_exp, LocalSize); } - int getSavedSize() const { - return ((int) sizeof(FComplex<FReal>)) * (PoleSize+LocalSize) + FSize getSavedSize() const { + return ((FSize) sizeof(FComplex<FReal>)) * (PoleSize+LocalSize) + FBasicCell::getSavedSize(); } - int getSavedSizeUp() const { - return ((int) sizeof(FComplex<FReal>)) * (PoleSize); + FSize getSavedSizeUp() const { + return ((FSize) sizeof(FComplex<FReal>)) * (PoleSize); } - int getSavedSizeDown() const { - return ((int) sizeof(FComplex<FReal>)) * (LocalSize); + FSize getSavedSizeDown() const { + return ((FSize) sizeof(FComplex<FReal>)) * (LocalSize); } }; @@ -196,7 +196,7 @@ public: FExtendCellType::resetToInitialState(); } - int getSavedSize() const { + FSize getSavedSize() const { return FExtendCellType::getSavedSize() + FSphericalCell<FReal>::getSavedSize(); } }; diff --git a/Src/Kernels/Taylor/FTaylorFlopsKernel.hpp b/Src/Kernels/Taylor/FTaylorFlopsKernel.hpp index 9aa8645b1..1309c59e7 100644 --- a/Src/Kernels/Taylor/FTaylorFlopsKernel.hpp +++ b/Src/Kernels/Taylor/FTaylorFlopsKernel.hpp @@ -32,220 +32,220 @@ template< class FReal, class CellClass, class ContainerClass, int P, int order> class FTaylorFlopsKernel : public FAbstractKernels<CellClass,ContainerClass> { - static const int SizeVector = ((P+1)*(P+2)*(P+3))*order/6; - static const int sizeDerivative = ((2*P+1)*(P+1)*(P+3))*order/3; - unsigned int incPowersFlop; - const unsigned treeHeight; - unsigned int pTIdx; - //Flops for each functions: - unsigned long long flopsP2M, flopsM2M, flopsM2L, flopsL2L, flopsL2P, flopsP2P; + static const int SizeVector = ((P+1)*(P+2)*(P+3))*order/6; + static const int sizeDerivative = ((2*P+1)*(P+1)*(P+3))*order/3; + unsigned int incPowersFlop; + const unsigned treeHeight; + unsigned int pTIdx; + //Flops for each functions: + unsigned long long flopsP2M, flopsM2M, flopsM2L, flopsL2L, flopsL2P, flopsP2P; - unsigned long long *flopsPerLevelM2M, *flopsPerLevelM2L, *flopsPerLevelL2L; + unsigned long long *flopsPerLevelM2M, *flopsPerLevelM2L, *flopsPerLevelL2L; - /** - * @brief Incrementation of powers in Taylor expansion - * Result : ...,[2,0,0],[1,1,0],[1,0,1],[0,2,0]... 3-tuple are sorted + /** + * @brief Incrementation of powers in Taylor expansion + * Result : ...,[2,0,0],[1,1,0],[1,0,1],[0,2,0]... 3-tuple are sorted * by size then alphabetical order. */ - void incPowers(int * const FRestrict a, int *const FRestrict b, int *const FRestrict c) - { - int t = (*a)+(*b)+(*c); - if(t==0) - {a[0]=1;} - else{ if(t==a[0]) - {a[0]--; b[0]++;} - else{ if(t==c[0]) - {a[0]=t+1; c[0]=0;} - else{ if(b[0]!=0) - {b[0]--; c[0]++;} - else{ - b[0]=c[0]+1; - a[0]--; - c[0]=0; - } - } - } + void incPowers(int * const FRestrict a, int *const FRestrict b, int *const FRestrict c) + { + int t = (*a)+(*b)+(*c); + if(t==0) + {a[0]=1;} + else{ if(t==a[0]) + {a[0]--; b[0]++;} + else{ if(t==c[0]) + {a[0]=t+1; c[0]=0;} + else{ if(b[0]!=0) + {b[0]--; c[0]++;} + else{ + b[0]=c[0]+1; + a[0]--; + c[0]=0; + } + } + } + } } - } public: - FTaylorFlopsKernel(const int inTreeHeight, const FReal inBoxWidth, const FPoint<FReal>& inBoxCenter) : - treeHeight(inTreeHeight), - flopsP2M(0), - flopsM2M(0), - flopsM2L(0), - flopsL2L(0), - flopsL2P(0), - flopsP2P(0), - pTIdx(10), - incPowersFlop(10), - flopsPerLevelM2M(NULL), - flopsPerLevelM2L(NULL), - flopsPerLevelL2L(NULL) - { - pTIdx = 10; - flopsPerLevelM2M = new unsigned long long [inTreeHeight]; - flopsPerLevelM2L = new unsigned long long [inTreeHeight]; - flopsPerLevelL2L = new unsigned long long [inTreeHeight]; - for (unsigned int level = 0; level<inTreeHeight; ++level){ - flopsPerLevelM2M[level] = flopsPerLevelM2L[level] = flopsPerLevelL2L[level] = 0; + FTaylorFlopsKernel(const int inTreeHeight, const FReal inBoxWidth, const FPoint<FReal>& inBoxCenter) : + treeHeight(inTreeHeight), + flopsP2M(0), + flopsM2M(0), + flopsM2L(0), + flopsL2L(0), + flopsL2P(0), + flopsP2P(0), + pTIdx(10), + incPowersFlop(10), + flopsPerLevelM2M(NULL), + flopsPerLevelM2L(NULL), + flopsPerLevelL2L(NULL) + { + pTIdx = 10; + flopsPerLevelM2M = new unsigned long long [inTreeHeight]; + flopsPerLevelM2L = new unsigned long long [inTreeHeight]; + flopsPerLevelL2L = new unsigned long long [inTreeHeight]; + for (unsigned int level = 0; level<inTreeHeight; ++level){ + flopsPerLevelM2M[level] = flopsPerLevelM2L[level] = flopsPerLevelL2L[level] = 0; + } } - } - - virtual ~FTaylorFlopsKernel(){ - std::cout << "\n==================================================" - << "\n- Flops for P2M = " << flopsP2M - << "\n- Flops for M2M = " << flopsM2M - << "\n- Flops for M2L = " << flopsM2L - << "\n- Flops for L2L = " << flopsL2L - << "\n- Flops for L2P = " << flopsL2P - << "\n- Flops for P2P = " << flopsP2P - << "\n- Overall Flops = " << flopsP2M + flopsM2M + flopsM2L + flopsL2L + flopsL2P + flopsP2P - << "\n==================================================\n" - << std::endl; - - std::cout << "\n==================================================" - << "\n- Flops for P2M/M2M" << std::endl; - for (unsigned int level=0; level<treeHeight; ++level) - if (level < treeHeight-1) - std::cout << " |- at level " << level << " flops = " << flopsPerLevelM2M[level] << std::endl; - else - std::cout << " |- at level " << level << " flops = " << flopsP2M << std::endl; - std::cout << "==================================================" - << "\n- Flops for M2L" << std::endl; - for (unsigned int level=0; level<treeHeight; ++level) - std::cout << " |- at level " << level << " flops = " << flopsPerLevelM2L[level] << std::endl; - std::cout << "==================================================" - << "\n- Flops for L2L/L2P" << std::endl; - for (unsigned int level=0; level<treeHeight; ++level) - if (level < treeHeight-1) - std::cout << " |- at level " << level << " flops = " << flopsPerLevelL2L[level] << std::endl; - else - std::cout << " |- at level " << level << " flops = " << flopsL2P << std::endl; - std::cout << "==================================================" << std::endl; - if (flopsPerLevelM2M) delete [] flopsPerLevelM2M; - if (flopsPerLevelM2L) delete [] flopsPerLevelM2L; - if (flopsPerLevelL2L) delete [] flopsPerLevelL2L; - - } - - void P2M(CellClass* const pole, - const ContainerClass* const particles) - { - //Nb_Particule * [3 (: dx,dy,dz) + SizeVector*4 (: Classic operations) ] + SizeVector (: multiply multipole by coefficient) - this->flopsP2M += (particles->getNbParticles())*(3+SizeVector*4)+SizeVector; - } - - void M2M(CellClass* const FRestrict pole, - const CellClass*const FRestrict *const FRestrict child, - const int inLevel) - { - //Powers of expansions - int a=0,b=0,c=0; - - //Indexes of powers - int idx_a,idx_b,idx_c; - - unsigned int flops = 8; - for (unsigned int ChildIndex=0; ChildIndex < 8; ++ChildIndex) - { - if (child[ChildIndex]) - { - a=0; b=0; c=0; - flops += 6 + 6*P; - for(int k=0 ; k<SizeVector ; ++k) - { - for(idx_a=0 ; idx_a <= a ; ++idx_a){ - for(idx_b=0 ; idx_b <= b ; ++idx_b){ - for(idx_c=0 ; idx_c <= c ; ++idx_c){ - flops += pTIdx; - flops += 30; - } - } - } - incPowers(&a,&b,&c); - flops+=incPowersFlop; - } - } - } - flopsM2M += flops; - flopsPerLevelM2M[inLevel] += flops; - } - - void M2L(CellClass* const FRestrict local, // Target cell - const CellClass* distantNeighbors[343], // Sources to be read - const int /*size*/, const int inLevel) - { - unsigned int flops = 343; - for (unsigned int idx=0; idx<343; ++idx) - { - if (distantNeighbors[idx]) - { - flops += 2+SizeVector*(2+SizeVector+2); - } - } - flopsM2L += flops; - flopsPerLevelM2L[inLevel] += flops; - } - - void L2L(const CellClass* const FRestrict fatherCell, - CellClass* FRestrict * const FRestrict childCell, - const int inLevel) - { - int ap, bp, cp, af, bf, cf; //Indexes of expansion for father and child. - unsigned int flops = 2; - for(int idxChild = 0 ; idxChild < 8 ; ++idxChild){ - // if child exists - if(childCell[idxChild]){ - af=0; bf=0; cf=0; - flops += 6 + 6*P; - for(int k=0 ; k<SizeVector ; ++k) - { - //Iterator over parent's local array - for(ap=af ; ap<=P ; ++ap) - { - for(bp=bf ; bp<=P ; ++bp) - { - for(cp=cf ; ((cp<=P) && (ap+bp+cp) <= P) ; ++cp) - { - flops += pTIdx; - flops += 2+3*2;/*3 calls to combin + multiplication of the 3 results*/ - flops += 5; - } - } - } - incPowers(&af,&bf,&cf); - flops += incPowersFlop; - } - } + + virtual ~FTaylorFlopsKernel(){ + std::cout << "\n==================================================" + << "\n- Flops for P2M = " << flopsP2M + << "\n- Flops for M2M = " << flopsM2M + << "\n- Flops for M2L = " << flopsM2L + << "\n- Flops for L2L = " << flopsL2L + << "\n- Flops for L2P = " << flopsL2P + << "\n- Flops for P2P = " << flopsP2P + << "\n- Overall Flops = " << flopsP2M + flopsM2M + flopsM2L + flopsL2L + flopsL2P + flopsP2P + << "\n==================================================\n" + << std::endl; + + std::cout << "\n==================================================" + << "\n- Flops for P2M/M2M" << std::endl; + for (unsigned int level=0; level<treeHeight; ++level) + if (level < treeHeight-1) + std::cout << " |- at level " << level << " flops = " << flopsPerLevelM2M[level] << std::endl; + else + std::cout << " |- at level " << level << " flops = " << flopsP2M << std::endl; + std::cout << "==================================================" + << "\n- Flops for M2L" << std::endl; + for (unsigned int level=0; level<treeHeight; ++level) + std::cout << " |- at level " << level << " flops = " << flopsPerLevelM2L[level] << std::endl; + std::cout << "==================================================" + << "\n- Flops for L2L/L2P" << std::endl; + for (unsigned int level=0; level<treeHeight; ++level) + if (level < treeHeight-1) + std::cout << " |- at level " << level << " flops = " << flopsPerLevelL2L[level] << std::endl; + else + std::cout << " |- at level " << level << " flops = " << flopsL2P << std::endl; + std::cout << "==================================================" << std::endl; + if (flopsPerLevelM2M) delete [] flopsPerLevelM2M; + if (flopsPerLevelM2L) delete [] flopsPerLevelM2L; + if (flopsPerLevelL2L) delete [] flopsPerLevelL2L; + + } + + void P2M(CellClass* const pole, + const ContainerClass* const particles) + { + //Nb_Particule * [3 (: dx,dy,dz) + SizeVector*4 (: Classic operations) ] + SizeVector (: multiply multipole by coefficient) + this->flopsP2M += (particles->getNbParticles())*(3+SizeVector*4)+SizeVector; + } + + void M2M(CellClass* const FRestrict pole, + const CellClass*const FRestrict *const FRestrict child, + const int inLevel) + { + //Powers of expansions + int a=0,b=0,c=0; + + //Indexes of powers + int idx_a,idx_b,idx_c; + + unsigned int flops = 8; + for (unsigned int ChildIndex=0; ChildIndex < 8; ++ChildIndex) + { + if (child[ChildIndex]) + { + a=0; b=0; c=0; + flops += 6 + 6*P; + for(int k=0 ; k<SizeVector ; ++k) + { + for(idx_a=0 ; idx_a <= a ; ++idx_a){ + for(idx_b=0 ; idx_b <= b ; ++idx_b){ + for(idx_c=0 ; idx_c <= c ; ++idx_c){ + flops += pTIdx; + flops += 30; + } + } + } + incPowers(&a,&b,&c); + flops+=incPowersFlop; + } + } + } + flopsM2M += flops; + flopsPerLevelM2M[inLevel] += flops; + } + + void M2L(CellClass* const FRestrict local, // Target cell + const CellClass* distantNeighbors[343], // Sources to be read + const int /*size*/, const int inLevel) + { + unsigned int flops = 343; + for (unsigned int idx=0; idx<343; ++idx) + { + if (distantNeighbors[idx]) + { + flops += 2+SizeVector*(2+SizeVector+2); + } + } + flopsM2L += flops; + flopsPerLevelM2L[inLevel] += flops; } - flopsL2L += flops; - flopsPerLevelL2L[inLevel] += flops; - } - - void L2P(const CellClass* const local, - ContainerClass* const particles) - { - unsigned int flops = 12; - int nbPart = particles->getNbParticles(); - for(int i=0 ; i<nbPart ; ++i){ - flops += 16 + 3*(P-1);/*Distances computation*/ - for(int j=0 ; j<SizeVector ; ++j){ - flops += 4+3*4; - flops += incPowersFlop; - } - flops += 1 + 3*2; /*store of results*/ + + void L2L(const CellClass* const FRestrict fatherCell, + CellClass* FRestrict * const FRestrict childCell, + const int inLevel) + { + int ap, bp, cp, af, bf, cf; //Indexes of expansion for father and child. + unsigned int flops = 2; + for(int idxChild = 0 ; idxChild < 8 ; ++idxChild){ + // if child exists + if(childCell[idxChild]){ + af=0; bf=0; cf=0; + flops += 6 + 6*P; + for(int k=0 ; k<SizeVector ; ++k) + { + //Iterator over parent's local array + for(ap=af ; ap<=P ; ++ap) + { + for(bp=bf ; bp<=P ; ++bp) + { + for(cp=cf ; ((cp<=P) && (ap+bp+cp) <= P) ; ++cp) + { + flops += pTIdx; + flops += 2+3*2;/*3 calls to combin + multiplication of the 3 results*/ + flops += 5; + } + } + } + incPowers(&af,&bf,&cf); + flops += incPowersFlop; + } + } + } + flopsL2L += flops; + flopsPerLevelL2L[inLevel] += flops; + } + + void L2P(const CellClass* const local, + ContainerClass* const particles) + { + unsigned int flops = 12; + FSize nbPart = particles->getNbParticles(); + for(int i=0 ; i<nbPart ; ++i){ + flops += 16 + 3*(P-1);/*Distances computation*/ + for(int j=0 ; j<SizeVector ; ++j){ + flops += 4+3*4; + flops += incPowersFlop; + } + flops += 1 + 3*2; /*store of results*/ + } + flopsL2P += flops; } - flopsL2P += flops; - } - void P2P(const FTreeCoordinate& /*inLeafPosition*/, - ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict /*sources*/, - ContainerClass* const directNeighborsParticles[27], const int /*size*/) - {} + void P2P(const FTreeCoordinate& /*inLeafPosition*/, + ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict /*sources*/, + ContainerClass* const directNeighborsParticles[27], const int /*size*/) + {} }; diff --git a/Src/Kernels/Taylor/FTaylorKernel.hpp b/Src/Kernels/Taylor/FTaylorKernel.hpp index 30ebffbd5..ee6245c6c 100644 --- a/Src/Kernels/Taylor/FTaylorKernel.hpp +++ b/Src/Kernels/Taylor/FTaylorKernel.hpp @@ -553,7 +553,7 @@ public: FReal multipole2[SizeVector] ; - int nbPart = particles->getNbParticles(), i; + FSize nbPart = particles->getNbParticles(), i; const FReal* const * positions = particles->getPositions(); const FReal* posX = positions[0]; const FReal* posY = positions[1]; @@ -564,7 +564,7 @@ public: // Iterating over Particles FReal xc = cellCenter.getX(), yc = cellCenter.getY(), zc = cellCenter.getZ() ; FReal dx[3] ; - for(int idPart=0 ; idPart<nbPart ; ++idPart){ + for(FSize idPart=0 ; idPart<nbPart ; ++idPart){ dx[0] = xc - posX[idPart] ; dx[1] = yc - posY[idPart] ; @@ -876,7 +876,7 @@ public: { FPoint<FReal> locCenter = getLeafCenter(local->getCoordinate()); //Iterator over particles - int nbPart = particles->getNbParticles(); + FSize nbPart = particles->getNbParticles(); const FReal * iterLocal = local->getLocal(); const FReal * const * positions = particles->getPositions(); @@ -893,7 +893,7 @@ public: FReal * phyValues = particles->getPhysicalValues(); //Iteration over particles - for(int i=0 ; i<nbPart ; ++i){ + for(FSize i=0 ; i<nbPart ; ++i){ FReal dx = posX[i] - locCenter.getX(); FReal dy = posY[i] - locCenter.getY(); diff --git a/Src/Kernels/Taylor/FTaylorKernelSimple.hpp b/Src/Kernels/Taylor/FTaylorKernelSimple.hpp index 38362f6d6..22ad62176 100644 --- a/Src/Kernels/Taylor/FTaylorKernelSimple.hpp +++ b/Src/Kernels/Taylor/FTaylorKernelSimple.hpp @@ -471,7 +471,7 @@ public: FReal multipole2[SizeVector] ; // Iterator over Particles - int nbPart = particles->getNbParticles(), i; + FSize nbPart = particles->getNbParticles(), i; const FReal* const * positions = particles->getPositions(); const FReal* posX = positions[0]; const FReal* posY = positions[1]; @@ -482,7 +482,7 @@ public: // Iterating over Particles FReal xc = cellCenter.getX(), yc = cellCenter.getY(), zc = cellCenter.getZ() ; FReal dx[3] ; - for(int idPart=0 ; idPart<nbPart ; ++idPart){ + for(FSize idPart=0 ; idPart<nbPart ; ++idPart){ dx[0] = xc - posX[idPart] ; dx[1] = yc - posY[idPart] ; dx[2] = zc - posZ[idPart] ; @@ -812,7 +812,7 @@ public: { FPoint<FReal> locCenter = getLeafCenter(local->getCoordinate()); //Iterator over particles - int nbPart = particles->getNbParticles(); + FSize nbPart = particles->getNbParticles(); //Iteration over Local array // @@ -829,7 +829,7 @@ public: FReal * phyValues = particles->getPhysicalValues(); //Iteration over particles - for(int i=0 ; i<nbPart ; ++i){ + for(FSize i=0 ; i<nbPart ; ++i){ // FReal dx = posX[i] - locCenter.getX(); FReal dy = posY[i] - locCenter.getY(); diff --git a/Src/Kernels/Uniform/FUnifCell.hpp b/Src/Kernels/Uniform/FUnifCell.hpp index 2f9f7ac98..eb905a51c 100644 --- a/Src/Kernels/Uniform/FUnifCell.hpp +++ b/Src/Kernels/Uniform/FUnifCell.hpp @@ -32,8 +32,8 @@ * Please read the license * * This class defines a cell used in the Lagrange based FMM. - * - * PB: This class also contains the storage and accessors for the transformed + * + * PB: This class also contains the storage and accessors for the transformed * expansion (in Fourier space, i.e. complex valued). * * @param NVALS is the number of right hand side. @@ -41,179 +41,182 @@ template < class FReal, int ORDER, int NRHS = 1, int NLHS = 1, int NVALS = 1> class FUnifCell : public FBasicCell { - static const int VectorSize = TensorTraits<ORDER>::nnodes; - static const int TransformedVectorSize = (2*ORDER-1)*(2*ORDER-1)*(2*ORDER-1); + static const int VectorSize = TensorTraits<ORDER>::nnodes; + static const int TransformedVectorSize = (2*ORDER-1)*(2*ORDER-1)*(2*ORDER-1); - FReal multipole_exp[NRHS * NVALS * VectorSize]; //< Multipole expansion - FReal local_exp[NLHS * NVALS * VectorSize]; //< Local expansion - // PB: Store multipole and local expansion in Fourier space - FComplex<FReal> transformed_multipole_exp[NRHS * NVALS * TransformedVectorSize]; - FComplex<FReal> transformed_local_exp[NLHS * NVALS * TransformedVectorSize]; + FReal multipole_exp[NRHS * NVALS * VectorSize]; //< Multipole expansion + FReal local_exp[NLHS * NVALS * VectorSize]; //< Local expansion + // PB: Store multipole and local expansion in Fourier space + FComplex<FReal> transformed_multipole_exp[NRHS * NVALS * TransformedVectorSize]; + FComplex<FReal> transformed_local_exp[NLHS * NVALS * TransformedVectorSize]; public: - FUnifCell(){ - memset(multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize); - memset(local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize); - memset(transformed_multipole_exp, 0, - sizeof(FComplex<FReal>) * NRHS * NVALS * TransformedVectorSize); - memset(transformed_local_exp, 0, - sizeof(FComplex<FReal>) * NLHS * NVALS * TransformedVectorSize); - } - - ~FUnifCell() {} - - /** Get Multipole */ - const FReal* getMultipole(const int inRhs) const - { return this->multipole_exp + inRhs*VectorSize; - } - /** Get Local */ - const FReal* getLocal(const int inRhs) const{ - return this->local_exp + inRhs*VectorSize; - } - - /** Get Multipole */ - FReal* getMultipole(const int inRhs){ - return this->multipole_exp + inRhs*VectorSize; - } - /** Get Local */ - FReal* getLocal(const int inRhs){ - return this->local_exp + inRhs*VectorSize; - } - - /** To get the leading dim of a vec */ - int getVectorSize() const{ - return VectorSize; - } - - /** Get Transformed Multipole */ - const FComplex<FReal>* getTransformedMultipole(const int inRhs) const{ - return this->transformed_multipole_exp + inRhs*TransformedVectorSize; - } - /** Get Transformed Local */ - const FComplex<FReal>* getTransformedLocal(const int inRhs) const{ - return this->transformed_local_exp + inRhs*TransformedVectorSize; - } - - /** Get Transformed Multipole */ - FComplex<FReal>* getTransformedMultipole(const int inRhs){ - return this->transformed_multipole_exp + inRhs*TransformedVectorSize; - } - /** Get Transformed Local */ - FComplex<FReal>* getTransformedLocal(const int inRhs){ - return this->transformed_local_exp + inRhs*TransformedVectorSize; - } - - /** To get the leading dim of a vec */ - int getTransformedVectorSize() const{ - return TransformedVectorSize; - } - - /** Make it like the begining */ - void resetToInitialState(){ - memset(multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize); - memset(local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize); - memset(transformed_multipole_exp, 0, - sizeof(FComplex<FReal>) * NRHS * NVALS * TransformedVectorSize); - memset(transformed_local_exp, 0, - sizeof(FComplex<FReal>) * NLHS * NVALS * TransformedVectorSize); - } - - /////////////////////////////////////////////////////// - // to extend FAbstractSendable - /////////////////////////////////////////////////////// - template <class BufferWriterClass> - void serializeUp(BufferWriterClass& buffer) const{ - buffer.write(multipole_exp, VectorSize*NVALS*NRHS); - buffer.write(transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS); - } - - template <class BufferReaderClass> - void deserializeUp(BufferReaderClass& buffer){ - buffer.fillArray(multipole_exp, VectorSize*NVALS*NRHS); - buffer.fillArray(transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS); - } - - template <class BufferWriterClass> - void serializeDown(BufferWriterClass& buffer) const{ - buffer.write(local_exp, VectorSize*NVALS*NLHS); - buffer.write(transformed_local_exp, TransformedVectorSize*NVALS*NLHS); - } - - template <class BufferReaderClass> - void deserializeDown(BufferReaderClass& buffer){ - buffer.fillArray(local_exp, VectorSize*NVALS*NLHS); - buffer.fillArray(transformed_local_exp, TransformedVectorSize*NVALS*NLHS); - } - - /////////////////////////////////////////////////////// - // to extend Serializable - /////////////////////////////////////////////////////// - template <class BufferWriterClass> - void save(BufferWriterClass& buffer) const{ - FBasicCell::save(buffer); - buffer.write(multipole_exp, VectorSize*NVALS*NRHS); - buffer.write(transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS); - buffer.write(local_exp, VectorSize*NVALS*NLHS); - buffer.write(transformed_local_exp, TransformedVectorSize*NVALS*NLHS); - } - - template <class BufferReaderClass> - void restore(BufferReaderClass& buffer){ - FBasicCell::restore(buffer); - buffer.fillArray(multipole_exp, VectorSize*NVALS*NRHS); - buffer.fillArray(transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS); - buffer.fillArray(local_exp, VectorSize*NVALS*NLHS); - buffer.fillArray(transformed_local_exp, TransformedVectorSize*NVALS*NLHS); - } - - int getSavedSize() const { - return (NRHS+NLHS)*NVALS*VectorSize * (int) sizeof(FReal) + (NRHS+NLHS)*NVALS*TransformedVectorSize * (int) sizeof(FComplex<FReal>) - + FBasicCell::getSavedSize(); - } - - int getSavedSizeUp() const { - return (NRHS)*NVALS*VectorSize * (int) sizeof(FReal) + (NRHS)*NVALS*TransformedVectorSize * (int) sizeof(FComplex<FReal>); - } - - int getSavedSizeDown() const { - return (NLHS)*NVALS*VectorSize * (int) sizeof(FReal) + (NLHS)*NVALS*TransformedVectorSize * (int) sizeof(FComplex<FReal>); - } - - template <class StreamClass> + FUnifCell(){ + memset(multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize); + memset(local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize); + memset(transformed_multipole_exp, 0, + sizeof(FComplex<FReal>) * NRHS * NVALS * TransformedVectorSize); + memset(transformed_local_exp, 0, + sizeof(FComplex<FReal>) * NLHS * NVALS * TransformedVectorSize); + } + + ~FUnifCell() {} + + /** Get Multipole */ + const FReal* getMultipole(const int inRhs) const + { return this->multipole_exp + inRhs*VectorSize; + } + /** Get Local */ + const FReal* getLocal(const int inRhs) const{ + return this->local_exp + inRhs*VectorSize; + } + + /** Get Multipole */ + FReal* getMultipole(const int inRhs){ + return this->multipole_exp + inRhs*VectorSize; + } + /** Get Local */ + FReal* getLocal(const int inRhs){ + return this->local_exp + inRhs*VectorSize; + } + + /** To get the leading dim of a vec */ + int getVectorSize() const{ + return VectorSize; + } + + /** Get Transformed Multipole */ + const FComplex<FReal>* getTransformedMultipole(const int inRhs) const{ + return this->transformed_multipole_exp + inRhs*TransformedVectorSize; + } + /** Get Transformed Local */ + const FComplex<FReal>* getTransformedLocal(const int inRhs) const{ + return this->transformed_local_exp + inRhs*TransformedVectorSize; + } + + /** Get Transformed Multipole */ + FComplex<FReal>* getTransformedMultipole(const int inRhs){ + return this->transformed_multipole_exp + inRhs*TransformedVectorSize; + } + /** Get Transformed Local */ + FComplex<FReal>* getTransformedLocal(const int inRhs){ + return this->transformed_local_exp + inRhs*TransformedVectorSize; + } + + /** To get the leading dim of a vec */ + int getTransformedVectorSize() const{ + return TransformedVectorSize; + } + + /** Make it like the begining */ + void resetToInitialState(){ + memset(multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize); + memset(local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize); + memset(transformed_multipole_exp, 0, + sizeof(FComplex<FReal>) * NRHS * NVALS * TransformedVectorSize); + memset(transformed_local_exp, 0, + sizeof(FComplex<FReal>) * NLHS * NVALS * TransformedVectorSize); + } + + /////////////////////////////////////////////////////// + // to extend FAbstractSendable + /////////////////////////////////////////////////////// + template <class BufferWriterClass> + void serializeUp(BufferWriterClass& buffer) const{ + buffer.write(multipole_exp, VectorSize*NVALS*NRHS); + buffer.write(transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS); + } + + template <class BufferReaderClass> + void deserializeUp(BufferReaderClass& buffer){ + buffer.fillArray(multipole_exp, VectorSize*NVALS*NRHS); + buffer.fillArray(transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS); + } + + template <class BufferWriterClass> + void serializeDown(BufferWriterClass& buffer) const{ + buffer.write(local_exp, VectorSize*NVALS*NLHS); + buffer.write(transformed_local_exp, TransformedVectorSize*NVALS*NLHS); + } + + template <class BufferReaderClass> + void deserializeDown(BufferReaderClass& buffer){ + buffer.fillArray(local_exp, VectorSize*NVALS*NLHS); + buffer.fillArray(transformed_local_exp, TransformedVectorSize*NVALS*NLHS); + } + + /////////////////////////////////////////////////////// + // to extend Serializable + /////////////////////////////////////////////////////// + template <class BufferWriterClass> + void save(BufferWriterClass& buffer) const{ + FBasicCell::save(buffer); + buffer.write(multipole_exp, VectorSize*NVALS*NRHS); + buffer.write(transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS); + buffer.write(local_exp, VectorSize*NVALS*NLHS); + buffer.write(transformed_local_exp, TransformedVectorSize*NVALS*NLHS); + } + + template <class BufferReaderClass> + void restore(BufferReaderClass& buffer){ + FBasicCell::restore(buffer); + buffer.fillArray(multipole_exp, VectorSize*NVALS*NRHS); + buffer.fillArray(transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS); + buffer.fillArray(local_exp, VectorSize*NVALS*NLHS); + buffer.fillArray(transformed_local_exp, TransformedVectorSize*NVALS*NLHS); + } + + FSize getSavedSize() const { + return (NRHS+NLHS)*NVALS*VectorSize * (FSize) sizeof(FReal) + (NRHS+NLHS)*NVALS*TransformedVectorSize * (FSize) sizeof(FComplex<FReal>) + + FBasicCell::getSavedSize(); + } + + FSize getSavedSizeUp() const { + return (NRHS)*NVALS*VectorSize * (FSize) sizeof(FReal) + (NRHS)*NVALS*TransformedVectorSize * (FSize) sizeof(FComplex<FReal>); + } + + FSize getSavedSizeDown() const { + return (NLHS)*NVALS*VectorSize * (FSize) sizeof(FReal) + (NLHS)*NVALS*TransformedVectorSize * (FSize) sizeof(FComplex<FReal>); + } + + template <class StreamClass> friend StreamClass& operator<<(StreamClass& output, const FUnifCell<FReal,ORDER, NRHS, NLHS, NVALS>& cell){ - output <<" Multipole exp NRHS " << NRHS <<" NVALS " <<NVALS << " VectorSize " << cell.getVectorSize() << std::endl; - for (int rhs= 0 ; rhs < NRHS ; ++rhs) { - const FReal* pole = cell.getMultipole(rhs); - for (int val= 0 ; val < NVALS ; ++val) { - output<< " val : " << val << " exp: " ; - for (int i= 0 ; i < cell.getVectorSize() ; ++i) { - output<< pole[i] << " "; - } - output << std::endl; - } - } - return output; - } + output <<" Multipole exp NRHS " << NRHS <<" NVALS " <<NVALS << " VectorSize " << cell.getVectorSize() << std::endl; + for (int rhs= 0 ; rhs < NRHS ; ++rhs) { + const FReal* pole = cell.getMultipole(rhs); + for (int val= 0 ; val < NVALS ; ++val) { + output<< " val : " << val << " exp: " ; + for (int i= 0 ; i < cell.getVectorSize() ; ++i) { + output<< pole[i] << " "; + } + output << std::endl; + } + } + return output; + } }; template <class FReal, int ORDER, int NRHS = 1, int NLHS = 1, int NVALS = 1> class FTypedUnifCell : public FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>, public FExtendCellType { public: - template <class BufferWriterClass> - void save(BufferWriterClass& buffer) const{ - FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>::save(buffer); - FExtendCellType::save(buffer); - } - template <class BufferReaderClass> - void restore(BufferReaderClass& buffer){ - FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>::restore(buffer); - FExtendCellType::restore(buffer); - } - void resetToInitialState(){ - FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>::resetToInitialState(); - FExtendCellType::resetToInitialState(); - } + template <class BufferWriterClass> + void save(BufferWriterClass& buffer) const{ + FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>::save(buffer); + FExtendCellType::save(buffer); + } + template <class BufferReaderClass> + void restore(BufferReaderClass& buffer){ + FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>::restore(buffer); + FExtendCellType::restore(buffer); + } + void resetToInitialState(){ + FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS>::resetToInitialState(); + FExtendCellType::resetToInitialState(); + } + FSize getSavedSize() const { + return FExtendCellType::getSavedSize() + FUnifCell<FReal, ORDER,NRHS,NLHS,NVALS>::getSavedSize(); + } }; #endif //FUNIFCELL_HPP diff --git a/Src/Kernels/Uniform/FUnifInterpolator.hpp b/Src/Kernels/Uniform/FUnifInterpolator.hpp index 276707693..bd052c215 100644 --- a/Src/Kernels/Uniform/FUnifInterpolator.hpp +++ b/Src/Kernels/Uniform/FUnifInterpolator.hpp @@ -429,7 +429,7 @@ inline void FUnifInterpolator<FReal, ORDER,MatrixKernelClass,NVALS>::applyP2M(co const FReal*const positionsY = inParticles->getPositions()[1]; const FReal*const positionsZ = inParticles->getPositions()[2]; - for(int idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++idxPart){ // map global position to [-1,1] map(FPoint<FReal>(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]), localPosition); // 15 flops // evaluate Lagrange polynomial at local position @@ -490,9 +490,9 @@ inline void FUnifInterpolator<FReal, ORDER,MatrixKernelClass,NVALS>::applyL2P(co const FReal*const positionsY = inParticles->getPositions()[1]; const FReal*const positionsZ = inParticles->getPositions()[2]; - const int nParticles = inParticles->getNbParticles(); + const FSize nParticles = inParticles->getNbParticles(); - for(int idxPart = 0 ; idxPart < nParticles ; ++ idxPart){ + for(FSize idxPart = 0 ; idxPart < nParticles ; ++ idxPart){ // map global position to [-1,1] map(FPoint<FReal>(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]), localPosition); // 15 flops @@ -578,9 +578,9 @@ inline void FUnifInterpolator<FReal, ORDER,MatrixKernelClass,NVALS>::applyL2PGra const FReal*const positionsY = inParticles->getPositions()[1]; const FReal*const positionsZ = inParticles->getPositions()[2]; -// const unsigned int nParticles = inParticles->getNbParticles(); +// const FSize nParticles = inParticles->getNbParticles(); - for(int idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++ idxPart){ + for(FSize idxPart = 0 ; idxPart < inParticles->getNbParticles() ; ++ idxPart){ // map global position to [-1,1] map(FPoint<FReal>(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]), localPosition); diff --git a/Src/Utils/FCompareResults.hpp b/Src/Utils/FCompareResults.hpp index 84850db1b..706d9e117 100644 --- a/Src/Utils/FCompareResults.hpp +++ b/Src/Utils/FCompareResults.hpp @@ -23,14 +23,14 @@ #include "Files/FFmaGenericLoader.hpp" template <class FReal, class classArrayType> -int compareTwoArrays(const std::string &tag, const int &nbParticles, const classArrayType &array1, +FSize compareTwoArrays(const std::string &tag, const FSize &nbParticles, const classArrayType &array1, const classArrayType &array2){ // FMath::FAccurater<FReal> potentialDiff; FMath::FAccurater<FReal> fx, fy, fz; double energy1= 0.0, energy2= 0.0; - int error = 0 ; - for(int idxPart = 0 ; idxPart < nbParticles ;++idxPart){ + FSize error = 0 ; + for(FSize idxPart = 0 ; idxPart < nbParticles ;++idxPart){ if(array1[idxPart].getPosition() != array2[idxPart].getPosition() ){ std::cerr <<"Wrong positions " <<std::endl << " P1: " <<array1[idxPart].getPosition()<<std::endl @@ -56,12 +56,12 @@ int compareTwoArrays(const std::string &tag, const int &nbParticles, const clas } // template <class FReal, class classArrayType> -void computeFirstMoment( const int &nbParticles, const classArrayType &particles, FPoint<FReal> &FirstMoment){ +void computeFirstMoment( const FSize &nbParticles, const classArrayType &particles, FPoint<FReal> &FirstMoment){ FReal mx,my,mz ; // #pragma omp parallel for shared(nbParticles,particles) reduction(+:mx,my,mz) - for(int idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ // mx += particles[idxPart].getPhysicalValue()*particles[idxPart].getPosition().getX() ; my += particles[idxPart].getPhysicalValue()*particles[idxPart].getPosition().getY() ; @@ -71,7 +71,7 @@ void computeFirstMoment( const int &nbParticles, const classArrayType &particles } ; template < class FReal, class classArrayType> -void removeFirstMoment( const std::string& TYPE, const int &nbParticles, const classArrayType &particles, FReal &volume) { +void removeFirstMoment( const std::string& TYPE, const FSize &nbParticles, const classArrayType &particles, FReal &volume) { FPoint<FReal> FirstMoment ; computeFirstMoment<FReal, classArrayType>( nbParticles, particles, FirstMoment); std::cout << std::endl; @@ -98,7 +98,7 @@ void removeFirstMoment( const std::string& TYPE, const int &nbParticles, const c } // double tmp; - for(int idx = 0 ; idx < nbParticles ; ++idx){ + for(FSize idx = 0 ; idx < nbParticles ; ++idx){ tmp = particles[idx].getPosition().getX()*FirstMoment.getX() + particles[idx].getPosition().getY()*FirstMoment.getY() + particles[idx].getPosition().getZ()*FirstMoment.getZ() ; FReal Q = particles[idx].getPhysicalValue(), P = particles[idx].getPotential(); diff --git a/Src/Utils/FMath.hpp b/Src/Utils/FMath.hpp index a96b48869..b477a025d 100644 --- a/Src/Utils/FMath.hpp +++ b/Src/Utils/FMath.hpp @@ -360,9 +360,9 @@ struct FMath{ /** A class to compute accuracy */ - template <class FReal> + template <class FReal, class IndexType = FSize> class FAccurater { - int nbElements; + IndexType nbElements; FReal l2Dot; FReal l2Diff; FReal max; @@ -371,7 +371,7 @@ struct FMath{ FAccurater() : nbElements(0),l2Dot(0.0), l2Diff(0.0), max(0.0), maxDiff(0.0) { } /** with inital values */ - FAccurater(const FReal inGood[], const FReal inBad[], const int nbValues) + FAccurater(const FReal inGood[], const FReal inBad[], const IndexType nbValues) : nbElements(0),l2Dot(0.0), l2Diff(0.0), max(0.0), maxDiff(0.0) { add(inGood, inBad, nbValues); } @@ -386,8 +386,8 @@ struct FMath{ nbElements += 1 ; } /** Add array of values */ - void add(const FReal inGood[], const FReal inBad[], const int nbValues){ - for(int idx = 0 ; idx < nbValues ; ++idx){ + void add(const FReal inGood[], const FReal inBad[], const IndexType nbValues){ + for(IndexType idx = 0 ; idx < nbValues ; ++idx){ add(inGood[idx],inBad[idx]); } nbElements += nbValues ; @@ -411,10 +411,10 @@ struct FMath{ FReal getmax() const{ return max; } - int getNbElements() const{ + IndexType getNbElements() const{ return nbElements; } - void setNbElements(const int & n) { + void setNbElements(const IndexType & n) { nbElements = n; } diff --git a/Src/Utils/FQuickSortMpi.hpp b/Src/Utils/FQuickSortMpi.hpp index 40bff8e97..ac432658c 100644 --- a/Src/Utils/FQuickSortMpi.hpp +++ b/Src/Utils/FQuickSortMpi.hpp @@ -182,7 +182,7 @@ class FQuickSortMpi : public FQuickSort< SortType, IndexType> { //// FMpi::TagQuickSort, currentComm.getComm(), &requests[idxPack]) , __LINE__); // Work per max size const IndexType nbElementsInPack = (pack.toElement - pack.fromElement); - const IndexType totalByteToRecv = nbElementsInPack*sizeof(SortType); + const IndexType totalByteToRecv = IndexType(nbElementsInPack*sizeof(SortType)); unsigned char*const ptrDataToRecv = (unsigned char*)&recvBuffer[pack.fromElement]; for(IndexType idxSize = 0 ; idxSize < totalByteToRecv ; idxSize += FQS_MAX_MPI_BYTES){ MPI_Request currentRequest; @@ -220,7 +220,7 @@ class FQuickSortMpi : public FQuickSort< SortType, IndexType> { //// FMpi::TagQuickSort, currentComm.getComm(), &requests[idxPack]) , __LINE__); // Work per max size const IndexType nbElementsInPack = (pack.toElement - pack.fromElement); - const IndexType totalByteToSend = nbElementsInPack*sizeof(SortType); + const IndexType totalByteToSend = IndexType(nbElementsInPack*sizeof(SortType)); unsigned char*const ptrDataToSend = (unsigned char*)const_cast<SortType*>(&inPartToSend[pack.fromElement]); for(IndexType idxSize = 0 ; idxSize < totalByteToSend ; idxSize += FQS_MAX_MPI_BYTES){ MPI_Request currentRequest; diff --git a/Tests/Kernels/DirectAlgorithm.cpp b/Tests/Kernels/DirectAlgorithm.cpp index 2ce936a83..03d7a75ee 100644 --- a/Tests/Kernels/DirectAlgorithm.cpp +++ b/Tests/Kernels/DirectAlgorithm.cpp @@ -148,10 +148,10 @@ int main(int argc, char ** argv){ particlesDirect = new MDParticle<FReal>[loader->getNumberOfParticles()]; std::memset(particlesDirect, 0, sizeof(MDParticle<FReal>) * loader->getNumberOfParticles()) ; // - int nbParticles = static_cast<int>(loader->getNumberOfParticles()); + FSize nbParticles = (loader->getNumberOfParticles()); double totalCharge = 0.0; // - for(int idxPart = 0 ; idxPart < loader->getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader->getNumberOfParticles() ; ++idxPart){ // loader->fillParticle(&particles[idxPart].position, particles[idxPart].forces, &particles[idxPart].physicalValue,&particles[idxPart].index); diff --git a/Tests/Kernels/testAdaptiveChebSymFMM.cpp b/Tests/Kernels/testAdaptiveChebSymFMM.cpp index 18c7e95bc..07fdb05cd 100644 --- a/Tests/Kernels/testAdaptiveChebSymFMM.cpp +++ b/Tests/Kernels/testAdaptiveChebSymFMM.cpp @@ -94,7 +94,7 @@ int main(int argc, char ** argv){ const unsigned int SubTreeHeight = FParameters::getValue(argc, argv, FParameterDefinitions::OctreeSubHeight.options, 2); FFmaGenericLoader<FReal> loader(fileName); - const long int NbPart = loader.getNumberOfParticles() ; + const FSize NbPart = loader.getNumberOfParticles() ; ////////////////////////////////////////////////////////////////////////////////// OctreeClass tree(TreeHeight, SubTreeHeight, loader.getBoxWidth(), loader.getCenterOfBox()); @@ -111,7 +111,7 @@ int main(int argc, char ** argv){ FmaRWParticle<FReal, 8,8>* const particles = new FmaRWParticle<FReal, 8,8>[NbPart]; loader.fillParticle(particles,NbPart); - for(int idxPart = 0 ; idxPart < NbPart; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < NbPart; ++idxPart){ const FPoint<FReal> PP(particles[idxPart].getPosition() ) ; tree.insert(PP, idxPart, particles[idxPart].getPhysicalValue()); } @@ -138,7 +138,7 @@ int main(int argc, char ** argv){ // Compute direct energy ///////////////////////////////////////////////////////////////////////////////////////////////// FReal energyD = 0.0 ; - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } @@ -159,11 +159,11 @@ int main(int argc, char ** argv){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/Tests/Kernels/testChebAlgorithm.cpp b/Tests/Kernels/testChebAlgorithm.cpp index 5150b77f9..670486376 100644 --- a/Tests/Kernels/testChebAlgorithm.cpp +++ b/Tests/Kernels/testChebAlgorithm.cpp @@ -90,7 +90,7 @@ int main(int argc, char* argv[]) if(!loader.isOpen()) throw std::runtime_error("Particle file couldn't be opened!"); TestParticle* const particles = new TestParticle[loader.getNumberOfParticles()]; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> position; FReal physicalValue = 0.0; loader.fillParticle(&position,&physicalValue); @@ -109,8 +109,8 @@ int main(int argc, char* argv[]) time.tic(); { - for(int idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ - for(int idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ + for(FSize idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ + for(FSize idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ FP2P::MutualParticles(particles[idxTarget].position.getX(), particles[idxTarget].position.getY(), particles[idxTarget].position.getZ(), particles[idxTarget].physicalValue, &particles[idxTarget].forces[0], &particles[idxTarget].forces[1], @@ -153,7 +153,7 @@ int main(int argc, char* argv[]) std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl; time.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // put in tree tree.insert(particles[idxPart].position, idxPart, particles[idxPart].physicalValue); } @@ -185,11 +185,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].potential,potentials[idxPart]); fx.add(particles[indexPartOrig].forces[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].forces[1],forcesY[idxPart]); diff --git a/Tests/Kernels/testChebAlgorithmProc.cpp b/Tests/Kernels/testChebAlgorithmProc.cpp index e8a78ad31..08c7aff1e 100644 --- a/Tests/Kernels/testChebAlgorithmProc.cpp +++ b/Tests/Kernels/testChebAlgorithmProc.cpp @@ -112,7 +112,7 @@ int main(int argc, char* argv[]) time.tic(); TestParticle* particles = new TestParticle[loader.getMyNumberOfParticles()]; memset(particles,0,(unsigned int) (sizeof(TestParticle)* loader.getMyNumberOfParticles())); - for(int idxPart = 0 ; idxPart < loader.getMyNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getMyNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particles[idxPart].position,&particles[idxPart].physicalValue); } @@ -129,7 +129,7 @@ int main(int argc, char* argv[]) std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl; time.tic(); - for(int idxPart = 0 ; idxPart < finalParticles.getSize() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < finalParticles.getSize() ; ++idxPart){ // put in tree tree.insert(finalParticles[idxPart].position, idxPart, finalParticles[idxPart].physicalValue); } @@ -161,9 +161,9 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ potential += potentials[idxPart]; fx += forcesX[idxPart]; fy += forcesY[idxPart]; diff --git a/Tests/Kernels/testChebTensorialAlgorithm.cpp b/Tests/Kernels/testChebTensorialAlgorithm.cpp index 9b55bdea1..5dc9cccf8 100644 --- a/Tests/Kernels/testChebTensorialAlgorithm.cpp +++ b/Tests/Kernels/testChebTensorialAlgorithm.cpp @@ -97,7 +97,7 @@ int main(int argc, char* argv[]) if(!loader.isOpen()) throw std::runtime_error("Particle file couldn't be opened!"); TestParticle* const particles = new TestParticle[loader.getNumberOfParticles()]; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> position; FReal physicalValue = 0.0; loader.fillParticle(&position,&physicalValue); @@ -125,8 +125,8 @@ int main(int argc, char* argv[]) std::cout << "\nDirect Computation ... " << std::endl; time.tic(); { - for(int idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ - for(int idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ + for(FSize idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ + for(FSize idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ FP2P::MutualParticlesKIJ(particles[idxTarget].position.getX(), particles[idxTarget].position.getY(), particles[idxTarget].position.getZ(), particles[idxTarget].physicalValue, particles[idxTarget].forces[0], particles[idxTarget].forces[1], @@ -186,7 +186,7 @@ int main(int argc, char* argv[]) std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl; time.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // put in tree // PB: here we have to know NPV... if(NPV==1) @@ -231,11 +231,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(idxPot); const FReal*const forcesY = leaf->getTargets()->getForcesY(idxPot); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(idxPot); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; //PB: store potential in array[nbParticles] checkPotential[indexPartOrig][idxPot]=potentials[idxPart]; diff --git a/Tests/Kernels/testFlopsChebAlgorithm.cpp b/Tests/Kernels/testFlopsChebAlgorithm.cpp index 114f6478d..be4ca0159 100644 --- a/Tests/Kernels/testFlopsChebAlgorithm.cpp +++ b/Tests/Kernels/testFlopsChebAlgorithm.cpp @@ -95,7 +95,7 @@ int main(int argc, char* argv[]) { FPoint<FReal> particlePosition; FReal physicalValue = 0.0; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particlePosition,&physicalValue); tree.insert(particlePosition, physicalValue); } diff --git a/Tests/Kernels/testP2PEfficency.cpp b/Tests/Kernels/testP2PEfficency.cpp index 4b2b2f81c..315e3e8da 100644 --- a/Tests/Kernels/testP2PEfficency.cpp +++ b/Tests/Kernels/testP2PEfficency.cpp @@ -45,7 +45,7 @@ int main(int argc, char ** argv){ ">> This executable test the efficiency of the computation of the P2P", FParameterDefinitions::NbParticles); - const int nbParticles = FParameters::getValue(argc, argv, FParameterDefinitions::NbParticles.options, 1000); + const FSize nbParticles = FParameters::getValue(argc, argv, FParameterDefinitions::NbParticles.options, 1000); std::cout << "Test with " << nbParticles << " particles." << std::endl; ////////////////////////////////////////////////////////// @@ -56,14 +56,14 @@ int main(int argc, char ** argv){ FTic timer; FP2PParticleContainer<FReal> leaf1; - for(int idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ FPoint<FReal> pos; loader.fillParticle(&pos); leaf1.push(pos, 1.0); } FP2PParticleContainer<FReal> leaf2; - for(int idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ FPoint<FReal> pos; loader.fillParticle(&pos); leaf2.push(pos, 1.0); diff --git a/Tests/Kernels/testRotationAlgorithm.cpp b/Tests/Kernels/testRotationAlgorithm.cpp index d83a84e05..a5fb0ba55 100644 --- a/Tests/Kernels/testRotationAlgorithm.cpp +++ b/Tests/Kernels/testRotationAlgorithm.cpp @@ -88,7 +88,7 @@ int main(int argc, char** argv){ std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; counter.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; FReal physicalValue; loader.fillParticle(&particlePosition,&physicalValue); @@ -140,9 +140,9 @@ int main(int argc, char** argv){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ potential += potentials[idxPart]; fx += forcesX[idxPart]; fy += forcesY[idxPart]; diff --git a/Tests/Kernels/testRotationPeriodicBench.cpp b/Tests/Kernels/testRotationPeriodicBench.cpp index 113b05d20..d6b03099b 100644 --- a/Tests/Kernels/testRotationPeriodicBench.cpp +++ b/Tests/Kernels/testRotationPeriodicBench.cpp @@ -92,7 +92,7 @@ int main(int argc, char** argv){ FRandomLoader<FReal> loader(NbParticles); FPoint<FReal>* const particlePositions = new FPoint<FReal>[NbParticles]; - for(int idxPart = 0 ; idxPart < NbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < NbParticles ; ++idxPart){ loader.fillParticle(&particlePositions[idxPart]); } @@ -105,7 +105,7 @@ int main(int argc, char** argv){ OctreeClass treePer(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); // insert in tree - for(int idxPart = 0 ; idxPart < NbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < NbParticles ; ++idxPart){ // put in tree treePer.insert(particlePositions[idxPart], idxPart, (idxPart&1?0.00010:-0.00010)); } @@ -130,8 +130,8 @@ int main(int argc, char** argv){ treePer.forEachLeaf([&](LeafClass* leaf){ const FReal*const potentials = leaf->getTargets()->getPotentials(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < leaf->getTargets()->getNbParticles() ; ++idxPart){ + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); + for(FSize idxPart = 0 ; idxPart < leaf->getTargets()->getNbParticles() ; ++idxPart){ if( indexes[idxPart] < NbParticlesPrint){ allPotential[(idxLevelAbove - MinLevelAbove)*NbParticlesPrint + indexes[idxPart]] = potentials[idxPart]; } @@ -149,7 +149,7 @@ int main(int argc, char** argv){ std::cout << idxLevelAbove << "\t"; } std::cout << "\n"; - for(int idxPart = 0 ; idxPart < NbParticlesPrint ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < NbParticlesPrint ; ++idxPart){ std::cout << idxPart << "\t"; for(int idxLevelAbove = MinLevelAbove; idxLevelAbove < MaxLevelAbove ; idxLevelAbove += IncLevelAbove){ std::cout << allPotential[(idxLevelAbove - MinLevelAbove)*NbParticlesPrint + idxPart] << "\t"; @@ -163,7 +163,7 @@ int main(int argc, char** argv){ std::cout << idxLevelAbove << "/" << idxLevelAbove-1 << "\t"; } std::cout << "\n"; - for(int idxPart = 0 ; idxPart < NbParticlesPrint ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < NbParticlesPrint ; ++idxPart){ std::cout << idxPart << "\t"; for(int idxLevelAbove = MinLevelAbove +1; idxLevelAbove < MaxLevelAbove ; idxLevelAbove += IncLevelAbove){ std::cout << FMath::Abs((allPotential[(idxLevelAbove - MinLevelAbove)*NbParticlesPrint + idxPart] diff --git a/Tests/Kernels/testSphericalAlgorithm.cpp b/Tests/Kernels/testSphericalAlgorithm.cpp index 621d63a86..53ab29317 100644 --- a/Tests/Kernels/testSphericalAlgorithm.cpp +++ b/Tests/Kernels/testSphericalAlgorithm.cpp @@ -92,7 +92,7 @@ int main(int argc, char ** argv){ std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; counter.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; FReal physicalValue; loader.fillParticle(&particlePosition,&physicalValue); @@ -144,9 +144,9 @@ int main(int argc, char ** argv){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ potential += potentials[idxPart]; fx += forcesX[idxPart]; fy += forcesY[idxPart]; diff --git a/Tests/Kernels/testSphericalBench.cpp b/Tests/Kernels/testSphericalBench.cpp index 0051ab0c6..4eb11881d 100644 --- a/Tests/Kernels/testSphericalBench.cpp +++ b/Tests/Kernels/testSphericalBench.cpp @@ -82,7 +82,7 @@ void doATest(const int NbParticles, const int minP, const int maxP, const int mi const bool computeDirectAndDiff = timeForDirect || allAbsoluteDiff || allPotentialDiff; { - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particles[idxPart].position); if((idxPart & 1) && neutral){ particles[idxPart].physicalValue = -physicalValue; @@ -96,8 +96,8 @@ void doATest(const int NbParticles, const int minP, const int maxP, const int mi if(computeDirectAndDiff){ printf("Compute direct!\n"); counter.tic(); - for(int idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ - for(int idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ + for(FSize idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ + for(FSize idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ FP2PR::MutualParticles(particles[idxTarget].position.getX(), particles[idxTarget].position.getY(), particles[idxTarget].position.getZ(),particles[idxTarget].physicalValue, &particles[idxTarget].forces[0],&particles[idxTarget].forces[1], @@ -127,7 +127,7 @@ void doATest(const int NbParticles, const int minP, const int maxP, const int mi std::cout << "\tHeight : " << idxH << " \t sub-height : " << SizeSubLevels << std::endl; counter.tic(); - for(int idxPart = 0 ; idxPart < NbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < NbParticles ; ++idxPart){ tree.insert(particles[idxPart].position, idxPart, particles[idxPart].physicalValue); } @@ -168,11 +168,11 @@ void doATest(const int NbParticles, const int minP, const int maxP, const int mi const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].potential,potentials[idxPart]); fx.add(particles[indexPartOrig].forces[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].forces[1],forcesY[idxPart]); @@ -320,11 +320,11 @@ int main(int argc, char ** argv){ tree.forEachLeaf([&](LeafClass* leaf){ const FReal*const potentials = leaf->getTargets()->getPotentials(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; const Particle<FReal>& other = (indexPartOrig==0?centeredParticle:otherParticle); potentialDiff[idxP].add(other.potential,potentials[idxPart]); } @@ -423,7 +423,7 @@ int main(int argc, char ** argv){ FReal timeCounter[3][NbSteps]; - for(int idxPart = 0 ; idxPart < NbSteps ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < NbSteps ; ++idxPart){ for(int idxP = 0 ; idxP < 3 ; ++idxP){ doATest(ParticlesNumbers[idxPart],DevsP[idxP],DevsP[idxP],AllLevels[idxPart],AllLevels[idxPart], physicalValue, neutral, nullptr, nullptr, @@ -437,7 +437,7 @@ int main(int argc, char ** argv){ fprintf(fres, "\t%d\t%d\t%d", DevsP[0],DevsP[1],DevsP[2]); fprintf(fres, "\n"); - for(int idxPart = 0 ; idxPart < NbSteps ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < NbSteps ; ++idxPart){ fprintf(fres, "%d", ParticlesNumbers[idxPart]); for(int idxP = 0 ; idxP < 3 ; ++idxP){ fprintf(fres, "\t%e", timeCounter[idxP][idxPart]); diff --git a/Tests/Kernels/testSphericalBlasAlgorithm.cpp b/Tests/Kernels/testSphericalBlasAlgorithm.cpp index 1b940b36e..b06479193 100644 --- a/Tests/Kernels/testSphericalBlasAlgorithm.cpp +++ b/Tests/Kernels/testSphericalBlasAlgorithm.cpp @@ -97,7 +97,7 @@ int main(int argc, char ** argv){ std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; counter.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; FReal physicalValue = 0.0; loader.fillParticle(&particlePosition,&physicalValue); @@ -150,9 +150,9 @@ int main(int argc, char ** argv){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ potential += potentials[idxPart] * physicalValues[idxPart]; fx += forcesX[idxPart]; fy += forcesY[idxPart]; diff --git a/Tests/Kernels/testSphericalBlockBlasAlgorithm.cpp b/Tests/Kernels/testSphericalBlockBlasAlgorithm.cpp index 85be35759..3b39326ed 100644 --- a/Tests/Kernels/testSphericalBlockBlasAlgorithm.cpp +++ b/Tests/Kernels/testSphericalBlockBlasAlgorithm.cpp @@ -100,7 +100,7 @@ int main(int argc, char ** argv){ std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; counter.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; FReal physicalValue = 0.0; loader.fillParticle(&particlePosition,&physicalValue); @@ -153,9 +153,9 @@ int main(int argc, char ** argv){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ potential += potentials[idxPart] * physicalValues[idxPart]; fx += forcesX[idxPart]; fy += forcesY[idxPart]; diff --git a/Tests/Kernels/testSphericalDlpolyAlgorithm.cpp b/Tests/Kernels/testSphericalDlpolyAlgorithm.cpp index c0cbf33f1..4fdd46c2f 100644 --- a/Tests/Kernels/testSphericalDlpolyAlgorithm.cpp +++ b/Tests/Kernels/testSphericalDlpolyAlgorithm.cpp @@ -174,7 +174,7 @@ int main(int argc, char ** argv){ EwalParticle<FReal> * const particles = new EwalParticle<FReal>[loader->getNumberOfParticles()]; memset(particles, 0, sizeof(EwalParticle<FReal>) * loader->getNumberOfParticles()); double totalCharge = 0.0; - for(int idxPart = 0 ; idxPart < loader->getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader->getNumberOfParticles() ; ++idxPart){ // loader->fillParticle(&particles[idxPart].position, particles[idxPart].forces, &particles[idxPart].physicalValue,&particles[idxPart].index); @@ -297,7 +297,7 @@ int main(int argc, char ** argv){ // particlesDirect : Direct results // counter.tic(); - for(int idxTarget = 0 ; idxTarget < loader->getNumberOfParticles() ; ++idxTarget){ + for(FSize idxTarget = 0 ; idxTarget < loader->getNumberOfParticles() ; ++idxTarget){ particlesDirect[idxTarget] = particles[idxTarget]; EwalParticle<FReal> & part = particlesDirect[idxTarget]; part.forces[0] = part.forces[1] = part.forces[2] = 0.0; @@ -307,7 +307,7 @@ int main(int argc, char ** argv){ // // Compute force and potential between particles[idxTarget] and particles inside the box // - for(int idxOther = 0; idxOther < loader->getNumberOfParticles() ; ++idxOther){ + for(FSize idxOther = 0; idxOther < loader->getNumberOfParticles() ; ++idxOther){ if( idxOther != idxTarget ){ FP2P::NonMutualParticles( particles[idxOther].position.getX(), particles[idxOther].position.getY(), @@ -336,7 +336,7 @@ int main(int argc, char ** argv){ loader->getBoxWidth() * FReal(idxY), loader->getBoxWidth() * FReal(idxZ)); // std::cout <<" ( "<< idxX<<" , "<<idxY << " , "<< idxZ << " ) "<< offset <<std::endl; - for(int idxSource = 0 ; idxSource < loader->getNumberOfParticles() ; ++idxSource){ + for(FSize idxSource = 0 ; idxSource < loader->getNumberOfParticles() ; ++idxSource){ EwalParticle<FReal> source = particles[idxSource]; source.position += offset; // std::cout << "Part "<<idxSource<< " " <<source.position.getX()<< " " << source.position.getY()<< " " <<source.position.getZ()<< " " <<source.physicalValue <<std::endl ; @@ -437,11 +437,11 @@ int main(int argc, char ** argv){ const FReal*const positionsX = leaf->getTargets()->getPositions()[0]; const FReal*const positionsY = leaf->getTargets()->getPositions()[1]; const FReal*const positionsZ = leaf->getTargets()->getPositions()[2]; - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); // - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; if(scale){ // // remove dipole correction for DL_POLY diff --git a/Tests/Kernels/testSphericalGalaxyCsv.cpp b/Tests/Kernels/testSphericalGalaxyCsv.cpp index 5db21b8e0..763f7b14b 100644 --- a/Tests/Kernels/testSphericalGalaxyCsv.cpp +++ b/Tests/Kernels/testSphericalGalaxyCsv.cpp @@ -64,7 +64,7 @@ public: return velocities; } - void fillToCsv(const int partIdx, FReal values[4]) const { + void fillToCsv(const FSize partIdx, FReal values[4]) const { values[0] = Parent::getPositions()[0][partIdx]; values[1] = Parent::getPositions()[1][partIdx]; values[2] = Parent::getPositions()[2][partIdx]; @@ -101,12 +101,12 @@ public: } /** To get the position of the particle at idx idxPart in leaf lf */ - void getParticlePosition(VelocityContainer<FReal>* lf, const int idxPart, FPoint<FReal>* particlePos){ + void getParticlePosition(VelocityContainer<FReal>* lf, const FSize idxPart, FPoint<FReal>* particlePos){ (*particlePos) = FPoint<FReal>(lf->getPositions()[0][idxPart],lf->getPositions()[1][idxPart],lf->getPositions()[2][idxPart]); } /** Remove a particle but keep it to reinsert it later*/ - void removeFromLeafAndKeep(VelocityContainer<FReal>* lf, const FPoint<FReal>& particlePos, const int idxPart,FParticleType /*type*/){ + void removeFromLeafAndKeep(VelocityContainer<FReal>* lf, const FPoint<FReal>& particlePos, const FSize idxPart,FParticleType /*type*/){ std::array<typename VelocityContainer<FReal>::AttributesClass, VelocityContainer<FReal>::NbAttributes> particleValues; for(int idxAttr = 0 ; idxAttr < VelocityContainer<FReal>::NbAttributes ; ++idxAttr){ particleValues[idxAttr] = lf->getAttribute(idxAttr)[idxPart]; @@ -122,7 +122,7 @@ public: void insertAllParticles(OctreeClass* tree){ std::array<typename VelocityContainer<FReal>::AttributesClass, VelocityContainer<FReal>::NbAttributes> particleValues; - for(int idxToInsert = 0; idxToInsert<toStoreRemovedParts.getNbParticles() ; ++idxToInsert){ + for(FSize idxToInsert = 0; idxToInsert<toStoreRemovedParts.getNbParticles() ; ++idxToInsert){ for(int idxAttr = 0 ; idxAttr < VelocityContainer<FReal>::NbAttributes ; ++idxAttr){ particleValues[idxAttr] = toStoreRemovedParts.getAttribute(idxAttr)[idxToInsert]; } @@ -185,7 +185,7 @@ int main(int argc, char ** argv){ FPoint<FReal> position, velocity; FReal physicalValue; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&position, &physicalValue, &velocity); tree.insert(position, velocity, physicalValue); } diff --git a/Tests/Kernels/testSphericalProcAlgorithm.cpp b/Tests/Kernels/testSphericalProcAlgorithm.cpp index 19f322a29..749558581 100644 --- a/Tests/Kernels/testSphericalProcAlgorithm.cpp +++ b/Tests/Kernels/testSphericalProcAlgorithm.cpp @@ -170,7 +170,7 @@ void ValidateFMMAlgoProc(OctreeClass* const badTree, const FReal*const valideForcesY = valideLeaf->getForcesY(); const FReal*const valideForcesZ = valideLeaf->getForcesZ(); - for(int idxLeaf = 0 ; idxLeaf < firstLeaf->getNbParticles() ; ++idxLeaf){ + for(FSize idxLeaf = 0 ; idxLeaf < firstLeaf->getNbParticles() ; ++idxLeaf){ int idxValideLeaf = 0; for(; idxValideLeaf < valideLeaf->getNbParticles() ; ++idxValideLeaf){ @@ -286,7 +286,7 @@ int main(int argc, char ** argv){ TestParticle* particles = new TestParticle[loader.getNumberOfParticles()]; memset(particles, 0, sizeof(TestParticle) * loader.getNumberOfParticles()); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particles[idxPart].position,&particles[idxPart].physicalValue); } @@ -355,9 +355,9 @@ int main(int argc, char ** argv){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ potential += potentials[idxPart]; fx += forcesX[idxPart]; fy += forcesY[idxPart]; @@ -407,9 +407,9 @@ int main(int argc, char ** argv){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ potential += potentials[idxPart]; fx += forcesX[idxPart]; fy += forcesY[idxPart]; diff --git a/Tests/Kernels/testSphericalRotationAlgorithm.cpp b/Tests/Kernels/testSphericalRotationAlgorithm.cpp index ef6650d67..903584db9 100644 --- a/Tests/Kernels/testSphericalRotationAlgorithm.cpp +++ b/Tests/Kernels/testSphericalRotationAlgorithm.cpp @@ -94,7 +94,7 @@ int main(int argc, char ** argv){ std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; counter.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; FReal physicalValue = 0.0; loader.fillParticle(&particlePosition,&physicalValue); @@ -146,9 +146,9 @@ int main(int argc, char ** argv){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ potential += potentials[idxPart]; fx += forcesX[idxPart]; fy += forcesY[idxPart]; diff --git a/Tests/Kernels/testTaylor.cpp b/Tests/Kernels/testTaylor.cpp index e5590cc7d..44046bbde 100644 --- a/Tests/Kernels/testTaylor.cpp +++ b/Tests/Kernels/testTaylor.cpp @@ -84,7 +84,7 @@ int main(int argc, char* argv[]) if(!loader.isOpen()) throw std::runtime_error("Particle file couldn't be opened!"); TestParticle* const particles = new TestParticle[loader.getNumberOfParticles()]; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> position; FReal physicalValue = 0.0; loader.fillParticle(&position,&physicalValue); @@ -97,8 +97,8 @@ int main(int argc, char* argv[]) particles[idxPart].forces[2] = 0.0; } { - for(int idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ - for(int idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ + for(FSize idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ + for(FSize idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ FP2PR::MutualParticles(particles[idxTarget].position.getX(), particles[idxTarget].position.getY(), particles[idxTarget].position.getZ(),particles[idxTarget].physicalValue, &particles[idxTarget].forces[0],&particles[idxTarget].forces[1], @@ -138,7 +138,7 @@ int main(int argc, char* argv[]) << SubTreeHeight << std::endl; time.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // put in tree tree.insert(particles[idxPart].position, idxPart, particles[idxPart].physicalValue); } @@ -167,10 +167,10 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].potential,potentials[idxPart]); fx.add(particles[indexPartOrig].forces[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].forces[1],forcesY[idxPart]); diff --git a/Tests/Kernels/testTaylorSimple.cpp b/Tests/Kernels/testTaylorSimple.cpp index 3f43eb3ea..ecdee29e0 100644 --- a/Tests/Kernels/testTaylorSimple.cpp +++ b/Tests/Kernels/testTaylorSimple.cpp @@ -130,9 +130,9 @@ int main(int argc,char* argv[]){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ Energy += charges[idxPart]*potentials[idxPart]; fx += forcesX[idxPart]; fy += forcesY[idxPart]; diff --git a/Tests/Kernels/testTsmAlgorithm.cpp b/Tests/Kernels/testTsmAlgorithm.cpp index 2a535eb94..e1dbeb95f 100644 --- a/Tests/Kernels/testTsmAlgorithm.cpp +++ b/Tests/Kernels/testTsmAlgorithm.cpp @@ -76,7 +76,7 @@ int testFunction(int argc, char ** argv, Args ... kernelPreArgs){ std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; counter.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; FReal physicalValue = 0.0; FParticleType particleType; @@ -118,9 +118,9 @@ int testFunction(int argc, char ** argv, Args ... kernelPreArgs){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ potential += potentials[idxPart]; fx += forcesX[idxPart]; fy += forcesY[idxPart]; diff --git a/Tests/Kernels/testTuneSphericalBlockBlas.cpp b/Tests/Kernels/testTuneSphericalBlockBlas.cpp index 3a6c55ed7..e587ad47a 100644 --- a/Tests/Kernels/testTuneSphericalBlockBlas.cpp +++ b/Tests/Kernels/testTuneSphericalBlockBlas.cpp @@ -99,7 +99,7 @@ int main(int argc, char ** argv){ // ----------------------------------------------------- - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; FReal physicalValue = 0.0; loader.fillParticle(&particlePosition,&physicalValue); diff --git a/Tests/Kernels/testUnifAlgorithm.cpp b/Tests/Kernels/testUnifAlgorithm.cpp index 740069988..bb7ee25e8 100644 --- a/Tests/Kernels/testUnifAlgorithm.cpp +++ b/Tests/Kernels/testUnifAlgorithm.cpp @@ -97,7 +97,7 @@ int main(int argc, char* argv[]) if(!loader.isOpen()) throw std::runtime_error("Particle file couldn't be opened!"); TestParticle* const particles = new TestParticle[loader.getNumberOfParticles()]; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> position; FReal physicalValue = 0.0; loader.fillParticle(&position,&physicalValue); @@ -116,8 +116,8 @@ int main(int argc, char* argv[]) std::cout << "\nDirect computation ... " << std::endl; time.tic(); { - for(int idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ - for(int idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ + for(FSize idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ + for(FSize idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ FP2P::MutualParticles(particles[idxTarget].position.getX(), particles[idxTarget].position.getY(), particles[idxTarget].position.getZ(), particles[idxTarget].physicalValue, &particles[idxTarget].forces[0], &particles[idxTarget].forces[1], @@ -162,7 +162,7 @@ int main(int argc, char* argv[]) std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl; time.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // put in tree tree.insert(particles[idxPart].position, idxPart, particles[idxPart].physicalValue); } @@ -197,11 +197,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; //PB: store potential in nbParticles array checkPotential[indexPartOrig]=potentials[idxPart]; diff --git a/Tests/Kernels/testUnifAlgorithmProc.cpp b/Tests/Kernels/testUnifAlgorithmProc.cpp index 24f4c3c4a..e5274193e 100644 --- a/Tests/Kernels/testUnifAlgorithmProc.cpp +++ b/Tests/Kernels/testUnifAlgorithmProc.cpp @@ -121,7 +121,7 @@ int main(int argc, char* argv[]) time.tic(); TestParticle* particles = new TestParticle[loader.getMyNumberOfParticles()]; memset(particles,0,(unsigned int) (sizeof(TestParticle)* loader.getMyNumberOfParticles())); - for(int idxPart = 0 ; idxPart < loader.getMyNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getMyNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particles[idxPart].position,&particles[idxPart].physicalValue); } FVector<TestParticle> finalParticles; @@ -138,7 +138,7 @@ int main(int argc, char* argv[]) std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl; time.tic(); - for(int idxPart = 0 ; idxPart < finalParticles.getSize() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < finalParticles.getSize() ; ++idxPart){ // put in tree tree.insert(finalParticles[idxPart].position, idxPart, finalParticles[idxPart].physicalValue); } @@ -169,8 +169,8 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ potential += potentials[idxPart]; fx += forcesX[idxPart]; fy += forcesY[idxPart]; diff --git a/Tests/Kernels/testUnifTensorialAlgorithm.cpp b/Tests/Kernels/testUnifTensorialAlgorithm.cpp index 046e37254..b9cfa92f4 100644 --- a/Tests/Kernels/testUnifTensorialAlgorithm.cpp +++ b/Tests/Kernels/testUnifTensorialAlgorithm.cpp @@ -104,7 +104,7 @@ int main(int argc, char* argv[]) if(!loader.isOpen()) throw std::runtime_error("Particle file couldn't be opened!"); TestParticle* const particles = new TestParticle[loader.getNumberOfParticles()]; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> position; FReal physicalValue = 0.0; loader.fillParticle(&position,&physicalValue); @@ -132,8 +132,8 @@ int main(int argc, char* argv[]) std::cout << "\nDirect Computation ... " << std::endl; time.tic(); { - for(int idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ - for(int idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ + for(FSize idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ + for(FSize idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ FP2P::MutualParticlesKIJ(particles[idxTarget].position.getX(), particles[idxTarget].position.getY(), particles[idxTarget].position.getZ(), particles[idxTarget].physicalValue, particles[idxTarget].forces[0], particles[idxTarget].forces[1], @@ -192,7 +192,7 @@ int main(int argc, char* argv[]) std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl; time.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // put in tree if(NPV==1) // scalar kernels like ONE_OVER_R tree.insert(particles[idxPart].position, idxPart, @@ -237,11 +237,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(idxPot); const FReal*const forcesY = leaf->getTargets()->getForcesY(idxPot); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(idxPot); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; //PB: store potential in array[nbParticles] checkPotential[indexPartOrig][idxPot]=potentials[idxPart]; diff --git a/Tests/Utils/testChebInterpolator.cpp b/Tests/Utils/testChebInterpolator.cpp index 383eaa535..4bc537b72 100644 --- a/Tests/Utils/testChebInterpolator.cpp +++ b/Tests/Utils/testChebInterpolator.cpp @@ -162,13 +162,13 @@ int main(int argc, char ** argv){ { // start direct computation unsigned int counter = 0; - for(int idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ + for(FSize idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ const FPoint<FReal> x = FPoint<FReal>(X.getSrc()->getPositions()[0][idxPartX], X.getSrc()->getPositions()[1][idxPartX], X.getSrc()->getPositions()[2][idxPartX]); const FReal wx = X.getSrc()->getPhysicalValues()[idxPartX]; - for(int idxPartY = 0 ; idxPartY < Y.getSrc()->getNbParticles() ; ++idxPartY){ + for(FSize idxPartY = 0 ; idxPartY < Y.getSrc()->getNbParticles() ; ++idxPartY){ const FPoint<FReal> y = FPoint<FReal>(Y.getSrc()->getPositions()[0][idxPartY], Y.getSrc()->getPositions()[1][idxPartY], Y.getSrc()->getPositions()[2][idxPartY]); @@ -196,7 +196,7 @@ int main(int argc, char ** argv){ //////////////////////////////////////////////////////////////////// unsigned int counter = 0; - for(int idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ + for(FSize idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ approx_p[counter] = X.getSrc()->getPotentials()[idxPartX]; const FPoint<FReal> force = FPoint<FReal>(X.getSrc()->getForcesX()[idxPartX], X.getSrc()->getForcesY()[idxPartX], diff --git a/Tests/Utils/testChebInterpolatorExtendedBBox.cpp b/Tests/Utils/testChebInterpolatorExtendedBBox.cpp index a2deb9a5b..f2231deff 100644 --- a/Tests/Utils/testChebInterpolatorExtendedBBox.cpp +++ b/Tests/Utils/testChebInterpolatorExtendedBBox.cpp @@ -216,13 +216,13 @@ int main(int argc, char ** argv){ { // start direct computation unsigned int counter = 0; - for(int idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ + for(FSize idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ const FPoint<FReal> x = FPoint<FReal>(X.getSrc()->getPositions()[0][idxPartX], X.getSrc()->getPositions()[1][idxPartX], X.getSrc()->getPositions()[2][idxPartX]); const FReal wx = X.getSrc()->getPhysicalValues()[idxPartX]; - for(int idxPartY = 0 ; idxPartY < Y.getSrc()->getNbParticles() ; ++idxPartY){ + for(FSize idxPartY = 0 ; idxPartY < Y.getSrc()->getNbParticles() ; ++idxPartY){ const FPoint<FReal> y = FPoint<FReal>(Y.getSrc()->getPositions()[0][idxPartY], Y.getSrc()->getPositions()[1][idxPartY], Y.getSrc()->getPositions()[2][idxPartY]); @@ -250,7 +250,7 @@ int main(int argc, char ** argv){ //////////////////////////////////////////////////////////////////// unsigned int counter = 0; - for(int idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ + for(FSize idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ approx_p[counter] = X.getSrc()->getPotentials()[idxPartX]; const FPoint<FReal> force = FPoint<FReal>(X.getSrc()->getForcesX()[idxPartX], X.getSrc()->getForcesY()[idxPartX], diff --git a/Tests/Utils/testChebOctree.cpp b/Tests/Utils/testChebOctree.cpp index 46a953b95..2540f207a 100644 --- a/Tests/Utils/testChebOctree.cpp +++ b/Tests/Utils/testChebOctree.cpp @@ -99,7 +99,7 @@ int main(int argc, char ** argv){ const FReal*const positionsY = Particles->getPositions()[1]; const FReal*const positionsZ = Particles->getPositions()[2]; - for(int idxPart = 0 ; idxPart < Particles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < Particles->getNbParticles() ; ++idxPart){ const FPoint<FReal> distance(LeafCellCenter-FPoint<FReal>(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart])); if (std::abs(distance.getX())>BoxWidthLeaf/FReal(2.) || std::abs(distance.getY())>BoxWidthLeaf/FReal(2.) || diff --git a/Tests/Utils/testChebSxUCBSy.cpp b/Tests/Utils/testChebSxUCBSy.cpp index be0c9c1a3..8cfbe696a 100644 --- a/Tests/Utils/testChebSxUCBSy.cpp +++ b/Tests/Utils/testChebSxUCBSy.cpp @@ -179,7 +179,7 @@ int main(int argc, char* argv[]) const FReal*const positionsZ = Y.getSrc()->getPositions()[2]; const FReal*const physicalValues = Y.getSrc()->getPhysicalValues(); - for(int idxPart = 0 ; idxPart < Y.getSrc()->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < Y.getSrc()->getNbParticles() ; ++idxPart){ const FPoint<FReal> y = FPoint<FReal>(positionsX[idxPart],positionsY[idxPart],positionsZ[idxPart]); const FReal w = physicalValues[idxPart]; @@ -187,7 +187,7 @@ int main(int argc, char* argv[]) const FReal*const xpositionsY = X.getSrc()->getPositions()[1]; const FReal*const xpositionsZ = X.getSrc()->getPositions()[2]; - for(int idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ + for(FSize idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ const FPoint<FReal> x = FPoint<FReal>(xpositionsX[idxPart],xpositionsY[idxPart],xpositionsZ[idxPart]); f[idxPartX] += MatrixKernel.evaluate(x,y) * w; } @@ -199,7 +199,7 @@ int main(int argc, char* argv[]) //////////////////////////////////////////////////////////////////// const FReal*const potentials = X.getSrc()->getPotentials(); - for(int idxPart = 0 ; idxPart < X.getSrc()->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < X.getSrc()->getNbParticles() ; ++idxPart){ approx_f[idxPart] = potentials[idxPart]; } diff --git a/Tests/Utils/testFmmAdaptiveAlgorithm.cpp b/Tests/Utils/testFmmAdaptiveAlgorithm.cpp index 549a13947..5f449d1ed 100644 --- a/Tests/Utils/testFmmAdaptiveAlgorithm.cpp +++ b/Tests/Utils/testFmmAdaptiveAlgorithm.cpp @@ -99,7 +99,7 @@ int main(int argc, char ** argv){ { FPoint<FReal> particlePosition; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particlePosition); tree.insert(particlePosition); } @@ -126,7 +126,7 @@ int main(int argc, char ** argv){ tree.forEachCellLeaf([&](CellWrapperClass*, LeafClass* leaf){ long long int*const particlesAttributes = leaf->getTargets()->getDataDown(); - for(int idxPart = 0 ; idxPart < leaf->getTargets()->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < leaf->getTargets()->getNbParticles() ; ++idxPart){ if(particlesAttributes[idxPart] != (loader.getNumberOfParticles()-1)){ std::cout << "Incorrect " << particlesAttributes[idxPart] << " instead of " << (loader.getNumberOfParticles()-1) << "\n"; } diff --git a/Tests/Utils/testFmmAdaptiveAlgorithmAdvanced.cpp b/Tests/Utils/testFmmAdaptiveAlgorithmAdvanced.cpp index 14ca4efdf..3424a6c6d 100644 --- a/Tests/Utils/testFmmAdaptiveAlgorithmAdvanced.cpp +++ b/Tests/Utils/testFmmAdaptiveAlgorithmAdvanced.cpp @@ -105,7 +105,7 @@ int main(int argc, char ** argv){ { FPoint<FReal> particlePosition; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FReal pv; loader.fillParticle(&particlePosition, &pv); //loader.fillParticle(&particlePosition); @@ -139,7 +139,7 @@ int main(int argc, char ** argv){ tree.forEachCellLeaf([&](CellWrapperClass*, LeafClass* leaf){ long long int*const particlesAttributes = leaf->getTargets()->getDataDown(); - for(int idxPart = 0 ; idxPart < leaf->getTargets()->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < leaf->getTargets()->getNbParticles() ; ++idxPart){ if(particlesAttributes[idxPart] != (loader.getNumberOfParticles()-1)){ std::cout << "Incorrect " << particlesAttributes[idxPart] << " instead of " << (loader.getNumberOfParticles()-1) << "\n"; } diff --git a/Tests/Utils/testFmmAdaptiveStats.cpp b/Tests/Utils/testFmmAdaptiveStats.cpp index 915ca62de..d1d4989f4 100644 --- a/Tests/Utils/testFmmAdaptiveStats.cpp +++ b/Tests/Utils/testFmmAdaptiveStats.cpp @@ -237,7 +237,7 @@ public: bool preferP2M(const int /*atLevel*/, const ContainerClass*const particles[], const int nbContainers) override { nbAdaptiveFmmOperations += 1; - int counterParticles = 0; + FSize counterParticles = 0; for(int idxContainer = 0 ; idxContainer < nbContainers ; ++idxContainer){ counterParticles += particles[idxContainer]->getNbParticles(); } @@ -292,7 +292,7 @@ int main(int argc, char ** argv){ { FPoint<FReal> particlePosition; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particlePosition); tree.insert(particlePosition); } diff --git a/Tests/Utils/testFmmAlgorithm.cpp b/Tests/Utils/testFmmAlgorithm.cpp index 007f371ca..f6f73d62f 100644 --- a/Tests/Utils/testFmmAlgorithm.cpp +++ b/Tests/Utils/testFmmAlgorithm.cpp @@ -88,7 +88,7 @@ int main(int argc, char ** argv){ { FPoint<FReal> particlePosition; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particlePosition); tree.insert(particlePosition); } diff --git a/Tests/Utils/testFmmAlgorithmPeriodic.cpp b/Tests/Utils/testFmmAlgorithmPeriodic.cpp index ec6be8a55..e9fa2b0df 100644 --- a/Tests/Utils/testFmmAlgorithmPeriodic.cpp +++ b/Tests/Utils/testFmmAlgorithmPeriodic.cpp @@ -91,7 +91,7 @@ int main(int argc, char ** argv){ { FPoint<FReal> particlePosition; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particlePosition); tree.insert(particlePosition); } @@ -146,7 +146,7 @@ int main(int argc, char ** argv){ std::cout << "Min is " << min << " Max is " << max << std::endl; tree.forEachLeaf([&](LeafClass* leaf){ - for(int idxPart = 0 ; idxPart < leaf->getSrc()->getNbParticles() ; ++idxPart ){ + for(FSize idxPart = 0 ; idxPart < leaf->getSrc()->getNbParticles() ; ++idxPart ){ if( NbParticlesEntireSystem - 1 != leaf->getSrc()->getDataDown()[idxPart]){ std::cout << "P2P probleme, should be " << NbParticlesEntireSystem - 1 << " iter.data().getDataDown() "<< leaf->getSrc()->getDataDown()[idxPart] << std::endl; diff --git a/Tests/Utils/testFmmAlgorithmProc.cpp b/Tests/Utils/testFmmAlgorithmProc.cpp index 43071a511..12ab7f356 100644 --- a/Tests/Utils/testFmmAlgorithmProc.cpp +++ b/Tests/Utils/testFmmAlgorithmProc.cpp @@ -211,7 +211,7 @@ void ValidateFMMAlgoProc(OctreeClass* const badTree, do { if(octreeIterator.getCurrentListSrc()->getNbParticles() != octreeIterator.getCurrentCell()->getDataUp()){ - printf("P2M Problem nb part %d data up %lld \n", + printf("P2M Problem nb part %lld data up %lld \n", octreeIterator.getCurrentListSrc()->getNbParticles(), octreeIterator.getCurrentCell()->getDataUp()); } } while( octreeIterator.moveRight() ); @@ -237,7 +237,7 @@ void ValidateFMMAlgoProc(OctreeClass* const badTree, } if(octreeIterator.getCurrentListTargets()->getNbParticles() != valideOctreeIterator.getCurrentListTargets()->getNbParticles()){ - printf("Problem Do not have the same number of particle at leaf id %lld, valide %d invalide %d \n", + printf("Problem Do not have the same number of particle at leaf id %lld, valide %lld invalide %lld \n", octreeIterator.getCurrentGlobalIndex(), valideOctreeIterator.getCurrentListTargets()->getNbParticles(), octreeIterator.getCurrentListTargets()->getNbParticles()); } @@ -248,7 +248,7 @@ void ValidateFMMAlgoProc(OctreeClass* const badTree, ContainerClass* containerValide = (valideOctreeIterator.getCurrentListTargets()); const long long int*const dataDownValide = containerValide->getDataDown(); - for(int idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){ // If a particles has been impacted by less than NbPart - 1 (the current particle) // there is a problem if( dataDown[idxPart] != dataDownValide[idxPart]){ @@ -330,7 +330,7 @@ int main(int argc, char ** argv){ FMpiFmaGenericLoader<FReal> loader(filename,app.global()); if(!loader.isOpen()) throw std::runtime_error("Particle file couldn't be opened!"); - const int nbPartsForMe = loader.getMyNumberOfParticles(); + const FSize nbPartsForMe = loader.getMyNumberOfParticles(); const FReal boxWidth = loader.getBoxWidth(); const FPoint<FReal> centerOfBox = loader.getCenterOfBox(); @@ -358,7 +358,7 @@ int main(int argc, char ** argv){ TestParticle* particles = new TestParticle[nbPartsForMe]; memset(particles, 0, sizeof(TestParticle) * nbPartsForMe); - for(int idxPart = 0 ; idxPart < nbPartsForMe ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbPartsForMe ; ++idxPart){ FPoint<FReal> position; FReal physicalValue; loader.fillParticle(&position, &physicalValue); @@ -403,7 +403,7 @@ int main(int argc, char ** argv){ FFmaGenericLoader<FReal> loaderValide(filename); if(!loaderValide.isOpen()) throw std::runtime_error("Particle file couldn't be opened!"); - const int nbPartsValide = loaderValide.getNumberOfParticles(); + const FSize nbPartsValide = loaderValide.getNumberOfParticles(); const FReal boxWidthValide = loaderValide.getBoxWidth(); const FPoint<FReal> centerOfBoxValide = loaderValide.getCenterOfBox(); diff --git a/Tests/Utils/testFmmAlgorithmProcPeriodic.cpp b/Tests/Utils/testFmmAlgorithmProcPeriodic.cpp index 2d3dea1d1..5c07650e9 100644 --- a/Tests/Utils/testFmmAlgorithmProcPeriodic.cpp +++ b/Tests/Utils/testFmmAlgorithmProcPeriodic.cpp @@ -160,7 +160,7 @@ int main(int argc, char ** argv){ ContainerClass* container = (octreeIterator.getCurrentListTargets()); const long long int*const dataDown = container->getDataDown(); - for(int idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){ if( NbParticlesEntireSystem - 1 != dataDown[idxPart]){ std::cout << "P2P probleme, should be " << NbParticlesEntireSystem - 1 << " iter.data().getDataDown() "<< dataDown[idxPart] << std::endl; @@ -177,7 +177,7 @@ int main(int argc, char ** argv){ for(int idx = 0 ; idx < app.global().processCount() ; ++idx ){ FPoint<FReal> position; FRandomLoader<FReal> loaderSeq(NbParticles,FReal(1.0),FPoint<FReal>(0,0,0), idx); - for(int idxPart = 0 ; idxPart < loaderSeq.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loaderSeq.getNumberOfParticles() ; ++idxPart){ loaderSeq.fillParticle(&position); treeSeq.insert(position); } @@ -256,7 +256,7 @@ int main(int argc, char ** argv){ std::cout << "\t Not Correct is " << container->getNbParticles() << "\n"; } - for(int idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){ // If a particles has been impacted by less than NbPart - 1 (the current particle) // there is a problem if( dataDown[idxPart] != dataDownValide[idxPart]){ diff --git a/Tests/Utils/testFmmAlgorithmProcRotation.cpp b/Tests/Utils/testFmmAlgorithmProcRotation.cpp index 7d2b20b49..0ca2b962d 100644 --- a/Tests/Utils/testFmmAlgorithmProcRotation.cpp +++ b/Tests/Utils/testFmmAlgorithmProcRotation.cpp @@ -171,7 +171,7 @@ void ValidateFMMAlgoProc(OctreeClass* const badTree, const FReal*const valideForcesY = valideLeaf->getForcesY(); const FReal*const valideForcesZ = valideLeaf->getForcesZ(); - for(int idxLeaf = 0 ; idxLeaf < firstLeaf->getNbParticles() ; ++idxLeaf){ + for(FSize idxLeaf = 0 ; idxLeaf < firstLeaf->getNbParticles() ; ++idxLeaf){ int idxValideLeaf = 0; for(; idxValideLeaf < valideLeaf->getNbParticles() ; ++idxValideLeaf){ @@ -287,7 +287,7 @@ int main(int argc, char ** argv){ TestParticle* particles = new TestParticle[loader.getMyNumberOfParticles()]; memset(particles, 0, (unsigned int) (sizeof(TestParticle) * loader.getMyNumberOfParticles())); - for(int idxPart = 0 ; idxPart < loader.getMyNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getMyNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particles[idxPart].position,&particles[idxPart].physicalValue); } @@ -353,9 +353,9 @@ int main(int argc, char ** argv){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ potential += potentials[idxPart]; fx += forcesX[idxPart]; fy += forcesY[idxPart]; @@ -405,9 +405,9 @@ int main(int argc, char ** argv){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ potential += potentials[idxPart]; fx += forcesX[idxPart]; fy += forcesY[idxPart]; diff --git a/Tests/Utils/testFmmAlgorithmTsm.cpp b/Tests/Utils/testFmmAlgorithmTsm.cpp index 1557a4182..e8b36e2ef 100644 --- a/Tests/Utils/testFmmAlgorithmTsm.cpp +++ b/Tests/Utils/testFmmAlgorithmTsm.cpp @@ -92,7 +92,7 @@ int main(int argc, char ** argv){ { FPoint<FReal> particlePosition; FParticleType particleType; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particlePosition, &particleType); tree.insert(particlePosition, particleType); } diff --git a/Tests/Utils/testFmmDemonstration.cpp b/Tests/Utils/testFmmDemonstration.cpp index dd8db7b44..7f9de59a0 100644 --- a/Tests/Utils/testFmmDemonstration.cpp +++ b/Tests/Utils/testFmmDemonstration.cpp @@ -52,18 +52,18 @@ class MyCell : public FBasicCell { // particles (nothing more!) template <class FReal> class MyContainer : public FAbstractParticleContainer<FReal> { - FVector<int> indexes; + FVector<FSize> indexes; public: template<typename... Args> - void push(const FPoint<FReal>& /*inParticlePosition*/, const int newParticleIndex, Args ... /*args*/){ + void push(const FPoint<FReal>& /*inParticlePosition*/, const FSize newParticleIndex, Args ... /*args*/){ indexes.push(newParticleIndex); } - int getSize() const { + FSize getSize() const { return indexes.getSize(); } - const FVector<int>& getIndexes() const{ + const FVector<FSize>& getIndexes() const{ return indexes; } }; @@ -102,7 +102,7 @@ public: } void P2M(CellClass* const cell, const ContainerClass* const particles) { - for(int idxPart = 0 ; idxPart < particles->getSize() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < particles->getSize() ; ++idxPart){ // save the current morton index for each particles indexForEachParticle[ particles->getIndexes()[idxPart] ] = cell->getMortonIndex(); } @@ -181,7 +181,7 @@ int main(int argc, char ** argv){ { FPoint<FReal> particlePosition; bool keepIt; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // get a random position loader.fillParticle(&particlePosition); // let say we remove 1/5 particles @@ -205,7 +205,7 @@ int main(int argc, char ** argv){ OctreeClass::Iterator octreeIterator(&tree); octreeIterator.gotoBottomLeft(); do{ - FVector<int>::ConstBasicIterator iter(octreeIterator.getCurrentListTargets()->getIndexes()); + FVector<FSize>::ConstBasicIterator iter(octreeIterator.getCurrentListTargets()->getIndexes()); const MortonIndex indexAtThisLeaf = octreeIterator.getCurrentGlobalIndex(); while( iter.hasNotFinished() ){ diff --git a/Tests/Utils/testLoader.cpp b/Tests/Utils/testLoader.cpp index f0cfec19a..025f5f9e7 100644 --- a/Tests/Utils/testLoader.cpp +++ b/Tests/Utils/testLoader.cpp @@ -84,7 +84,7 @@ int main(int argc, char ** argv){ counter.tic(); FPoint<FReal> particlePosition; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particlePosition); tree.insert(particlePosition); } diff --git a/Tests/Utils/testLoaderFMATsm.cpp b/Tests/Utils/testLoaderFMATsm.cpp index f9360bf88..05fa92bcf 100644 --- a/Tests/Utils/testLoaderFMATsm.cpp +++ b/Tests/Utils/testLoaderFMATsm.cpp @@ -78,7 +78,7 @@ int main(int argc, char ** argv ){ FPoint<FReal> particlePosition; FReal physicalValue = 0.0; FParticleType particleType; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particlePosition,&physicalValue, &particleType); tree.insert(particlePosition, particleType, physicalValue); } diff --git a/Tests/Utils/testMemStats.cpp b/Tests/Utils/testMemStats.cpp index bb8d44a50..9b557b067 100644 --- a/Tests/Utils/testMemStats.cpp +++ b/Tests/Utils/testMemStats.cpp @@ -95,7 +95,7 @@ int main(int argc, char ** argv){ { FPoint<FReal> particlePosition; FReal physicalValue = 0.10; - for(int idxPart = 0 ; idxPart < NbPart ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < NbPart ; ++idxPart){ particlePosition.setPosition(FReal(drand48()),FReal(drand48()),FReal(drand48())); tree.insert(particlePosition, physicalValue); } diff --git a/Tests/Utils/testMpiCsvSaver.cpp b/Tests/Utils/testMpiCsvSaver.cpp index 4a8300b59..5dff866cf 100644 --- a/Tests/Utils/testMpiCsvSaver.cpp +++ b/Tests/Utils/testMpiCsvSaver.cpp @@ -61,7 +61,7 @@ public: return velocities; } - void fillToCsv(const int partIdx, FReal values[4]) const { + void fillToCsv(const FSize partIdx, FReal values[4]) const { values[0] = Parent::getPositions()[0][partIdx]; values[1] = Parent::getPositions()[1][partIdx]; values[2] = Parent::getPositions()[2][partIdx]; @@ -168,7 +168,7 @@ int main(int argc, char ** argv){ FPoint<FReal> position, velocity; FReal physicalValue; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&position, &physicalValue, &velocity); if( (idxPart+1) % (app.global().processId()+1) == 0) tree.insert(position,velocity,physicalValue); } diff --git a/Tests/Utils/testOctree.cpp b/Tests/Utils/testOctree.cpp index 37cdc726b..fab20e762 100644 --- a/Tests/Utils/testOctree.cpp +++ b/Tests/Utils/testOctree.cpp @@ -66,7 +66,7 @@ int main(int argc, char ** argv){ counter.tic(); FPoint<FReal> particlePosition; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particlePosition); tree.insert(particlePosition); } diff --git a/Tests/Utils/testOctreeFuncteur.cpp b/Tests/Utils/testOctreeFuncteur.cpp index 310798f97..dad93965d 100644 --- a/Tests/Utils/testOctreeFuncteur.cpp +++ b/Tests/Utils/testOctreeFuncteur.cpp @@ -68,7 +68,7 @@ int main(int argc, char ** argv){ { FPoint<FReal> particlePosition; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particlePosition); tree.insert(particlePosition); } diff --git a/Tests/Utils/testOctreeParallelFuncteur.cpp b/Tests/Utils/testOctreeParallelFuncteur.cpp index 207ffda57..0d347162d 100644 --- a/Tests/Utils/testOctreeParallelFuncteur.cpp +++ b/Tests/Utils/testOctreeParallelFuncteur.cpp @@ -70,7 +70,7 @@ int main(int argc, char ** argv){ { FPoint<FReal> particlePosition; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particlePosition); tree.insert(particlePosition); } diff --git a/Tests/Utils/testOctreeRearrange.cpp b/Tests/Utils/testOctreeRearrange.cpp index 260405b0f..6bfd46243 100644 --- a/Tests/Utils/testOctreeRearrange.cpp +++ b/Tests/Utils/testOctreeRearrange.cpp @@ -89,7 +89,7 @@ int main(int argc, char ** argv){ { FPoint<FReal> particleToFill; - for(int idxPart = 0 ; idxPart < NbPart ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < NbPart ; ++idxPart){ particleToFill.setPosition( (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)), (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)), @@ -115,7 +115,7 @@ int main(int argc, char ** argv){ octreeIterator.gotoBottomLeft(); do{ ContainerClass* particles = octreeIterator.getCurrentListTargets(); - for(int idxPart = 0; idxPart < particles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0; idxPart < particles->getNbParticles() ; ++idxPart){ particles->getWPositions()[0][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)); particles->getWPositions()[1][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)); particles->getWPositions()[2][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)); @@ -155,7 +155,7 @@ int main(int argc, char ** argv){ const MortonIndex leafIndex = octreeIterator.getCurrentGlobalIndex(); ContainerClass* particles = octreeIterator.getCurrentListTargets(); - for(int idxPart = 0; idxPart < particles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0; idxPart < particles->getNbParticles() ; ++idxPart){ const FPoint<FReal> particlePosition( particles->getWPositions()[0][idxPart], particles->getWPositions()[1][idxPart], particles->getWPositions()[2][idxPart]); diff --git a/Tests/Utils/testOctreeRearrangePeriodic.cpp b/Tests/Utils/testOctreeRearrangePeriodic.cpp index bace9448a..9eb78cd6e 100644 --- a/Tests/Utils/testOctreeRearrangePeriodic.cpp +++ b/Tests/Utils/testOctreeRearrangePeriodic.cpp @@ -91,7 +91,7 @@ int main(int argc, char ** argv){ { FPoint<FReal> particleToFill; - for(int idxPart = 0 ; idxPart < NbPart ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < NbPart ; ++idxPart){ particleToFill.setPosition( (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)), (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)), @@ -116,7 +116,7 @@ int main(int argc, char ** argv){ octreeIterator.gotoBottomLeft(); do{ ContainerClass* particles = octreeIterator.getCurrentListTargets(); - for(int idxPart = 0; idxPart < particles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0; idxPart < particles->getNbParticles() ; ++idxPart){ particles->getWPositions()[0][idxPart] = (FReal(drand48()))*BoxWidth*4 + (BoxCenter-(BoxWidth/2)); particles->getWPositions()[1][idxPart] = (FReal(drand48()))*BoxWidth*4 + (BoxCenter-(BoxWidth/2)); particles->getWPositions()[2][idxPart] = (FReal(drand48()))*BoxWidth*4 + (BoxCenter-(BoxWidth/2)); @@ -156,7 +156,7 @@ int main(int argc, char ** argv){ const MortonIndex leafIndex = octreeIterator.getCurrentGlobalIndex(); ContainerClass* particles = octreeIterator.getCurrentListTargets(); - for(int idxPart = 0; idxPart < particles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0; idxPart < particles->getNbParticles() ; ++idxPart){ const FPoint<FReal> particlePosition( particles->getWPositions()[0][idxPart], particles->getWPositions()[1][idxPart], particles->getWPositions()[2][idxPart]); diff --git a/Tests/Utils/testOctreeRearrangeProc.cpp b/Tests/Utils/testOctreeRearrangeProc.cpp index bfa636a82..a837bcb77 100644 --- a/Tests/Utils/testOctreeRearrangeProc.cpp +++ b/Tests/Utils/testOctreeRearrangeProc.cpp @@ -56,7 +56,7 @@ template <class FReal, class ParticleClass> class Converter { public: template <class ContainerClass> - static ParticleClass GetParticleAndRemove(ContainerClass* container, const int idxExtract){ + static ParticleClass GetParticleAndRemove(ContainerClass* container, const FSize idxExtract){ TestParticle<FReal> part; part.position.setPosition( container->getPositions()[0][idxExtract], @@ -122,7 +122,7 @@ int main(int argc, char ** argv){ { TestParticle<FReal>* particles = new TestParticle<FReal>[NbPart]; - for(int idxPart = 0 ; idxPart < NbPart ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < NbPart ; ++idxPart){ particles[idxPart].position.setPosition( (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/FReal(2.0))), (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/FReal(2.0))), @@ -160,7 +160,7 @@ int main(int argc, char ** argv){ octreeIterator.gotoBottomLeft(); do{ ContainerClass* particles = octreeIterator.getCurrentListTargets(); - for(int idxPart = 0; idxPart < particles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0; idxPart < particles->getNbParticles() ; ++idxPart){ particles->getWPositions()[0][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)); particles->getWPositions()[1][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)); particles->getWPositions()[2][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)); @@ -202,7 +202,7 @@ int main(int argc, char ** argv){ const MortonIndex leafIndex = octreeIterator.getCurrentGlobalIndex(); ContainerClass* particles = octreeIterator.getCurrentListTargets(); - for(int idxPart = 0; idxPart < particles->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0; idxPart < particles->getNbParticles() ; ++idxPart){ const FPoint<FReal> particlePosition( particles->getWPositions()[0][idxPart], particles->getWPositions()[1][idxPart], particles->getWPositions()[2][idxPart]); diff --git a/Tests/Utils/testOctreeRearrangeTsm.cpp b/Tests/Utils/testOctreeRearrangeTsm.cpp index 4f6f8cb80..efda9bfcc 100644 --- a/Tests/Utils/testOctreeRearrangeTsm.cpp +++ b/Tests/Utils/testOctreeRearrangeTsm.cpp @@ -93,7 +93,7 @@ int main(int argc, char ** argv){ { FPoint<FReal> particleToFill; - for(int idxPart = 0 ; idxPart < NbPart_Source; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < NbPart_Source; ++idxPart){ particleToFill.setPosition( (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)), (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)), @@ -101,7 +101,7 @@ int main(int argc, char ** argv){ tree.insert(particleToFill,FParticleTypeSource,idxPart); } - for(int idxPart = 0 ; idxPart < NbPart_Target; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < NbPart_Target; ++idxPart){ particleToFill.setPosition( (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)), (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)), @@ -130,12 +130,12 @@ int main(int argc, char ** argv){ do{ ContainerClass* particles_sources = octreeIterator.getCurrentListTargets(); ContainerClass* particles_targets = octreeIterator.getCurrentListSrc(); - for(int idxPart = 0; idxPart < particles_sources->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0; idxPart < particles_sources->getNbParticles() ; ++idxPart){ particles_sources->getWPositions()[0][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)); particles_sources->getWPositions()[1][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)); particles_sources->getWPositions()[2][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)); } - for(int idxPart = 0; idxPart < particles_targets->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0; idxPart < particles_targets->getNbParticles() ; ++idxPart){ particles_targets->getWPositions()[0][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)); particles_targets->getWPositions()[1][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)); particles_targets->getWPositions()[2][idxPart] = (BoxWidth*FReal(drand48())) + (BoxCenter-(BoxWidth/2)); @@ -177,7 +177,7 @@ int main(int argc, char ** argv){ ContainerClass* particles_targets = octreeIterator.getCurrentLeaf()->getTargets(); ContainerClass* particles_sources = octreeIterator.getCurrentLeaf()->getSrc();; //Check for current sources - for(int idxPart = 0; idxPart < particles_sources->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0; idxPart < particles_sources->getNbParticles() ; ++idxPart){ const FPoint<FReal> particlePosition( particles_sources->getWPositions()[0][idxPart], particles_sources->getWPositions()[1][idxPart], particles_sources->getWPositions()[2][idxPart]); @@ -189,7 +189,7 @@ int main(int argc, char ** argv){ } //Check for current targets - for(int idxPart = 0; idxPart < particles_targets->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0; idxPart < particles_targets->getNbParticles() ; ++idxPart){ const FPoint<FReal> particlePosition( particles_targets->getWPositions()[0][idxPart], particles_targets->getWPositions()[1][idxPart], particles_targets->getWPositions()[2][idxPart]); diff --git a/Tests/Utils/testStatsTree.cpp b/Tests/Utils/testStatsTree.cpp index 597289dd0..93cd8e2dd 100644 --- a/Tests/Utils/testStatsTree.cpp +++ b/Tests/Utils/testStatsTree.cpp @@ -88,7 +88,7 @@ int main(int argc, char ** argv){ std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; counter.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; FReal physicalValue; loader.fillParticle(&particlePosition,&physicalValue); diff --git a/Tests/Utils/testTreeBuilderThread.cpp b/Tests/Utils/testTreeBuilderThread.cpp index b9215ab70..bfba378a6 100644 --- a/Tests/Utils/testTreeBuilderThread.cpp +++ b/Tests/Utils/testTreeBuilderThread.cpp @@ -75,7 +75,7 @@ int main(int argc, char** argv){ { ContainerClass particles; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; FReal physicalValue; loader.fillParticle(&particlePosition,&physicalValue); diff --git a/Tests/Utils/testTreeIO.cpp b/Tests/Utils/testTreeIO.cpp index 00bdf848b..4311005af 100644 --- a/Tests/Utils/testTreeIO.cpp +++ b/Tests/Utils/testTreeIO.cpp @@ -83,7 +83,7 @@ int main(int argc, char ** argv){ std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl; counter.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; FReal physicalValue = 0.0; loader.fillParticle(&particlePosition,&physicalValue); diff --git a/Tests/Utils/testUnifInterpolator.cpp b/Tests/Utils/testUnifInterpolator.cpp index 59dad5df2..68ebee997 100644 --- a/Tests/Utils/testUnifInterpolator.cpp +++ b/Tests/Utils/testUnifInterpolator.cpp @@ -481,13 +481,13 @@ int main(int argc, char ** argv){ { // start direct computation unsigned int counter = 0; - for(int idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ + for(FSize idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ const FPoint<FReal> x = FPoint<FReal>(X.getSrc()->getPositions()[0][idxPartX], X.getSrc()->getPositions()[1][idxPartX], X.getSrc()->getPositions()[2][idxPartX]); const FReal wx = X.getSrc()->getPhysicalValues()[idxPartX]; - for(int idxPartY = 0 ; idxPartY < Y.getSrc()->getNbParticles() ; ++idxPartY){ + for(FSize idxPartY = 0 ; idxPartY < Y.getSrc()->getNbParticles() ; ++idxPartY){ const FPoint<FReal> y = FPoint<FReal>(Y.getSrc()->getPositions()[0][idxPartY], Y.getSrc()->getPositions()[1][idxPartY], Y.getSrc()->getPositions()[2][idxPartY]); @@ -515,7 +515,7 @@ int main(int argc, char ** argv){ //////////////////////////////////////////////////////////////////// unsigned int counter = 0; - for(int idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ + for(FSize idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ approx_p[counter] = X.getSrc()->getPotentials()[idxPartX]; const FPoint<FReal> force = FPoint<FReal>(X.getSrc()->getForcesX()[idxPartX], X.getSrc()->getForcesY()[idxPartX], @@ -528,7 +528,7 @@ int main(int argc, char ** argv){ } // std::cout << "Check Potential, forceX, forceY, forceZ " << std::endl; - // for(int idxPart = 0 ; idxPart < 20 ; ++idxPart){ + // for(FSize idxPart = 0 ; idxPart < 20 ; ++idxPart){ // std::cout << approx_p[idxPart] << ", "<< p[idxPart] << "|| "; // std::cout << approx_f[idxPart] << ", "<< f[idxPart] << "|| "; // std::cout << approx_f[idxPart+M] << ", "<< f[idxPart+M] << "|| "; diff --git a/Tests/Utils/testUnifTensorialInterpolator.cpp b/Tests/Utils/testUnifTensorialInterpolator.cpp index de102c94e..15e5a7822 100644 --- a/Tests/Utils/testUnifTensorialInterpolator.cpp +++ b/Tests/Utils/testUnifTensorialInterpolator.cpp @@ -534,7 +534,7 @@ int main(int argc, char ** argv){ { // start direct computation unsigned int counter = 0; - for(int idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ + for(FSize idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ const FPoint<FReal> x = FPoint<FReal>(X.getSrc()->getPositions()[0][idxPartX], X.getSrc()->getPositions()[1][idxPartX], X.getSrc()->getPositions()[2][idxPartX]); @@ -542,7 +542,7 @@ int main(int argc, char ** argv){ X.getSrc()->getPhysicalValues(1)[idxPartX], X.getSrc()->getPhysicalValues(2)[idxPartX]}; - for(int idxPartY = 0 ; idxPartY < Y.getSrc()->getNbParticles() ; ++idxPartY){ + for(FSize idxPartY = 0 ; idxPartY < Y.getSrc()->getNbParticles() ; ++idxPartY){ const FPoint<FReal> y = FPoint<FReal>(Y.getSrc()->getPositions()[0][idxPartY], Y.getSrc()->getPositions()[1][idxPartY], Y.getSrc()->getPositions()[2][idxPartY]); @@ -593,7 +593,7 @@ int main(int argc, char ** argv){ //////////////////////////////////////////////////////////////////// unsigned int counter = 0; - for(int idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ + for(FSize idxPartX = 0 ; idxPartX < X.getSrc()->getNbParticles() ; ++idxPartX){ for (unsigned int i=0; i<npot; ++i){ approx_p[i][counter] = X.getSrc()->getPotentials(i)[idxPartX]; const FPoint<FReal> force = FPoint<FReal>(X.getSrc()->getForcesX(i)[idxPartX], @@ -609,7 +609,7 @@ int main(int argc, char ** argv){ // std::cout << "Check Potential, forceX, forceY, forceZ " << std::endl; // for (unsigned int i=0; i<npot; ++i){ // std::cout<< "idxLhs="<< i << std::endl; - // for(int idxPart = 0 ; idxPart < 20 ; ++idxPart){ + // for(FSize idxPart = 0 ; idxPart < 20 ; ++idxPart){ // std::cout << approx_p[i][idxPart] << ", "<< p[i][idxPart] << "|| "; // std::cout << approx_f[i][idxPart] << ", "<< f[i][idxPart] << "|| "; // std::cout << approx_f[i][idxPart+M] << ", "<< f[i][idxPart+M] << "|| "; diff --git a/Tests/noDist/ChebyshevPeriodic.cpp b/Tests/noDist/ChebyshevPeriodic.cpp index f0e30b832..58425bb91 100644 --- a/Tests/noDist/ChebyshevPeriodic.cpp +++ b/Tests/noDist/ChebyshevPeriodic.cpp @@ -121,7 +121,6 @@ int main(int argc, char* argv[]) typedef FOctree<FReal,CellClass,ContainerClass,LeafClass> OctreeClass; // typedef FInterpMatrixKernelR<FReal> MatrixKernelClass; - const MatrixKernelClass MatrixKernel; typedef FChebSymKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; // typedef FFmmAlgorithmPeriodic<FReal, OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass; @@ -139,7 +138,7 @@ int main(int argc, char* argv[]) // loader.fillParticle(particles,nbParticles); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue() ); } @@ -178,7 +177,7 @@ int main(int argc, char* argv[]) // Compute direct energy ///////////////////////////////////////////////////////////////////////////////////////////////// - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } // @@ -201,13 +200,13 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); const FReal*const physicalValues = leaf->getTargets()->getPhysicalValues(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; // particlesOut[indexPartOrig].setPosition(posX[idxPart],posY[idxPart],posZ[idxPart]) ; particlesOut[indexPartOrig].setPhysicalValue(physicalValues[idxPart]) ; diff --git a/Tests/noDist/FMMnonUnitCube.cpp b/Tests/noDist/FMMnonUnitCube.cpp index 6856259d7..08bcb1185 100644 --- a/Tests/noDist/FMMnonUnitCube.cpp +++ b/Tests/noDist/FMMnonUnitCube.cpp @@ -126,7 +126,7 @@ int main(int argc, char* argv[]) loader.fillParticle(particles,nbParticles); FReal LL = loader.getBoxWidth() ; FPoint<FReal> maxPos(-LL,-LL,-LL),minPos(LL,LL,LL), BoxWidth; - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ const FPoint<FReal> PP(particles[idxPart].getPosition() ) ; // minPos.setX(FMath::Min(minPos.getX(),PP.getX())) ; @@ -156,7 +156,7 @@ int main(int argc, char* argv[]) FReal energyD =0.0, totPhysicalValue =0.0; //#pragma omp parallel for reduction(+:energyD,totPhysicalValue) - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; totPhysicalValue += particles[idx].getPhysicalValue() ; } @@ -169,7 +169,7 @@ int main(int argc, char* argv[]) FReal boxWidth = 1.0 ;// BoxWidth.getX(); // // Scale the Points - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree // std::cout << idxPart<< " "<< particles[idxPart].getPosition()<< " "; FPoint<FReal> PP(particles[idxPart].getPosition()/= BoxWidth) ; @@ -216,7 +216,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); // Insert and scale the Points - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -246,11 +246,11 @@ int main(int argc, char* argv[]) FReal*const forcesX = leaf->getTargets()->getForcesX(); FReal*const forcesY = leaf->getTargets()->getForcesY(); FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; // Rescale the forces forcesX[idxPart] /= LX; forcesY[idxPart] /= LY; @@ -305,7 +305,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart <nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart <nbParticles ; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -334,11 +334,11 @@ int main(int argc, char* argv[]) FReal*const forcesX = leaf->getTargets()->getForcesX(); FReal*const forcesY = leaf->getTargets()->getForcesY(); FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; forcesX[idxPart] /= LX; forcesY[idxPart] /= LY; forcesZ[idxPart] /= LZ; diff --git a/Tests/noDist/testAdaptiveChebSymFMMDebug.cpp b/Tests/noDist/testAdaptiveChebSymFMMDebug.cpp index bb0899588..1da3533d2 100644 --- a/Tests/noDist/testAdaptiveChebSymFMMDebug.cpp +++ b/Tests/noDist/testAdaptiveChebSymFMMDebug.cpp @@ -125,7 +125,7 @@ int main(int argc, char ** argv){ // Not Random Loader ////////////////////////////////////////////////////////////////////////////////// FFmaGenericLoader<FReal> loader(fileName); - const long int NbPart = loader.getNumberOfParticles() ; + const FSize NbPart = loader.getNumberOfParticles() ; ////////////////////////////////////////////////////////////////////////////////// OctreeClass tree(TreeHeight, SubTreeHeight, loader.getBoxWidth(), loader.getCenterOfBox()); @@ -149,7 +149,7 @@ int main(int argc, char ** argv){ // loader.fillParticle(particles,NbPart); - for(int idxPart = 0 ; idxPart < NbPart; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < NbPart; ++idxPart){ const FPoint<FReal> PP(particles[idxPart].getPosition() ) ; // minPos.setX(FMath::Min(minPos.getX(),PP.getX())) ; @@ -196,7 +196,7 @@ int main(int argc, char ** argv){ // Compute direct energy ///////////////////////////////////////////////////////////////////////////////////////////////// - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -219,11 +219,11 @@ int main(int argc, char ** argv){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -270,11 +270,11 @@ int main(int argc, char ** argv){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/Tests/noDist/testAdaptiveUnifFMM.cpp b/Tests/noDist/testAdaptiveUnifFMM.cpp index c83ab1357..db76677aa 100644 --- a/Tests/noDist/testAdaptiveUnifFMM.cpp +++ b/Tests/noDist/testAdaptiveUnifFMM.cpp @@ -136,7 +136,7 @@ int main(int argc, char ** argv){ ////////////////////////////////////////////////////////////////////////////////// FFmaGenericLoader<FReal> loader(fileName); - const long int NbPart = loader.getNumberOfParticles() ; + const FSize NbPart = loader.getNumberOfParticles() ; // Random Loader //const int NbPart = FParameters::getValue(argc,argv,"-nb", 2000000); // FRandomLoader<FReal> loader(NbPart, 1, FPoint<FReal>(0.5,0.5,0.5), 1); @@ -162,7 +162,7 @@ int main(int argc, char ** argv){ // loader.fillParticle(particles,NbPart); - for(int idxPart = 0 ; idxPart < NbPart; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < NbPart; ++idxPart){ const FPoint<FReal> PP(particles[idxPart].getPosition() ) ; // minPos.setX(FMath::Min(minPos.getX(),PP.getX())) ; @@ -205,7 +205,7 @@ int main(int argc, char ** argv){ // Compute direct energy ///////////////////////////////////////////////////////////////////////////////////////////////// - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -223,11 +223,11 @@ int main(int argc, char ** argv){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/Tests/noDist/testBlockedAlgorithm.cpp b/Tests/noDist/testBlockedAlgorithm.cpp index 2ef70f832..a8b896d95 100644 --- a/Tests/noDist/testBlockedAlgorithm.cpp +++ b/Tests/noDist/testBlockedAlgorithm.cpp @@ -105,7 +105,7 @@ int main(int argc, char* argv[]){ OctreeClass tree(NbLevels, 2, loader.getBoxWidth(), loader.getCenterOfBox()); FTestParticleContainer<FReal> allParticles; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; #ifndef LOAD_FILE loader.fillParticle(&particlePosition); @@ -149,15 +149,15 @@ int main(int argc, char* argv[]){ // Validate the result groupedTree.forEachCellLeaf<GroupContainerClass>([&](GroupCellClass cell, GroupContainerClass* leaf){ - const int nbPartsInLeaf = leaf->getNbParticles(); + const FSize nbPartsInLeaf = leaf->getNbParticles(); if(cell.getDataUp() != nbPartsInLeaf){ std::cout << "[P2M] Error a Cell has " << cell.getDataUp() << " (it should be " << nbPartsInLeaf << ")\n"; } }); groupedTree.forEachCellLeaf<GroupContainerClass>([&](GroupCellClass cell, GroupContainerClass* leaf){ - const int nbPartsInLeaf = leaf->getNbParticles(); + const FSize nbPartsInLeaf = leaf->getNbParticles(); const long long int* dataDown = leaf->getDataDown(); - for(int idxPart = 0 ; idxPart < nbPartsInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbPartsInLeaf ; ++idxPart){ if(dataDown[idxPart] != loader.getNumberOfParticles()-1){ std::cout << "[Full] Error a particle has " << dataDown[idxPart] << " (it should be " << (loader.getNumberOfParticles()-1) << ") at index " << cell.getMortonIndex() << "\n"; } diff --git a/Tests/noDist/testBlockedChebyshev.cpp b/Tests/noDist/testBlockedChebyshev.cpp index 368923bd5..d0e1e0170 100644 --- a/Tests/noDist/testBlockedChebyshev.cpp +++ b/Tests/noDist/testBlockedChebyshev.cpp @@ -97,7 +97,7 @@ int main(int argc, char* argv[]){ FTic timer; FP2PParticleContainer<FReal> allParticles; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; FReal physicalValue; #ifdef RANDOM_PARTICLES @@ -127,7 +127,7 @@ int main(int argc, char* argv[]){ // Validate the result if(FParameters::existParameter(argc, argv, LocalOptionNoValidate.options) == false){ - int offsetParticles = 0; + FSize offsetParticles = 0; FReal*const allPhysicalValues = allParticles.getPhysicalValues(); FReal*const allPosX = const_cast<FReal*>( allParticles.getPositions()[0]); FReal*const allPosY = const_cast<FReal*>( allParticles.getPositions()[1]); @@ -138,9 +138,9 @@ int main(int argc, char* argv[]){ const FReal*const posX = leafTarget->getPositions()[0]; const FReal*const posY = leafTarget->getPositions()[1]; const FReal*const posZ = leafTarget->getPositions()[2]; - const int nbPartsInLeafTarget = leafTarget->getNbParticles(); + const FSize nbPartsInLeafTarget = leafTarget->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbPartsInLeafTarget ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbPartsInLeafTarget ; ++idxPart){ allPhysicalValues[offsetParticles + idxPart] = physicalValues[idxPart]; allPosX[offsetParticles + idxPart] = posX[idxPart]; allPosY[offsetParticles + idxPart] = posY[idxPart]; @@ -176,7 +176,7 @@ int main(int argc, char* argv[]){ const FReal*const forcesX = leafTarget->getForcesX(); const FReal*const forcesY = leafTarget->getForcesY(); const FReal*const forcesZ = leafTarget->getForcesZ(); - const int nbPartsInLeafTarget = leafTarget->getNbParticles(); + const FSize nbPartsInLeafTarget = leafTarget->getNbParticles(); for(int idxTgt = 0 ; idxTgt < nbPartsInLeafTarget ; ++idxTgt){ potentialDiff.add(allDirectPotentials[idxTgt + offsetParticles], potentials[idxTgt]); diff --git a/Tests/noDist/testBlockedMpiAlgorithm.cpp b/Tests/noDist/testBlockedMpiAlgorithm.cpp index f8f7656ea..04495072c 100644 --- a/Tests/noDist/testBlockedMpiAlgorithm.cpp +++ b/Tests/noDist/testBlockedMpiAlgorithm.cpp @@ -91,7 +91,7 @@ int main(int argc, char* argv[]){ std::unique_ptr<TestParticle[]> particles(new TestParticle[loader.getNumberOfParticles()]); memset(particles.get(), 0, sizeof(TestParticle) * loader.getNumberOfParticles()); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particles[idxPart].position); } // Sort in parallel @@ -107,7 +107,7 @@ int main(int argc, char* argv[]){ &balancer); FTestParticleContainer<FReal> allParticles; - for(int idxPart = 0 ; idxPart < myParticles.getSize() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < myParticles.getSize() ; ++idxPart){ allParticles.push(myParticles[idxPart].position); } @@ -144,9 +144,9 @@ int main(int argc, char* argv[]){ groupalgo.execute(); groupedTree.forEachCellLeaf<GroupContainerClass>([&](GroupCellClass cell, GroupContainerClass* leaf){ - const int nbPartsInLeaf = leaf->getNbParticles(); + const FSize nbPartsInLeaf = leaf->getNbParticles(); const long long int* dataDown = leaf->getDataDown(); - for(int idxPart = 0 ; idxPart < nbPartsInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbPartsInLeaf ; ++idxPart){ if(dataDown[idxPart] != totalNbParticles-1){ std::cout << "[Full] Error a particle has " << dataDown[idxPart] << " (it should be " << (totalNbParticles-1) << ") at index " << cell.getMortonIndex() << "\n"; } @@ -166,7 +166,7 @@ int main(int argc, char* argv[]){ OctreeClass tree(NbLevels, 2, loader.getBoxWidth(), loader.getCenterOfBox()); for(int idxProc = 0 ; idxProc < mpiComm.global().processCount() ; ++idxProc){ FRandomLoader<FReal> loaderAll(NbParticles, 1.0, FPoint<FReal>(0,0,0), idxProc); - for(int idxPart = 0 ; idxPart < loaderAll.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loaderAll.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> pos; loaderAll.fillParticle(&pos); tree.insert(pos); diff --git a/Tests/noDist/testBlockedMpiChebyshev.cpp b/Tests/noDist/testBlockedMpiChebyshev.cpp index c80a35791..3a9c45bdb 100644 --- a/Tests/noDist/testBlockedMpiChebyshev.cpp +++ b/Tests/noDist/testBlockedMpiChebyshev.cpp @@ -103,7 +103,7 @@ int main(int argc, char* argv[]){ TestParticle* allParticles = new TestParticle[loader.getMyNumberOfParticles()]; memset(allParticles,0,(unsigned int) (sizeof(TestParticle)* loader.getMyNumberOfParticles())); - for(int idxPart = 0 ; idxPart < loader.getMyNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getMyNumberOfParticles() ; ++idxPart){ loader.fillParticle(&allParticles[idxPart].position,&allParticles[idxPart].physicalValue); } @@ -133,7 +133,7 @@ int main(int argc, char* argv[]){ mpiComm.global().getComm(), MPI_STATUS_IGNORE), __LINE__); } if(mpiComm.global().processId() != mpiComm.global().processCount()-1){ - FMpi::Assert(MPI_Send((void*)&myLeftLimite, sizeof(myLeftLimite), MPI_BYTE, + FMpi::Assert(MPI_Send(const_cast<MortonIndex*>(&myLeftLimite), sizeof(myLeftLimite), MPI_BYTE, mpiComm.global().processId()+1, 0, mpiComm.global().getComm()), __LINE__); } @@ -143,7 +143,7 @@ int main(int argc, char* argv[]){ // Put the data into the tree FP2PParticleContainer<FReal> myParticlesInContainer; - for(int idxPart = 0 ; idxPart < myParticles.getSize() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < myParticles.getSize() ; ++idxPart){ myParticlesInContainer.push(myParticles[idxPart].position, myParticles[idxPart].physicalValue); } @@ -159,8 +159,8 @@ int main(int argc, char* argv[]){ std::cout << "\nChebyshev FMM (ORDER="<< ORDER << ") ... " << std::endl; timer.tic(); + MatrixKernelClass MatrixKernel; // Create Matrix Kernel - const MatrixKernelClass MatrixKernel; GroupKernelClass groupkernel(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox(), &MatrixKernel); // Run the algorithm GroupAlgorithm groupalgo(mpiComm.global(), &groupedTree,&groupkernel); @@ -174,7 +174,6 @@ int main(int argc, char* argv[]){ if(FParameters::existParameter(argc, argv, LocalOptionNoValidate.options) == false){ typedef FP2PParticleContainer<FReal> ContainerClass; typedef FSimpleLeaf<FReal, ContainerClass > LeafClass; - typedef FInterpMatrixKernelR<FReal> MatrixKernelClass; typedef FChebCell<FReal,ORDER> CellClass; typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass; typedef FChebSymKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass; @@ -184,13 +183,13 @@ int main(int argc, char* argv[]){ OctreeClass treeCheck(TreeHeight, SubTreeHeight,loader.getBoxWidth(),loader.getCenterOfBox()); - for(int idxPart = 0 ; idxPart < myParticles.getSize() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < myParticles.getSize() ; ++idxPart){ // put in tree treeCheck.insert(myParticles[idxPart].position, myParticles[idxPart].physicalValue); } - const MatrixKernelClass MatrixKernel; + MatrixKernelClass MatrixKernel; KernelClass kernels(TreeHeight, loader.getBoxWidth(), loader.getCenterOfBox(), &MatrixKernel); FmmClass algorithm(mpiComm.global(),&treeCheck, &kernels); algorithm.execute(); @@ -224,7 +223,7 @@ int main(int argc, char* argv[]){ const FReal*const gposX = leafTarget->getPositions()[0]; const FReal*const gposY = leafTarget->getPositions()[1]; const FReal*const gposZ = leafTarget->getPositions()[2]; - const int gnbPartsInLeafTarget = leafTarget->getNbParticles(); + const FSize gnbPartsInLeafTarget = leafTarget->getNbParticles(); const FReal*const gforceX = leafTarget->getForcesX(); const FReal*const gforceY = leafTarget->getForcesY(); const FReal*const gforceZ = leafTarget->getForcesZ(); @@ -233,7 +232,7 @@ int main(int argc, char* argv[]){ const FReal*const posX = targets->getPositions()[0]; const FReal*const posY = targets->getPositions()[1]; const FReal*const posZ = targets->getPositions()[2]; - const int nbPartsInLeafTarget = targets->getNbParticles(); + const FSize nbPartsInLeafTarget = targets->getNbParticles(); const FReal*const forceX = targets->getForcesX(); const FReal*const forceY = targets->getForcesY(); const FReal*const forceZ = targets->getForcesZ(); @@ -246,7 +245,7 @@ int main(int argc, char* argv[]){ else{ FMath::FAccurater<FReal> potentialDiff; FMath::FAccurater<FReal> fx, fy, fz; - for(int idxPart = 0 ; idxPart < nbPartsInLeafTarget ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbPartsInLeafTarget ; ++idxPart){ if(gposX[idxPart] != posX[idxPart] || gposY[idxPart] != posY[idxPart] || gposZ[idxPart] != posZ[idxPart]){ std::cout << "[Empty] Not the same particlea at " << gcell.getMortonIndex() << " idx " << idxPart diff --git a/Tests/noDist/testBlockedRotation.cpp b/Tests/noDist/testBlockedRotation.cpp index e24cffe99..11f06160d 100644 --- a/Tests/noDist/testBlockedRotation.cpp +++ b/Tests/noDist/testBlockedRotation.cpp @@ -82,7 +82,7 @@ int main(int argc, char* argv[]){ FTic timer; FP2PParticleContainer<FReal> allParticles; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FReal physicalValue; FPoint<FReal> particlePosition; loader.fillParticle(&particlePosition, &physicalValue); @@ -106,7 +106,7 @@ int main(int argc, char* argv[]){ // Validate the result if(FParameters::existParameter(argc, argv, LocalOptionNoValidate.options) == false){ - int offsetParticles = 0; + FSize offsetParticles = 0; FReal*const allPhysicalValues = allParticles.getPhysicalValues(); FReal*const allPosX = const_cast<FReal*>( allParticles.getPositions()[0]); FReal*const allPosY = const_cast<FReal*>( allParticles.getPositions()[1]); @@ -117,9 +117,9 @@ int main(int argc, char* argv[]){ const FReal*const posX = leafTarget->getPositions()[0]; const FReal*const posY = leafTarget->getPositions()[1]; const FReal*const posZ = leafTarget->getPositions()[2]; - const int nbPartsInLeafTarget = leafTarget->getNbParticles(); + const FSize nbPartsInLeafTarget = leafTarget->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbPartsInLeafTarget ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbPartsInLeafTarget ; ++idxPart){ allPhysicalValues[offsetParticles + idxPart] = physicalValues[idxPart]; allPosX[offsetParticles + idxPart] = posX[idxPart]; allPosY[offsetParticles + idxPart] = posY[idxPart]; @@ -155,7 +155,7 @@ int main(int argc, char* argv[]){ const FReal*const forcesX = leafTarget->getForcesX(); const FReal*const forcesY = leafTarget->getForcesY(); const FReal*const forcesZ = leafTarget->getForcesZ(); - const int nbPartsInLeafTarget = leafTarget->getNbParticles(); + const FSize nbPartsInLeafTarget = leafTarget->getNbParticles(); for(int idxTgt = 0 ; idxTgt < nbPartsInLeafTarget ; ++idxTgt){ potentialDiff.add(allDirectPotentials[idxTgt + offsetParticles], potentials[idxTgt]); diff --git a/Tests/noDist/testBlockedTaylor.cpp b/Tests/noDist/testBlockedTaylor.cpp index a3c03ef94..b8487b170 100644 --- a/Tests/noDist/testBlockedTaylor.cpp +++ b/Tests/noDist/testBlockedTaylor.cpp @@ -82,7 +82,7 @@ int main(int argc, char* argv[]){ FTic timer; FP2PParticleContainer<FReal> allParticles; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FReal physicalValue; FPoint<FReal> particlePosition; loader.fillParticle(&particlePosition, &physicalValue); @@ -106,7 +106,7 @@ int main(int argc, char* argv[]){ // Validate the result if(FParameters::existParameter(argc, argv, LocalOptionNoValidate.options) == false){ - int offsetParticles = 0; + FSize offsetParticles = 0; FReal*const allPhysicalValues = allParticles.getPhysicalValues(); FReal*const allPosX = const_cast<FReal*>( allParticles.getPositions()[0]); FReal*const allPosY = const_cast<FReal*>( allParticles.getPositions()[1]); @@ -117,9 +117,9 @@ int main(int argc, char* argv[]){ const FReal*const posX = leafTarget->getPositions()[0]; const FReal*const posY = leafTarget->getPositions()[1]; const FReal*const posZ = leafTarget->getPositions()[2]; - const int nbPartsInLeafTarget = leafTarget->getNbParticles(); + const FSize nbPartsInLeafTarget = leafTarget->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbPartsInLeafTarget ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbPartsInLeafTarget ; ++idxPart){ allPhysicalValues[offsetParticles + idxPart] = physicalValues[idxPart]; allPosX[offsetParticles + idxPart] = posX[idxPart]; allPosY[offsetParticles + idxPart] = posY[idxPart]; @@ -155,7 +155,7 @@ int main(int argc, char* argv[]){ const FReal*const forcesX = leafTarget->getForcesX(); const FReal*const forcesY = leafTarget->getForcesY(); const FReal*const forcesZ = leafTarget->getForcesZ(); - const int nbPartsInLeafTarget = leafTarget->getNbParticles(); + const FSize nbPartsInLeafTarget = leafTarget->getNbParticles(); for(int idxTgt = 0 ; idxTgt < nbPartsInLeafTarget ; ++idxTgt){ potentialDiff.add(allDirectPotentials[idxTgt + offsetParticles], potentials[idxTgt]); diff --git a/Tests/noDist/testBlockedTree.cpp b/Tests/noDist/testBlockedTree.cpp index 795451506..8ad7ca984 100644 --- a/Tests/noDist/testBlockedTree.cpp +++ b/Tests/noDist/testBlockedTree.cpp @@ -81,7 +81,7 @@ int main(int argc, char* argv[]){ FP2PParticleContainer<FReal> allParticles; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; FReal physicalValue; loader.fillParticle(&particlePosition,&physicalValue); diff --git a/Tests/noDist/testBlockedUniform.cpp b/Tests/noDist/testBlockedUniform.cpp index 2af447ae6..e90a59092 100644 --- a/Tests/noDist/testBlockedUniform.cpp +++ b/Tests/noDist/testBlockedUniform.cpp @@ -101,7 +101,7 @@ int main(int argc, char* argv[]){ FTic timer; FP2PParticleContainer<FReal> allParticles; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; FReal physicalValue; #ifdef RANDOM_PARTICLES @@ -131,7 +131,7 @@ int main(int argc, char* argv[]){ // Validate the result if(FParameters::existParameter(argc, argv, LocalOptionNoValidate.options) == false){ - int offsetParticles = 0; + FSize offsetParticles = 0; FReal*const allPhysicalValues = allParticles.getPhysicalValues(); FReal*const allPosX = const_cast<FReal*>( allParticles.getPositions()[0]); FReal*const allPosY = const_cast<FReal*>( allParticles.getPositions()[1]); @@ -142,9 +142,9 @@ int main(int argc, char* argv[]){ const FReal*const posX = leafTarget->getPositions()[0]; const FReal*const posY = leafTarget->getPositions()[1]; const FReal*const posZ = leafTarget->getPositions()[2]; - const int nbPartsInLeafTarget = leafTarget->getNbParticles(); + const FSize nbPartsInLeafTarget = leafTarget->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbPartsInLeafTarget ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbPartsInLeafTarget ; ++idxPart){ allPhysicalValues[offsetParticles + idxPart] = physicalValues[idxPart]; allPosX[offsetParticles + idxPart] = posX[idxPart]; allPosY[offsetParticles + idxPart] = posY[idxPart]; @@ -180,7 +180,7 @@ int main(int argc, char* argv[]){ const FReal*const forcesX = leafTarget->getForcesX(); const FReal*const forcesY = leafTarget->getForcesY(); const FReal*const forcesZ = leafTarget->getForcesZ(); - const int nbPartsInLeafTarget = leafTarget->getNbParticles(); + const FSize nbPartsInLeafTarget = leafTarget->getNbParticles(); for(int idxTgt = 0 ; idxTgt < nbPartsInLeafTarget ; ++idxTgt){ potentialDiff.add(allDirectPotentials[idxTgt + offsetParticles], potentials[idxTgt]); diff --git a/Tests/noDist/testBlockedWithCudaAlgorithm.cpp b/Tests/noDist/testBlockedWithCudaAlgorithm.cpp index 3d744830f..d6517782d 100644 --- a/Tests/noDist/testBlockedWithCudaAlgorithm.cpp +++ b/Tests/noDist/testBlockedWithCudaAlgorithm.cpp @@ -120,7 +120,7 @@ int main(int argc, char* argv[]){ OctreeClass tree(NbLevels, 2, loader.getBoxWidth(), loader.getCenterOfBox()); FP2PParticleContainer<FReal> allParticles; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; #ifndef LOAD_FILE loader.fillParticle(&particlePosition); @@ -162,15 +162,15 @@ int main(int argc, char* argv[]){ // Validate the result groupedTree.forEachCellLeaf<GroupContainerClass>([&](GroupCellClass cell, GroupContainerClass* leaf){ - const int nbPartsInLeaf = leaf->getNbParticles(); + const FSize nbPartsInLeaf = leaf->getNbParticles(); if(cell.getDataUp() != nbPartsInLeaf){ std::cout << "[P2M] Error a Cell has " << cell.getDataUp() << " (it should be " << nbPartsInLeaf << ")\n"; } }); groupedTree.forEachCellLeaf<GroupContainerClass>([&](GroupCellClass cell, GroupContainerClass* leaf){ - const int nbPartsInLeaf = leaf->getNbParticles(); + const FSize nbPartsInLeaf = leaf->getNbParticles(); const long long int* dataDown = leaf->getDataDown(); - for(int idxPart = 0 ; idxPart < nbPartsInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbPartsInLeaf ; ++idxPart){ if(dataDown[idxPart] != loader.getNumberOfParticles()-1){ std::cout << "[Full] Error a particle has " << dataDown[idxPart] << " (it should be " << (loader.getNumberOfParticles()-1) << ") at index " << cell.getMortonIndex() << "\n"; } diff --git a/Tests/noDist/testBlockedWithOpenCLAlgorithm.cpp b/Tests/noDist/testBlockedWithOpenCLAlgorithm.cpp index fb501305d..fdfdc1fcc 100644 --- a/Tests/noDist/testBlockedWithOpenCLAlgorithm.cpp +++ b/Tests/noDist/testBlockedWithOpenCLAlgorithm.cpp @@ -110,7 +110,7 @@ int main(int argc, char* argv[]){ OctreeClass tree(NbLevels, 2, loader.getBoxWidth(), loader.getCenterOfBox()); FP2PParticleContainer<FReal> allParticles; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; #ifndef LOAD_FILE loader.fillParticle(&particlePosition); @@ -152,15 +152,15 @@ int main(int argc, char* argv[]){ // Validate the result groupedTree.forEachCellLeaf<GroupContainerClass>([&](GroupCellClass cell, GroupContainerClass* leaf){ - const int nbPartsInLeaf = leaf->getNbParticles(); + const FSize nbPartsInLeaf = leaf->getNbParticles(); if(cell.getDataUp() != nbPartsInLeaf){ std::cout << "[P2M] Error a Cell has " << cell.getDataUp() << " (it should be " << nbPartsInLeaf << ")\n"; } }); groupedTree.forEachCellLeaf<GroupContainerClass>([&](GroupCellClass cell, GroupContainerClass* leaf){ - const int nbPartsInLeaf = leaf->getNbParticles(); + const FSize nbPartsInLeaf = leaf->getNbParticles(); const long long int* dataDown = leaf->getDataDown(); - for(int idxPart = 0 ; idxPart < nbPartsInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbPartsInLeaf ; ++idxPart){ if(dataDown[idxPart] != loader.getNumberOfParticles()-1){ std::cout << "[Full] Error a particle has " << dataDown[idxPart] << " (it should be " << (loader.getNumberOfParticles()-1) << ") at index " << cell.getMortonIndex() << "\n"; } diff --git a/Tests/noDist/testChebIntFMM.cpp b/Tests/noDist/testChebIntFMM.cpp index 32050a768..9da548b48 100644 --- a/Tests/noDist/testChebIntFMM.cpp +++ b/Tests/noDist/testChebIntFMM.cpp @@ -161,7 +161,7 @@ static void Run(int argc, char* argv[]) std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl; time.tic(); // - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // // Read particle per particle from file // @@ -217,11 +217,11 @@ static void Run(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/Tests/noDist/testCompareKernels.cpp b/Tests/noDist/testCompareKernels.cpp index 8812ac3f2..7dc1bd018 100644 --- a/Tests/noDist/testCompareKernels.cpp +++ b/Tests/noDist/testCompareKernels.cpp @@ -100,7 +100,7 @@ int main(int argc, char* argv[]) if(!loader.isOpen()) throw std::runtime_error("Particle file couldn't be opened!"); TestParticle* const particles = new TestParticle[loader.getNumberOfParticles()]; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> position; FReal physicalValue = 0.0; loader.fillParticle(&position,&physicalValue); @@ -113,8 +113,8 @@ int main(int argc, char* argv[]) particles[idxPart].forces[2] = 0.0; } { - for(int idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ - for(int idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ + for(FSize idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ + for(FSize idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ FP2P::MutualParticles(particles[idxTarget].position.getX(), particles[idxTarget].position.getY(), particles[idxTarget].position.getZ(),particles[idxTarget].physicalValue, &particles[idxTarget].forces[0],&particles[idxTarget].forces[1], @@ -155,7 +155,7 @@ int main(int argc, char* argv[]) std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl; time.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // put in tree tree.insert(particles[idxPart].position, idxPart, particles[idxPart].physicalValue); } @@ -184,11 +184,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].potential,potentials[idxPart]); fx.add(particles[indexPartOrig].forces[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].forces[1],forcesY[idxPart]); @@ -232,7 +232,7 @@ int main(int argc, char* argv[]) << SubTreeHeight << std::endl; time.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // put in tree tree.insert(particles[idxPart].position, idxPart, particles[idxPart].physicalValue); } @@ -261,11 +261,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].potential,potentials[idxPart]); fx.add(particles[indexPartOrig].forces[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].forces[1],forcesY[idxPart]); diff --git a/Tests/noDist/testInsert.cpp b/Tests/noDist/testInsert.cpp index f142d97c6..5385885ff 100644 --- a/Tests/noDist/testInsert.cpp +++ b/Tests/noDist/testInsert.cpp @@ -69,34 +69,34 @@ int main(int argc, char** argv){ typedef double FReal; struct TestParticle{ - MortonIndex index; - FSize indexInFile; - FPoint<FReal> position; - FReal physicalValue; - const FPoint<FReal>& getPosition()const{ - return position; - } - TestParticle& operator=(const TestParticle& other){ - index=other.index; - indexInFile=other.indexInFile; - position=other.position; - physicalValue=other.physicalValue; - return *this; - } - bool operator<=(const TestParticle& rhs)const{ - if(rhs.index < this->index){return false;} - else{ - if(rhs.index > this->index){return true;} - else{ - if(rhs.indexInFile == this->indexInFile){ - return true; - } - else { - return rhs.indexInFile> this->indexInFile ; - } - } - } - } + MortonIndex index; + FSize indexInFile; + FPoint<FReal> position; + FReal physicalValue; + const FPoint<FReal>& getPosition()const{ + return position; + } + TestParticle& operator=(const TestParticle& other){ + index=other.index; + indexInFile=other.indexInFile; + position=other.position; + physicalValue=other.physicalValue; + return *this; + } + bool operator<=(const TestParticle& rhs)const{ + if(rhs.index < this->index){return false;} + else{ + if(rhs.index > this->index){return true;} + else{ + if(rhs.indexInFile == this->indexInFile){ + return true; + } + else { + return rhs.indexInFile> this->indexInFile ; + } + } + } + } }; @@ -122,29 +122,29 @@ int main(int argc, char** argv){ FFmaGenericLoader<FReal> loaderRef(filename); if(!loaderRef.isOpen()){ - std::cout << "LoaderRef Error, " << filename << " is missing\n"; - return 1; + std::cout << "LoaderRef Error, " << filename << " is missing\n"; + return 1; } FTic regInsert; // ----------------------------------------------------- { - OctreeClass treeRef(NbLevels, SizeSubLevels, loaderRef.getBoxWidth(), loaderRef.getCenterOfBox()); + OctreeClass treeRef(NbLevels, SizeSubLevels, loaderRef.getBoxWidth(), loaderRef.getCenterOfBox()); - std::cout << "Creating & Inserting " << loaderRef.getNumberOfParticles() << " particles ..." << std::endl; - std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; + std::cout << "Creating & Inserting " << loaderRef.getNumberOfParticles() << " particles ..." << std::endl; + std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; - regInsert.tic(); + regInsert.tic(); - for(int idxPart = 0 ; idxPart < loaderRef.getNumberOfParticles() ; ++idxPart){ - FPoint<FReal> particlePosition; - FReal physicalValue; - loaderRef.fillParticle(&particlePosition,&physicalValue); - treeRef.insert(particlePosition, physicalValue ); - } + for(FSize idxPart = 0 ; idxPart < loaderRef.getNumberOfParticles() ; ++idxPart){ + FPoint<FReal> particlePosition; + FReal physicalValue; + loaderRef.fillParticle(&particlePosition,&physicalValue); + treeRef.insert(particlePosition, physicalValue ); + } - regInsert.tac(); - std::cout << "Time needed for regular insert : " << regInsert.elapsed() << " secondes" << std::endl; + regInsert.tac(); + std::cout << "Time needed for regular insert : " << regInsert.elapsed() << " secondes" << std::endl; } //Second solution, parts must be sorted for that @@ -159,8 +159,8 @@ int main(int argc, char** argv){ FFmaGenericLoader<FReal> loader(filename); if(!loader.isOpen()){ - std::cout << "Loader Error, " << filename << " is missing\n"; - return 1; + std::cout << "Loader Error, " << filename << " is missing\n"; + return 1; } //Get the needed informations @@ -177,16 +177,16 @@ int main(int argc, char** argv){ fillTimer.tic(); - for(int idxPart = 0 ; idxPart < nbOfParticles ; ++idxPart){ - loader.fillParticle(&arrayOfParts[idxPart].position,&arrayOfParts[idxPart].physicalValue); - //Build temporary TreeCoordinate - host.setX( FCoordinateComputer::GetTreeCoordinate<FReal>( arrayOfParts[idxPart].getPosition().getX() - boxCorner.getX(), boxWidth, boxWidthAtLeafLevel, NbLevels )); - host.setY( FCoordinateComputer::GetTreeCoordinate<FReal>( arrayOfParts[idxPart].getPosition().getY() - boxCorner.getY(), boxWidth, boxWidthAtLeafLevel, NbLevels )); - host.setZ( FCoordinateComputer::GetTreeCoordinate<FReal>( arrayOfParts[idxPart].getPosition().getZ() - boxCorner.getZ(), boxWidth, boxWidthAtLeafLevel, NbLevels )); + for(FSize idxPart = 0 ; idxPart < nbOfParticles ; ++idxPart){ + loader.fillParticle(&arrayOfParts[idxPart].position,&arrayOfParts[idxPart].physicalValue); + //Build temporary TreeCoordinate + host.setX( FCoordinateComputer::GetTreeCoordinate<FReal>( arrayOfParts[idxPart].getPosition().getX() - boxCorner.getX(), boxWidth, boxWidthAtLeafLevel, NbLevels )); + host.setY( FCoordinateComputer::GetTreeCoordinate<FReal>( arrayOfParts[idxPart].getPosition().getY() - boxCorner.getY(), boxWidth, boxWidthAtLeafLevel, NbLevels )); + host.setZ( FCoordinateComputer::GetTreeCoordinate<FReal>( arrayOfParts[idxPart].getPosition().getZ() - boxCorner.getZ(), boxWidth, boxWidthAtLeafLevel, NbLevels )); - //Set Morton index from Tree Coordinate - arrayOfParts[idxPart].index = host.getMortonIndex(NbLevels - 1); - arrayOfParts[idxPart].indexInFile = idxPart; + //Set Morton index from Tree Coordinate + arrayOfParts[idxPart].index = host.getMortonIndex(NbLevels - 1); + arrayOfParts[idxPart].indexInFile = idxPart; } @@ -206,30 +206,30 @@ int main(int argc, char** argv){ unsigned int numberOfLeaves = 0; enumTimer.tic(); - for(int idxParts = 1 ; idxParts < nbOfParticles ; ++idxParts){ - if(arrayOfParts[idxParts].index != arrayOfParts[idxParts-1].index){ - numberOfLeaves++; - } + for(FSize idxParts = 1 ; idxParts < nbOfParticles ; ++idxParts){ + if(arrayOfParts[idxParts].index != arrayOfParts[idxParts-1].index){ + numberOfLeaves++; + } } enumTimer.tac(); std::cout << "Time needed for enumerate the leaves : "<< enumTimer.elapsed() << " secondes !" << std::endl; std::cout << "Found " << numberOfLeaves << " leaves differents." << std::endl; //Store the size of each subOctree - int * arrayOfSizeNbLeaves = new int[numberOfLeaves]; - memset(arrayOfSizeNbLeaves,0,sizeof(int)*(numberOfLeaves)); + FSize * arrayOfSizeNbLeaves = new FSize[numberOfLeaves]; + memset(arrayOfSizeNbLeaves,0,sizeof(FSize)*(numberOfLeaves)); //Init int indexInLeafArray = 0; arrayOfSizeNbLeaves[0] = 1; leavesOffset.tic(); - for(int idxParts = 1 ; idxParts < nbOfParticles ; ++idxParts){ - if(arrayOfParts[idxParts].index == arrayOfParts[idxParts-1].index){ - arrayOfSizeNbLeaves[indexInLeafArray]++; - } - else{ - indexInLeafArray++; - } + for(FSize idxParts = 1 ; idxParts < nbOfParticles ; ++idxParts){ + if(arrayOfParts[idxParts].index == arrayOfParts[idxParts-1].index){ + arrayOfSizeNbLeaves[indexInLeafArray]++; + } + else{ + indexInLeafArray++; + } } leavesOffset.tac(); @@ -240,11 +240,11 @@ int main(int argc, char** argv){ //Then, we create the leaves inside the tree //Idx of the first part in this leaf in the array of part - int idxOfFirstPartInLeaf = 0; + FSize idxOfFirstPartInLeaf = 0; struct LeafToFill{ - LeafClass * leaf; - FSize idxOfLeafInPartArray; + LeafClass * leaf; + FSize idxOfLeafInPartArray; }; leavesPtr.tic(); @@ -255,21 +255,21 @@ int main(int argc, char** argv){ for(FSize idxLeaf = 0; idxLeaf < numberOfLeaves ; ++idxLeaf){ - leavesToFill[idxLeaf].leaf = tree.createLeaf(arrayOfParts[idxOfFirstPartInLeaf].index); - idxOfFirstPartInLeaf += arrayOfSizeNbLeaves[idxLeaf]; - leavesToFill[idxLeaf].idxOfLeafInPartArray += idxOfFirstPartInLeaf; + leavesToFill[idxLeaf].leaf = tree.createLeaf(arrayOfParts[idxOfFirstPartInLeaf].index); + idxOfFirstPartInLeaf += arrayOfSizeNbLeaves[idxLeaf]; + leavesToFill[idxLeaf].idxOfLeafInPartArray += idxOfFirstPartInLeaf; } leavesPtr.tac(); std::cout << "Time needed for creating empty leaves : "<< leavesPtr.elapsed() << " secondes !" << std::endl; -#pragma omp parallel for schedule(auto) + #pragma omp parallel for schedule(auto) for(FSize idxLeaf=0 ; idxLeaf<numberOfLeaves ; ++idxLeaf ){ - //Task consists in copy the parts inside the leaf - leavesToFill[idxLeaf].leaf->pushArray(&arrayOfParts[leavesToFill[idxLeaf].idxOfLeafInPartArray].position, - arrayOfSizeNbLeaves[idxLeaf], - &arrayOfParts[leavesToFill[idxLeaf].idxOfLeafInPartArray].physicalValue); + //Task consists in copy the parts inside the leaf + leavesToFill[idxLeaf].leaf->pushArray(&arrayOfParts[leavesToFill[idxLeaf].idxOfLeafInPartArray].position, + arrayOfSizeNbLeaves[idxLeaf], + &arrayOfParts[leavesToFill[idxLeaf].idxOfLeafInPartArray].physicalValue); } @@ -278,8 +278,8 @@ int main(int argc, char** argv){ std::cout << "Time needed for inserting the parts " << insertTimer.elapsed() << " secondes !" << std::endl; double totalTimeForThatStrat = insertTimer.elapsed() + sortTimer.elapsed() - + fillTimer.elapsed() + enumTimer.elapsed() - + leavesPtr.elapsed() + leavesOffset.elapsed(); + + fillTimer.elapsed() + enumTimer.elapsed() + + leavesPtr.elapsed() + leavesOffset.elapsed(); std::cout << "Total time for that strat : " << totalTimeForThatStrat << " secondes !" << std::endl; std::cout << "---------Total------------> Difference : " << regInsert.elapsed() - totalTimeForThatStrat << " secondes !" << std::endl; std::cout << "-------On Insert----------> Difference : " << regInsert.elapsed() - insertTimer.elapsed() << " secondes !" << std::endl; diff --git a/Tests/noDist/testMpiInsert.cpp b/Tests/noDist/testMpiInsert.cpp index 8887a9b66..16bbd31ea 100644 --- a/Tests/noDist/testMpiInsert.cpp +++ b/Tests/noDist/testMpiInsert.cpp @@ -75,34 +75,34 @@ int main(int argc, char** argv){ typedef double FReal; struct TestParticle{ - MortonIndex index; - FSize indexInFile; - FPoint<FReal> position; - FReal physicalValue; - const FPoint<FReal>& getPosition()const{ - return position; - } - TestParticle& operator=(const TestParticle& other){ - index=other.index; - indexInFile=other.indexInFile; - position=other.position; - physicalValue=other.physicalValue; - return *this; - } - bool operator<=(const TestParticle& rhs)const{ - if(rhs.index < this->index){return false;} - else{ - if(rhs.index > this->index){return true;} - else{ - if(rhs.indexInFile == this->indexInFile){ - return true; - } - else { - return rhs.indexInFile> this->indexInFile ; - } - } - } - } + MortonIndex index; + FSize indexInFile; + FPoint<FReal> position; + FReal physicalValue; + const FPoint<FReal>& getPosition()const{ + return position; + } + TestParticle& operator=(const TestParticle& other){ + index=other.index; + indexInFile=other.indexInFile; + position=other.position; + physicalValue=other.physicalValue; + return *this; + } + bool operator<=(const TestParticle& rhs)const{ + if(rhs.index < this->index){return false;} + else{ + if(rhs.index > this->index){return true;} + else{ + if(rhs.indexInFile == this->indexInFile){ + return true; + } + else { + return rhs.indexInFile> this->indexInFile ; + } + } + } + } }; FMpi app( argc, argv); @@ -128,8 +128,8 @@ int main(int argc, char** argv){ FMpiFmaGenericLoader<FReal> loaderRef(filename,app.global()); if(!loaderRef.isOpen()){ - std::cout << "LoaderRef Error, " << filename << " is missing\n"; - return 1; + std::cout << "LoaderRef Error, " << filename << " is missing\n"; + return 1; } FTic regInsert; OctreeClass treeRef(NbLevels, SizeSubLevels, loaderRef.getBoxWidth(), loaderRef.getCenterOfBox()); @@ -138,35 +138,35 @@ int main(int argc, char** argv){ { - std::cout << "Creating & Inserting " << loaderRef.getNumberOfParticles() << " particles ..." << std::endl; - std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; + std::cout << "Creating & Inserting " << loaderRef.getNumberOfParticles() << " particles ..." << std::endl; + std::cout << "\tHeight : " << NbLevels << " \t sub-height : " << SizeSubLevels << std::endl; - //Store the parts - FmaRWParticle<FReal, 4,4>* particles = new FmaRWParticle<FReal,4,4>[loaderRef.getNumberOfParticles()]; - memset(particles, 0, sizeof(FmaRWParticle<FReal,4,4>) * loaderRef.getNumberOfParticles()); + //Store the parts + FmaRWParticle<FReal, 4,4>* particles = new FmaRWParticle<FReal,4,4>[loaderRef.getNumberOfParticles()]; + memset(particles, 0, sizeof(FmaRWParticle<FReal,4,4>) * loaderRef.getNumberOfParticles()); - for(int idxPart = 0 ; idxPart < loaderRef.getNumberOfParticles() ; ++idxPart){ - FPoint<FReal> pos; - loaderRef.fillParticle(&pos,particles[idxPart].setPhysicalValue()); - particles[idxPart].setPosition(pos); - } - - FVector<FmaRWParticle<FReal,4,4>> finalParticles; - FLeafBalance balancer; - FMpiTreeBuilder< FReal,FmaRWParticle<FReal,4,4> >::DistributeArrayToContainer(app.global(),particles, - loaderRef.getMyNumberOfParticles(), - treeRef.getBoxCenter(), - treeRef.getBoxWidth(),treeRef.getHeight(), - &finalParticles, &balancer); - - regInsert.tic(); - for(int idxPart = 0 ; idxPart < finalParticles.getSize() ; ++idxPart){ - treeRef.insert(finalParticles[idxPart].getPosition(),finalParticles[idxPart].getPhysicalValue() ); - } - - regInsert.tac(); - std::cout << "Time needed for regular insert : " << regInsert.elapsed() << " secondes" << std::endl; + for(FSize idxPart = 0 ; idxPart < loaderRef.getNumberOfParticles() ; ++idxPart){ + FPoint<FReal> pos; + loaderRef.fillParticle(&pos,particles[idxPart].setPhysicalValue()); + particles[idxPart].setPosition(pos); + } + + FVector<FmaRWParticle<FReal,4,4>> finalParticles; + FLeafBalance balancer; + FMpiTreeBuilder< FReal,FmaRWParticle<FReal,4,4> >::DistributeArrayToContainer(app.global(),particles, + loaderRef.getMyNumberOfParticles(), + treeRef.getBoxCenter(), + treeRef.getBoxWidth(),treeRef.getHeight(), + &finalParticles, &balancer); + + regInsert.tic(); + for(FSize idxPart = 0 ; idxPart < finalParticles.getSize() ; ++idxPart){ + treeRef.insert(finalParticles[idxPart].getPosition(),finalParticles[idxPart].getPhysicalValue() ); + } + + regInsert.tac(); + std::cout << "Time needed for regular insert : " << regInsert.elapsed() << " secondes" << std::endl; } //Second solution, parts must be sorted for that @@ -181,8 +181,8 @@ int main(int argc, char** argv){ FMpiFmaGenericLoader<FReal> loader(filename,app.global()); if(!loader.isOpen()){ - std::cout << "Loader Error, " << filename << " is missing\n"; - return 1; + std::cout << "Loader Error, " << filename << " is missing\n"; + return 1; } //Get the needed informations @@ -195,10 +195,10 @@ int main(int argc, char** argv){ fillTimer.tic(); - for(int idxPart = 0 ; idxPart < nbOfParticles ; ++idxPart){ - FPoint<FReal> pos; - loader.fillParticle(&pos,arrayOfParts[idxPart].setPhysicalValue()); - arrayOfParts[idxPart].setPosition(pos); + for(FSize idxPart = 0 ; idxPart < nbOfParticles ; ++idxPart){ + FPoint<FReal> pos; + loader.fillParticle(&pos,arrayOfParts[idxPart].setPhysicalValue()); + arrayOfParts[idxPart].setPosition(pos); } @@ -211,10 +211,10 @@ int main(int argc, char** argv){ FTic paraSort; paraSort.tic(); FMpiTreeBuilder< FReal,FmaRWParticle<FReal,4,4> >::DistributeArrayToContainer(app.global(),arrayOfParts, - loader.getMyNumberOfParticles(), - tree.getBoxCenter(), - tree.getBoxWidth(),tree.getHeight(), - &finalParticles, &balancer); + loader.getMyNumberOfParticles(), + tree.getBoxCenter(), + tree.getBoxWidth(),tree.getHeight(), + &finalParticles, &balancer); paraSort.tac(); std::cout << "Time needed for FMpiTreeBuilder part : "<< paraSort.elapsed() << " secondes !" << std::endl; @@ -222,9 +222,9 @@ int main(int argc, char** argv){ parts.reserve(finalParticles.getSize()); //Convert ouput of DistributeArrayToContainer to a ContainerClass - for(int idxPart = 0; idxPart < finalParticles.getSize(); ++idxPart){ + for(FSize idxPart = 0; idxPart < finalParticles.getSize(); ++idxPart){ - parts.push(finalParticles[idxPart].getPosition(),finalParticles[idxPart].getPhysicalValue()); + parts.push(finalParticles[idxPart].getPosition(),finalParticles[idxPart].getPhysicalValue()); } FTic treeBuilder; @@ -237,47 +237,47 @@ int main(int argc, char** argv){ #ifdef CHECK_TREE FILE * fd = fopen("Tree","a+"); - int acc = 0; + FSize acc = 0; int accL = 0; tree.forEachLeaf([&](LeafClass* leaf){ - ContainerClass * parts = leaf->getSrc(); - int nbPa = parts->getNbParticles(); - acc += nbPa; - accL++; - const FReal * xPos = parts->getPositions()[0]; - const FReal * yPos = parts->getPositions()[1]; - const FReal * zPos = parts->getPositions()[2]; - const FReal * phyVal = parts->getAttribute(0); - fprintf(fd,"Proc : %d, containing %d \n", - app.global().processId(),nbPa); - for(int idP = 0 ; idP < nbPa ; ++idP){ - fprintf(fd,"[%d] : %e,%e,%e, phy : %e\n", - app.global().processId(), xPos[idP],yPos[idP],zPos[idP],phyVal[idP]); - } - }); - printf("Number of parts in MY Tree : %d, Number of leaves : %d \n",acc,accL); + ContainerClass * partSrc = leaf->getSrc(); + FSize nbPa = partSrc->getNbParticles(); + acc += nbPa; + accL++; + const FReal * xPos = partSrc->getPositions()[0]; + const FReal * yPos = partSrc->getPositions()[1]; + const FReal * zPos = partSrc->getPositions()[2]; + const FReal * phyVal = partSrc->getAttribute(0); + fprintf(fd,"Proc : %d, containing %lld \n", + app.global().processId(),nbPa); + for(int idP = 0 ; idP < nbPa ; ++idP){ + fprintf(fd,"[%d] : %e,%e,%e, phy : %e\n", + app.global().processId(), xPos[idP],yPos[idP],zPos[idP],phyVal[idP]); + } + }); + printf("Number of parts in MY Tree : %lld, Number of leaves : %d \n",acc,accL); fclose(fd); - int accRef = 0; + FSize accRef = 0; int accRefL = 0; FILE * fd2 = fopen("TreeRef","a+"); treeRef.forEachLeaf([&](LeafClass* leaf){ - ContainerClass * parts = leaf->getSrc(); - int nbPa = parts->getNbParticles(); - accRef+=nbPa; - accRefL++; - const FReal * xPos = parts->getPositions()[0]; - const FReal * yPos = parts->getPositions()[1]; - const FReal * zPos = parts->getPositions()[2]; - const FReal * phyVal = parts->getAttribute(0); - fprintf(fd2,"Proc : %d, containing %d \n", - app.global().processId(),nbPa); - for(int idP = 0 ; idP < nbPa ; ++idP){ - fprintf(fd2,"[%d] : %e,%e,%e, phy : %e\n",app.global().processId(), xPos[idP],yPos[idP],zPos[idP],phyVal[idP]); - } - }); + ContainerClass * partSrc = leaf->getSrc(); + FSize nbPa = partSrc->getNbParticles(); + accRef+=nbPa; + accRefL++; + const FReal * xPos = partSrc->getPositions()[0]; + const FReal * yPos = partSrc->getPositions()[1]; + const FReal * zPos = partSrc->getPositions()[2]; + const FReal * phyVal = partSrc->getAttribute(0); + fprintf(fd2,"Proc : %d, containing %lld \n", + app.global().processId(),nbPa); + for(int idP = 0 ; idP < nbPa ; ++idP){ + fprintf(fd2,"[%d] : %e,%e,%e, phy : %e\n",app.global().processId(), xPos[idP],yPos[idP],zPos[idP],phyVal[idP]); + } + }); fclose(fd2); - printf("Number of parts in REG Tree : %d, number of leaves %d\n",accRef,accRefL); + printf("Number of parts in REG Tree : %lld, number of leaves %d\n",accRef,accRefL); #endif //CHECK_TREE delete [] arrayOfParts; diff --git a/Tests/noDist/testNewCompareKernels.cpp b/Tests/noDist/testNewCompareKernels.cpp index 0c201ee04..5051cfc0c 100644 --- a/Tests/noDist/testNewCompareKernels.cpp +++ b/Tests/noDist/testNewCompareKernels.cpp @@ -146,7 +146,7 @@ int main(int argc, char* argv[]) FReal energyD =0.0, totPhysicalValue =0.0; #pragma omp parallel for reduction(+:energyD,totPhysicalValue) - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; totPhysicalValue += particles[idx].getPhysicalValue() ; } @@ -180,7 +180,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -207,11 +207,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -255,7 +255,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -283,11 +283,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -326,7 +326,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -355,11 +355,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -394,7 +394,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -423,11 +423,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -462,7 +462,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -491,11 +491,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -547,7 +547,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart <nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart <nbParticles ; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -576,11 +576,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -617,7 +617,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -649,11 +649,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -689,7 +689,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -720,11 +720,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -765,7 +765,7 @@ int main(int argc, char* argv[]) { // ----------------------------------------------------- time.tic(); - for(int idxPart = 0 ; idxPart <nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart <nbParticles ; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -794,11 +794,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/Tests/noDist/testP2PAvx.cpp b/Tests/noDist/testP2PAvx.cpp index 3d9bac478..ae3d6c604 100644 --- a/Tests/noDist/testP2PAvx.cpp +++ b/Tests/noDist/testP2PAvx.cpp @@ -84,7 +84,7 @@ int main(int argc, char ** argv){ // FFmaGenericLoader<FReal> loader(filenameIn); // - int nbParticles = static_cast<int>(loader.getNumberOfParticles()); + FSize nbParticles = static_cast<int>(loader.getNumberOfParticles()); std::cout << "Read " << nbParticles << " particles ..." << std::endl; double BoxWith=loader.getBoxWidth(); FPoint<FReal> Centre(loader.getCenterOfBox().getX(), loader.getCenterOfBox().getY() , loader.getCenterOfBox().getZ()); @@ -166,7 +166,7 @@ int main(int argc, char ** argv){ FReal cumulPot = 0.0; k=0; tree.forEachLeaf([&](LeafClass * leaf){ - int maxParts = leaf->getSrc()->getNbParticles(); + FSize maxParts = leaf->getSrc()->getNbParticles(); FReal* datas = leaf->getSrc()->getPotentials(); for(int i=0 ; i<maxParts ; ++i){ cumulPot += datas[i]; diff --git a/Tests/noDist/testSmallCase.cpp b/Tests/noDist/testSmallCase.cpp index 06a2f8563..259b47ca9 100644 --- a/Tests/noDist/testSmallCase.cpp +++ b/Tests/noDist/testSmallCase.cpp @@ -175,7 +175,7 @@ int main(int argc, char ** argv){ ////////////////////////////////////////////////////////////////////////////////// tree.forEachLeaf([&](LeafClass* leaf){ - const int nbParticles = leaf->getSrc()->getNbParticles(); + const FSize nbParticles = leaf->getSrc()->getNbParticles(); const FReal* posx = leaf->getSrc()->getPositions()[0]; const FReal* posy = leaf->getSrc()->getPositions()[1]; const FReal* posz = leaf->getSrc()->getPositions()[2]; @@ -183,8 +183,8 @@ int main(int argc, char ** argv){ const FReal* fy = leaf->getSrc()->getForcesY(); const FReal* fz = leaf->getSrc()->getForcesZ(); const FReal* pot = leaf->getSrc()->getPotentials(); - const FVector<int>& indexes = leaf->getSrc()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); + for(FSize idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ std::cout << "[FMM] Particle pos " << posx[idxPart] << " " << posy[idxPart] << " " << posz[idxPart] << "\n"; std::cout << "\t>> res pot " << pot[idxPart] << " forces " << fx[idxPart] << " " << fy[idxPart] << " " << fz[idxPart] << "\n"; std::cout << "[Direct] Particle pos " << particles[indexes[idxPart]].pos.getX() << " " << particles[indexes[idxPart]].pos.getY() << " " << particles[indexes[idxPart]].pos.getZ() << "\n"; diff --git a/Tests/noDist/testSphericalBlasBlockProc.cpp b/Tests/noDist/testSphericalBlasBlockProc.cpp index 96a00b749..22f9175a6 100644 --- a/Tests/noDist/testSphericalBlasBlockProc.cpp +++ b/Tests/noDist/testSphericalBlasBlockProc.cpp @@ -124,7 +124,7 @@ int main(int argc, char ** argv){ TestParticle* particles = new TestParticle[loader.getNumberOfParticles()]; memset(particles, 0, sizeof(TestParticle) * loader.getNumberOfParticles()); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particles[idxPart].position,&particles[idxPart].physicalValue); } @@ -144,7 +144,7 @@ int main(int argc, char ** argv){ parts.reserve(finalParticles.getSize()); //Convert ouput of DistributeArrayToContainer to a ContainerClass - for(int idxPart = 0; idxPart < finalParticles.getSize(); ++idxPart){ + for(FSize idxPart = 0; idxPart < finalParticles.getSize(); ++idxPart){ parts.push(finalParticles[idxPart].getPosition(),finalParticles[idxPart].physicalValue); } @@ -202,9 +202,9 @@ int main(int argc, char ** argv){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ potential += potentials[idxPart]; fx += forcesX[idxPart]; fy += forcesY[idxPart]; diff --git a/Tests/noDist/testSphericalBlasProc.cpp b/Tests/noDist/testSphericalBlasProc.cpp index 4a0c34e7a..fcd8ee18a 100644 --- a/Tests/noDist/testSphericalBlasProc.cpp +++ b/Tests/noDist/testSphericalBlasProc.cpp @@ -123,7 +123,7 @@ int main(int argc, char ** argv){ TestParticle* particles = new TestParticle[loader.getNumberOfParticles()]; memset(particles, 0, sizeof(TestParticle) * loader.getNumberOfParticles()); - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particles[idxPart].position,&particles[idxPart].physicalValue); } @@ -192,9 +192,9 @@ int main(int argc, char ** argv){ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ potential += potentials[idxPart]; fx += forcesX[idxPart]; fy += forcesY[idxPart]; diff --git a/Tests/noDist/testSphericalDebug.cpp b/Tests/noDist/testSphericalDebug.cpp index 9add05b04..f72ca2a39 100644 --- a/Tests/noDist/testSphericalDebug.cpp +++ b/Tests/noDist/testSphericalDebug.cpp @@ -58,7 +58,7 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { const int DevP = 2; // Warning in make test the exec dir it Build/UTests // Load particles - const int nbParticles = 2; + const FSize nbParticles = 2; const FReal boxWidth = 1.0; const FPoint<FReal> boxCenter(boxWidth/2.0,boxWidth/2.0,boxWidth/2.0); @@ -115,7 +115,7 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { // Create octree OctreeClass tree(NbLevels, SizeSubLevels, boxWidth, boxCenter); - for(int idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ // put in tree tree.insert(particles[idxPart].position, idxPart, particles[idxPart].physicalValue); // get copy @@ -160,11 +160,11 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].potential,potentials[idxPart]); fx.add(particles[indexPartOrig].forces[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].forces[1],forcesY[idxPart]); diff --git a/Tests/noDist/testTreeBuilder.cpp b/Tests/noDist/testTreeBuilder.cpp index 6f54822ac..bf04e0a04 100644 --- a/Tests/noDist/testTreeBuilder.cpp +++ b/Tests/noDist/testTreeBuilder.cpp @@ -143,7 +143,7 @@ int main(int argc, char** argv){ regInsert.tic(); - for(int idxPart = 0 ; idxPart < loaderRef.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loaderRef.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> particlePosition; FReal physicalValue; loaderRef.fillParticle(&particlePosition,&physicalValue); @@ -173,7 +173,7 @@ int main(int argc, char** argv){ TestParticle * arrayOfParts = new TestParticle[nbOfParticles]; memset(arrayOfParts,0,sizeof(TestParticle)*nbOfParticles); - for(int idxPart = 0 ; idxPart < nbOfParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbOfParticles ; ++idxPart){ loader.fillParticle(&arrayOfParts[idxPart].position,&arrayOfParts[idxPart].physicalValue); //Build temporary TreeCoordinate host.setX( FCoordinateComputer::GetTreeCoordinate<FReal>( arrayOfParts[idxPart].getPosition().getX() - boxCorner.getX(), boxWidth, boxWidthAtLeafLevel, NbLevels )); diff --git a/Tests/noDist/testUnifMultiRhs.cpp b/Tests/noDist/testUnifMultiRhs.cpp index 67b3eddba..6886930a2 100644 --- a/Tests/noDist/testUnifMultiRhs.cpp +++ b/Tests/noDist/testUnifMultiRhs.cpp @@ -116,10 +116,10 @@ int main(int argc, char* argv[]) FFmaGenericLoader<FReal> loader(filename); if(!loader.isOpen()) throw std::runtime_error("Particle file couldn't be opened!"); - const int nbParticles = loader.getNumberOfParticles(); + const FSize nbParticles = loader.getNumberOfParticles(); TestParticle* const particles = new TestParticle[nbParticles]; - for(int idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ FPoint<FReal> position; FReal physicalValue = 0.0; loader.fillParticle(&position,&physicalValue); @@ -141,7 +141,7 @@ int main(int argc, char* argv[]) time.tic(); for(int idxVals = 0 ; idxVals < 1 ; ++idxVals){ for(int idxTarget = 0 ; idxTarget < nbParticles ; ++idxTarget){ - for(int idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ + for(FSize idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ FP2P::MutualParticles(particles[idxTarget].position.getX(), particles[idxTarget].position.getY(), particles[idxTarget].position.getZ(), particles[idxTarget].physicalValue[idxVals], &particles[idxTarget].forces[idxVals][0], &particles[idxTarget].forces[idxVals][1], @@ -187,7 +187,7 @@ int main(int argc, char* argv[]) std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl; time.tic(); - for(int idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ // Convert FReal[NVALS] to std::array<FReal,NVALS> std::array<FReal, (1+4*1)*NVALS> physicalState; for(int idxVals = 0 ; idxVals < NVALS ; ++idxVals){ @@ -232,11 +232,11 @@ int main(int argc, char* argv[]) const FReal*const forcesX = leaf->getTargets()->getForcesX(idxVals); const FReal*const forcesY = leaf->getTargets()->getForcesY(idxVals); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(idxVals); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].potential[0],potentials[idxPart]); fx.add(particles[indexPartOrig].forces[0][0],forcesX[idxPart]); diff --git a/UTests/FUKernelTester.hpp b/UTests/FUKernelTester.hpp index 25e1c5827..039508304 100644 --- a/UTests/FUKernelTester.hpp +++ b/UTests/FUKernelTester.hpp @@ -81,7 +81,7 @@ public: OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); // Insert particle in the tree // - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ tree.insert(particles[idxPart].getPosition() , idxPart, particles[idxPart].getPhysicalValue() ); } // @@ -101,7 +101,7 @@ public: // Compute direct energy ///////////////////////////////////////////////////////////////////////////////////////////////// - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -118,11 +118,11 @@ public: const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/UTests/utestChebyshevDirectPeriodic.cpp b/UTests/utestChebyshevDirectPeriodic.cpp index d7783a141..4403960dd 100644 --- a/UTests/utestChebyshevDirectPeriodic.cpp +++ b/UTests/utestChebyshevDirectPeriodic.cpp @@ -64,7 +64,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { const int SizeSubLevels = 2; const int PeriodicDeep = 3; - int NbParticles = 150; + FSize NbParticles = 150; FReal BoxWidth; FPoint<FReal> CenterOfBox ; FRandomLoader<FReal> loader(NbParticles); @@ -90,7 +90,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { }; FReal coeff = -1.0, value = 0.10, sum = 0.0; TestParticle* const particles = new TestParticle[loader.getNumberOfParticles()]; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> position; loader.fillParticle(&position); // put in tree @@ -128,8 +128,8 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { algo.repetitionsIntervals(&min, &max); FReal energy= 0.0 , energyD = 0.0 ; - for(int idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ - for(int idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ + for(FSize idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ + for(FSize idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ FP2P::MutualParticles(particles[idxTarget].position.getX(), particles[idxTarget].position.getY(), particles[idxTarget].position.getZ(),particles[idxTarget].physicalValue, &particles[idxTarget].forces[0],&particles[idxTarget].forces[1], @@ -166,7 +166,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { } } } - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].potential*particles[idx].physicalValue ; } ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -185,11 +185,11 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].potential,potentials[idxPart]); fx.add(particles[indexPartOrig].forces[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].forces[1],forcesY[idxPart]); diff --git a/UTests/utestChebyshevMpi.cpp b/UTests/utestChebyshevMpi.cpp index aa0484943..0b83caee5 100644 --- a/UTests/utestChebyshevMpi.cpp +++ b/UTests/utestChebyshevMpi.cpp @@ -128,10 +128,10 @@ class TestChebyshevMpiDirect : public FUTesterMpi<TestChebyshevMpiDirect>{ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ const FSize indexPartOrig = FSize(indexes[idxPart])-idxStart; //It's a proc on my left that used to keep this part if(indexPartOrig < 0){ @@ -153,7 +153,7 @@ class TestChebyshevMpiDirect : public FUTesterMpi<TestChebyshevMpiDirect>{ fz.add(datas[7],forcesZ[idxPart]); energy += potentials[idxPart]*physicalValues[idxPart]; if(datas[0] != leaf->getTargets()->getPositions()[0][idxPart]){ - printf("- %d - Problem %d !! \t [%e,%e,%e,%e] [%e,%e,%e,%e] \n", + printf("- %d - Problem %lld !! \t [%e,%e,%e,%e] [%e,%e,%e,%e] \n", app.global().processId(),indexes[idxPart], datas[0],datas[1],datas[2],datas[3], potentials[idxPart],forcesX[idxPart], @@ -182,7 +182,7 @@ class TestChebyshevMpiDirect : public FUTesterMpi<TestChebyshevMpiDirect>{ //Compute Direct Energy FReal energyD = 0.0; - for(int idx = 0 ; idx < loader.getMyNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getMyNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } diff --git a/UTests/utestChebyshevThread.cpp b/UTests/utestChebyshevThread.cpp index 9f8aaf0e7..b15198ca7 100644 --- a/UTests/utestChebyshevThread.cpp +++ b/UTests/utestChebyshevThread.cpp @@ -95,7 +95,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { // // Insert particle in the tree // - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ tree.insert(particles[idxPart].getPosition() , idxPart, particles[idxPart].getPhysicalValue() ); } // @@ -112,7 +112,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { // Compute direct energy ///////////////////////////////////////////////////////////////////////////////////////////////// - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -129,11 +129,11 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> { const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/UTests/utestFmmAlgorithmProc.cpp b/UTests/utestFmmAlgorithmProc.cpp index fe6cf5eaa..8ecea9667 100644 --- a/UTests/utestFmmAlgorithmProc.cpp +++ b/UTests/utestFmmAlgorithmProc.cpp @@ -201,7 +201,7 @@ class TestFmmAlgoProc : public FUTesterMpi<TestFmmAlgoProc> { ContainerClass* containerValide = (valideOctreeIterator.getCurrentListTargets()); const long long int*const dataDownValide = containerValide->getDataDown(); - for(int idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < container->getNbParticles() ; ++idxPart){ uassert(dataDown[idxPart] == dataDownValide[idxPart]); } } @@ -241,7 +241,7 @@ class TestFmmAlgoProc : public FUTesterMpi<TestFmmAlgoProc> { TestParticle* particles = new TestParticle[loader.getNumberOfParticles()]; memset(particles, 0, sizeof(TestParticle) * loader.getNumberOfParticles()); FReal physicalValue; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ loader.fillParticle(&particles[idxPart].position,&physicalValue); } diff --git a/UTests/utestInterpolationMultiRhs.cpp b/UTests/utestInterpolationMultiRhs.cpp index 9123e4ca3..b20767fde 100644 --- a/UTests/utestInterpolationMultiRhs.cpp +++ b/UTests/utestInterpolationMultiRhs.cpp @@ -103,7 +103,7 @@ class TestInterpolationKernel : public FUTester<TestInterpolationKernel> { // Create octree OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); // Insert particle in the tree - for(int idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ // Convert FReal[NVALS] to std::array<FReal,NVALS> std::array<FReal, (1+4*1)*NVals> physicalState; for(int idxVals = 0 ; idxVals < NVals ; ++idxVals){ @@ -125,7 +125,7 @@ class TestInterpolationKernel : public FUTester<TestInterpolationKernel> { algo.execute(); // FReal energy= 0.0 , energyD = 0.0 ; - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } // @@ -142,12 +142,12 @@ class TestInterpolationKernel : public FUTester<TestInterpolationKernel> { const FReal*const forcesX = leaf->getTargets()->getForcesX(idxVals); const FReal*const forcesY = leaf->getTargets()->getForcesY(idxVals); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(idxVals); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + const FSize indexPartOrig = indexes[idxPart]; // std::cout << " index "<< indexPartOrig << " " << particles[indexPartOrig].getPotential() << " " << potentials[idxPart] << std::endl; potentialDiff[idxVals].add(particles[indexPartOrig].getPotential(),potentials[idxPart]); // diff --git a/UTests/utestLagrange.cpp b/UTests/utestLagrange.cpp index a4615e029..d71a17f43 100644 --- a/UTests/utestLagrange.cpp +++ b/UTests/utestLagrange.cpp @@ -90,7 +90,7 @@ class TestLagrange : public FUTester<TestLagrange> { // // Insert particle in the tree // - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue() ); } // @@ -107,7 +107,7 @@ class TestLagrange : public FUTester<TestLagrange> { // Compute direct energy ///////////////////////////////////////////////////////////////////////////////////////////////// - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -124,11 +124,11 @@ class TestLagrange : public FUTester<TestLagrange> { const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/UTests/utestLagrangeMpi.cpp b/UTests/utestLagrangeMpi.cpp index f67ea8cb3..dda5be85f 100644 --- a/UTests/utestLagrangeMpi.cpp +++ b/UTests/utestLagrangeMpi.cpp @@ -128,10 +128,10 @@ class TestLagrangeMpiDirect : public FUTesterMpi<TestLagrangeMpiDirect>{ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ const FSize indexPartOrig = FSize(indexes[idxPart])-idxStart; //It's a proc on my left that used to keep this part if(indexPartOrig < 0){ @@ -153,7 +153,7 @@ class TestLagrangeMpiDirect : public FUTesterMpi<TestLagrangeMpiDirect>{ fz.add(datas[7],forcesZ[idxPart]); energy += potentials[idxPart]*physicalValues[idxPart]; if(datas[0] != leaf->getTargets()->getPositions()[0][idxPart]){ - printf("- %d - Problem %d !! \t [%e,%e,%e,%e] [%e,%e,%e,%e] \n", + printf("- %d - Problem %lld !! \t [%e,%e,%e,%e] [%e,%e,%e,%e] \n", app.global().processId(),indexes[idxPart], datas[0],datas[1],datas[2],datas[3], potentials[idxPart],forcesX[idxPart], @@ -182,7 +182,7 @@ class TestLagrangeMpiDirect : public FUTesterMpi<TestLagrangeMpiDirect>{ //Compute Direct Energy FReal energyD = 0.0; - for(int idx = 0 ; idx < loader.getMyNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getMyNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } diff --git a/UTests/utestLagrangeThread.cpp b/UTests/utestLagrangeThread.cpp index bb2fb05d5..c4358c654 100644 --- a/UTests/utestLagrangeThread.cpp +++ b/UTests/utestLagrangeThread.cpp @@ -96,7 +96,7 @@ class TestLagrange : public FUTester<TestLagrange> { // // Insert particle in the tree // - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ tree.insert(particles[idxPart].getPosition() , idxPart, particles[idxPart].getPhysicalValue() ); } // @@ -113,7 +113,7 @@ class TestLagrange : public FUTester<TestLagrange> { // Compute direct energy ///////////////////////////////////////////////////////////////////////////////////////////////// - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -130,11 +130,11 @@ class TestLagrange : public FUTester<TestLagrange> { const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/UTests/utestMpiTreeBuilder.cpp b/UTests/utestMpiTreeBuilder.cpp index d6517e689..25263a164 100644 --- a/UTests/utestMpiTreeBuilder.cpp +++ b/UTests/utestMpiTreeBuilder.cpp @@ -144,7 +144,7 @@ class TestMpiTreeBuilder : public FUTesterMpi< class TestMpiTreeBuilder> { MortonIndex ref = -1; int numMort = 0; if(app.global().processId()==0){ - for(int i=0 ; i<loaderSeq.getNumberOfParticles() ; ++i){ + for(FSize i=0 ; i<loaderSeq.getNumberOfParticles() ; ++i){ if (arrayOfParticles[i].index !=ref){ numMort++; ref = arrayOfParticles[i].index; @@ -159,11 +159,11 @@ class TestMpiTreeBuilder : public FUTesterMpi< class TestMpiTreeBuilder> { FMpiFmaGenericLoader<FReal> loader(filename,app.global()); if(!loader.isOpen()) throw std::runtime_error("Particle file couldn't be opened!") ; //Now, we sort again the particles with MPI QuickSort - int idxStart = loader.getStart(); + FSize idxStart = loader.getStart(); FMpiTreeBuilder<FReal,TestParticle<FReal>>::IndexedParticle * arrayToBeSorted = new FMpiTreeBuilder<FReal,TestParticle<FReal>>::IndexedParticle[loader.getMyNumberOfParticles()]; //Copy the TestParticles into an array of indexedParticle - for(int i=0 ; i<loader.getMyNumberOfParticles() ; ++i){ + for(FSize i=0 ; i<loader.getMyNumberOfParticles() ; ++i){ arrayToBeSorted[i].particle = originalArray[i+idxStart]; arrayToBeSorted[i].index = arrayToBeSorted[i].particle.index; } @@ -200,17 +200,17 @@ class TestMpiTreeBuilder : public FUTesterMpi< class TestMpiTreeBuilder> { //Gather size of output int * nbPartPerProcess = new int[app.global().processCount()]; - nbPartPerProcess[app.global().processId()] = outputSize; - MPI_Gather(&nbPartPerProcess[app.global().processId()],1,MPI_INT,nbPartPerProcess,1,MPI_INT,0,app.global().getComm()); + nbPartPerProcess[app.global().processId()] = int(outputSize); + MPI_Gather(&nbPartPerProcess[app.global().processId()],1,FMpi::GetType(*nbPartPerProcess),nbPartPerProcess,1,FMpi::GetType(*nbPartPerProcess),0,app.global().getComm()); - int * toSend = new int[outputSize]; + FSize * toSend = new FSize[outputSize]; int * displ = nullptr; int * recvParts = nullptr; - int * myPart = nullptr; + FSize * myPart = nullptr; //Prepare the indexInFile to send for(int idPart=0 ; idPart<outputSize ; ++idPart){ - toSend[idPart] = int(outputArray[idPart].particle.indexInFile); + toSend[idPart] = FSize(outputArray[idPart].particle.indexInFile); } if(app.global().processId() == 0){ @@ -218,20 +218,21 @@ class TestMpiTreeBuilder : public FUTesterMpi< class TestMpiTreeBuilder> { displ = new int[app.global().processCount()]; displ[0] = 0; for(int idProc = 1 ; idProc < app.global().processCount() ; ++idProc){ - displ[idProc] = nbPartPerProcess[idProc-1] + displ[idProc-1]; + displ[idProc] = int( nbPartPerProcess[idProc-1] + displ[idProc-1]); } //Buffer to recv into recvParts = new int[loader.getNumberOfParticles()]; - MPI_Gatherv(toSend,outputSize,MPI_INT,recvParts,nbPartPerProcess,displ,MPI_INT,0,app.global().getComm()); + FAssertLF(outputSize < std::numeric_limits<int>::max()); + MPI_Gatherv(toSend,int(outputSize),FMpi::GetType(*toSend),recvParts,nbPartPerProcess,displ,FMpi::GetType(*toSend),0,app.global().getComm()); //Buffer to put result into - myPart = new int[loader.getNumberOfParticles()]; - memset(myPart,0,sizeof(int)*loader.getNumberOfParticles()); - for(int idP = 0 ; idP < loader.getNumberOfParticles() ; ++idP){ + myPart = new FSize[loader.getNumberOfParticles()]; + memset(myPart,0,sizeof(FSize)*loader.getNumberOfParticles()); + for(FSize idP = 0 ; idP < loader.getNumberOfParticles() ; ++idP){ myPart[recvParts[idP]] += 1; } //Check if everything is set to 1 - for(int idP = 0 ; idP < loader.getNumberOfParticles() ; ++idP){ + for(FSize idP = 0 ; idP < loader.getNumberOfParticles() ; ++idP){ if(myPart[idP] != 1){ std::cout << "Part number "<< idP << " in file is lost or duplicated : "<< myPart[idP]<< std::endl; resultQsMpi = false; @@ -239,7 +240,8 @@ class TestMpiTreeBuilder : public FUTesterMpi< class TestMpiTreeBuilder> { } } else{ - MPI_Gatherv(toSend,outputSize,MPI_INT,recvParts,nbPartPerProcess,displ,MPI_INT,0,app.global().getComm()); + FAssertLF(outputSize < std::numeric_limits<int>::max()); + MPI_Gatherv(toSend,int(outputSize),FMpi::GetType(*toSend),recvParts,nbPartPerProcess,displ,FMpi::GetType(*toSend),0,app.global().getComm()); } @@ -268,7 +270,7 @@ class TestMpiTreeBuilder : public FUTesterMpi< class TestMpiTreeBuilder> { //we need to know how many parts still remains FSize CounterStart = 0; //We use a prefix sum - MPI_Exscan(&outputSize,&CounterStart,1,MPI_LONG_LONG_INT,MPI_SUM,app.global().getComm()); + MPI_Exscan(&outputSize,&CounterStart,1,FMpi::GetType(outputSize),MPI_SUM,app.global().getComm()); //Test if no problems for(FSize k=0 ; k<outputSize ; ++k){ @@ -291,13 +293,13 @@ class TestMpiTreeBuilder : public FUTesterMpi< class TestMpiTreeBuilder> { FMpiTreeBuilder<FReal,TestParticle<FReal>>::EqualizeAndFillContainer(app.global(),&finalParticles,leavesIndices,leavesArray,leaveSize,outputSize,&balancer); //Ok now count the Particles at the end of the Equalize - int finalNbPart = finalParticles.getSize(); - int finalStart = 0; + FSize finalNbPart = finalParticles.getSize(); + FSize finalStart = 0; - MPI_Exscan(&finalNbPart,&finalStart,1,MPI_INT,MPI_SUM,app.global().getComm()); + MPI_Exscan(&finalNbPart,&finalStart,1,FMpi::GetType(finalNbPart),MPI_SUM,app.global().getComm()); for (int k=0; k<finalNbPart ; k++){ if(finalParticles[k].indexInFile != arrayOfParticles[k+finalStart].indexInFile){ - printf("Equalize :: Proc %d, k=[%d+%d] finalParticles : %lld,%lld, sortedArray %lld,%lld \n", + printf("Equalize :: Proc %d, k=[%d+%lld] finalParticles : %lld,%lld, sortedArray %lld,%lld \n", app.global().processId(),k,finalStart, finalParticles[k].index,finalParticles[k].indexInFile, arrayOfParticles[k+finalStart].index,arrayOfParticles[k+finalStart].indexInFile); diff --git a/UTests/utestRotation.cpp b/UTests/utestRotation.cpp index 0e874ba07..be07c5f57 100644 --- a/UTests/utestRotation.cpp +++ b/UTests/utestRotation.cpp @@ -82,7 +82,7 @@ class TestRotationDirect : public FUTester<TestRotationDirect> { // FReal sum = 0.0, a= 0.0; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> position(particles[idxPart].getPosition() ); // tree.insert(particles[idxPart].getPosition() , idxPart, particles[idxPart].getPhysicalValue()); @@ -109,7 +109,7 @@ class TestRotationDirect : public FUTester<TestRotationDirect> { // Compute direct energy ///////////////////////////////////////////////////////////////////////////////////////////////// - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -126,11 +126,11 @@ class TestRotationDirect : public FUTester<TestRotationDirect> { const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/UTests/utestRotationDirectPeriodic.cpp b/UTests/utestRotationDirectPeriodic.cpp index 1820e9986..78add97ff 100644 --- a/UTests/utestRotationDirectPeriodic.cpp +++ b/UTests/utestRotationDirectPeriodic.cpp @@ -50,7 +50,7 @@ class TestRotationDirectPeriodic : public FUTester<TestRotationDirectPeriodic> { const int NbLevels = 4; const int SizeSubLevels = 2; const int PeriodicDeep = 2; - const int nbParticles = 100; + const FSize nbParticles = 100; FRandomLoader<FReal> loader(nbParticles); // @@ -63,7 +63,7 @@ class TestRotationDirectPeriodic : public FUTester<TestRotationDirectPeriodic> { }; FReal coeff = -1.0, value = 0.10, sum = 0.0, coerr =0.0, a=0.0; TestParticle* const particles = new TestParticle[loader.getNumberOfParticles()]; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> position; loader.fillParticle(&position); value *= coeff ; @@ -99,8 +99,8 @@ class TestRotationDirectPeriodic : public FUTester<TestRotationDirectPeriodic> { Print("Run direct..."); FTreeCoordinate min, max; algo.repetitionsIntervals(&min, &max); - for(int idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ - for(int idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ + for(FSize idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ + for(FSize idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ FP2PR::MutualParticles(particles[idxTarget].position.getX(), particles[idxTarget].position.getY(), particles[idxTarget].position.getZ(),particles[idxTarget].physicalValue, &particles[idxTarget].forces[0],&particles[idxTarget].forces[1], @@ -141,7 +141,7 @@ class TestRotationDirectPeriodic : public FUTester<TestRotationDirectPeriodic> { // Compute direct energy ///////////////////////////////////////////////////////////////////////////////////////////////// - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].potential*particles[idx].physicalValue ; } @@ -157,11 +157,11 @@ class TestRotationDirectPeriodic : public FUTester<TestRotationDirectPeriodic> { const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].potential,potentials[idxPart]); fx.add(particles[indexPartOrig].forces[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].forces[1],forcesY[idxPart]); diff --git a/UTests/utestRotationDirectSeveralTime.cpp b/UTests/utestRotationDirectSeveralTime.cpp index dc9cb4ead..cad757de9 100644 --- a/UTests/utestRotationDirectSeveralTime.cpp +++ b/UTests/utestRotationDirectSeveralTime.cpp @@ -63,7 +63,7 @@ class TestRotationDirectSeveralTime : public FUTester<TestRotationDirectSeveralT OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); // Insert particle in the tree // - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ tree.insert(particles[idxPart].getPosition() , idxPart, particles[idxPart].getPhysicalValue() ); } // @@ -72,7 +72,7 @@ class TestRotationDirectSeveralTime : public FUTester<TestRotationDirectSeveralT // Compute direct energy ///////////////////////////////////////////////////////////////////////////////////////////////// - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } // Run FMM @@ -114,11 +114,11 @@ class TestRotationDirectSeveralTime : public FUTester<TestRotationDirectSeveralT const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/UTests/utestRotationDirectTsm.cpp b/UTests/utestRotationDirectTsm.cpp index aeb6a0ee9..a963c8a6c 100644 --- a/UTests/utestRotationDirectTsm.cpp +++ b/UTests/utestRotationDirectTsm.cpp @@ -64,7 +64,7 @@ class TestRotationDirectTsm : public FUTester<TestRotationDirectTsm> { const FReal physicalValue = 0.10; // FmaRWParticle<FReal, 8,8>* const particlesTargets = new FmaRWParticle<FReal, 8,8>[nbTargets]; - for(int idxPart = 0 ; idxPart < nbTargets ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbTargets ; ++idxPart){ FPoint<FReal> position; loader.fillParticle(&position); // put in tree @@ -79,7 +79,7 @@ class TestRotationDirectTsm : public FUTester<TestRotationDirectTsm> { } FmaRWParticle<FReal, 8,8>* const particlesSources = new FmaRWParticle<FReal, 8,8>[nbSources]; - for(int idxPart = 0 ; idxPart < nbSources ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbSources ; ++idxPart){ FPoint<FReal> position; loader.fillParticle(&position); // put in tree @@ -137,11 +137,11 @@ class TestRotationDirectTsm : public FUTester<TestRotationDirectTsm> { const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particlesTargets[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particlesTargets[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particlesTargets[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/UTests/utestRotationThread.cpp b/UTests/utestRotationThread.cpp index 624264639..fece34ae6 100644 --- a/UTests/utestRotationThread.cpp +++ b/UTests/utestRotationThread.cpp @@ -74,7 +74,7 @@ class TestRotationDirect : public FUTester<TestRotationDirect> { OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); // Insert particle in the tree // - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ tree.insert(particles[idxPart].getPosition() , idxPart, particles[idxPart].getPhysicalValue() ); } @@ -92,7 +92,7 @@ class TestRotationDirect : public FUTester<TestRotationDirect> { // Compute direct energy ///////////////////////////////////////////////////////////////////////////////////////////////// - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -109,11 +109,11 @@ class TestRotationDirect : public FUTester<TestRotationDirect> { const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/UTests/utestSpherical.cpp b/UTests/utestSpherical.cpp index 0b74ff4a6..5faf0be19 100644 --- a/UTests/utestSpherical.cpp +++ b/UTests/utestSpherical.cpp @@ -84,7 +84,7 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); // Insert particle in the tree // - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ tree.insert(particles[idxPart].getPosition() , idxPart, particles[idxPart].getPhysicalValue() ); } @@ -102,7 +102,7 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { // Compute direct energy ///////////////////////////////////////////////////////////////////////////////////////////////// - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -119,11 +119,11 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/UTests/utestSphericalBlasAlgorithm.cpp b/UTests/utestSphericalBlasAlgorithm.cpp index 2f7567ea5..618e12bac 100644 --- a/UTests/utestSphericalBlasAlgorithm.cpp +++ b/UTests/utestSphericalBlasAlgorithm.cpp @@ -84,7 +84,7 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); // Insert particle in the tree // - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ tree.insert(particles[idxPart].getPosition() , idxPart, particles[idxPart].getPhysicalValue() ); } @@ -102,7 +102,7 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { // Compute direct energy ///////////////////////////////////////////////////////////////////////////////////////////////// - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -119,11 +119,11 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/UTests/utestSphericalDirect.cpp b/UTests/utestSphericalDirect.cpp index 64c730b6c..7643066fd 100644 --- a/UTests/utestSphericalDirect.cpp +++ b/UTests/utestSphericalDirect.cpp @@ -87,7 +87,7 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { OctreeClass tree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); // Insert particle in the tree // - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ tree.insert(particles[idxPart].getPosition() , idxPart, particles[idxPart].getPhysicalValue() ); } @@ -108,7 +108,7 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { // Compute direct energy ///////////////////////////////////////////////////////////////////////////////////////////////// - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; } ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -125,11 +125,11 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> { const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); diff --git a/UTests/utestSphericalDirectPeriodic.cpp b/UTests/utestSphericalDirectPeriodic.cpp index cac4b2c5c..ab49957d5 100644 --- a/UTests/utestSphericalDirectPeriodic.cpp +++ b/UTests/utestSphericalDirectPeriodic.cpp @@ -66,7 +66,7 @@ class TestSphericalDirectPeriodic : public FUTester<TestSphericalDirectPeriodic> }; FReal coeff = -1.0, value = 0.10, sum = 0.0, a= 0.0; TestParticle* const particles = new TestParticle[loader.getNumberOfParticles()]; - for(int idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ FPoint<FReal> position; loader.fillParticle(&position); value *= coeff ; @@ -94,8 +94,8 @@ class TestSphericalDirectPeriodic : public FUTester<TestSphericalDirectPeriodic> Print("Run direct..."); FTreeCoordinate min, max; algo.repetitionsIntervals(&min, &max); - for(int idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ - for(int idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ + for(FSize idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){ + for(FSize idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){ FP2PR::MutualParticles(particles[idxTarget].position.getX(), particles[idxTarget].position.getY(), particles[idxTarget].position.getZ(),particles[idxTarget].physicalValue, &particles[idxTarget].forces[0],&particles[idxTarget].forces[1], @@ -145,11 +145,11 @@ class TestSphericalDirectPeriodic : public FUTester<TestSphericalDirectPeriodic> const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].potential,potentials[idxPart]); fx.add(particles[indexPartOrig].forces[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].forces[1],forcesY[idxPart]); diff --git a/UTests/utestSphericalWithPrevious.cpp b/UTests/utestSphericalWithPrevious.cpp index ea8318f10..070c8a3bf 100644 --- a/UTests/utestSphericalWithPrevious.cpp +++ b/UTests/utestSphericalWithPrevious.cpp @@ -95,7 +95,7 @@ class TestSphericalWithPrevious : public FUTester<TestSphericalWithPrevious> { // OctreeClass testTree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); // - for(int idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles ; ++idxPart){ FPoint<FReal> position; FReal physicalValue = 0.0; loader.fillParticle(&position,&physicalValue); @@ -140,7 +140,7 @@ class TestSphericalWithPrevious : public FUTester<TestSphericalWithPrevious> { const ContainerClass* testLeaf = testOctreeIterator.getCurrentListSrc(); const ContainerClass* goodLeaf = goodOctreeIterator.getCurrentListSrc(); - for(int idxPart = 0 ; idxPart < testLeaf->getNbParticles() ; ++idxPart ){ + for(FSize idxPart = 0 ; idxPart < testLeaf->getNbParticles() ; ++idxPart ){ uassert( IsSimilar(goodLeaf->getPotentials()[idxPart], testLeaf->getPotentials()[idxPart]) ); uassert( IsSimilar(goodLeaf->getForcesX()[idxPart], testLeaf->getForcesX()[idxPart]) ); uassert( IsSimilar(goodLeaf->getForcesY()[idxPart], testLeaf->getForcesY()[idxPart]) ); diff --git a/Utils/noDist/FmmAlgorithmTsm.cpp b/Utils/noDist/FmmAlgorithmTsm.cpp index de906efcc..05c2b8b70 100644 --- a/Utils/noDist/FmmAlgorithmTsm.cpp +++ b/Utils/noDist/FmmAlgorithmTsm.cpp @@ -147,13 +147,13 @@ struct TempMainStruct{ FPoint<FReal> particlePosition; double physicalValue = 1.0; - int nbSRC = loader.getNumberOfParticles(); + FSize nbSRC = loader.getNumberOfParticles(); sourcePart<FReal> *tabSrc = new sourcePart<FReal>[nbSRC ]; { // Insert sources FParticleType particleType, source = FParticleTypeSource; - for(int idxPart = 0 ; idxPart < nbSRC ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbSRC ; ++idxPart){ loader.fillParticle(&particlePosition, &particleType); // std::cout << idxPart << " " << particlePosition << " type " << particleType // << " physicalValue: " << physicalValue<< std::endl; @@ -171,13 +171,13 @@ struct TempMainStruct{ double dx = boxSize/(nbTargets-1) ; // std::cout << " TARGETS " <<std::endl; - FPoint<FReal> particlePosition(-dx,dimLeaf+quarterDimLeaf,quarterDimLeaf); + FPoint<FReal> particlePosition2(-dx,dimLeaf+quarterDimLeaf,quarterDimLeaf); // int nbTargets = 256; - for(int idxPart = 0 ; idxPart < nbTargets; ++idxPart){ - particlePosition.incX(dx); - std::cout << idxPart << " " <<particlePosition.getX()/dimLeaf<< " " << particlePosition << " type " << FParticleTypeTarget + for(FSize idxPart = 0 ; idxPart < nbTargets; ++idxPart){ + particlePosition2.incX(dx); + std::cout << idxPart << " " <<particlePosition2.getX()/dimLeaf<< " " << particlePosition2 << " type " << FParticleTypeTarget << " " <<physicalValue<<std::endl; - tree.insert(particlePosition, FParticleTypeTarget,idxPart,physicalValue ); + tree.insert(particlePosition2, FParticleTypeTarget,idxPart,physicalValue ); } } @@ -217,9 +217,9 @@ struct TempMainStruct{ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); // - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ double pot = 0.0 , xx,yy,zz; FPoint<FReal> FF ; for(int idxSrc = 0 ; idxSrc < nbSRC ; ++idxSrc){ diff --git a/Utils/noDist/compare2Files.cpp b/Utils/noDist/compare2Files.cpp index c0ef94df4..25a0a2bd0 100644 --- a/Utils/noDist/compare2Files.cpp +++ b/Utils/noDist/compare2Files.cpp @@ -62,7 +62,7 @@ int main(int argc, char ** argv){ // Allocation // FSize nbParticles = loader1.getNumberOfParticles(); - const unsigned int nbData = loader1.getNbRecordPerline() ; + const FSize nbData = loader1.getNbRecordPerline() ; if(nbParticles != loader2.getNumberOfParticles()){ std::cerr << "Number of points is different in the two files."<<std::endl ; return -1 ; @@ -80,12 +80,12 @@ int main(int argc, char ** argv){ loader2.fillParticle(particles2,nbParticles); - const int error = compareTwoArrays<FReal, FmaRWParticle<FReal,8,8>* >("TAG", nbParticles, particles1, particles2); + const FSize error = compareTwoArrays<FReal, FmaRWParticle<FReal,8,8>* >("TAG", nbParticles, particles1, particles2); // delete[] particles1 ; delete[] particles2 ; // - return error; + return int(error); } diff --git a/Utils/noDist/removeMoment.cpp b/Utils/noDist/removeMoment.cpp index 5636c0d1f..88fd4938f 100644 --- a/Utils/noDist/removeMoment.cpp +++ b/Utils/noDist/removeMoment.cpp @@ -169,7 +169,7 @@ int main(int argc, char ** argv){ particlesIn = new FmaRWParticle<FReal, 8,8>[numberofParticles]; memset(particlesIn, 0, sizeof( FmaRWParticle<FReal, 8,8>) * numberofParticles) ; - for(int idxPart = 0 ; idxPart < numberofParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < numberofParticles; ++idxPart){ // FPoint<FReal> position; FReal forces[3]; @@ -209,7 +209,7 @@ int main(int argc, char ** argv){ // double totalCharge = 0.0, readEnergy = 0.0; // - for(int idxPart = 0 ; idxPart < numberofParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < numberofParticles; ++idxPart){ // totalCharge += particlesIn[idxPart].getPhysicalValue() ; readEnergy += particlesIn[idxPart].getPhysicalValue() *particlesIn[idxPart].getPotential() ; diff --git a/Utils/noDist/stamp2Fma.cpp b/Utils/noDist/stamp2Fma.cpp index 9e47e44f2..1669acf05 100644 --- a/Utils/noDist/stamp2Fma.cpp +++ b/Utils/noDist/stamp2Fma.cpp @@ -74,7 +74,7 @@ int main(int argc, char ** argv){ typedef double FReal; FReal * particles = nullptr ; FFmaGenericLoader<FReal> * loader; - unsigned int nbData; + FSize nbData; bool stampFile = false ; if (FParameters::existParameter(argc, argv, "-fstamp")) { stampFile = true ; @@ -92,14 +92,14 @@ int main(int argc, char ** argv){ // NbPoints = loader->getNumberOfParticles(); nbData = loader->getNbRecordPerline() ; - const unsigned int arraySize =nbData*NbPoints; + const FSize arraySize =nbData*NbPoints; // particles = new FReal[arraySize] ; std::memset(particles,0,arraySize*sizeof(FReal)); // // Read Data - int j = 0 ; - for(int idxPart = 0 ; idxPart < NbPoints ;++idxPart, j+=nbData){ + FSize j = 0 ; + for(FSize idxPart = 0 ; idxPart < NbPoints ;++idxPart, j+=nbData){ // // loader->fillParticle(&particles[j],nbData); // std::cout << "idxPart "<< idxPart << " "; @@ -111,7 +111,7 @@ int main(int argc, char ** argv){ if(stampFile) { j=0 ; FReal D= loader->getBoxWidth(); - for(int idxPart = 0 ; idxPart < NbPoints ;++idxPart, j+=nbData){ + for(FSize idxPart = 0 ; idxPart < NbPoints ;++idxPart, j+=nbData){ particles[j] *= D ; particles[j+1] *= D ; particles[j+2] *= D ; @@ -128,7 +128,7 @@ int main(int argc, char ** argv){ // // NbPoints = loader->getNumberOfParticles() ; // // particles = new FReal[arraySize] ; // // std::memset(particles,0,arraySize*sizeof(FReal)); - // // for(int idxPart = 0 ; idxPart < NbPoints ; ++idxPart){ + // // for(FSize idxPart = 0 ; idxPart < NbPoints ; ++idxPart){ // // // // int index ; // // FPoint<FReal> P ; FReal t[3]; @@ -166,7 +166,7 @@ int main(int argc, char ** argv){ driverExportData(outfilename, particles , NbPoints); } // - delete particles ; + delete[] particles ; // return 1; diff --git a/Utils/noDist/testAccuracyChebFMM.cpp b/Utils/noDist/testAccuracyChebFMM.cpp index 60377095f..601eab983 100644 --- a/Utils/noDist/testAccuracyChebFMM.cpp +++ b/Utils/noDist/testAccuracyChebFMM.cpp @@ -160,7 +160,7 @@ struct TempMainStruct{ std::cout << "\tHeight : " << TreeHeight << " \t sub-height : " << SubTreeHeight << std::endl; time.tic(); // - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // // Read particle per particle from file // @@ -216,11 +216,11 @@ struct TempMainStruct{ const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); // const std::string outputFile("accuracyChebyschev.txt") ; diff --git a/Utils/noDist/testChebOrderEpsilon.cpp b/Utils/noDist/testChebOrderEpsilon.cpp index 7b38459f9..594bdd7c4 100644 --- a/Utils/noDist/testChebOrderEpsilon.cpp +++ b/Utils/noDist/testChebOrderEpsilon.cpp @@ -91,11 +91,11 @@ void checkResAndPrint(OctreeClass * tree, FmaRWParticle<FReal, 8,8> * const part const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -168,7 +168,7 @@ struct ChebMainStruct{ FReal epsilon = FMath::pow(10.0,static_cast<FReal>(-powerOf10)); const MatrixKernelClass MatrixKernel; { // ----------------------------------------------------- - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -228,7 +228,7 @@ int main(int argc, char** argv){ FReal energyD =0.0, totPhysicalValue =0.0; #pragma omp parallel for reduction(+:energyD,totPhysicalValue) - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; totPhysicalValue += particles[idx].getPhysicalValue() ; } diff --git a/Utils/noDist/testPrecisionAllKernel.cpp b/Utils/noDist/testPrecisionAllKernel.cpp index fa334e30d..32f4c2527 100644 --- a/Utils/noDist/testPrecisionAllKernel.cpp +++ b/Utils/noDist/testPrecisionAllKernel.cpp @@ -96,11 +96,11 @@ void checkResAndPrint(OctreeClass * tree, FmaRWParticle<FReal, 8,8> * const part const FReal*const forcesX = leaf->getTargets()->getForcesX(); const FReal*const forcesY = leaf->getTargets()->getForcesY(); const FReal*const forcesZ = leaf->getTargets()->getForcesZ(); - const int nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); - const FVector<int>& indexes = leaf->getTargets()->getIndexes(); + const FSize nbParticlesInLeaf = leaf->getTargets()->getNbParticles(); + const FVector<FSize>& indexes = leaf->getTargets()->getIndexes(); - for(int idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ - const int indexPartOrig = indexes[idxPart]; + for(FSize idxPart = 0 ; idxPart < nbParticlesInLeaf ; ++idxPart){ + const FSize indexPartOrig = indexes[idxPart]; potentialDiff.add(particles[indexPartOrig].getPotential(),potentials[idxPart]); fx.add(particles[indexPartOrig].getForces()[0],forcesX[idxPart]); fy.add(particles[indexPartOrig].getForces()[1],forcesY[idxPart]); @@ -162,7 +162,7 @@ struct ChebMainStruct{ // Create Matrix Kernel const MatrixKernelClass MatrixKernel; { // ----------------------------------------------------- - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -212,7 +212,7 @@ struct UnifMainStruct{ // Create Matrix Kernel const MatrixKernelClass MatrixKernel; { // ----------------------------------------------------- - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -258,7 +258,7 @@ struct RotMainStruct{ // init oct-tree OctreeClass tree(TreeHeight, SubTreeHeight, BoxWidth,CenterOfBox); { // ----------------------------------------------------- - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -304,7 +304,7 @@ struct TaylorMainStruct{ // init oct-tree OctreeClass tree(TreeHeight, SubTreeHeight, BoxWidth,CenterOfBox); { // ----------------------------------------------------- - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -352,7 +352,7 @@ struct SphericalBlasMainStruct{ // init oct-tree OctreeClass tree(TreeHeight, SubTreeHeight, BoxWidth,CenterOfBox); { // ----------------------------------------------------- - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -399,7 +399,7 @@ struct SphericalBlockBlasMainStruct{ // init oct-tree OctreeClass tree(TreeHeight, SubTreeHeight, BoxWidth,CenterOfBox); { // ----------------------------------------------------- - for(int idxPart = 0 ; idxPart < nbParticles; ++idxPart){ + for(FSize idxPart = 0 ; idxPart < nbParticles; ++idxPart){ // put in tree tree.insert(particles[idxPart].getPosition(), idxPart, particles[idxPart].getPhysicalValue()); } @@ -455,7 +455,7 @@ int main(int argc, char** argv){ FReal energyD =0.0, totPhysicalValue =0.0; #pragma omp parallel for reduction(+:energyD,totPhysicalValue) - for(int idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ + for(FSize idx = 0 ; idx < loader.getNumberOfParticles() ; ++idx){ energyD += particles[idx].getPotential()*particles[idx].getPhysicalValue() ; totPhysicalValue += particles[idx].getPhysicalValue() ; } -- GitLab