[Swift-commit] r5998 - SwiftApps/SciColSim
wilde at ci.uchicago.edu
wilde at ci.uchicago.edu
Mon Oct 29 13:53:23 CDT 2012
Author: wilde
Date: 2012-10-29 13:53:23 -0500 (Mon, 29 Oct 2012)
New Revision: 5998
Modified:
SwiftApps/SciColSim/graphsim.cpp
SwiftApps/SciColSim/testgraph.py
Log:
Set test graph to float to save RAM.
Modified: SwiftApps/SciColSim/graphsim.cpp
===================================================================
--- SwiftApps/SciColSim/graphsim.cpp 2012-10-27 14:31:40 UTC (rev 5997)
+++ SwiftApps/SciColSim/graphsim.cpp 2012-10-29 18:53:23 UTC (rev 5998)
@@ -32,6 +32,7 @@
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
+#include "unistd.h"
#ifdef P_DISPATCH
#include <dispatch/dispatch.h>
@@ -237,6 +238,47 @@
}
//================================================
+
+typedef struct {
+ unsigned long size,resident,share,text,lib,data,dt;
+} statm_t;
+
+void read_memory_status(statm_t *sp)
+{
+ unsigned long dummy;
+ const char* statm_path = "/proc/self/statm";
+
+ FILE *f = fopen(statm_path,"r");
+ if(!f){
+ perror(statm_path);
+ exit(99);
+ }
+
+ if(7 != fscanf(f,"%ld %ld %ld %ld %ld %ld %ld",
+ &sp->size,&sp->resident,&sp->share,&sp->text,&sp->lib,&sp->data,&sp->dt))
+ {
+ perror(statm_path);
+ exit(99);
+ }
+ fclose(f);
+}
+
+#define MB(v) (result.v * ps) / (1024*1024)
+
+void print_memory_status()
+{
+ unsigned long dummy;
+ const char* statm_path = "/proc/self/statm";
+ statm_t result;
+ unsigned long ps = sysconf(_SC_PAGESIZE);
+
+ read_memory_status(&result);
+ printf("size: %ld resident: %ld share: %ld text: %ld lib: %ld data: %ld dt: %ld\n",
+ MB(size), MB(resident), MB(share), MB(text), MB(lib), MB(data), MB(dt) );
+}
+
+//================================================
+
class Universe {
private:
@@ -272,13 +314,15 @@
graph_t Full_g;
- double **Prob;
- double **Tried;
- double **Dist;
- double **Final;
- double **EdgeIndex;
- double *Rank;
+#define GraphRes float // was double
+ GraphRes **Prob;
+ GraphRes **Tried;
+ GraphRes **Dist;
+ GraphRes **Final;
+ GraphRes **EdgeIndex;
+ GraphRes *Rank;
+
base_generator_type generator;
boost::uniform_real<> uni_dist;
boost::geometric_distribution<double> geo;
@@ -925,7 +969,7 @@
//================================================
// Allocate memory
- double** allocate_2Dmatrix(int N, int M)
+ double** allocate_2Dmatrix_double(int N, int M)
{
double **pointer;
@@ -938,14 +982,28 @@
return pointer;
}
+ // Allocate memory
+ GraphRes** allocate_2Dmatrix(int N, int M)
+ {
+ GraphRes **pointer;
+
+ if (verbose_level == 2){
+ std::cout<< "["<<N<<"|"<<M<<"]"<<std::endl;
+ }
+ pointer = new GraphRes*[N];
+ for (int i = 0; i < N; ++i)
+ pointer[i] = new GraphRes[M];
+
+ return pointer;
+ }
//===================
- double* allocate_1Dmatrix(int N)
+ GraphRes* allocate_1Dmatrix(int N)
{
- double *pointer;
+ GraphRes *pointer;
if(N > 0){
- pointer = new double[N];
+ pointer = new GraphRes[N];
}else {
@@ -958,7 +1016,7 @@
//==============================================
// De-Allocate memory to prevent memory leak
- void delete_2Dmatrix(double **pointer, int N){
+ void delete_2Dmatrix_double(double **pointer, int N){
if (pointer != NULL){
@@ -968,8 +1026,18 @@
delete [] pointer;
}
}
+ void delete_2Dmatrix(GraphRes **pointer, int N){
+
+ if (pointer != NULL){
+
+ for (int i = 0; i < N; ++i){
+ delete [] pointer[i];
+ }
+ delete [] pointer;
+ }
+ }
//====================
- void delete_1Dmatrix(double *pointer){
+ void delete_1Dmatrix(GraphRes *pointer){
delete [] pointer;
}
@@ -1819,6 +1887,8 @@
double T_start=params2[0], T_end=params2[1], Target_rejection=params2[3], starting_jump=params2[4];
int Annealing_repeats = (int) params2[2];
+ print_memory_status();
+
#ifdef P_DISPATCH
dispatch_group_t group = dispatch_group_create();
Modified: SwiftApps/SciColSim/testgraph.py
===================================================================
--- SwiftApps/SciColSim/testgraph.py 2012-10-27 14:31:40 UTC (rev 5997)
+++ SwiftApps/SciColSim/testgraph.py 2012-10-29 18:53:23 UTC (rev 5998)
@@ -8,6 +8,7 @@
app = "./orig-optimizer"; # For Mac only: original code (+1 loop fix) using Grnd Central Dispatch
app = "./dispatch-optimizer"; # For Mac only: sing Grand Central Dispatch
app = "./openmp-optimizer"; # For Mac or Linux: Using OpenMP (Default)
+app = "./graphsim"; # For Mac or Linux: does graph simulation only - Using OpenMP (Default)
#paramset="default"
paramset="mw3"
@@ -139,11 +140,11 @@
optimizerRepeats = 1
evolveReruns = 1
annealingSteps = 1
- NWorkers = "8"
+ NWorkers = "1"
openmp = "OMP_NUM_THREADS=" + NWorkers
operation = "m" # n=normal, m=manual (runs 1 multi_loss call)
- seed = "123456"
- app = "./openmp-optimizer";
+ seed = "" # "123456"
+ app = "./graphsim";
# Ensure we dont pass new parameters to original optimizer versions
# (but they would be ignored)
More information about the Swift-commit
mailing list