berenger-eu / tbfmm

Task-based fast multipole method, parallelized using OpenMP and StarPU. With StarPU it supports multiple GPUs (CUDA).
Other
9 stars 3 forks source link

After tree rebuild, particle position data is malformed #2

Closed michaelrampl closed 3 years ago

michaelrampl commented 3 years ago

If you just take the example kernel and print out all positions at the end (add this snippet at the end of the main function), you will end up with malformed positions after the first tree rebuild.

for (int i = 0; i < 2; i++)
{
    tree.applyToAllLeaves([](auto &leafHeader, const long int *particleIndexes,
                                const std::array<ParticleDataType *, NbDataValuesPerParticle> particleDataPtr,
                                const std::array<ParticleRhsType *, NbRhsValuesPerParticle> particleRhsPtr)
                            {
                                for (long int idxPart = 0; idxPart < leafHeader.nbParticles; ++idxPart)
                                {
                                    printf("* %f, %f, %f\n", particleDataPtr[0][idxPart], particleDataPtr[1][idxPart], particleDataPtr[2][idxPart]);
                                }
                            });
    printf("----------\n");
    tree.rebuild();
    algorithm.execute(tree);
}

After executing this, I get the following output

* 0.297535, 0.056713, 0.272656
* 0.140351, 0.870087, 0.473608
* 0.392785, 0.836079, 0.337396
* 0.477665, 0.812169, 0.479977
* 0.758616, 0.105908, 0.473600
* 0.648172, 0.368242, 0.957155
* 0.847252, 0.623564, 0.384382
* 0.720633, 0.582020, 0.537373
* 0.592845, 0.844266, 0.857946
* 0.800911, 0.520477, 0.678880
----------
* 0.000000, 0.000000, 0.000000
* 0.000000, 0.000000, 0.000000
* 0.000000, 0.000000, 0.000000
* 0.000000, 0.000000, 0.000000
* 0.758616, 0.000000, 0.000000
* 0.847252, 0.297535, 0.473608
* 0.537373, 0.140351, 0.800911
* 0.857946, 0.384382, 0.870087
* 0.592845, 0.847252, 0.297535
* 0.844266, 0.623564, 0.140351

There, you can clearly see, that not only have the first 4 rows been cleared, also the other values are completely mixed up or even malformed.

The issue happens on both gcc 11.1.1 and clang 12.0.0 regardless if OpenMP has been used or not.

berenger-eu commented 3 years ago

@michaelrampl Thanks a lot for your feedback! Indeed, I was having a dumb error, and it seems to be fixed. I close the issue.

michaelrampl commented 3 years ago

@berenger-eu I confirm the that the issue has been fixed! Many thanks for the quick response and the excellent library :+1: