Commit 86589ad1 authored by Jack Doerner's avatar Jack Doerner

Accommodated changes to obliv-c. Refactored protocol splitting so it only...

Accommodated changes to obliv-c. Refactored protocol splitting so it only happens once. Added manual flushes to places where the lack of them could cause deadlocks.
parent 383a1c29
......@@ -23,6 +23,7 @@ struct bitpropagator {
obliv bool * advicebits;
obliv uint8_t * keyL;
obliv uint8_t * keyR;
ProtocolDesc * pd2;
omp_lock_t * locks;
bitpropagator_offline * bpo;
};
......@@ -46,6 +47,9 @@ void bitpropagator_Z_pusher(bitpropagator * bp, bitpropagator_offline * bpo, Pro
revealOblivBool(&advicebit_local_r, bp->advicebits[thislevel*2+1], 2);
bitpropagator_offline_push_Z(bpo, Z_local, advicebit_local_l, advicebit_local_r, ii);
//Other threads may depend on the fact that we've pushed successfully
if (pd != NULL) oflush(pd);
}
free(Z_local);
......@@ -173,10 +177,7 @@ void bitpropagator_getblockvector_with_callback(obliv uint8_t * activeblock_delt
#ifdef _OPENMP
//This is a hack to work around the fact that openmp and obliv-c are incompatible.
ProtocolDesc pd2;
splitProtocol(&pd2, ocCurrentProto());
bitpropagator_offline_parallelizer(bp, bp->bpo, &index, local_output, local_bit_output, &pd2, bitpropagator_traverselevels, bitpropagator_Z_pusher, cbfn, cbpass);
cleanupProtocol(&pd2);
bitpropagator_offline_parallelizer(bp, bp->bpo, &index, local_output, local_bit_output, bp->pd2, bitpropagator_traverselevels, bitpropagator_Z_pusher, cbfn, cbpass);
#else
bitpropagator_offline_parallelizer(bp, bp->bpo, &index, local_output, local_bit_output, NULL, bitpropagator_traverselevels, bitpropagator_Z_pusher, cbfn, cbpass);
#endif
......@@ -237,6 +238,11 @@ bitpropagator * bitpropagator_new(size_t size, size_t blockmultiple, uint32_t st
omp_set_lock(&bp->locks[ii]);
}
#ifdef _OPENMP
bp->pd2 = calloc(1, sizeof(ProtocolDesc));
ocSplitProto(bp->pd2, ocCurrentProto());
#endif
return bp;
}
......@@ -255,6 +261,11 @@ void bitpropagator_free(bitpropagator * bp) {
free(bp->advicebits);
bitpropagator_offline_free(bp->bpo);
#ifdef _OPENMP
ocCleanupProto(bp->pd2);
free(bp->pd2);
#endif
for (int ii = 0; ii < (bp->endlevel - bp->startlevel); ii++) {
omp_destroy_lock(&bp->locks[ii]);
}
......
......@@ -18,6 +18,7 @@ struct bitpropagator_cprg {
uint8_t * L_local;
uint8_t * R_local;
uint8_t * Z_local;
ProtocolDesc * pd2;
bitpropagator_cprg_offline * bpo;
};
......@@ -56,6 +57,9 @@ void bitpropagator_cprg_traverselevels(obliv uint8_t * active_block_delta, uint8
revealOblivBool(&advicebit_R_local, bp->advicebits[1], 1);
for( size_t jj=0; jj< BLOCKSIZE/sizeof(uint64_t); jj++) revealOblivLLong(&((uint64_t *)bp->Z_local)[jj], ((obliv uint64_t *)bp->Z)[jj], 1);
//make sure both parties have transmitted everything before we start the offline phase.
oflush(ocCurrentProto());
if (ii < bp->endlevel) {
bitpropagator_cprg_offline_process_round(bp->L_local, bp->R_local, bp->Z_local, advicebit_L_local, advicebit_R_local, bp->bpo);
} else {
......@@ -78,10 +82,7 @@ void bitpropagator_cprg_getblockvector_with_callback(obliv uint8_t * active_bloc
#ifdef _OPENMP
//This is a hack to work around the fact that openmp and obliv-c are incompatible.
ProtocolDesc pd2;
splitProtocol(&pd2, ocCurrentProto());
bitpropagator_cprg_offline_parallelizer(bp, &index, active_block_delta, local_output, local_bit_output, &pd2, bitpropagator_cprg_traverselevels, cbfn, cbpass);
cleanupProtocol(&pd2);
bitpropagator_cprg_offline_parallelizer(bp, &index, active_block_delta, local_output, local_bit_output, bp->pd2, bitpropagator_cprg_traverselevels, cbfn, cbpass);
#else
bitpropagator_cprg_offline_parallelizer(bp, &index, active_block_delta, local_output, local_bit_output, NULL, bitpropagator_cprg_traverselevels, cbfn, cbpass);
#endif
......@@ -123,6 +124,11 @@ bitpropagator_cprg * bitpropagator_cprg_new(size_t size, size_t blockmultiple) {
free(keyL);
free(keyR);
#ifdef _OPENMP
bp->pd2 = calloc(1,sizeof(ProtocolDesc));
ocSplitProto(bp->pd2, ocCurrentProto());
#endif
return bp;
}
......@@ -135,5 +141,9 @@ void bitpropagator_cprg_free(bitpropagator_cprg * bp) {
free(bp->R_local);
free(bp->advicebits);
bitpropagator_cprg_offline_free(bp->bpo);
#ifdef _OPENMP
ocCleanupProto(bp->pd2);
free(bp->pd2);
#endif
free(bp);
}
\ No newline at end of file
......@@ -86,6 +86,9 @@ void floram_scan_callback(facb_pass * input, ProtocolDesc *pd) {
}
input->found=found;
// this protocol may not do anything else for a while, but other threads could be waiting for it
if (pd != NULL) oflush(pd);
#ifdef PROFILE_SCHEDULING
printf("END STASH SCAN %lld\n", current_timestamp());
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment