Commit d153ff9a authored by Quentin Khan's avatar Quentin Khan

Update adaptive tests to recent dev

parent de4d2b1d
......@@ -140,21 +140,22 @@ struct FCountKernel {
}
template<class Symb>
void M2M(typename CellClass::multipole_t * const node_multipole,
const typename CellClass::multipole_t * const * const children_multipole,
const int level)
const Symb* const node_symbolic_data ,
const typename CellClass::multipole_t * const * const child_multipoles,
const Symb* const /* child_symbolic_data */ [])
{
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';
if(child_multipoles[idx]) {
node_multipole->up += child_multipoles[idx]->up;
if(child_multipoles[idx]->dummy) {
std::cerr << "P2M/M2M parallelism overlap... lvl:" << node_symbolic_data->getLevel() << "\n";
std::cerr << child_multipoles[idx]->dummy << '\n';
}
}
}
......@@ -162,11 +163,13 @@ struct FCountKernel {
}
template<class Symb>
void M2L(typename CellClass::local_expansion_t* const node_local_expansion,
const Symb* const /*node_symbolic_data*/,
const typename CellClass::multipole_t* const v_item_multipoles[],
const Symb* const /*v_item_symbolic_data*/[],
const int /*position*/[],
const int v_item_data_size,
const int /*level*/)
const int v_item_data_size)
{
mtx.lock();
this->call_count["M2L"] += v_item_data_size;
......@@ -179,9 +182,11 @@ struct FCountKernel {
}
template<class Symb>
void L2L(const typename CellClass::local_expansion_t* const node_local_exp,
const Symb* const /*node_symbolic_data*/,
typename CellClass::local_expansion_t** const child_local_exps,
const int /*level*/)
const Symb* const /*child_symbolic_data*/[])
{
mtx.lock();
this->call_count["L2L"] += 1;
......@@ -197,7 +202,8 @@ struct FCountKernel {
template<class Symb>
void P2L(typename CellClass::local_expansion_t* const node_local_expansion,
const Symb* const /* node_symbolic_data */,
const ContainerClass* const source_particle_container)
const ContainerClass* const source_particle_container,
const Symb* const /* leaf_symbolic_data */)
{
mtx.lock();
this->call_count["P2L"] += 1;
......@@ -223,7 +229,8 @@ struct FCountKernel {
template<class Symb>
void M2P(const typename CellClass::multipole_t* const node_multipole,
const Symb* const /* node_symbolic_data */,
ContainerClass* const target_particle_container)
ContainerClass* const target_particle_container,
const Symb* const /* leaf_symbolic_data */)
{
mtx.lock();
this->call_count["M2P"] += 1;
......
/**
* \file
*
* \author Quentin Khan
*
* \brief Test program for the task adaptive FMM implementation
*
* Tests:
* - test 1, counts the particles that interact with each particle
* - TODO test computation of an actual kernel against sequential result
*
* ##### Test 1
*
* Fills an adaptive tree with mock particles. Those are made of a position and
* a count attribute set to 0.
*
* The algorithm is run with a kernel that counts the particles that interact.
*
* ###### Expected result
*
* At the end of the run, every particle must hold the total particle count in
* its count attribute.
*
*/
#include <iostream>
#include <string>
#include <vector>
#include "Files/FFmaGenericLoader.hpp"
#include "Components/FBasicParticle.hpp"
#include "Adaptive/new/FAdaptiveTask.hpp"
#include "Adaptive/new/FTree.hpp"
#include "Adaptive/new/FVariadicParticleContainer.hpp"
#include "FCountKernel.hpp"
template<typename tree_t, typename position_vector_t>
void test_particle_count(tree_t& tree, const position_vector_t& position_vector) {
for(auto&& leaf : tree.leaves()) {
for(auto particle : *(leaf->getParticleContainer())) {
if(std::get<tree_t::particle_t::COUNT>(particle) != position_vector.size())
std::cout << "error-particle-count "
<< leaf->getIndex() << " "
<< FTreeCoordinate(leaf->getIndex()) << " "
<< std::get<tree_t::particle_t::COUNT>(particle) << " "
<< position_vector.size()
<< std::endl;
}
}
}
int main() {
/// Floating point representation
using FReal = double;
/// Space dimension
constexpr std::size_t Dim = 3;
/// Particle type
using particle_t = TestCountParticle<FReal, Dim>;
/// Particle container type
using particle_container_t = FVariadicParticleContainer<particle_t>;
/// Node data type
using node_data_t = TestCountNodeData;
/// Adaptive tree type
using tree_t = FTree<particle_container_t, node_data_t>;
/// Kernel type
using kernel_t = FCountKernel<node_data_t, particle_container_t>;
/// FMM algorithm type
using fmm_algo_t = FAdaptiveTask<tree_t, kernel_t>;
// Load the test particle distribution
FFmaGenericLoader<FReal> loader("../Data/test20k.fma");
// Tree setup
tree_t tree({loader.getBoxWidth(), loader.getCenterOfBox()});
tree.leaf_max_particle_count(1);
std::vector<particle_t::position_t> position_vect;
// Load the particles into the list and the tree
for(int i = 0; i < loader.getNumberOfParticles(); ++i) {
FReal tmp_val;
typename particle_t::position_t tmp_pos;
loader.fillParticle(&tmp_pos, &tmp_val);
position_vect.push_back(tmp_pos);
tree.insert(tmp_pos, 0);
}
// Create kernel and FMM object
kernel_t kernel;
fmm_algo_t fmm_algo(&tree, &kernel);
// Run algorithm
fmm_algo.execute();
test_particle_count(tree, position_vect);
}
......@@ -24,6 +24,8 @@
#include "Adaptive/new/FVariadicParticleContainer.hpp"
#include "Kernels/Generic/FGenericData.hpp"
/** \brief Random position generator
*
* \tparam FReal Floating point number representation
......@@ -117,7 +119,7 @@ struct TestParticle : public FBasicParticle<FReal, 3> {
*
* Inheritance from FBasicCell is for the FUnifKernel.
*/
struct TestNodeData : public FBasicCell {};
using TestNodeData = FGenericData<int, int>;
/** \brief Noop matrix kernel
*
......@@ -145,6 +147,9 @@ int main(int argc, char** argv) {
using tree_t = FTree<particle_container_t, node_data_t>;
using matrix_kernel_t = FNoopMatrixFlopsKernel;
using kernel_t = FUnifFlopsKernel<ORDER, 1, matrix_kernel_t, node_data_t, particle_container_t>;
scalfmm::meta::check_adaptive_compatible<tree_t, kernel_t>();
using fmm_algo_t = FAdaptiveSequential<tree_t, kernel_t>;
// Process command line
......
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