Commit 1afca526 authored by BRAMAS Berenger's avatar BRAMAS Berenger

Prepare for templatize FReal

parent a466119d
...@@ -57,7 +57,7 @@ struct DirectInteractionComputer<1,1> ...@@ -57,7 +57,7 @@ struct DirectInteractionComputer<1,1>
static void P2P( ContainerClass* const FRestrict TargetParticles, static void P2P( ContainerClass* const FRestrict TargetParticles,
ContainerClass* const NeighborSourceParticles[27], ContainerClass* const NeighborSourceParticles[27],
const MatrixKernelClass *const MatrixKernel){ const MatrixKernelClass *const MatrixKernel){
FP2P::FullMutual(TargetParticles,NeighborSourceParticles,14,MatrixKernel); FP2PT<FReal>::FullMutual<ContainerClass,MatrixKernelClass> (TargetParticles,NeighborSourceParticles,14,MatrixKernel);
} }
template <typename ContainerClass, typename MatrixKernelClass> template <typename ContainerClass, typename MatrixKernelClass>
...@@ -65,7 +65,7 @@ struct DirectInteractionComputer<1,1> ...@@ -65,7 +65,7 @@ struct DirectInteractionComputer<1,1>
ContainerClass* const inNeighbors[27], ContainerClass* const inNeighbors[27],
const int inSize, const int inSize,
const MatrixKernelClass *const MatrixKernel){ const MatrixKernelClass *const MatrixKernel){
FP2P::FullRemote(inTargets,inNeighbors,inSize,MatrixKernel); FP2PT<FReal>::FullRemote<ContainerClass,MatrixKernelClass>(inTargets,inNeighbors,inSize,MatrixKernel);
} }
}; };
......
This diff is collapsed.
...@@ -300,92 +300,107 @@ static void GenericFullRemote(ContainerClass* const FRestrict inTargets, Contain ...@@ -300,92 +300,107 @@ static void GenericFullRemote(ContainerClass* const FRestrict inTargets, Contain
} }
} }
#ifdef ScalFMM_USE_DOUBLE_PRECISION } // End namespace
template <class ValueClass>
struct FP2PRT{
};
#if defined(ScalFMM_USE_AVX) #if defined(ScalFMM_USE_AVX)
// AVX DOUBLE
template <class ContainerClass>
static void FullMutual(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
const int limiteNeighbors){
GenericFullMutual<ContainerClass, __m256d, 4>(inTargets, inNeighbors, limiteNeighbors);
}
template <class ContainerClass> template <>
static void FullRemote(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[], struct FP2PRT<double>{
const int limiteNeighbors){ template <class ContainerClass>
GenericFullRemote<ContainerClass, __m256d, 4>(inTargets, inNeighbors, limiteNeighbors); static void FullMutual(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
} const int limiteNeighbors){
#elif defined(ScalFMM_USE_SSE) FP2PR::GenericFullMutual<ContainerClass, __m256d, 4>(inTargets, inNeighbors, limiteNeighbors);
// SSE DOUBLE }
template <class ContainerClass>
static void FullMutual(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
const int limiteNeighbors){
GenericFullMutual<ContainerClass, __m128d, 2>(inTargets, inNeighbors, limiteNeighbors);
}
template <class ContainerClass> template <class ContainerClass>
static void FullRemote(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[], static void FullRemote(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
const int limiteNeighbors){ const int limiteNeighbors){
GenericFullRemote<ContainerClass, __m128d, 2>(inTargets, inNeighbors, limiteNeighbors); FP2PR::GenericFullRemote<ContainerClass, __m256d, 4>(inTargets, inNeighbors, limiteNeighbors);
} }
#else };
// SSE DOUBLE
template <class ContainerClass> template <>
static void FullMutual(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[], struct FP2PRT<float>{
const int limiteNeighbors){ template <class ContainerClass>
GenericFullMutual<ContainerClass, FReal, 1>(inTargets, inNeighbors, limiteNeighbors); static void FullMutual(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
} const int limiteNeighbors){
FP2PR::GenericFullMutual<ContainerClass, __m256, 8>(inTargets, inNeighbors, limiteNeighbors);
}
template <class ContainerClass> template <class ContainerClass>
static void FullRemote(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[], static void FullRemote(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
const int limiteNeighbors){ const int limiteNeighbors){
GenericFullRemote<ContainerClass, FReal, 1>(inTargets, inNeighbors, limiteNeighbors); FP2PR::GenericFullRemote<ContainerClass, __m256, 8>(inTargets, inNeighbors, limiteNeighbors);
} }
#endif };
#else
#if defined(ScalFMM_USE_AVX)
// AVX DOUBLE
template <class ContainerClass>
static void FullMutual(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
const int limiteNeighbors){
GenericFullMutual<ContainerClass, __m256, 8>(inTargets, inNeighbors, limiteNeighbors);
}
template <class ContainerClass>
static void FullRemote(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
const int limiteNeighbors){
GenericFullRemote<ContainerClass, __m256, 8>(inTargets, inNeighbors, limiteNeighbors);
}
#elif defined(ScalFMM_USE_SSE) #elif defined(ScalFMM_USE_SSE)
// SSE DOUBLE template <>
template <class ContainerClass> struct FP2PRT<double>{
static void FullMutual(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[], template <class ContainerClass>
const int limiteNeighbors){ static void FullMutual(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
GenericFullMutual<ContainerClass, __m128, 4>(inTargets, inNeighbors, limiteNeighbors); const int limiteNeighbors){
} FP2PR::GenericFullMutual<ContainerClass, __m128d, 2>(inTargets, inNeighbors, limiteNeighbors);
}
template <class ContainerClass>
static void FullRemote(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
const int limiteNeighbors){
FP2PR::GenericFullRemote<ContainerClass, __m128d, 2>(inTargets, inNeighbors, limiteNeighbors);
}
};
template <>
struct FP2PRT<float>{
template <class ContainerClass>
static void FullMutual(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
const int limiteNeighbors){
FP2PR::GenericFullMutual<ContainerClass, __m128, 4>(inTargets, inNeighbors, limiteNeighbors);
}
template <class ContainerClass>
static void FullRemote(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
const int limiteNeighbors){
FP2PR::GenericFullRemote<ContainerClass, __m128, 4>(inTargets, inNeighbors, limiteNeighbors);
}
};
template <class ContainerClass>
static void FullRemote(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
const int limiteNeighbors){
GenericFullRemote<ContainerClass, __m128, 4>(inTargets, inNeighbors, limiteNeighbors);
}
#else #else
// SSE DOUBLE template <>
template <class ContainerClass> struct FP2PRT<double>{
static void FullMutual(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[], template <class ContainerClass>
const int limiteNeighbors){ static void FullMutual(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
GenericFullMutual<ContainerClass, FReal, 1>(inTargets, inNeighbors, limiteNeighbors); const int limiteNeighbors){
} FP2PR::GenericFullMutual<ContainerClass, FReal, 1>(inTargets, inNeighbors, limiteNeighbors);
}
template <class ContainerClass> template <class ContainerClass>
static void FullRemote(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[], static void FullRemote(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
const int limiteNeighbors){ const int limiteNeighbors){
GenericFullRemote<ContainerClass, FReal, 1>(inTargets, inNeighbors, limiteNeighbors); FP2PR::GenericFullRemote<ContainerClass, FReal, 1>(inTargets, inNeighbors, limiteNeighbors);
} }
#endif };
#endif
template <>
struct FP2PRT<float>{
template <class ContainerClass>
static void FullMutual(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
const int limiteNeighbors){
FP2PR::GenericFullMutual<ContainerClass, FReal, 1>(inTargets, inNeighbors, limiteNeighbors);
}
template <class ContainerClass>
static void FullRemote(ContainerClass* const FRestrict inTargets, ContainerClass* const inNeighbors[],
const int limiteNeighbors){
FP2PR::GenericFullRemote<ContainerClass, FReal, 1>(inTargets, inNeighbors, limiteNeighbors);
}
};
#endif
}
......
...@@ -1310,7 +1310,7 @@ public: ...@@ -1310,7 +1310,7 @@ public:
void P2P(const FTreeCoordinate& /*inPosition*/, void P2P(const FTreeCoordinate& /*inPosition*/,
ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/,
ContainerClass* const inNeighbors[27], const int /*inSize*/){ ContainerClass* const inNeighbors[27], const int /*inSize*/){
FP2PR::FullMutual(inTargets,inNeighbors,14); FP2PRT<FReal>::FullMutual<ContainerClass>(inTargets,inNeighbors,14);
} }
...@@ -1318,7 +1318,7 @@ public: ...@@ -1318,7 +1318,7 @@ public:
void P2PRemote(const FTreeCoordinate& /*inPosition*/, void P2PRemote(const FTreeCoordinate& /*inPosition*/,
ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/,
ContainerClass* const inNeighbors[27], const int /*inSize*/){ ContainerClass* const inNeighbors[27], const int /*inSize*/){
FP2PR::FullRemote(inTargets,inNeighbors,27); FP2PRT<FReal>::FullRemote<ContainerClass>(inTargets,inNeighbors,27);
} }
}; };
......
...@@ -800,7 +800,7 @@ public: ...@@ -800,7 +800,7 @@ public:
void P2P(const FTreeCoordinate& /*inPosition*/, void P2P(const FTreeCoordinate& /*inPosition*/,
ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/,
ContainerClass* const inNeighbors[27], const int /*inSize*/){ ContainerClass* const inNeighbors[27], const int /*inSize*/){
FP2PR::FullMutual(inTargets,inNeighbors,14); FP2PRT<FReal>::FullMutual<ContainerClass>(inTargets,inNeighbors,14);
} }
...@@ -808,7 +808,7 @@ public: ...@@ -808,7 +808,7 @@ public:
void P2PRemote(const FTreeCoordinate& /*inPosition*/, void P2PRemote(const FTreeCoordinate& /*inPosition*/,
ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/,
ContainerClass* const inNeighbors[27], const int /*inSize*/){ ContainerClass* const inNeighbors[27], const int /*inSize*/){
FP2PR::FullRemote(inTargets,inNeighbors,27); FP2PRT<FReal>::FullRemote<ContainerClass>(inTargets,inNeighbors,27);
} }
}; };
......
...@@ -222,7 +222,7 @@ public: ...@@ -222,7 +222,7 @@ public:
void P2P(const FTreeCoordinate& inLeafPosition, void P2P(const FTreeCoordinate& inLeafPosition,
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources, ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources,
ContainerClass* const directNeighborsParticles[27], const int /*size*/){ ContainerClass* const directNeighborsParticles[27], const int /*size*/){
FP2PR::FullMutual(targets,directNeighborsParticles,14); FP2PRT<FReal>::FullMutual<ContainerClass>(targets,directNeighborsParticles,14);
} }
/** This P2P has to be used when target != sources /** This P2P has to be used when target != sources
...@@ -236,7 +236,7 @@ public: ...@@ -236,7 +236,7 @@ public:
void P2PRemote(const FTreeCoordinate& , void P2PRemote(const FTreeCoordinate& ,
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict , ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict ,
ContainerClass* const directNeighborsParticles[27], const int /*size*/){ ContainerClass* const directNeighborsParticles[27], const int /*size*/){
FP2PR::FullRemote(targets,directNeighborsParticles,27); FP2PRT<FReal>::FullRemote<ContainerClass>(targets,directNeighborsParticles,27);
} }
private: private:
......
...@@ -969,14 +969,14 @@ public: ...@@ -969,14 +969,14 @@ public:
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict /*sources*/, ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict /*sources*/,
ContainerClass* const directNeighborsParticles[27], const int /*size*/) ContainerClass* const directNeighborsParticles[27], const int /*size*/)
{ {
FP2PR::FullMutual(targets,directNeighborsParticles,14); FP2PRT<FReal>::FullMutual<ContainerClass>(targets,directNeighborsParticles,14);
} }
/** Use mutual even if it not useful and call particlesMutualInteraction */ /** Use mutual even if it not useful and call particlesMutualInteraction */
void P2PRemote(const FTreeCoordinate& /*inPosition*/, void P2PRemote(const FTreeCoordinate& /*inPosition*/,
ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/, ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/,
ContainerClass* const inNeighbors[27], const int /*inSize*/){ ContainerClass* const inNeighbors[27], const int /*inSize*/){
FP2PR::FullRemote(inTargets,inNeighbors,27); FP2PRT<FReal>::FullRemote<ContainerClass>(inTargets,inNeighbors,27);
} }
}; };
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "../../Utils/FMemUtils.hpp" #include "../../Utils/FMemUtils.hpp"
#include "../../Utils/FLog.hpp" #include "../../Utils/FLog.hpp"
#include "../P2P/FP2P.hpp" #include "../P2P/FP2PR.hpp"
/** /**
* @author Cyrille Piacibello * @author Cyrille Piacibello
...@@ -882,7 +882,13 @@ public: ...@@ -882,7 +882,13 @@ public:
ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict /*sources*/, ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict /*sources*/,
ContainerClass* const directNeighborsParticles[27], const int /*size*/) ContainerClass* const directNeighborsParticles[27], const int /*size*/)
{ {
FP2P::FullMutual(targets,directNeighborsParticles,14); FP2PRT<FReal>::FullMutual<ContainerClass>(targets,directNeighborsParticles,14);
}
void P2PRemote(const FTreeCoordinate& /*inPosition*/,
ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/,
ContainerClass* const inNeighbors[27], const int /*inSize*/){
FP2PRT<FReal>::FullRemote<ContainerClass>(inTargets,inNeighbors,27);
} }
}; };
......
...@@ -72,12 +72,12 @@ int main(int argc, char ** argv){ ...@@ -72,12 +72,12 @@ int main(int argc, char ** argv){
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
timer.tic(); timer.tic();
FP2PR::FullMutual<FP2PParticleContainer<>>( &leaf1, &pleaf2, 1); FP2PRT<FReal>::FullMutual<FP2PParticleContainer<>>( &leaf1, &pleaf2, 1);
timer.tac(); timer.tac();
std::cout << "Timer taken by FullMutual = " << timer.elapsed() << "s" << std::endl; std::cout << "Timer taken by FullMutual = " << timer.elapsed() << "s" << std::endl;
timer.tic(); timer.tic();
FP2PR::FullRemote<FP2PParticleContainer<>>( &leaf1, &pleaf2, 1); FP2PRT<FReal>::FullRemote<FP2PParticleContainer<>>( &leaf1, &pleaf2, 1);
timer.tac(); timer.tac();
std::cout << "Timer taken by FullRemote = " << timer.elapsed() << "s" << std::endl; std::cout << "Timer taken by FullRemote = " << timer.elapsed() << "s" << std::endl;
......
...@@ -130,12 +130,9 @@ int main(int argc, char ** argv){ ...@@ -130,12 +130,9 @@ int main(int argc, char ** argv){
// ---------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------
// //
// computation // computation
// //
#ifdef ScalFMM_USE_DOUBLE_PRECISION printf("Precision, sizeof Real %lu\n", sizeof(FReal));
printf("Double precision \n");
#else
printf("Simple precision \n");
#endif
#ifdef ScalFMM_USE_AVX #ifdef ScalFMM_USE_AVX
printf("AVX incomming .......\n\n"); printf("AVX incomming .......\n\n");
#endif #endif
...@@ -158,7 +155,7 @@ int main(int argc, char ** argv){ ...@@ -158,7 +155,7 @@ int main(int argc, char ** argv){
FTreeCoordinate coord = iterator.getCurrentGlobalCoordinate(); FTreeCoordinate coord = iterator.getCurrentGlobalCoordinate();
ContainerClass** neighbors = new ContainerClass*[27]; ContainerClass** neighbors = new ContainerClass*[27];
tree.getLeafsNeighbors(neighbors,coord,1); tree.getLeafsNeighbors(neighbors,coord,1);
FP2PR::FullMutual(iterator.getCurrentLeaf()->getTargets(),neighbors,27); FP2PRT<FReal>::FullMutual<ContainerClass>(iterator.getCurrentLeaf()->getTargets(),neighbors,27);
}while(iterator.moveRight()); }while(iterator.moveRight());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment