Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 8fc0a545 authored by BRAMAS Berenger's avatar BRAMAS Berenger
Browse files

remove MPI loading file bug

parent 27bef454
No related branches found
No related tags found
No related merge requests found
...@@ -81,7 +81,7 @@ public: ...@@ -81,7 +81,7 @@ public:
MPI_Status status; MPI_Status status;
if( MPI_File_read(file, &sizeOfElement, 1, MPI_INT, &status) == MPI_SUCCESS if( MPI_File_read(file, &sizeOfElement, 1, MPI_INT, &status) == MPI_SUCCESS
&& MPI_File_read(file, &this->totalNbParticles, 1, MPI_LONG_LONG, &status) == MPI_SUCCESS && MPI_File_read(file, &this->totalNbParticles, 1, MPI_LONG_LONG, &status) == MPI_SUCCESS
&& MPI_File_read(file, xyzBoxWidth, 4, MPI_FLOAT, &status) == MPI_SUCCESS ){ && MPI_File_read(file, xyzBoxWidth, 4, FMpi::GetType(xyzBoxWidth[0]), &status) == MPI_SUCCESS ){
FLOG(if(sizeOfElement != sizeof(FReal)){) FLOG(if(sizeOfElement != sizeof(FReal)){)
FLOG( FLog::Controller.writeFromLine("Warning type size between file and FReal are differents\n", __LINE__, __FILE__); ) FLOG( FLog::Controller.writeFromLine("Warning type size between file and FReal are differents\n", __LINE__, __FILE__); )
...@@ -110,13 +110,7 @@ public: ...@@ -110,13 +110,7 @@ public:
// local number to read // local number to read
particles = new FReal[bufsize]; particles = new FReal[bufsize];
if( sizeof(FReal) == sizeof(float) ){ MPI_File_read_at(file, headDataOffSet + startPart * 4 * sizeof(FReal), particles, int(bufsize), FMpi::GetType(xyzBoxWidth[0]), &status);
MPI_File_read_at(file, headDataOffSet + startPart * 4 * sizeof(FReal), particles, int(bufsize), MPI_FLOAT, &status);
}
else{
MPI_File_read_at(file, headDataOffSet + startPart * 4 * sizeof(FReal), particles, int(bufsize), MPI_DOUBLE, &status);
}
// check if needed // check if needed
int count(0); int count(0);
...@@ -142,7 +136,6 @@ public: ...@@ -142,7 +136,6 @@ public:
FLOG( FLog::Controller.writeFromLine("Warning type size between file and FReal are differents\n", __LINE__, __FILE__); ) FLOG( FLog::Controller.writeFromLine("Warning type size between file and FReal are differents\n", __LINE__, __FILE__); )
FLOG(}) FLOG(})
removeWarning += fread(&this->totalNbParticles, sizeof(FSize), 1, file); removeWarning += fread(&this->totalNbParticles, sizeof(FSize), 1, file);
removeWarning += fread(&this->boxWidth, sizeof(FReal), 1, file); removeWarning += fread(&this->boxWidth, sizeof(FReal), 1, file);
this->boxWidth *= 2; this->boxWidth *= 2;
...@@ -160,6 +153,7 @@ public: ...@@ -160,6 +153,7 @@ public:
if(filesize/4 != this->totalNbParticles){ if(filesize/4 != this->totalNbParticles){
printf("Error fileSize %ld, nbPart %lld\n", filesize/4, this->totalNbParticles); printf("Error fileSize %ld, nbPart %lld\n", filesize/4, this->totalNbParticles);
exit(0);
} }
// in number of floats // in number of floats
...@@ -172,7 +166,10 @@ public: ...@@ -172,7 +166,10 @@ public:
fseek(file, long(headDataOffSet + startPart * 4 * sizeof(FReal)), SEEK_SET); fseek(file, long(headDataOffSet + startPart * 4 * sizeof(FReal)), SEEK_SET);
removeWarning += fread(particles, sizeof(FReal), int(bufsize), file); if( fread(particles, sizeof(FReal), int(bufsize), file) != unsigned(bufsize)){
printf("Error when reading file.\n");
exit(0);
}
fclose(file); fclose(file);
} }
...@@ -226,6 +223,10 @@ public: ...@@ -226,6 +223,10 @@ public:
* @param the particle to fill * @param the particle to fill
*/ */
void fillParticle(FPoint*const inParticlePositions, FReal*const inPhysicalValue){ void fillParticle(FPoint*const inParticlePositions, FReal*const inPhysicalValue){
if(nbParticles*4 <= idxParticles){
printf("Error you're loading too much particles.\n");
exit(0);
}
inParticlePositions->setPosition(particles[idxParticles],particles[idxParticles+1],particles[idxParticles+2]); inParticlePositions->setPosition(particles[idxParticles],particles[idxParticles+1],particles[idxParticles+2]);
(*inPhysicalValue) = (particles[idxParticles+3]); (*inPhysicalValue) = (particles[idxParticles+3]);
idxParticles += 4; idxParticles += 4;
......
...@@ -327,6 +327,11 @@ int main(int argc, char ** argv){ ...@@ -327,6 +327,11 @@ int main(int argc, char ** argv){
return 1; return 1;
} }
std::cout << "Simulation properties :\n";
std::cout << "Nb Particles " << loader.getNumberOfParticles() << "\n";
std::cout << "Box Width : " << loader.getBoxWidth() << "\n";
std::cout << "Box Center : " << loader.getCenterOfBox() << "\n";
// The real tree to work on // The real tree to work on
OctreeClass realTree(NbLevels, SizeSubLevels,loader.getBoxWidth(),loader.getCenterOfBox()); OctreeClass realTree(NbLevels, SizeSubLevels,loader.getBoxWidth(),loader.getCenterOfBox());
...@@ -371,7 +376,8 @@ int main(int argc, char ** argv){ ...@@ -371,7 +376,8 @@ int main(int argc, char ** argv){
else{ else{
FPoint position; FPoint position;
FReal physicalValue; FReal physicalValue;
for(FSize idxPart = 0 ; idxPart < loader.getNumberOfParticles() ; ++idxPart){ const FSize nbParticles = loader.getNumberOfParticles();
for(FSize idxPart = 0 ; idxPart < nbParticles ; ++idxPart){
loader.fillParticle(&position,&physicalValue); loader.fillParticle(&position,&physicalValue);
realTree.insert(position); realTree.insert(position);
} }
...@@ -384,10 +390,16 @@ int main(int argc, char ** argv){ ...@@ -384,10 +390,16 @@ int main(int argc, char ** argv){
OctreeClass treeValide(NbLevels, SizeSubLevels,loader.getBoxWidth(),loader.getCenterOfBox()); OctreeClass treeValide(NbLevels, SizeSubLevels,loader.getBoxWidth(),loader.getCenterOfBox());
{ {
FFmaBinLoader loaderSeq(filename); FFmaBinLoader loaderSeq(filename);
std::cout << "Simulation properties :\n";
std::cout << "Nb Particles " << loaderSeq.getNumberOfParticles() << "\n";
std::cout << "Box Width : " << loaderSeq.getBoxWidth() << "\n";
std::cout << "Box Center : " << loaderSeq.getCenterOfBox() << "\n";
FPoint position; FPoint position;
FReal physicalValue; FReal physicalValue;
for(FSize idxPart = 0 ; idxPart < loaderSeq.getNumberOfParticles() ; ++idxPart){ for(FSize idxPart = 0 ; idxPart < loaderSeq.getNumberOfParticles() ; ++idxPart){
loader.fillParticle(&position,&physicalValue); loaderSeq.fillParticle(&position,&physicalValue);
treeValide.insert(position); treeValide.insert(position);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment