Commit c61aaca5 authored by BRAMAS Berenger's avatar BRAMAS Berenger
Browse files

Add new classes to manage the capacities

parent 18c35280
......@@ -48,7 +48,7 @@ template <class OctreeClass, class CellContainerClass, class CellClass, class Ke
class CudaKernelClass = FCudaEmptyKernel<>
#endif
#ifdef ScalFMM_ENABLE_OPENCL_KERNEL
, class OpenCLDeviceWrapperClass = FOpenCLDeviceWrapper<KernelClass, nullptr>
, class OpenCLDeviceWrapperClass = FOpenCLDeviceWrapper<KernelClass>
#endif
>
class FGroupTaskStarPUMpiAlgorithm {
......
......@@ -18,58 +18,91 @@ public:
virtual bool supportP2P(const FStarPUTypes inPu) const = 0;
};
/**
* This is for the kernels that implement all the methods.
*/
template <class BaseClass>
class FStarPUAllYesCapacities : public BaseClass, public FStarPUKernelCapacities {
class FStarPUAbstractCapacities : public FStarPUKernelCapacities {
protected:
virtual bool check(const FStarPUTypes inPu) const = 0;
public:
using BaseClass::BaseClass;
bool supportP2M(const FStarPUTypes /*inPu*/) const override {
return true;
bool supportP2M(const FStarPUTypes inPu) const override {
return check(inPu);
}
bool supportM2M(const FStarPUTypes /*inPu*/) const override {
return true;
bool supportM2M(const FStarPUTypes inPu) const override {
return check(inPu);
}
bool supportM2L(const FStarPUTypes /*inPu*/) const override {
return true;
bool supportM2L(const FStarPUTypes inPu) const override {
return check(inPu);
}
bool supportL2L(const FStarPUTypes /*inPu*/) const override {
return true;
bool supportL2L(const FStarPUTypes inPu) const override {
return check(inPu);
}
bool supportL2P(const FStarPUTypes /*inPu*/) const override {
return true;
bool supportL2P(const FStarPUTypes inPu) const override {
return check(inPu);
}
bool supportP2P(const FStarPUTypes /*inPu*/) const override {
return true;
bool supportP2P(const FStarPUTypes inPu) const override {
return check(inPu);
}
};
/**
* This is for the kernels that implement all the methods.
*/
template <class BaseClass>
class FStarPUAllCpuCapacities : public BaseClass, public FStarPUKernelCapacities {
class FStarPUAllYesCapacities : public BaseClass, public FStarPUAbstractCapacities {
bool check(const FStarPUTypes inPu) const override{
return true;
}
public:
using BaseClass::BaseClass;
};
bool supportP2M(const FStarPUTypes inPu) const override {
return inPu == FSTARPU_CPU_IDX;
}
bool supportM2M(const FStarPUTypes inPu) const override {
template <class BaseClass>
class FStarPUAllCpuCapacities : public BaseClass, public FStarPUAbstractCapacities {
bool check(const FStarPUTypes inPu) const override{
return inPu == FSTARPU_CPU_IDX;
}
bool supportM2L(const FStarPUTypes inPu) const override {
return inPu == FSTARPU_CPU_IDX;
public:
using BaseClass::BaseClass;
};
#ifdef ScalFMM_ENABLE_CUDA_KERNEL
template <class BaseClass>
class FStarPUAllCudaCapacities : public BaseClass, public FStarPUAbstractCapacities {
bool check(const FStarPUTypes inPu) const override{
return inPu == FSTARPU_CUDA_IDX;
}
bool supportL2L(const FStarPUTypes inPu) const override {
return inPu == FSTARPU_CPU_IDX;
public:
using BaseClass::BaseClass;
};
template <class BaseClass>
class FStarPUAllCpuCudaCapacities : public BaseClass, public FStarPUAbstractCapacities {
bool check(const FStarPUTypes inPu) const override{
return inPu == FSTARPU_CPU_IDX || inPu == FSTARPU_CUDA_IDX;
}
bool supportL2P(const FStarPUTypes inPu) const override {
return inPu == FSTARPU_CPU_IDX;
public:
using BaseClass::BaseClass;
};
#endif
#ifdef ScalFMM_ENABLE_OPENCL_KERNEL
template <class BaseClass>
class FStarPUAllOpenCLCapacities : public BaseClass, public FStarPUAbstractCapacities {
bool check(const FStarPUTypes inPu) const override{
return inPu == FSTARPU_OPENCL_IDX;
}
bool supportP2P(const FStarPUTypes inPu) const override {
return inPu == FSTARPU_CPU_IDX;
public:
using BaseClass::BaseClass;
};
template <class BaseClass>
class FStarPUAllCpuOpenCLCapacities : public BaseClass, public FStarPUAbstractCapacities {
bool check(const FStarPUTypes inPu) const override {
return inPu == FSTARPU_CPU_IDX || inPu == FSTARPU_OPENCL_IDX;
}
public:
using BaseClass::BaseClass;
};
#endif
#endif // FSTARPUKERNELCAPACITIES_HPP
......@@ -68,7 +68,7 @@ int main(int argc, char* argv[]){
typedef FTestCell GroupCellClass;
typedef FGroupTestParticleContainer GroupContainerClass;
typedef FGroupTree< GroupCellClass, GroupContainerClass, 2, long long int> GroupOctreeClass;
typedef FStarPUAllYesCapacities<FTestKernels< GroupCellClass, GroupContainerClass >> GroupKernelClass;
typedef FStarPUAllCpuCudaCapacities<FTestKernels< GroupCellClass, GroupContainerClass >> GroupKernelClass;
typedef FGroupTaskStarPUAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, GroupCellClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupContainerClass
, FCudaGroupOfCells<sizeof(FTestCell)>, FCudaGroupOfParticles<2, long long int>, FCudaGroupAttachedLeaf<2, long long int>, FTestCudaKernels< FCudaGroupAttachedLeaf<2, long long int> > > GroupAlgorithm;
......
......@@ -57,7 +57,7 @@ int main(int argc, char* argv[]){
typedef FTestCell GroupCellClass;
typedef FGroupTestParticleContainer GroupContainerClass;
typedef FGroupTree< GroupCellClass, GroupContainerClass, 2, long long int> GroupOctreeClass;
typedef FStarPUAllYesCapacities<FTestKernels< GroupCellClass, GroupContainerClass >> GroupKernelClass;
typedef FStarPUAllCpuOpenCLCapacities<FTestKernels< GroupCellClass, GroupContainerClass >> GroupKernelClass;
typedef FGroupTaskStarPUAlgorithm<GroupOctreeClass, typename GroupOctreeClass::CellGroupClass, GroupCellClass, GroupKernelClass, typename GroupOctreeClass::ParticleGroupClass, GroupContainerClass
#ifdef ScalFMM_ENABLE_CUDA_KERNEL
, FCudaGroupOfCells<0>, FCudaGroupOfParticles<0, int>, FCudaGroupAttachedLeaf<0, int>, FCudaEmptyKernel<>
......
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