Commit f671a577 authored by Jack Doerner's avatar Jack Doerner

Added a compile time option to profile the scheduling of Floram.

parent 3d9b882e
......@@ -59,6 +59,11 @@ void bitpropagator_offline_readblockvector(uint8_t * local_output, bool * local_
expansion_stride = BLOCKSIZE;
}
#ifdef PROFILE_SCHEDULING
#pragma omp single nowait
printf("START FSS OFFLINE LEVEL 0 %lld\n", current_timestamp());
#endif
#pragma omp for
for (size_t ii = 0; ii < 4*(nextlevelblocks/8); ii+=4) {
offline_prf_oct(&b2[ii*2*expansion_stride], &b2[(ii*2+1)*expansion_stride], &b2[(ii*2+2)*expansion_stride], &b2[(ii*2+3)*expansion_stride],
......@@ -84,10 +89,20 @@ void bitpropagator_offline_readblockvector(uint8_t * local_output, bool * local_
a_bits[ii] = a2[ii*BLOCKSIZE] & 1;
}
#ifdef PROFILE_SCHEDULING
#pragma omp single nowait
printf("END FSS OFFLINE LEVEL 0 %lld\n", current_timestamp());
#endif
for (thislevel = bpo->startlevel +1; thislevel < bpo->endlevel; thislevel++) {
#pragma omp single
omp_set_lock(&bpo->locks[thislevel- bpo->startlevel -1 ]);
#ifdef PROFILE_SCHEDULING
#pragma omp single nowait
printf("START FSS OFFLINE LEVEL %d %lld\n", thislevel,current_timestamp());
#endif
thislevelblocks = nextlevelblocks;
nextlevelblocks = (bpo->size + (1ll<<(bpo->endlevel - thislevel -1)) - 1) / (1ll<<(bpo->endlevel - thislevel -1));
if (thislevel == bpo->endlevel -1) nextlevelblocks = bpo->size;
......@@ -160,11 +175,21 @@ void bitpropagator_offline_readblockvector(uint8_t * local_output, bool * local_
offline_prf(&b2[ii*2*expansion_stride], &a2[ii*BLOCKSIZE], bpo->keyL);
}
}
#ifdef PROFILE_SCHEDULING
#pragma omp single nowait
printf("END FSS OFFLINE LEVEL %d %lld\n", thislevel,current_timestamp());
#endif
}
#pragma omp single
omp_set_lock(&bpo->locks[thislevel- bpo->startlevel -1 ]);
#ifdef PROFILE_SCHEDULING
#pragma omp single nowait
printf("START FSS LEVEL %d %lld\n", thislevel,current_timestamp());
#endif
thislevelblocks = nextlevelblocks;
advicebit_l = bpo->advicebits_l[thislevel - bpo->startlevel -1];
......@@ -259,6 +284,11 @@ void bitpropagator_offline_readblockvector(uint8_t * local_output, bool * local_
}
}
}
#ifdef PROFILE_SCHEDULING
#pragma omp single nowait
printf("END FSS LEVEL %d %lld\n", thislevel,current_timestamp());
#endif
}
for (int ii = 0; ii < (bpo->endlevel - bpo->startlevel); ii++) {
......
......@@ -52,6 +52,9 @@ void bitpropagator_Z_pusher(bitpropagator * bp, bitpropagator_offline * bpo, Pro
}
void bitpropagator_traverselevels(bitpropagator * bp, obliv size_t * indexp) {
#ifdef PROFILE_SCHEDULING
printf("START FSS ONLINE %lld\n", current_timestamp());
#endif
obliv uint32_t levelindex;
obliv size_t index = *indexp;
......@@ -124,6 +127,10 @@ void bitpropagator_traverselevels(bitpropagator * bp, obliv size_t * indexp) {
for (size_t ii = 1; ii < bp->blockmultiple; ii++) {
online_prf_double(&bp->activeblock_A[BLOCKSIZE * ii], &bp->activeblock_B[BLOCKSIZE * ii], &bp->activeblock_A[BLOCKSIZE * (ii-1)], &bp->activeblock_B[BLOCKSIZE * (ii-1)], bp->keyL, bp->keyL);
}
#ifdef PROFILE_SCHEDULING
printf("END FSS ONLINE %lld\n", current_timestamp());
#endif
}
void bitpropagator_getblockvector(obliv uint8_t * activeblock_delta, uint8_t * local_output, bool * local_bit_output, bitpropagator * bp, obliv size_t index) {
......@@ -131,6 +138,9 @@ void bitpropagator_getblockvector(obliv uint8_t * activeblock_delta, uint8_t * l
}
void bitpropagator_getblockvector_with_callback(obliv uint8_t * activeblock_delta, uint8_t * local_output, bool * local_bit_output, bitpropagator * bp, obliv size_t index, facb_fn cbfn, void* cbpass) {
#ifdef PROFILE_SCHEDULING
printf("START FSS SETUP %lld\n", current_timestamp());
#endif
//Collect a set of random blocks for the top level
get_random_bytes(bp->toplevel_local, ((1ll << bp->startlevel) + 1) * BLOCKSIZE);
......@@ -155,6 +165,10 @@ void bitpropagator_getblockvector_with_callback(obliv uint8_t * activeblock_delt
ocCopyN(&ocCopyChar, bp->activeblock_B, &bp->toplevel[(1ll << bp->startlevel)*BLOCKSIZE], BLOCKSIZE);
#ifdef PROFILE_SCHEDULING
printf("END FSS SETUP %lld\n", current_timestamp());
#endif
bitpropagator_offline_start(bp->bpo, bp->toplevel_local);
//This is a hack to work around the fact that openmp and obliv-c are incompatible.
......
......@@ -44,6 +44,10 @@ void bitpropagator_cprg_offline_start(uint8_t * local_output, bool * local_bit_o
bpo->thislevelblocks = 1;
bpo->nextlevelblocks = 2;
#ifdef PROFILE_SCHEDULING
printf("START FSS CPRG OFFLINE LEVEL %d %lld\n", bpo->thislevel,current_timestamp());
#endif
bpo->lda = (uint64_t *)bpo->level_data;
bpo->lda2 = (uint8_t *)bpo->level_data;
bpo->ldb = (uint64_t *)local_output;
......@@ -72,6 +76,10 @@ void bitpropagator_cprg_offline_start(uint8_t * local_output, bool * local_bit_o
}
bpo->lba[0] = bpo->lda2[0] & 1;
#ifdef PROFILE_SCHEDULING
printf("END FSS CPRG OFFLINE LEVEL %d %lld\n", bpo->thislevel,current_timestamp());
#endif
}
void bitpropagator_cprg_offline_process_round(uint8_t * accumulator_L, uint8_t * accumulator_R, uint8_t * z, bool advicebit_l, bool advicebit_r, bitpropagator_cprg_offline * bpo) {
......@@ -80,6 +88,10 @@ void bitpropagator_cprg_offline_process_round(uint8_t * accumulator_L, uint8_t *
bpo->nextlevelblocks = (bpo->size + (1ll<<(bpo->endlevel - bpo->thislevel -1)) - 1) / (1ll<<(bpo->endlevel - bpo->thislevel -1));
if (bpo->thislevel == bpo->endlevel -1) bpo->nextlevelblocks = bpo->size;
#ifdef PROFILE_SCHEDULING
printf("START FSS CPRG OFFLINE LEVEL %d %lld\n", bpo->thislevel,current_timestamp());
#endif
uint64_t* t; uint8_t* t2; bool * tb;
size_t expansion_stride;
......@@ -174,12 +186,20 @@ void bitpropagator_cprg_offline_process_round(uint8_t * accumulator_L, uint8_t *
((uint64_t *)accumulator_L)[jj] = accL.data[jj];
((uint64_t *)accumulator_R)[jj] = accR.data[jj];
}
#ifdef PROFILE_SCHEDULING
printf("END FSS CPRG OFFLINE LEVEL %d %lld\n", bpo->thislevel,current_timestamp());
#endif
}
void bitpropagator_cprg_offline_finalize(uint8_t * accumulator, uint8_t * z, bool advicebit_l, bool advicebit_r, bitpropagator_cprg_offline * bpo) {
bpo->thislevel += 1;
bpo->thislevelblocks = bpo->nextlevelblocks;
#ifdef PROFILE_SCHEDULING
printf("START FSS CPRG OFFLINE LEVEL %d %lld\n", bpo->thislevel,current_timestamp());
#endif
uint64_t* t; uint8_t* t2; bool * tb;
t2 = bpo->ldb2; t = bpo->ldb; tb = bpo->lbb;
......@@ -310,6 +330,10 @@ void bitpropagator_cprg_offline_finalize(uint8_t * accumulator, uint8_t * z, boo
((uint64_t *)accumulator)[jj*BLOCKSIZE/sizeof(uint64_t)+ii] = acc.data[ii];
}
}
#ifdef PROFILE_SCHEDULING
printf("END FSS CPRG OFFLINE LEVEL %d %lld\n", bpo->thislevel,current_timestamp());
#endif
}
void bitpropagator_cprg_offline_parallelizer(void* bp, void* indexp, void *blockdelta, void * local_output, void * local_bit_output, void* pd, bp_cprg_traverser_fn fn, facb_fn cbfn, void* cbpass) {
......
......@@ -22,6 +22,9 @@ struct bitpropagator_cprg {
};
void bitpropagator_cprg_traverselevels(obliv uint8_t * active_block_delta, uint8_t * local_output, bool * local_bit_output, bitpropagator_cprg * bp, obliv size_t * indexp) {
#ifdef PROFILE_SCHEDULING
printf("START FSS CPRG ONLINE %lld\n", current_timestamp());
#endif
obliv uint32_t levelindex;
obliv size_t index = *indexp;
......@@ -61,6 +64,10 @@ void bitpropagator_cprg_traverselevels(obliv uint8_t * active_block_delta, uint8
}
ocFromSharedCharN(ocCurrentProto(), active_block_delta, bp->L_local, BLOCKSIZE*bp->blockmultiple);
#ifdef PROFILE_SCHEDULING
printf("END FSS CPRG ONLINE %lld\n", current_timestamp());
#endif
}
void bitpropagator_cprg_getblockvector(obliv uint8_t * active_block_delta, uint8_t * local_output, bool * local_bit_output, bitpropagator_cprg * bp, obliv size_t index) {
......
......@@ -10,4 +10,7 @@
#define KEYSIZE 16
#define BLOCKSIZE 16
//#define SCANROM_DISABLE_ENCRYPTION
//#define PROFILE_SCHEDULING
#endif
\ No newline at end of file
......@@ -42,6 +42,10 @@ typedef struct facb_pass {
} facb_pass;
void floram_refresh(floram* ram) {
#ifdef PROFILE_SCHEDULING
printf("BEGIN REFRESH %lld\n", current_timestamp());
#endif
ram->progress = 0;
get_random_bytes(ram->rom_key_half, KEYSIZE);
scanrom_set_key(ram->rom, ram->rom_key_half);
......@@ -49,11 +53,19 @@ void floram_refresh(floram* ram) {
for (size_t ii = 0; ii < ram->period; ii++) {
ram->stashi[ii] = -1;
}
#ifdef PROFILE_SCHEDULING
printf("END REFRESH %lld\n", current_timestamp());
#endif
}
void floram_scan_callback(facb_pass * input, ProtocolDesc *pd) {
if (pd != NULL) ocSetCurrentProto(pd);
#ifdef PROFILE_SCHEDULING
printf("BEGIN STASH SCAN %lld\n", current_timestamp());
#endif
floram * ram = input->ram;
obliv size_t blockid = input->blockid;
obliv bool found = false;
......@@ -73,6 +85,10 @@ void floram_scan_callback(facb_pass * input, ProtocolDesc *pd) {
}
}
input->found=found;
#ifdef PROFILE_SCHEDULING
printf("END STASH SCAN %lld\n", current_timestamp());
#endif
}
void floram_read(void* data, floram* ram, obliv size_t index) obliv {
......@@ -94,6 +110,10 @@ void floram_read(void* data, floram* ram, obliv size_t index) obliv {
}
void floram_apply(floram* ram, void* data, floram_block_access_function fn, obliv size_t index) obliv {
#ifdef PROFILE_SCHEDULING
~obliv() printf("BEGIN APPLY %lld\n", current_timestamp());
#endif
obliv size_t blockid = index / ram->elementsperblock;
obliv size_t subblockid = index % ram->elementsperblock;
......@@ -106,18 +126,30 @@ void floram_apply(floram* ram, void* data, floram_block_access_function fn, obli
ram->stashi[0] = blockid;
}
#ifdef PROFILE_SCHEDULING
~obliv() printf("BEGIN FUNCTION APPLICATION %lld\n", current_timestamp());
#endif
ocCopy(&ram->memblockcpy, ram->blocktemp, ram->stash);
for (uint32_t jj = 0; jj < ram->elementsperblock; jj ++) {
obliv if (subblockid == jj) fn(ram->cpy, element(ram->cpy, ram->stash, jj), data);
}
#ifdef PROFILE_SCHEDULING
~obliv() printf("END FUNCTION APPLICATION %lld\n", current_timestamp());
#endif
scanwrom_write_with_blockvector(ram->wrom, ram->activeblock_delta, ram->blockvector_local, ram->bitvector_local, ram->blocktemp, ram->stash);
~obliv() {
ram->progress++;
if (ram->progress == ram->period) floram_refresh(ram);
}
#ifdef PROFILE_SCHEDULING
~obliv() printf("END APPLY %lld\n\n", current_timestamp());
#endif
}
void writer_function(OcCopy * cpy, void * oram_block, void * ext_block) obliv {
......
......@@ -2,8 +2,6 @@
#define SCANROM_H
#include "floram.h"
//#define SCANROM_DISABLE_ENCRYPTION
typedef void (* duplexer_fn)(void *, void *);
void scanrom_read_with_bitvector_offline(uint8_t * data, uint8_t * local_data, bool * bitvector, size_t fullblocksize, size_t blockcount);
......
......@@ -5,6 +5,7 @@
#include "bitpropagate.oh"
#include "bitpropagate.h"
#include "floram_util.oh"
#include "../ackutil.h"
#include <obliv.h>
#include <copy.oh>
......@@ -33,6 +34,10 @@ struct scanwrom {
void scanrom_read_with_bitvector(obliv uint8_t * data, scanrom * rom, obliv size_t index, bool * bitvector) obliv {
#ifdef PROFILE_SCHEDULING
~obliv() printf("BEGIN ROM READ %lld\n", current_timestamp());
#endif
~obliv() {
scanrom_read_with_bitvector_offline(rom->local_blocktemp, rom->local_data, bitvector, rom->memblocksize, rom->blockcount);
memset(rom->ivtemp, 0, BLOCKSIZE * sizeof(obliv uint8_t));
......@@ -63,6 +68,10 @@ void scanrom_read_with_bitvector(obliv uint8_t * data, scanrom * rom, obliv size
ocCopyN(&ocCopyChar, data, rom->blocktemp, rom->memblocksize);
#ifdef PROFILE_SCHEDULING
~obliv() printf("END ROM READ %lld\n", current_timestamp());
#endif
}
void scanrom_write_xor_shares(scanrom* rom, obliv uint8_t * data, size_t index, size_t len) {
......@@ -161,6 +170,10 @@ void scanwrom_write(scanwrom* rom, obliv uint8_t* data, size_t index) {
}
void scanwrom_write_with_blockvector(scanwrom* rom, obliv uint8_t * active_block_delta, uint8_t * blockvector, bool * bitvector, obliv uint8_t * old_data, obliv uint8_t * new_data) obliv {
#ifdef PROFILE_SCHEDULING
~obliv() printf("BEGIN WOM WRITE %lld\n", current_timestamp());
#endif
~obliv(en) {
memset(rom->blocktemp, 0, rom->memblocksize*sizeof(obliv uint8_t));
obliv if (en) {
......@@ -178,6 +191,10 @@ void scanwrom_write_with_blockvector(scanwrom* rom, obliv uint8_t * active_block
scanwrom_write_with_blockvector_offline(rom->local_data, blockvector, bitvector, rom->local_blocktemp, rom->memblocksize, rom->blockcount);
}
#ifdef PROFILE_SCHEDULING
~obliv() printf("END WOM WRITE %lld\n", current_timestamp());
#endif
}
void scanwrom_read_xor_shares(uint8_t * data, scanwrom* rom, size_t index, size_t len) {
......
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