2 #include "Teuchos_CommHelpers.hpp"
3 #include "Teuchos_DefaultComm.hpp"
4 #include "Teuchos_RCP.hpp"
5 #include "Tpetra_Map.hpp"
6 #include "Tpetra_MultiVector.hpp"
27 pageSize = sysconf(_SC_PAGESIZE);
29 #warning "Page size query is not possible. No per-process memory stats."
34 std::ostringstream
fname;
35 fname <<
"/proc/" << pid <<
"/statm";
36 std::ifstream memFile;
39 memFile.open(fname.str().c_str());
47 while (memFile.good()){
48 memFile.getline(buf, 128);
54 std::istringstream sbuf(buf);
58 long pageKBytes = pageSize / 1024;
59 totalPages = atol(buf);
61 return totalPages * pageKBytes;
66 int main(
int narg,
char **arg)
68 Tpetra::ScopeGuard tscope(&narg, &arg);
69 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
71 int me = comm->getRank();
72 int nprocs = comm->getSize();
75 std::cout <<
"Run with 4 MPI ranks " << std::endl;
77 typedef Tpetra::Map<z2TestLO, z2TestGO>
map_t;
80 Teuchos::ParameterList myParams(
"testParameterList");
81 myParams.set(
"memory_procs",
"0");
82 myParams.set(
"memory_output_stream",
"std::cout");
84 z2TestLO newnumLocalCoords = 1000000;
86 newnumLocalCoords = 999999;
88 newnumLocalCoords = 1000001;
90 newnumLocalCoords = 1000000;
92 typedef Tpetra::MultiVector<z2TestScalar, z2TestLO, z2TestGO> mvector_t;
96 std::cout << me <<
" "
98 <<
" Before map construction "
101 for (
int i = 0 ; i < 20; i++)
104 std::cout << me <<
" "
106 <<
" Inside the loop " << i
108 Teuchos::RCP<const map_t> tmap = rcp(
new map_t(numGlobalCoords,
109 numLocalCoords, 0, comm));
110 Teuchos::RCP<const map_t> newTmap = rcp(
new map_t(numGlobalCoords,
111 newnumLocalCoords, 0, comm));
112 Teuchos::RCP<mvector_t> newMvector = rcp(
new mvector_t(tmap, 3,
true));
113 Teuchos::RCP<Tpetra::Import<z2TestLO, z2TestGO> > importer = rcp(
114 new Tpetra::Import<z2TestLO, z2TestGO>(tmap, newTmap));
120 std::cout << me <<
" "
122 <<
" After map construction "
125 int iAmOK = (before == after);
127 Teuchos::reduceAll(*comm, Teuchos::REDUCE_MIN, iAmOK, &weAreOK);
130 if (weAreOK) std::cout <<
"PASS" << std::endl;
131 else std::cout <<
"FAIL before " << before
132 <<
" != after " << after << std::endl;
int main(int narg, char **arg)
static long getProcessKilobytes()