From 22d1a432d1ce36bf06c777bb92d403eb3c22598c Mon Sep 17 00:00:00 2001
From: Pedro Gonnet <pedro.gonnet@durham.ac.uk>
Date: Thu, 30 Aug 2012 11:35:19 +0000
Subject: [PATCH] make splitsize variable.

Former-commit-id: d1b9c1bdc5509ad7348ff490f8a5f74d73a6dffc
---
 runner.h | 2 +-
 space.c  | 3 +++
 space.h  | 5 ++++-
 test.c   | 7 ++++++-
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/runner.h b/runner.h
index 6bb7cbe768..5ab9feba8f 100644
--- a/runner.h
+++ b/runner.h
@@ -96,7 +96,7 @@ extern int runner_counter[ runner_counter_count ];
 
 /* Histogram functions. */
 #define runner_hist_a 1.0
-#define runner_hist_b 6.0
+#define runner_hist_b 10.0
 #define runner_hist_N 99
 long long int runner_hist_bins[ runner_hist_N ];
 #define runner_hist_hit( x ) __sync_add_and_fetch( &runner_hist_bins[ (int)fmax( 0.0 , fmin( runner_hist_N-1 , ((x) - runner_hist_a) / (runner_hist_b - runner_hist_a) * runner_hist_N ) ) ] , 1 )
diff --git a/space.c b/space.c
index fe226689e0..4ae7898fa4 100644
--- a/space.c
+++ b/space.c
@@ -39,6 +39,9 @@
 /* Convert cell location to ID. */
 #define cell_getid( cdim , i , j , k ) ( (int)(k) + (cdim)[2]*( (int)(j) + (cdim)[1]*(int)(i) ) )
 
+/* Split size. */
+int space_splitsize = space_splitsize_default;
+
 /* Task type names. */
 const char *taskID_names[tid_count] = { "none" , "sort" , "self" , "pair" , "sub" };
 
diff --git a/space.h b/space.h
index e7d8d12472..0368cf937b 100644
--- a/space.h
+++ b/space.h
@@ -24,11 +24,14 @@
 #define space_maxdepth                  10
 #define space_cellallocchunk            1000
 #define space_splitratio                0.875
-#define space_splitsize                 800
+#define space_splitsize_default         800
 #define task_maxwait                    3
 #define task_maxunlock                  39
 
 
+/* Split size. */
+extern int space_splitsize;
+
 /* Map shift vector to sortlist. */
 extern const int sortlistID[27];
     
diff --git a/test.c b/test.c
index 165c74dbfc..a02ccd9b63 100644
--- a/test.c
+++ b/test.c
@@ -491,7 +491,7 @@ int main ( int argc , char *argv[] ) {
     bzero( &s , sizeof(struct space) );
     
     /* Parse the options. */
-    while ( ( c = getopt( argc , argv  , "a:b:p:d:N:c:h:v:m:s:t:q:r:i:m:" ) ) != -1 )
+    while ( ( c = getopt( argc , argv  , "a:b:p:d:N:c:h:v:m:s:t:q:r:i:m:z:" ) ) != -1 )
         switch ( c ) {
             case 'N':
                 if ( sscanf( optarg , "%d" , &N ) != 1 )
@@ -568,6 +568,11 @@ int main ( int argc , char *argv[] ) {
                     error( "Error parsing number of threads." );
                 omp_set_num_threads( nr_threads );
                 break;
+            case 'z':
+                if ( sscanf( optarg , "%d" , &space_splitsize ) != 1 )
+                    error( "Error parsing split size." );
+                printf( "main: split size set to %i.\n" , space_splitsize );
+                break;
             case '?':
                 error( "Unknown option." );
                 break;
-- 
GitLab