int __cdecl main(int argc, char **argv) { // Initialize the global parameters params = &Globals; try_parse_args(params, argc, argv); #ifdef SORA_PLATFORM // Start Sora HW if (Globals.inType == TY_SDR || Globals.outType == TY_SDR) { #ifdef BLADE_RF if (BladeRF_RadioStart(params) < 0) { exit(1); } #endif #ifdef SORA_RF // SORA RadioStart(&Globals); if (Globals.inType == TY_SDR) { InitSoraRx(params); } if (Globals.outType == TY_SDR) { InitSoraTx(params); } #endif } // Start NDIS if (Globals.inType == TY_IP || Globals.outType == TY_IP) { HRESULT hResult = SoraUEnableGetTxPacket(); assert(hResult == S_OK); Ndis_init(NULL); } // Start measuring time initMeasurementInfo(&(Globals.measurementInfo), Globals.latencyCDFSize); #endif // Init initBufCtxBlock(&buf_ctx); initHeapCtxBlock(&heap_ctx, Globals.heapSize); wpl_global_init(Globals.heapSize); wpl_input_initialize(); #ifdef SORA_PLATFORM ///////////////////////////////////////////////////////////////////////////// // DV: Pass the User_Routines here int no_threads = wpl_set_up_threads(User_Routines); printf("Setting up threads...\n"); ULONGLONG ttstart, ttend; printf("Starting %d threads...\n", no_threads); StartThreads(&ttstart, &ttend, &Globals.measurementInfo.tsinfo, no_threads, User_Routines); printf("Total input items (including EOF): %d (%d B), output items: %d (%d B)\n", buf_ctx.total_in, buf_ctx.total_in*buf_ctx.size_in, buf_ctx.total_out, buf_ctx.total_out*buf_ctx.size_out); printf("Time Elapsed: %ld us \n", SoraTimeElapsed((ttend / 1000 - ttstart / 1000), &Globals.measurementInfo.tsinfo)); if (Globals.latencySampling > 0) { printf("Min write latency: %ld, max write latency: %ld\n", (ulong)Globals.measurementInfo.minDiff, (ulong) Globals.measurementInfo.maxDiff); printf("CDF: \n "); unsigned int i = 0; while (i < Globals.measurementInfo.aDiffPtr) { printf("%ld ", Globals.measurementInfo.aDiff[i]); if (i % 10 == 9) { printf("\n "); } i++; } printf("\n"); } // Free thread separators // NB: these are typically allocated in blink_set_up_threads ts_free(); #else int usec; #ifdef __GNUC__ struct timespec start, end; clock_gettime(CLOCK_MONOTONIC, &start); wpl_go(); clock_gettime(CLOCK_MONOTONIC, &end); usec = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000; #else clock_t start = clock(), diff; wpl_go(); diff = clock() - start; usec = diff * 1000000 / CLOCKS_PER_SEC; #endif printf("Time Elapsed: %d\n", usec); #endif printf("Bytes copied: %ld\n", bytes_copied); wpl_output_finalize(); #ifdef SORA_PLATFORM // Stop Sora HW if (Globals.inType == TY_SDR || Globals.outType == TY_SDR) { #ifdef BLADE_RF BladeRF_RadioStop(params); #endif #ifdef SORA_RF RadioStop(&Globals); #endif } // Stop NDIS if (Globals.inType == TY_IP || Globals.outType == TY_IP) { if (hUplinkThread != NULL) { // Sora cleanup. SoraUThreadStop(hUplinkThread); SoraUThreadFree(hUplinkThread); } SoraUDisableGetTxPacket(); // Winsock cleanup. closesocket(ConnectSocket); WSACleanup(); } #endif return 0; }
int __cdecl main(int argc, char **argv) { ULONGLONG ttstart, ttend; params_tx = &(params[0]); params_rx = &(params[1]); // Initialize the global parameters try_parse_args(params, argc, argv); printf("Setting up threads...\n"); if (mac_type == 0) { // **** Single-thread MAC // Initialize various parameters init_mac_1thread(); //SINGLE MODULE CODE: int no_threads = wpl_set_up_threads_tx(User_Routines); int no_threads = SetUpThreads_1t(User_Routines); StartThreads(&ttstart, &ttend, &(params_tx->measurementInfo.tsinfo), no_threads, User_Routines); printf("Time Elapsed: %ld us \n", SoraTimeElapsed((ttend / 1000 - ttstart / 1000), &(params_tx->measurementInfo.tsinfo))); if (params_tx->latencySampling > 0) { printf("Min write latency: %ld, max write latency: %ld\n", (ulong)params_tx->measurementInfo.minDiff, (ulong)params_tx->measurementInfo.maxDiff); printf("CDF: \n "); unsigned int i = 0; while (i < params_tx->measurementInfo.aDiffPtr) { printf("%ld ", params_tx->measurementInfo.aDiff[i]); if (i % 10 == 9) { printf("\n "); } i++; } printf("\n"); } } else { // **** TX/RX(2)-threaded MAC // Initialize various parameters init_mac_2threads(); //SINGLE MODULE CODE: int no_threads = wpl_set_up_threads_tx(User_Routines); int no_threads = SetUpThreads_2t(User_Routines); StartThreads(&ttstart, &ttend, &(params_tx->measurementInfo.tsinfo), no_threads, User_Routines); printf("Time Elapsed: %ld us \n", SoraTimeElapsed((ttend / 1000 - ttstart / 1000), &(params_tx->measurementInfo.tsinfo))); } // Free thread separators // NB: these are typically allocated in blink_set_up_threads ts_free(); // Start Sora HW if (params_rx->inType == TY_SORA || params_tx->outType == TY_SORA) { RadioStop(*params_tx); } // Start NDIS if (params_tx->inType == TY_IP) { if (hUplinkThread != NULL) { // Sora cleanup. SoraUThreadStop(hUplinkThread); SoraUThreadFree(hUplinkThread); } SoraUDisableGetTxPacket(); // Winsock cleanup. closesocket(ConnectSocket); WSACleanup(); } if (params_rx->outType == TY_IP) { // To be implemented /* if (hUplinkThread != NULL) { // Sora cleanup. SoraUThreadStop(hUplinkThread); SoraUThreadFree(hUplinkThread); } SoraUDisableGetTxPacket(); // Winsock cleanup. closesocket(ConnectSocket); WSACleanup(); */ } return 0; }