Created
February 28, 2011 23:54
-
-
Save zonca/848310 to your computer and use it in GitHub Desktop.
Trilinos VbrMatrix ram usage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g++ -O2 testVBR.cpp -ltrilinos_epetra -I/usr/include/trilinos/ -I/usr/include/openmpi -o testVBR && mpirun -n 2 ./testVBR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include "Epetra_ConfigDefs.h" | |
#ifdef HAVE_MPI | |
#include "mpi.h" | |
#include "Epetra_MpiComm.h" | |
#else | |
#include "Epetra_SerialComm.h" | |
#endif | |
#include "Epetra_BlockMap.h" | |
#include "Epetra_VbrMatrix.h" | |
using namespace std; | |
int log(int MyPID, string message) { | |
if( MyPID == 0 ) { | |
cout << "******** " << message << endl << endl << flush; | |
} | |
return true; | |
} | |
int main(int argc, char *argv[]) | |
{ | |
#ifdef HAVE_MPI | |
MPI_Init(&argc, &argv); | |
Epetra_MpiComm Comm(MPI_COMM_WORLD); | |
#else | |
Epetra_SerialComm Comm; | |
#endif | |
int err; | |
int MyPID = Comm.MyPID(); | |
log(MyPID, "Declaring Map"); | |
Epetra_BlockMap Map(5e6,1,0,Comm); | |
//RAM 6MB/proc | |
cout << MyPID << ":" << Map.MinMyGID() << " " << Map.NumMyElements() << endl; | |
log(MyPID, "Before declaring P"); | |
sleep(4); | |
Epetra_VbrMatrix P(Copy,Map,1); | |
log(MyPID, "After declaring P"); | |
sleep(4); //RAM 140MB/proc | |
double * Values; | |
Values = new double[3]; | |
Values[0] = 1.; | |
Values[1] = 2.; | |
Values[2] = 3.; | |
int Indices[1]; | |
log(MyPID, "Assembling P"); // each row contains 3 doubles | |
for( int i=0 ; i<Map.NumMyElements(); ++i ) { //loop on local rows | |
if (i%100000==0) { | |
cout << i << endl; | |
sleep(3); | |
} | |
int GlobalNode = Map.MyGlobalElements()[i]; | |
Indices[0] = i; | |
err = P.BeginInsertGlobalValues(GlobalNode, 1, Indices); | |
err = P.SubmitBlockEntry(Values, 1, 1, 3); | |
err = P.EndSubmitEntries(); | |
} | |
delete[] Values; | |
log(MyPID, "FillComplete P"); | |
sleep(4);//RAM 434MB/proc | |
P.FillComplete(); | |
log(MyPID, "FillComplete P done"); | |
//RAM 500MB/proc | |
#ifdef HAVE_MPI | |
MPI_Finalize(); | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see http://stackoverflow.com/questions/5200357/trilinos-sparse-block-matrix-anomalous-memory-consumption