MCPcopy Create free account
hub / github.com/data61/MP-SPDZ / run

Method run

Machines/OTMachine.cpp:281–399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279
280
281void OTMachine::run()
282{
283 // divide nOTs between threads and loops
284 nOTs = DIV_CEIL(nOTs, nthreads * nloops);
285 // round up to multiple of base OTs and subloops
286 // discount for discarded OTs
287 nOTs = DIV_CEIL(nOTs + 2 * 128, nbase * nsubloops) * nbase * nsubloops - 2 * 128;
288 cout << "Running " << nOTs << " OT extensions per thread and loop\n" << flush;
289
290 // PRG for generating inputs etc
291 PRNG G;
292 G.ReSeed();
293 BitVector receiverInput(nOTs);
294 receiverInput.randomize(G);
295 BaseOT& bot = *bot_;
296
297 cout << "Initialize OT Extension\n";
298 vector<OT_thread_info> tinfos(nthreads);
299 vector<pthread_t> threads(nthreads);
300 timeval OTextstart, OTextend;
301 gettimeofday(&OTextstart, NULL);
302
303 // copy base inputs/outputs for each thread
304 vector<BitVector> base_receiver_input_copy(nthreads);
305 vector<vector< array<BitVector, 2> > > base_sender_inputs_copy(nthreads, vector<array<BitVector, 2> >(nbase));
306 vector< vector<BitVector> > base_receiver_outputs_copy(nthreads, vector<BitVector>(nbase));
307 vector<TwoPartyPlayer*> players(nthreads);
308
309 for (int i = 0; i < nthreads; i++)
310 {
311 tinfos[i].receiverInput.assign(receiverInput);
312
313 base_receiver_input_copy[i].assign(baseReceiverInput);
314 for (int j = 0; j < nbase; j++)
315 {
316 base_sender_inputs_copy[i][j][0].assign(bot.sender_inputs[j][0]);
317 base_sender_inputs_copy[i][j][1].assign(bot.sender_inputs[j][1]);
318 base_receiver_outputs_copy[i][j].assign(bot.receiver_outputs[j]);
319 }
320 // now setup resources for each thread
321 // round robin with the names
322 players[i] = new RealTwoPartyPlayer(*N[i % N.size()], 1 - my_num,
323 "thread" + to_string(i));
324 tinfos[i].thread_num = i+1;
325 tinfos[i].other_player_num = 1 - my_num;
326 tinfos[i].nOTs = nOTs;
327 tinfos[i].ot_ext = new OTExtensionWithMatrix(
328 players[i],
329 ot_role,
330 passive,
331 nsubloops);
332 tinfos[i].ot_ext->init(base_receiver_input_copy[i],
333 base_sender_inputs_copy[i], base_receiver_outputs_copy[i]);
334 tinfos[i].nloops = nloops;
335
336 // create the thread
337 pthread_create(&threads[i], NULL, run_otext_thread, &tinfos[i]);
338

Callers 1

mainFunction · 0.45

Calls 15

DIV_CEILFunction · 0.85
timeval_diffFunction · 0.85
role_to_strFunction · 0.85
ReSeedMethod · 0.80
extend_lengthMethod · 0.80
isSetMethod · 0.80
closeMethod · 0.80
assign_bytesMethod · 0.80
get_receiver_outputMethod · 0.80
get_sender_outputMethod · 0.80
to_stringFunction · 0.50
randomizeMethod · 0.45

Tested by

no test coverage detected