Commit 8431ae74 authored by berenger-bramas's avatar berenger-bramas

Block blas WIP

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@415 2616d619-271b-44dc-8df4-d4a8f33a7222
parent caefec11
......@@ -173,6 +173,10 @@ private:
FDEBUG(computationCounter.tac());
} while(octreeIterator.moveRight());
FDEBUG(computationCounter.tic());
kernels->finishedLevelM2L(idxLevel);
FDEBUG(computationCounter.tac());
avoidGotoLeftIterator.moveDown();
octreeIterator = avoidGotoLeftIterator;
}
......
......@@ -28,9 +28,9 @@ protected:
/** A interaction properties */
struct ComputationPair {
FComplexe* FRestrict pole;
const FComplexe* FRestrict pole;
FComplexe* FRestrict local;
explicit ComputationPair(FComplexe* inPole = 0, FComplexe* inLocal = 0)
explicit ComputationPair(const FComplexe* const inPole = 0, FComplexe*const inLocal = 0)
: pole(inPole), local(inLocal) {}
};
......@@ -108,7 +108,7 @@ public:
* @param inBoxWidth the size of the simulation box
* @param inPeriodicLevel the number of level upper to 0 that will be requiried
*/
FSphericalBlockBlasKernel(const int inDevP, const int inTreeHeight, const FReal inBoxWidth, const F3DPosition& inBoxCenter, const int inBlockSize = 100, const int inPeriodicLevel = 0)
FSphericalBlockBlasKernel(const int inDevP, const int inTreeHeight, const FReal inBoxWidth, const F3DPosition& inBoxCenter, const int inBlockSize = 1000, const int inPeriodicLevel = 0)
: Parent(inDevP, inTreeHeight, inBoxWidth, inBoxCenter, inPeriodicLevel),
FF_MATRIX_ROW_DIM(Parent::harmonic.getExpSize()), FF_MATRIX_COLUMN_DIM(Parent::harmonic.getNExpSize()),
FF_MATRIX_SIZE(FF_MATRIX_ROW_DIM * FF_MATRIX_COLUMN_DIM),
......@@ -212,21 +212,25 @@ public:
// Copy original vector and compute exp2nexp
FMemUtils::copyall<FComplexe>(&multipoleMatrix[idxInter * FF_MATRIX_COLUMN_DIM],
interactions[interactionIndex][idxInter].pole, CellClass::GetPoleSize());
// Get a computable vector
preExpNExp(&multipoleMatrix[idxInter * FF_MATRIX_COLUMN_DIM]);
}
FBlas::c_gemmtva(
FBlas::c_gemtm(
static_cast<unsigned int>(FF_MATRIX_COLUMN_DIM),
static_cast<unsigned int>(FF_MATRIX_ROW_DIM),
static_cast<unsigned int>(interactions[interactionIndex].getSize()),
FReal(1.0),
(FReal*)&preM2LTransitions[inLevel + Parent::periodicLevels][interactionIndex * FF_MATRIX_SIZE],
static_cast<unsigned int>(FF_MATRIX_COLUMN_DIM),
(FReal*)multipoleMatrix,
(FReal*)localMatrix);
static_cast<unsigned int>(FF_MATRIX_COLUMN_DIM),
(FReal*)localMatrix,
static_cast<unsigned int>(FF_MATRIX_ROW_DIM));
for(int idxInter = 0 ; idxInter < interactions[interactionIndex].getSize() ; ++idxInter){
FMemUtils::addall<FComplexe>(interactions[interactionIndex][idxInter].local, &localMatrix[idxInter * FF_MATRIX_ROW_DIM], FF_MATRIX_ROW_DIM);
FMemUtils::addall<FComplexe>(interactions[interactionIndex][idxInter].local, &localMatrix[idxInter * FF_MATRIX_ROW_DIM], FF_MATRIX_ROW_DIM);
}
interactions[interactionIndex].clear();
......
......@@ -64,17 +64,17 @@ namespace FMemUtils {
/** copy all value from one vector to the other */
template <class TypeClass>
void copyall(TypeClass*const dest, const TypeClass*const source, const int nbElements){
for(int idx = 0 ; idx < nbElements ; ++idx){
dest[idx] = source[idx];
void copyall(TypeClass* dest, const TypeClass* source, int nbElements){
for(; 0 < nbElements ; --nbElements){
(*dest++) = (*source++);
}
}
/** copy all value from one vector to the other */
template <class TypeClass>
void addall(TypeClass*const dest, const TypeClass*const source, const int nbElements){
for(int idx = 0 ; idx < nbElements ; ++idx){
dest[idx] += source[idx];
void addall(TypeClass* dest, const TypeClass* source, int nbElements){
for(; 0 < nbElements ; --nbElements){
(*dest++) += (*source++);
}
}
......
......@@ -28,6 +28,7 @@
#include "../Src/Kernels/FSphericalBlockBlasKernel.hpp"
#include "../Src/Kernels/FSphericalParticle.hpp"
#include "../Src/Kernels/FSphericalCell.hpp"
#include "../Src/Files/FFmaScanfLoader.hpp"
......@@ -38,93 +39,11 @@
*/
class PointingSphericalCell : public FBasicCell {
protected:
static int DevP;
static int LocalSize;
static int PoleSize;
static bool UseBlas;
FComplexe* multipole_exp; //< For multipole extenssion
FComplexe* local_exp; //< For local extenssion
public:
static void Init(const int inDevP, const bool inUseBlas = false){
DevP = inDevP;
const int ExpP = int((inDevP+1) * (inDevP+2) * 0.5);
const int NExpP = (inDevP+1) * (inDevP+1);
LocalSize = ExpP;
if(inUseBlas) {
PoleSize = NExpP;
}
else{
PoleSize = ExpP;
}
}
static int GetLocalSize(){
return LocalSize;
}
static int GetPoleSize(){
return PoleSize;
}
/** Default constructor */
PointingSphericalCell()
: multipole_exp(0), local_exp(0){
//multipole_exp = new FComplexe[PoleSize];
local_exp = new FComplexe[LocalSize];
}
/** Default destructor */
virtual ~PointingSphericalCell(){
//delete[] multipole_exp;
delete[] local_exp;
}
/** Copy constructor */
PointingSphericalCell& operator=(const PointingSphericalCell& other) {
FMemUtils::copyall(multipole_exp, other.multipole_exp, PoleSize);
FMemUtils::copyall(local_exp, other.local_exp, LocalSize);
return *this;
}
/** Set Multipole adresse */
const void setMultipole(FComplexe*const inMultipole){
multipole_exp = inMultipole;
}
/** Get Multipole */
const FComplexe* getMultipole() const {
return multipole_exp;
}
/** Get Local */
const FComplexe* getLocal() const {
return local_exp;
}
/** Get Multipole */
FComplexe* getMultipole() {
return multipole_exp;
}
/** Get Local */
FComplexe* getLocal() {
return local_exp;
}
};
int PointingSphericalCell::DevP(-1);
int PointingSphericalCell::LocalSize(-1);
int PointingSphericalCell::PoleSize(-1);
// Simply create particles and try the kernels
int main(int argc, char ** argv){
typedef FSphericalParticle ParticleClass;
typedef PointingSphericalCell CellClass;
typedef FSphericalCell CellClass;
typedef FVector<ParticleClass> ContainerClass;
typedef FSimpleLeaf<ParticleClass, ContainerClass > LeafClass;
......@@ -150,7 +69,7 @@ int main(int argc, char ** argv){
}
// -----------------------------------------------------
CellClass::Init(DevP);
CellClass::Init(DevP, true);
OctreeClass tree(NbLevels, SizeSubLevels,loader.getBoxWidth(),loader.getCenterOfBox());
// -----------------------------------------------------
......@@ -164,30 +83,6 @@ int main(int argc, char ** argv){
counter.tac();
std::cout << "Done " << "(@Creating and Inserting Particles = " << counter.elapsed() << "s)." << std::endl;
// ---------------------------------------------
int cellsPerLevel[NbLevels];
tree.getNbCellsPerLevel(cellsPerLevel);
FComplexe* matrix[NbLevels];
memset(matrix, 0, sizeof(FComplexe*) * NbLevels);
{
OctreeClass::Iterator octreeIterator(&tree);
octreeIterator.gotoBottomLeft();
OctreeClass::Iterator avoidGoLeft(octreeIterator);
for(int idxLevel = NbLevels - 1 ; idxLevel > 0; --idxLevel ){
matrix[idxLevel] = new FComplexe[CellClass::GetPoleSize() * cellsPerLevel[idxLevel]];
int poleIndex = 0;
do{
octreeIterator.getCurrentCell()->setMultipole(&matrix[idxLevel][poleIndex]);
poleIndex += CellClass::GetPoleSize();
} while(octreeIterator.moveRight());
avoidGoLeft.moveUp();
octreeIterator = avoidGoLeft;
}
}
// -----------------------------------------------------
std::cout << "Working on particles ..." << std::endl;
......@@ -201,12 +96,6 @@ int main(int argc, char ** argv){
counter.tac();
std::cout << "Done " << "(@Algorithm = " << counter.elapsed() << "s)." << std::endl;
// ---------------------------------------------
FMemUtils::DeleteAll(matrix, NbLevels);
// ---------------------------------------------
{ // get sum forces&potential
FReal potential = 0;
F3DPosition forces;
......
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