Skip to content

Commit b45399d

Browse files
committed
Switched to mallinfo for memory usage information
1 parent 06c3b2e commit b45399d

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

Build.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ int SolveEquations(SparseMatrix &SM, int cols, vector<Unique_basis_pair> &BPtoCo
383383
"truncated-dense-avx-float",
384384
"precompute-division-cache"};
385385

386-
vector<pair<double, size_t> > profiles[7];
386+
vector<pair<double, int> > profiles[7];
387387
profiles[0] = memory_usage;
388388

389389
for (int i = 0; i < nfuncs; i++) {
@@ -403,9 +403,9 @@ int SolveEquations(SparseMatrix &SM, int cols, vector<Unique_basis_pair> &BPtoCo
403403
profiles[i+1] = memory_usage;
404404
}
405405
for(int i=0; i<profiles[0].size(); i++) {
406-
printf("%d:", i);
406+
printf("Profile%07d:", i);
407407
for(int j=0; j<nfuncs+1; j++) {
408-
printf("\t%.02f/%.02f", profiles[j][i].first, profiles[j][i].second/1024./1024.);
408+
printf("\t%.02f/%.02f", profiles[j][i].first, profiles[j][i].second/1024.);
409409
}
410410
putchar('\n');
411411
}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ LDFLAGS=-fopenmp
2424
#LDFLAGS=-fopenmp -fprofile-use -fprofile-correction
2525
#LDFLAGS=-g -O3 -flto
2626
#LIBS=-lcurses -ltermcap -lm
27-
LIBS=-lreadline
27+
LIBS=-lreadline -lprocps
2828

2929
C_FILES=$(wildcard *.c)
3030
CPP_FILES=$(wildcard *.cpp)

memory_usage.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,29 @@
88

99
#ifdef __linux__
1010
#include <proc/readproc.h>
11+
#include <malloc.h>
1112
#endif
1213

1314
using std::vector;
1415
using std::fill;
1516
using std::pair;
1617
using std::make_pair;
1718

18-
size_t memory_usage0;
19+
int memory_usage0;
1920
double t0;
20-
vector<pair<double, size_t> > memory_usage;
21+
vector<pair<double, int> > memory_usage;
2122

22-
size_t current_memory_usage() {
23+
int current_memory_usage() {
2324
#ifdef __linux__
25+
#if 0
2426
proc_t usage;
2527
look_up_our_self(&usage);
2628
return usage.vsize;
29+
#else
30+
struct mallinfo m = mallinfo();
31+
//return m.arena;
32+
return m.uordblks;
33+
#endif
2734
#else
2835
return 0;
2936
#endif

memory_usage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <vector>
1010

11-
extern std::vector<std::pair<double, size_t> > memory_usage;
11+
extern std::vector<std::pair<double, int> > memory_usage;
1212

1313
void memory_usage_init(int n);
1414

0 commit comments

Comments
 (0)