#include #include #include #include #include "spir.hpp" using std::cout; using std::cerr; static inline size_t elapsed_us(const struct timeval *start) { struct timeval end; gettimeofday(&end, NULL); return (end.tv_sec-start->tv_sec)*1000000 + end.tv_usec - start->tv_usec; } int main(int argc, char **argv) { if (argc < 2 || argc > 5) { cerr << "Usage: " << argv[0] << " r [num_threads [num_preproc [num_pirs]]]\n"; cerr << "r = log_2(num_records)\n"; exit(1); } uint32_t r, num_threads = 1, num_preproc = 1, num_pirs = 1; r = strtoul(argv[1], NULL, 10); if (argc > 2) { num_threads = strtoul(argv[2], NULL, 10); } if (argc > 3) { num_preproc = strtoul(argv[3], NULL, 10); } if (argc > 4) { num_pirs = strtoul(argv[4], NULL, 10); } else { num_pirs = num_preproc; } cout << "===== ONE-TIME SETUP =====\n\n"; struct timeval otsetup_start; gettimeofday(&otsetup_start, NULL); SPIR::init(num_threads); string pub_params; SPIR_Client client(r, pub_params); cout << "pub_params len = " << pub_params.length() << "\n"; SPIR_Server server(r, pub_params); size_t otsetup_us = elapsed_us(&otsetup_start); cout << "One-time setup: " << otsetup_us << " µs\n"; return 0; }