Commit 6be4be63 authored by Quentin Khan's avatar Quentin Khan
Browse files

Change interface to be compatible with GroupTree

parent ec08420a
......@@ -273,24 +273,24 @@ public:
const ContainerClass* const SourceParticles)
{
CellData symb {LeafCell->getLevel(), static_cast<std::size_t>(LeafCell->getMortonIndex())};
this->P2M(&LeafCell->multipole, &symb, SourceParticles);
this->P2M(LeafCell->up, &symb, SourceParticles);
}
void L2P(const CellClass* const LeafCell,
ContainerClass* const TargetParticles)
{
CellData symb {LeafCell->getLevel(), static_cast<std::size_t>(LeafCell->getMortonIndex())};
this->L2P(&LeafCell->local_expansion, &symb, TargetParticles);
this->L2P(LeafCell->down, &symb, TargetParticles);
}
void P2L(CellClass* const local, const ContainerClass* const particles) {
CellData symb {local->getLevel(), static_cast<std::size_t>(local->getMortonIndex())};
return this->P2L(&local->local_expansion, &symb , particles);
return this->P2L(local->down, &symb , particles);
}
void M2P(const CellClass* const pole, ContainerClass* const particles) {
CellData symb {pole->getLevel(), static_cast<std::size_t>(pole->getMortonIndex())};
return this->M2P(&pole->multipole, &symb , particles);
return this->M2P(pole->up, &symb , particles);
}
};
......
......@@ -179,13 +179,13 @@ private:
starpu_variable_data_register(
&(this->multipole),
STARPU_MAIN_RAM,
reinterpret_cast<uintptr_t>(&(n->getData()->multipole)),
sizeof(n->getData()->multipole));
reinterpret_cast<uintptr_t>(n->getData()->up),
sizeof(typename node_t::data_t::multipole_t));
starpu_variable_data_register(
&(this->local_exp),
STARPU_MAIN_RAM,
reinterpret_cast<uintptr_t>(&(n->getData()->local_expansion)),
sizeof(n->getData()->local_expansion));
reinterpret_cast<uintptr_t>(n->getData()->down),
sizeof(typename node_t::data_t::local_expansion_t));
if(n->is_leaf()) {
starpu_variable_data_register(
&(this->particles),
......
......@@ -15,6 +15,30 @@ struct alignas(FStarPUDefaultAlign::StructAlign) FUnifCellPODPole {
static const int TransformedVectorSize = (2*ORDER-1)*(2*ORDER-1)*(2*ORDER-1);
FReal multipole_exp[NRHS * NVALS * VectorSize]; //< Multipole expansion
FComplex<FReal> transformed_multipole_exp[NRHS * NVALS * TransformedVectorSize];
/** Get Multipole */
const FReal* getMultipole(const int inRhs) const
{ return this->multipole_exp + inRhs*this->VectorSize;
}
/** Get Multipole */
FReal* getMultipole(const int inRhs){
return this->multipole_exp + inRhs*this->VectorSize;
}
/** To get the leading dim of a vec */
int getVectorSize() const{
return this->VectorSize;
}
/** Get Transformed Multipole */
const FComplex<FReal>* getTransformedMultipole(const int inRhs) const{
return this->transformed_multipole_exp + inRhs*this->TransformedVectorSize;
}
/** Get Transformed Multipole */
FComplex<FReal>* getTransformedMultipole(const int inRhs){
return this->transformed_multipole_exp + inRhs*this->TransformedVectorSize;
}
/** To get the leading dim of a vec */
int getTransformedVectorSize() const{
return this->TransformedVectorSize;
}
};
template <class FReal, int ORDER, int NRHS = 1, int NLHS = 1, int NVALS = 1>
......@@ -23,15 +47,43 @@ struct alignas(FStarPUDefaultAlign::StructAlign) FUnifCellPODLocal {
static const int TransformedVectorSize = (2*ORDER-1)*(2*ORDER-1)*(2*ORDER-1);
FComplex<FReal> transformed_local_exp[NLHS * NVALS * TransformedVectorSize];
FReal local_exp[NLHS * NVALS * VectorSize]; //< Local expansion
/** Get Local */
const FReal* getLocal(const int inRhs) const{
return this->local_exp + inRhs*this->VectorSize;
}
/** Get Local */
FReal* getLocal(const int inRhs){
return this->local_exp + inRhs*this->VectorSize;
}
/** To get the leading dim of a vec */
int getVectorSize() const{
return this->VectorSize;
}
/** Get Transformed Local */
const FComplex<FReal>* getTransformedLocal(const int inRhs) const{
return this->transformed_local_exp + inRhs*this->TransformedVectorSize;
}
/** Get Transformed Local */
FComplex<FReal>* getTransformedLocal(const int inRhs){
return this->transformed_local_exp + inRhs*this->TransformedVectorSize;
}
/** To get the leading dim of a vec */
int getTransformedVectorSize() const{
return this->TransformedVectorSize;
}
};
template <class FReal, int ORDER, int NRHS = 1, int NLHS = 1, int NVALS = 1>
class FUnifCellPOD {
public:
FUnifCellPODCore* symb;
FUnifCellPODPole<FReal,ORDER,NRHS,NLHS,NVALS>* up;
FUnifCellPODLocal<FReal,ORDER,NRHS,NLHS,NVALS>* down;
public:
using multipole_t = FUnifCellPODPole<FReal,ORDER,NRHS,NLHS,NVALS>;
using local_expansion_t = FUnifCellPODLocal<FReal,ORDER,NRHS,NLHS,NVALS>;
FUnifCellPOD(FUnifCellPODCore* inSymb, FUnifCellPODPole<FReal,ORDER,NRHS,NLHS,NVALS>* inUp,
FUnifCellPODLocal<FReal,ORDER,NRHS,NLHS,NVALS>* inDown): symb(inSymb), up(inUp), down(inDown){
}
......
......@@ -76,15 +76,18 @@ public:
};
multipole_t multipole;
local_expansion_t local_expansion;
multipole_t m_data;
local_expansion_t l_data;
multipole_t* up = &m_data;
local_expansion_t* down = &l_data;
FUnifCell(){
memset(multipole.multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize);
memset(local_expansion.local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize);
memset(multipole.transformed_multipole_exp, 0,
memset(up->multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize);
memset(down->local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize);
memset(up->transformed_multipole_exp, 0,
sizeof(FComplex<FReal>) * NRHS * NVALS * TransformedVectorSize);
memset(local_expansion.transformed_local_exp, 0,
memset(down->transformed_local_exp, 0,
sizeof(FComplex<FReal>) * NLHS * NVALS * TransformedVectorSize);
}
......@@ -92,19 +95,19 @@ public:
/** Get Multipole */
const FReal* getMultipole(const int inRhs) const
{ return this->multipole.getMultipole(inRhs); }
{ return this->up->getMultipole(inRhs); }
/** Get Local */
const FReal* getLocal(const int inRhs) const{
return this->local_expansion.local_exp + inRhs*VectorSize;
return this->down->local_exp + inRhs*VectorSize;
}
/** Get Multipole */
FReal* getMultipole(const int inRhs){
return this->multipole.getMultipole(inRhs);
return this->up->getMultipole(inRhs);
}
/** Get Local */
FReal* getLocal(const int inRhs){
return this->local_expansion.local_exp + inRhs*VectorSize;
return this->down->local_exp + inRhs*VectorSize;
}
/** To get the leading dim of a vec */
......@@ -114,20 +117,20 @@ public:
/** Get Transformed Multipole */
const FComplex<FReal>* getTransformedMultipole(const int inRhs) const{
return this->multipole.transformed_multipole_exp + inRhs*TransformedVectorSize;
return this->up->transformed_multipole_exp + inRhs*TransformedVectorSize;
}
/** Get Transformed Local */
const FComplex<FReal>* getTransformedLocal(const int inRhs) const{
return this->local_expansion.transformed_local_exp + inRhs*TransformedVectorSize;
return this->down->transformed_local_exp + inRhs*TransformedVectorSize;
}
/** Get Transformed Multipole */
FComplex<FReal>* getTransformedMultipole(const int inRhs){
return this->multipole.transformed_multipole_exp + inRhs*TransformedVectorSize;
return this->up->transformed_multipole_exp + inRhs*TransformedVectorSize;
}
/** Get Transformed Local */
FComplex<FReal>* getTransformedLocal(const int inRhs){
return this->local_expansion.transformed_local_exp + inRhs*TransformedVectorSize;
return this->down->transformed_local_exp + inRhs*TransformedVectorSize;
}
/** To get the leading dim of a vec */
......@@ -137,11 +140,11 @@ public:
/** Make it like the begining */
void resetToInitialState(){
memset(multipole.multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize);
memset(local_expansion.local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize);
memset(multipole.transformed_multipole_exp, 0,
memset(up->multipole_exp, 0, sizeof(FReal) * NRHS * NVALS * VectorSize);
memset(down->local_exp, 0, sizeof(FReal) * NLHS * NVALS * VectorSize);
memset(up->transformed_multipole_exp, 0,
sizeof(FComplex<FReal>) * NRHS * NVALS * TransformedVectorSize);
memset(local_expansion.transformed_local_exp, 0,
memset(down->transformed_local_exp, 0,
sizeof(FComplex<FReal>) * NLHS * NVALS * TransformedVectorSize);
}
......@@ -150,26 +153,26 @@ public:
///////////////////////////////////////////////////////
template <class BufferWriterClass>
void serializeUp(BufferWriterClass& buffer) const{
buffer.write(multipole.multipole_exp, VectorSize*NVALS*NRHS);
buffer.write(multipole.transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS);
buffer.write(up->multipole_exp, VectorSize*NVALS*NRHS);
buffer.write(up->transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS);
}
template <class BufferReaderClass>
void deserializeUp(BufferReaderClass& buffer){
buffer.fillArray(multipole.multipole_exp, VectorSize*NVALS*NRHS);
buffer.fillArray(multipole.transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS);
buffer.fillArray(up->multipole_exp, VectorSize*NVALS*NRHS);
buffer.fillArray(up->transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS);
}
template <class BufferWriterClass>
void serializeDown(BufferWriterClass& buffer) const{
buffer.write(local_expansion.local_exp, VectorSize*NVALS*NLHS);
buffer.write(local_expansion.transformed_local_exp, TransformedVectorSize*NVALS*NLHS);
buffer.write(down->local_exp, VectorSize*NVALS*NLHS);
buffer.write(down->transformed_local_exp, TransformedVectorSize*NVALS*NLHS);
}
template <class BufferReaderClass>
void deserializeDown(BufferReaderClass& buffer){
buffer.fillArray(local_expansion.local_exp, VectorSize*NVALS*NLHS);
buffer.fillArray(local_expansion.transformed_local_exp, TransformedVectorSize*NVALS*NLHS);
buffer.fillArray(down->local_exp, VectorSize*NVALS*NLHS);
buffer.fillArray(down->transformed_local_exp, TransformedVectorSize*NVALS*NLHS);
}
///////////////////////////////////////////////////////
......@@ -178,19 +181,19 @@ public:
template <class BufferWriterClass>
void save(BufferWriterClass& buffer) const{
FBasicCell::save(buffer);
buffer.write(multipole.multipole_exp, VectorSize*NVALS*NRHS);
buffer.write(multipole.transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS);
buffer.write(local_expansion.local_exp, VectorSize*NVALS*NLHS);
buffer.write(local_expansion.transformed_local_exp, TransformedVectorSize*NVALS*NLHS);
buffer.write(up->multipole_exp, VectorSize*NVALS*NRHS);
buffer.write(up->transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS);
buffer.write(down->local_exp, VectorSize*NVALS*NLHS);
buffer.write(down->transformed_local_exp, TransformedVectorSize*NVALS*NLHS);
}
template <class BufferReaderClass>
void restore(BufferReaderClass& buffer){
FBasicCell::restore(buffer);
buffer.fillArray(multipole.multipole_exp, VectorSize*NVALS*NRHS);
buffer.fillArray(multipole.transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS);
buffer.fillArray(local_expansion.local_exp, VectorSize*NVALS*NLHS);
buffer.fillArray(local_expansion.transformed_local_exp, TransformedVectorSize*NVALS*NLHS);
buffer.fillArray(up->multipole_exp, VectorSize*NVALS*NRHS);
buffer.fillArray(up->transformed_multipole_exp, TransformedVectorSize*NVALS*NRHS);
buffer.fillArray(down->local_exp, VectorSize*NVALS*NLHS);
buffer.fillArray(down->transformed_local_exp, TransformedVectorSize*NVALS*NLHS);
}
FSize getSavedSize() const {
......
......@@ -110,8 +110,8 @@ public:
{
std::array<const typename CellClass::multipole_t*, 8> child_multipoles;
std::transform(ChildCells, ChildCells+8, child_multipoles.data(),
[](const CellClass * data) {return data ? &(data->multipole) : nullptr;});
this->M2M(&(ParentCell->multipole), child_multipoles.data(), TreeLevel);
[](const CellClass * data) {return data ? data->up : nullptr;});
this->M2M(ParentCell->up, child_multipoles.data(), TreeLevel);
}
void M2M(typename CellClass::multipole_t* const FRestrict ParentMultipole,
......@@ -183,8 +183,8 @@ public:
{
std::array<typename CellClass::local_expansion_t*, 8> child_expansions;
std::transform(ChildCells, ChildCells+8, child_expansions.data(),
[](CellClass * data) {return data ? &(data->local_expansion) : nullptr;});
this->L2L(&(ParentCell->local_expansion), child_expansions.data(), TreeLevel);
[](CellClass * data) {return data ? data->down : nullptr;});
this->L2L(ParentCell->down, child_expansions.data(), TreeLevel);
}
......
......@@ -8,8 +8,11 @@
#include <tuple>
#include <array>
#include <unordered_map>
#include <vector>
#include <mutex>
#include <thread>
#include <chrono>
#include "Containers/FTreeCoordinate.hpp"
#include "Components/FBasicParticle.hpp"
......@@ -44,13 +47,16 @@ struct TestCountNodeData : FBasicCell {
struct multipole_t {
std::size_t dummy = 0;
std::size_t up = 0;
} multipole;
} m_data;
/// Local development particle interaction count
struct local_expansion_t {
std::size_t down = 0;
std::size_t dummy = 0;
} local_expansion;
} l_data;
multipole_t* up;
local_expansion_t* down;
};
......@@ -64,6 +70,7 @@ struct FCountKernel {
std::mutex mtx;
bool is_main_kernel = true;
int tmp = 0;
std::unordered_map<std::string, std::size_t> call_count;
......@@ -121,7 +128,7 @@ struct FCountKernel {
void P2M(CellClass* const leaf_data,
const ContainerClass* const source_particle_container)
{
this->P2M(&(leaf_data->multipole), (void*)nullptr, source_particle_container);
this->P2M(leaf_data->up, (void*)nullptr, source_particle_container);
}
/** \brief Particle to multipole operator
......@@ -139,7 +146,9 @@ struct FCountKernel {
mtx.lock();
this->call_count["P2M"] += 1;
mtx.unlock();
leaf_multipole->dummy += 1;
leaf_multipole->up += source_particle_container->size();
leaf_multipole->dummy -= 1;
}
......@@ -158,22 +167,28 @@ struct FCountKernel {
{
std::array<const typename CellClass::multipole_t*, child_count> child_multipoles;
std::transform(child_data, child_data+child_count, child_multipoles.data(),
[](const CellClass * data) {return &(data->multipole);});
this->M2M(&(node_data->multipole), child_multipoles.data(), level);
[](const CellClass * data) {return data ? data->up : nullptr;});
return this->M2M(node_data->up, child_multipoles.data(), level);
}
void M2M(typename CellClass::multipole_t * const node_multipole,
const typename CellClass::multipole_t * const * const children_multipole,
const int /*level*/)
const int level)
{
mtx.lock();
this->call_count["M2M"] += 1;
mtx.unlock();
node_multipole->dummy++;
for(std::size_t idx = 0 ; idx < child_count ; ++idx) {
if(children_multipole[idx]) {
node_multipole->up += children_multipole[idx]->up;
if(children_multipole[idx]->dummy) {
std::cerr << "P2M/M2M parallelism overlap... lvl:" << level << "\n";
std::cerr << children_multipole[idx]->dummy << '\n';
}
}
}
node_multipole->dummy--;
}
......@@ -199,7 +214,10 @@ struct FCountKernel {
this->call_count["M2L"] += v_item_data_size;
for(int idx = 0 ; idx < v_item_data_size ; ++idx) {
if(v_item_data[idx]) {
node_data->local_expansion.down += v_item_data[idx]->multipole.up;
if(v_item_data[idx]->up->dummy) {
std::cerr << "M2M/M2L parallelism overlap...\n";
}
node_data->down->down += v_item_data[idx]->up->up;
}
}
}
......@@ -234,8 +252,8 @@ struct FCountKernel {
{
std::array<typename CellClass::local_expansion_t*, child_count> child_local_exps;
std::transform(child_data, child_data+child_count, child_local_exps.data(),
[](CellClass * data) {return data ? &(data->local_expansion) : nullptr;});
this->L2L(&(node_data->local_expansion), child_local_exps.data(), level);
[](CellClass * data) {return data ? data->down : nullptr;});
this->L2L(node_data->down, child_local_exps.data(), level);
}
void L2L(const typename CellClass::local_expansion_t* const node_local_exp,
......@@ -263,7 +281,7 @@ struct FCountKernel {
void P2L(CellClass* const node_data,
const ContainerClass* const source_particle_container)
{
this->P2L(&node_data->local_expansion, (void*)nullptr, source_particle_container);
this->P2L(node_data->down, (void*)nullptr, source_particle_container);
}
template<class Symb>
......@@ -287,7 +305,7 @@ struct FCountKernel {
void L2P(const CellClass* const leaf_data,
ContainerClass* const target_particle_container)
{
this->L2P(&leaf_data->local_expansion,(void*)nullptr, target_particle_container);
this->L2P(leaf_data->down,(void*)nullptr, target_particle_container);
}
template<class Symb>
......@@ -313,7 +331,7 @@ struct FCountKernel {
void M2P(const CellClass* const node_data,
ContainerClass* const target_particle_container)
{
this->M2P(&node_data->multipole, (void*)nullptr, target_particle_container);
this->M2P(node_data->up, (void*)nullptr, target_particle_container);
}
template<class Symb>
......
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