From 276947c0cbc058a06886095b91371f6e691d5212 Mon Sep 17 00:00:00 2001
From: Moises Fernandez <moisesf@fmrib.ox.ac.uk>
Date: Thu, 11 Apr 2013 15:40:55 +0000
Subject: [PATCH] Changed to use Dynamic Shared Memory and fix curand with a
 number of randoms not multiplo of 2

---
 CUDA/runmcmc.cu | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/CUDA/runmcmc.cu b/CUDA/runmcmc.cu
index 2c2011e..f0d9354 100644
--- a/CUDA/runmcmc.cu
+++ b/CUDA/runmcmc.cu
@@ -145,12 +145,19 @@ void runmcmc_burnin(	//INPUT
 		nrandoms = totalrandoms;
 		iters_step= opts.nburn.value();
 		steps = 0;
-  	 }   
+  	}
+	if(nrandoms%2){							//CURAND must generates multiples of 2 randoms
+		nrandoms++;
+	}   
 
    	myfile << "Process " << opts.nburn.value() << " iterations divided in "<< steps << " steps with "<< iters_step << " iterations in each one" << "\n";    
 
    	int last_step = opts.nburn.value() - (iters_step*steps);
    	int last_randoms= (last_step*minrandoms); 
+	if(last_randoms%2){					//CURAND must generates multiples of 2 randoms
+		last_randoms++;
+	}
+
 
    	myfile << "Last step with " << last_step << " iterations" << "\n"; 
 	
@@ -317,12 +324,19 @@ void runmcmc_record(	//INPUT
 		nrandoms = totalrandoms;
 		iters_step= opts.njumps.value();
 		steps = 0;
-  	 }   
+  	}
+	if(nrandoms%2){						//CURAND must generates multiples of 2 randoms
+		nrandoms++;
+	}   
 
    	myfile << "Process " << opts.njumps.value() << " iterations divided in "<< steps << " steps with "<< iters_step << " iterations in each one" << "\n";    
 
    	int last_step = opts.njumps.value() - (iters_step*steps);
    	int last_randoms= (last_step*minrandoms); 
+	if(last_randoms%2){					//CURAND must generates multiples of 2 randoms
+		last_randoms++;
+	}
+
 
    	myfile << "Last step with " << last_step << " iterations" << "\n"; 
 	
-- 
GitLab