|  | @@ -52,6 +52,7 @@ int main(int argc, char * argv[])
 | 
	
		
			
				|  |  |     const std::string host2 = (argc < 3) ? "127.0.0.1" : argv[2];
 | 
	
		
			
				|  |  |     const size_t n_threads = atoi(argv[3]);
 | 
	
		
			
				|  |  |     const size_t expo = atoi(argv[4]);
 | 
	
		
			
				|  |  | +   const size_t db_nitems = 1ULL << expo;
 | 
	
		
			
				|  |  |     const size_t maxRAM = atoi(argv[5]);
 | 
	
		
			
				|  |  |     //std::cout << "n_threads = " << n_threads << std::endl;
 | 
	
		
			
				|  |  |   
 | 
	
	
		
			
				|  | @@ -67,22 +68,21 @@ int main(int argc, char * argv[])
 | 
	
		
			
				|  |  |      /* The function make_connections appears in network.h */
 | 
	
		
			
				|  |  |     make_connections(party, host1, host2,  io_context, socketsPb, socketsP2, ports,  ports2_1, ports2_0, number_of_sockets);
 | 
	
		
			
				|  |  |   
 | 
	
		
			
				|  |  | -   const size_t db_nitems = 1ULL << atoi(argv[4]);
 | 
	
		
			
				|  |  | -      //std::cout << "maxRAM = "  << maxRAM << std::endl;
 | 
	
		
			
				|  |  | -      size_t RAM_needed = 0;
 | 
	
		
			
				|  |  | -      RAM_needed = n_threads * 164 * db_nitems;
 | 
	
		
			
				|  |  | -      //std::cout << "RAM needed = " << RAM_needed << " bytes = " << RAM_needed/1073741824 << " GiB" << std::endl;
 | 
	
		
			
				|  |  | -       size_t n_batches = std::ceil(double(RAM_needed)/(1073741824 * maxRAM));
 | 
	
		
			
				|  |  | -      //std::cout << "n_batches = " << n_batches << std::endl;
 | 
	
		
			
				|  |  | -      size_t thread_per_batch = std::ceil(double(n_threads)/n_batches);
 | 
	
		
			
				|  |  | -        //std::cout << "thread_per_batch = " << thread_per_batch << std::endl;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -   if(n_batches > n_threads)
 | 
	
		
			
				|  |  | -   {
 | 
	
		
			
				|  |  | -    std::cout << "You need more RAM" << std::endl;
 | 
	
		
			
				|  |  | -    exit(0);
 | 
	
		
			
				|  |  | -   }
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | +      size_t RAM_needed_per_thread = 164 * db_nitems;
 | 
	
		
			
				|  |  | +      std::cout << "RAM needed = " << n_threads*RAM_needed_per_thread << " bytes = " << n_threads*RAM_needed_per_thread/1073741824 << " GiB" << std::endl;
 | 
	
		
			
				|  |  | +      std::cout << "RAM needed per thread = " << RAM_needed_per_thread << " bytes = " << (RAM_needed_per_thread>>30) << " GiB" << std::endl;
 | 
	
		
			
				|  |  | +      size_t thread_per_batch = std::floor(double(maxRAM<<30)/RAM_needed_per_thread);
 | 
	
		
			
				|  |  | +      if (thread_per_batch > n_threads) {
 | 
	
		
			
				|  |  | +	thread_per_batch = n_threads;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      std::cout << "thread_per_batch = " << thread_per_batch << std::endl;
 | 
	
		
			
				|  |  | +      if (thread_per_batch < 1) {
 | 
	
		
			
				|  |  | +       std::cout << "You need more RAM" << std::endl;
 | 
	
		
			
				|  |  | +       exit(0);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      size_t n_batches = std::ceil(double(n_threads)/thread_per_batch);
 | 
	
		
			
				|  |  | +      std::cout << "n_batches = " << n_batches << std::endl;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |     uint8_t ** target_share_read = new uint8_t*[thread_per_batch];
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |     generate_random_targets(target_share_read,  thread_per_batch, party, expo);
 |