10 #include "Teuchos_CommHelpers.hpp"
11 #include "Teuchos_DefaultComm.hpp"
12 #include "Teuchos_RCP.hpp"
13 #include "Tpetra_Map.hpp"
14 #include "Tpetra_MultiVector.hpp"
35 pageSize = sysconf(_SC_PAGESIZE);
37 #warning "Page size query is not possible. No per-process memory stats."
42 std::ostringstream
fname;
43 fname <<
"/proc/" << pid <<
"/statm";
44 std::ifstream memFile;
47 memFile.open(fname.str().c_str());
55 while (memFile.good()){
56 memFile.getline(buf, 128);
62 std::istringstream sbuf(buf);
66 long pageKBytes = pageSize / 1024;
67 totalPages = atol(buf);
69 return totalPages * pageKBytes;
74 int main(
int narg,
char **arg)
76 Tpetra::ScopeGuard tscope(&narg, &arg);
77 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
79 int me = comm->getRank();
80 int nprocs = comm->getSize();
83 std::cout <<
"Run with 4 MPI ranks " << std::endl;
85 typedef Tpetra::Map<z2TestLO, z2TestGO>
map_t;
88 Teuchos::ParameterList myParams(
"testParameterList");
89 myParams.set(
"memory_procs",
"0");
90 myParams.set(
"memory_output_stream",
"std::cout");
92 z2TestLO newnumLocalCoords = 1000000;
94 newnumLocalCoords = 999999;
96 newnumLocalCoords = 1000001;
98 newnumLocalCoords = 1000000;
100 typedef Tpetra::MultiVector<z2TestScalar, z2TestLO, z2TestGO> mvector_t;
104 std::cout << me <<
" "
106 <<
" Before map construction "
109 for (
int i = 0 ; i < 20; i++)
112 std::cout << me <<
" "
114 <<
" Inside the loop " << i
116 Teuchos::RCP<const map_t> tmap = rcp(
new map_t(numGlobalCoords,
117 numLocalCoords, 0, comm));
118 Teuchos::RCP<const map_t> newTmap = rcp(
new map_t(numGlobalCoords,
119 newnumLocalCoords, 0, comm));
120 Teuchos::RCP<mvector_t> newMvector = rcp(
new mvector_t(tmap, 3,
true));
121 Teuchos::RCP<Tpetra::Import<z2TestLO, z2TestGO> > importer = rcp(
122 new Tpetra::Import<z2TestLO, z2TestGO>(tmap, newTmap));
128 std::cout << me <<
" "
130 <<
" After map construction "
133 int iAmOK = (before == after);
135 Teuchos::reduceAll(*comm, Teuchos::REDUCE_MIN, iAmOK, &weAreOK);
138 if (weAreOK) std::cout <<
"PASS" << std::endl;
139 else std::cout <<
"FAIL before " << before
140 <<
" != after " << after << std::endl;
int main(int narg, char **arg)
static long getProcessKilobytes()