/* ============================================================================= * main * ============================================================================= */ MAIN(argc, argv) { GOTO_REAL(); SETUP_NUMBER_TASKS(6); /* * Initialization */ parseArgs(argc, (char** const)argv); SIM_GET_NUM_CPU(global_numThread); TM_STARTUP(global_numThread, 0); P_MEMORY_STARTUP(global_numThread); SETUP_NUMBER_THREADS(global_numThread); thread_startup(global_numThread); int repeat = global_repeats; double time_total = 0.0; double energy_total = 0.0; for (; repeat > 0; --repeat) { global_meshPtr = mesh_alloc(); assert(global_meshPtr); long initNumElement = mesh_read(global_meshPtr, global_inputPrefix); global_workHeapPtr = heap_alloc(1, &element_heapCompare); assert(global_workHeapPtr); long initNumBadElement = initializeWork(global_workHeapPtr, global_meshPtr); TIMER_T start; TIMER_READ(start); GOTO_SIM(); thread_start(process, NULL); GOTO_REAL(); TIMER_T stop; TIMER_READ(stop); double time_tmp = TIMER_DIFF_SECONDS(start, stop); PRINT_STATS(); time_total += time_tmp; } printf("Time = %0.3lf\n", time_total); fflush(stdout); TM_SHUTDOWN(); P_MEMORY_SHUTDOWN(); GOTO_SIM(); thread_shutdown(); MAIN_RETURN(0); }
MAIN(argc, argv) { GOTO_REAL(); SETUP_NUMBER_TASKS(10); /* * Tuple for Scalable Data Generation * stores startVertex, endVertex, long weight and other info */ graphSDG* SDGdata; /* * The graph data structure for this benchmark - see defs.h */ graph* G; #ifdef ENABLE_KERNEL2 /* * Kernel 2 */ edge* maxIntWtList; edge* soughtStrWtList; long maxIntWtListSize; long soughtStrWtListSize; #endif /* ENABLE_KERNEL2 */ #ifdef ENABLE_KERNEL3 # ifndef ENABLE_KERNEL2 # error KERNEL3 requires KERNEL2 # endif /* * Kernel 3 */ V* intWtVList = NULL; V* strWtVList = NULL; Vl** intWtVLList = NULL; Vl** strWtVLList = NULL; Vd* intWtVDList = NULL; Vd* strWtVDList = NULL; #endif /* ENABLE_KERNEL3 */ double totalTime = 0.0; /* ------------------------------------------------------------------------- * Preamble * ------------------------------------------------------------------------- */ /* * User Interface: Configurable parameters, and global program control */ getUserParameters(argc, (char** const) argv); SIM_GET_NUM_CPU(THREADS); TM_STARTUP(THREADS, 0); P_MEMORY_STARTUP(THREADS); SETUP_NUMBER_THREADS(THREADS); thread_startup(THREADS); double time_total = 0.0; int repeat = REPEATS; for (; repeat > 0; --repeat) { SDGdata = (graphSDG*)malloc(sizeof(graphSDG)); assert(SDGdata); genScalData_seq(SDGdata); G = (graph*)malloc(sizeof(graph)); assert(G); computeGraph_arg_t computeGraphArgs; computeGraphArgs.GPtr = G; computeGraphArgs.SDGdataPtr = SDGdata; TIMER_T start; TIMER_READ(start); GOTO_SIM(); thread_start(computeGraph, (void*)&computeGraphArgs); GOTO_REAL(); TIMER_T stop; TIMER_READ(stop); double time_tmp = TIMER_DIFF_SECONDS(start, stop); PRINT_STATS(); time_total += time_tmp; } totalTime += time_total; #ifdef ENABLE_KERNEL2 /* ------------------------------------------------------------------------- * Kernel 2 - Find Max weight and sought string * ------------------------------------------------------------------------- */ printf("\nKernel 2 - getStartLists() beginning execution...\n"); maxIntWtListSize = 0; soughtStrWtListSize = 0; maxIntWtList = (edge*)malloc(sizeof(edge)); assert(maxIntWtList); soughtStrWtList = (edge*)malloc(sizeof(edge)); assert(soughtStrWtList); getStartLists_arg_t getStartListsArg; getStartListsArg.GPtr = G; getStartListsArg.maxIntWtListPtr = &maxIntWtList; getStartListsArg.maxIntWtListSize = &maxIntWtListSize; getStartListsArg.soughtStrWtListPtr = &soughtStrWtList; getStartListsArg.soughtStrWtListSize = &soughtStrWtListSize; TIMER_READ(start); GOTO_SIM(); #ifdef OTM #pragma omp parallel { getStartLists((void*)&getStartListsArg); } #else thread_start(getStartLists, (void*)&getStartListsArg); #endif GOTO_REAL(); TIMER_T stop; TIMER_READ(stop); time = TIMER_DIFF_SECONDS(start, stop); totalTime += time; printf("\n\tgetStartLists() completed execution.\n"); printf("\nTime taken for kernel 2 is %9.6f sec.\n\n", time); #endif /* ENABLE_KERNEL2 */ #ifdef ENABLE_KERNEL3 /* ------------------------------------------------------------------------- * Kernel 3 - Graph Extraction * ------------------------------------------------------------------------- */ printf("\nKernel 3 - findSubGraphs() beginning execution...\n"); if (K3_DS == 0) { intWtVList = (V*)malloc(G->numVertices * maxIntWtListSize * sizeof(V)); assert(intWtVList); strWtVList = (V*)malloc(G->numVertices * soughtStrWtListSize * sizeof(V)); assert(strWtVList); findSubGraphs0_arg_t findSubGraphs0Arg; findSubGraphs0Arg.GPtr = G; findSubGraphs0Arg.intWtVList = intWtVList; findSubGraphs0Arg.strWtVList = strWtVList; findSubGraphs0Arg.maxIntWtList = maxIntWtList; findSubGraphs0Arg.maxIntWtListSize = maxIntWtListSize; findSubGraphs0Arg.soughtStrWtList = soughtStrWtList; findSubGraphs0Arg.soughtStrWtListSize = soughtStrWtListSize; TIMER_READ(start); GOTO_SIM(); #ifdef OTM #pragma omp parallel { findSubGraphs0((void*)&findSubGraphs0Arg); } #else thread_start(findSubGraphs0, (void*)&findSubGraphs0Arg); #endif GOTO_REAL(); TIMER_READ(stop); } else if (K3_DS == 1) { intWtVLList = (Vl**)malloc(maxIntWtListSize * sizeof(Vl*)); assert(intWtVLList); strWtVLList = (Vl**)malloc(soughtStrWtListSize * sizeof(Vl*)); assert(strWtVLList); findSubGraphs1_arg_t findSubGraphs1Arg; findSubGraphs1Arg.GPtr = G; findSubGraphs1Arg.intWtVLList = intWtVLList; findSubGraphs1Arg.strWtVLList = strWtVLList; findSubGraphs1Arg.maxIntWtList = maxIntWtList; findSubGraphs1Arg.maxIntWtListSize = maxIntWtListSize; findSubGraphs1Arg.soughtStrWtList = soughtStrWtList; findSubGraphs1Arg.soughtStrWtListSize = soughtStrWtListSize; TIMER_READ(start); GOTO_SIM(); #ifdef OTM #pragma omp parallel { findSubGraphs1((void*)&findSubGraphs1Arg); } #else thread_start(findSubGraphs1, (void*)&findSubGraphs1Arg); #endif GOTO_REAL(); TIMER_READ(stop); /* Verification on_one_thread { for (i=0; i<maxIntWtListSize; i++) { printf("%ld -- ", i); currV = intWtVLList[i]; while (currV != NULL) { printf("[%ld %ld] ", currV->num, currV->depth); currV = currV->next; } printf("\n"); } for (i=0; i<soughtStrWtListSize; i++) { printf("%ld -- ", i); currV = strWtVLList[i]; while (currV != NULL) { printf("[%ld %ld] ", currV->num, currV->depth); currV = currV->next; } printf("\n"); } } */ } else if (K3_DS == 2) { intWtVDList = (Vd *) malloc(maxIntWtListSize * sizeof(Vd)); assert(intWtVDList); strWtVDList = (Vd *) malloc(soughtStrWtListSize * sizeof(Vd)); assert(strWtVDList); findSubGraphs2_arg_t findSubGraphs2Arg; findSubGraphs2Arg.GPtr = G; findSubGraphs2Arg.intWtVDList = intWtVDList; findSubGraphs2Arg.strWtVDList = strWtVDList; findSubGraphs2Arg.maxIntWtList = maxIntWtList; findSubGraphs2Arg.maxIntWtListSize = maxIntWtListSize; findSubGraphs2Arg.soughtStrWtList = soughtStrWtList; findSubGraphs2Arg.soughtStrWtListSize = soughtStrWtListSize; TIMER_READ(start); GOTO_SIM(); #ifdef OTM #pragma omp parallel { findSubGraphs2((void*)&findSubGraphs2Arg); } #else thread_start(findSubGraphs2, (void*)&findSubGraphs2Arg); #endif GOTO_REAL(); TIMER_READ(stop); /* Verification */ /* on_one_thread { printf("\nInt weight sub-graphs \n"); for (i=0; i<maxIntWtListSize; i++) { printf("%ld -- ", i); for (j=0; j<intWtVDList[i].numArrays; j++) { printf("\n [Array %ld] - \n", j); for (k=0; k<intWtVDList[i].arraySize[j]; k++) { printf("[%ld %ld] ", intWtVDList[i].vList[j][k].num, intWtVDList[i].vList[j][k].depth); } } printf("\n"); } printf("\nStr weight sub-graphs \n"); for (i=0; i<soughtStrWtListSize; i++) { printf("%ld -- ", i); for (j=0; j<strWtVDList[i].numArrays; j++) { printf("\n [Array %ld] - \n", j); for (k=0; k<strWtVDList[i].arraySize[j]; k++) { printf("[%ld %ld] ", strWtVDList[i].vList[j][k].num, strWtVDList[i].vList[j][k].depth); } } printf("\n"); } } */ } else { assert(0); } time = TIMER_DIFF_SECONDS(start, stop); totalTime += time; printf("\n\tfindSubGraphs() completed execution.\n"); printf("\nTime taken for kernel 3 is %9.6f sec.\n\n", time); #endif /* ENABLE_KERNEL3 */ #ifdef ENABLE_KERNEL4 /* ------------------------------------------------------------------------- * Kernel 4 - Graph Clustering * ------------------------------------------------------------------------- */ printf("\nKernel 4 - cutClusters() beginning execution...\n"); TIMER_READ(start); GOTO_SIM(); #ifdef OTM #pragma omp parallel { cutClusters((void*)G); } #else thread_start(cutClusters, (void*)G); #endif GOTO_REAL(); TIMER_READ(stop); time = TIMER_DIFF_SECONDS(start, stop); totalTime += time; printf("\n\tcutClusters() completed execution.\n"); printf("\nTime taken for Kernel 4 is %9.6f sec.\n\n", time); #endif /* ENABLE_KERNEL4 */ printf("Time = %9.6f \n", totalTime); /* ------------------------------------------------------------------------- * Cleanup * ------------------------------------------------------------------------- */ P_FREE(G->outDegree); P_FREE(G->outVertexIndex); P_FREE(G->outVertexList); P_FREE(G->paralEdgeIndex); P_FREE(G->inDegree); P_FREE(G->inVertexIndex); P_FREE(G->inVertexList); P_FREE(G->intWeight); P_FREE(G->strWeight); #ifdef ENABLE_KERNEL3 LONGINT_T i; LONGINT_T j; Vl* currV; Vl* tempV; if (K3_DS == 0) { P_FREE(strWtVList); P_FREE(intWtVList); } if (K3_DS == 1) { for (i = 0; i < maxIntWtListSize; i++) { currV = intWtVLList[i]; while (currV != NULL) { tempV = currV->next; P_FREE(currV); currV = tempV; } } for (i = 0; i < soughtStrWtListSize; i++) { currV = strWtVLList[i]; while (currV != NULL) { tempV = currV->next; P_FREE(currV); currV = tempV; } } P_FREE(strWtVLList); P_FREE(intWtVLList); } if (K3_DS == 2) { for (i = 0; i < maxIntWtListSize; i++) { for (j = 0; j < intWtVDList[i].numArrays; j++) { P_FREE(intWtVDList[i].vList[j]); } P_FREE(intWtVDList[i].vList); P_FREE(intWtVDList[i].arraySize); } for (i = 0; i < soughtStrWtListSize; i++) { for (j = 0; j < strWtVDList[i].numArrays; j++) { P_FREE(strWtVDList[i].vList[j]); } P_FREE(strWtVDList[i].vList); P_FREE(strWtVDList[i].arraySize); } P_FREE(strWtVDList); P_FREE(intWtVDList); } P_FREE(soughtStrWtList); P_FREE(maxIntWtList); #endif /* ENABLE_KERNEL2 */ P_FREE(SOUGHT_STRING); P_FREE(G); P_FREE(SDGdata); TM_SHUTDOWN(); P_MEMORY_SHUTDOWN(); GOTO_SIM(); thread_shutdown(); MAIN_RETURN(0); }
static void print_performance_data (void) { GList *iter; gint i = 0; GstClockTime last_start = 0; CaptureTimingStats max; CaptureTimingStats min; CaptureTimingStats avg; CaptureTimingStats avg_wo_first; GstClockTime shot_to_shot; if (!performance_measure) return; parse_target_values (); /* Initialize stats */ min.shot_to_shot = -1; min.shot_to_save = -1; min.shot_to_snapshot = -1; min.preview_to_precapture = -1; min.shot_to_buffer = -1; memset (&avg, 0, sizeof (CaptureTimingStats)); memset (&avg_wo_first, 0, sizeof (CaptureTimingStats)); memset (&max, 0, sizeof (CaptureTimingStats)); g_print ("-- Performance results --\n"); g_print ("Startup time: %" TIME_FORMAT "; Target: %" TIME_FORMAT "\n", TIME_ARGS (startup_time - initial_time), TIME_ARGS (target_startup)); g_print ("Change mode time: %" TIME_FORMAT "; Target: %" TIME_FORMAT "\n", TIME_ARGS (change_mode_after - change_mode_before), TIME_ARGS (target_change_mode)); g_print ("\n | Shot to save |Shot to snapshot| Shot to shot |" "Preview to precap| Shot to buffer\n"); capture_times = g_list_reverse (capture_times); for (iter = capture_times; iter; iter = g_list_next (iter)) { CaptureTiming *t = (CaptureTiming *) iter->data; CaptureTimingStats stats; stats.shot_to_save = SHOT_TO_SAVE (t); stats.shot_to_snapshot = SHOT_TO_SNAPSHOT (t); stats.shot_to_shot = i == 0 ? 0 : t->start_capture - last_start; stats.preview_to_precapture = PREVIEW_TO_PRECAPTURE (t); stats.shot_to_buffer = SHOT_TO_BUFFER (t); PRINT_STATS (i, &stats); if (i != 0) { capture_timing_stats_add (&avg_wo_first, &stats); } capture_timing_stats_add (&avg, &stats); if (stats.shot_to_save < min.shot_to_save) { min.shot_to_save = stats.shot_to_save; } if (stats.shot_to_snapshot < min.shot_to_snapshot) { min.shot_to_snapshot = stats.shot_to_snapshot; } if (stats.shot_to_shot < min.shot_to_shot && stats.shot_to_shot > 0) { min.shot_to_shot = stats.shot_to_shot; } if (stats.preview_to_precapture < min.preview_to_precapture) { min.preview_to_precapture = stats.preview_to_precapture; } if (stats.shot_to_buffer < min.shot_to_buffer) { min.shot_to_buffer = stats.shot_to_buffer; } if (stats.shot_to_save > max.shot_to_save) { max.shot_to_save = stats.shot_to_save; } if (stats.shot_to_snapshot > max.shot_to_snapshot) { max.shot_to_snapshot = stats.shot_to_snapshot; } if (stats.shot_to_shot > max.shot_to_shot) { max.shot_to_shot = stats.shot_to_shot; } if (stats.preview_to_precapture > max.preview_to_precapture) { max.preview_to_precapture = stats.preview_to_precapture; } if (stats.shot_to_buffer > max.shot_to_buffer) { max.shot_to_buffer = stats.shot_to_buffer; } last_start = t->start_capture; i++; } if (i > 1) shot_to_shot = avg.shot_to_shot / (i - 1); else shot_to_shot = GST_CLOCK_TIME_NONE; capture_timing_stats_div (&avg, i); avg.shot_to_shot = shot_to_shot; if (i > 1) capture_timing_stats_div (&avg_wo_first, i - 1); else { memset (&avg_wo_first, 0, sizeof (CaptureTimingStats)); } g_print ("\n Stats | MIN | MAX |" " AVG | AVG wo First | Target | Diff \n"); g_print ("Shot to shot | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIMEDIFF_FORMAT "\n", TIME_ARGS (min.shot_to_shot), TIME_ARGS (max.shot_to_shot), TIME_ARGS (avg.shot_to_shot), TIME_ARGS (avg_wo_first.shot_to_shot), TIME_ARGS (target_shot_to_shot), TIMEDIFF_ARGS (TIME_DIFF (avg.shot_to_shot, target_shot_to_shot))); g_print ("Shot to save | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIMEDIFF_FORMAT "\n", TIME_ARGS (min.shot_to_save), TIME_ARGS (max.shot_to_save), TIME_ARGS (avg.shot_to_save), TIME_ARGS (avg_wo_first.shot_to_save), TIME_ARGS (target_shot_to_save), TIMEDIFF_ARGS (TIME_DIFF (avg.shot_to_save, target_shot_to_save))); g_print ("Shot to snapshot | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIMEDIFF_FORMAT "\n", TIME_ARGS (min.shot_to_snapshot), TIME_ARGS (max.shot_to_snapshot), TIME_ARGS (avg.shot_to_snapshot), TIME_ARGS (avg_wo_first.shot_to_snapshot), TIME_ARGS (target_shot_to_snapshot), TIMEDIFF_ARGS (TIME_DIFF (avg.shot_to_snapshot, target_shot_to_snapshot))); g_print ("Preview to precapture | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIMEDIFF_FORMAT "\n", TIME_ARGS (min.preview_to_precapture), TIME_ARGS (max.preview_to_precapture), TIME_ARGS (avg.preview_to_precapture), TIME_ARGS (avg_wo_first.preview_to_precapture), TIME_ARGS (target_preview_to_precapture), TIMEDIFF_ARGS (TIME_DIFF (avg.preview_to_precapture, target_preview_to_precapture))); g_print ("Shot to buffer | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIME_FORMAT " | %" TIMEDIFF_FORMAT "\n", TIME_ARGS (min.shot_to_buffer), TIME_ARGS (max.shot_to_buffer), TIME_ARGS (avg.shot_to_buffer), TIME_ARGS (avg_wo_first.shot_to_buffer), TIME_ARGS (target_shot_to_buffer), TIMEDIFF_ARGS (TIME_DIFF (avg.shot_to_buffer, target_shot_to_buffer))); }
void dump_cache_stats(void) { PRINT_STATS(ParsedPMinisock); PRINT_STATS(Continuation); }
/* ============================================================================= * main * ============================================================================= */ MAIN(argc, argv) { GOTO_REAL(); /* * Initialization */ SETUP_NUMBER_TASKS(3); parseArgs(argc, (char** const)argv); long numThread = global_params[PARAM_THREAD]; SETUP_NUMBER_THREADS(numThread); SIM_GET_NUM_CPU(numThread); TM_STARTUP(numThread, 0); P_MEMORY_STARTUP(numThread); thread_startup(numThread); long percentAttack = global_params[PARAM_ATTACK]; long maxDataLength = global_params[PARAM_LENGTH]; long numFlow = global_params[PARAM_NUM]; long randomSeed = global_params[PARAM_SEED]; /* printf("Percent attack = %li\n", percentAttack); printf("Max data length = %li\n", maxDataLength); printf("Num flow = %li\n", numFlow); printf("Random seed = %li\n", randomSeed); */ double time_total = 0.0; int repeats = global_params[PARAM_REPEAT]; for (; repeats > 0; --repeats) { dictionary_t* dictionaryPtr = dictionary_alloc(); assert(dictionaryPtr); stream_t* streamPtr = stream_alloc(percentAttack); assert(streamPtr); long numAttack = stream_generate(streamPtr, dictionaryPtr, numFlow, randomSeed, maxDataLength); // printf("Num attack = %li\n", numAttack); decoder_t* decoderPtr = decoder_alloc(); assert(decoderPtr); vector_t** errorVectors = (vector_t**)malloc(numThread * sizeof(vector_t*)); assert(errorVectors); long i; for (i = 0; i < numThread; i++) { vector_t* errorVectorPtr = vector_alloc(numFlow); assert(errorVectorPtr); errorVectors[i] = errorVectorPtr; } arg_t arg; arg.streamPtr = streamPtr; arg.decoderPtr = decoderPtr; arg.errorVectors = errorVectors; /* * Run transactions */ TIMER_T startTime; TIMER_READ(startTime); tm_time_t start_clock=TM_TIMER_READ(); GOTO_SIM(); thread_start(processPackets, (void*)&arg); GOTO_REAL(); TIMER_T stopTime; tm_time_t end_clock=TM_TIMER_READ(); TIMER_READ(stopTime); double time_tmp = TIMER_DIFF_SECONDS(startTime, stopTime); time_total += time_tmp; PRINT_STATS(); PRINT_CLOCK_THROUGHPUT(end_clock-start_clock); /* * Check solution */ long numFound = 0; for (i = 0; i < numThread; i++) { vector_t* errorVectorPtr = errorVectors[i]; long e; long numError = vector_getSize(errorVectorPtr); numFound += numError; for (e = 0; e < numError; e++) { long flowId = (long)vector_at(errorVectorPtr, e); bool_t status = stream_isAttack(streamPtr, flowId); assert(status); } } // printf("Num found = %li\n", numFound); assert(numFound == numAttack); /* * Clean up */ for (i = 0; i < numThread; i++) { vector_free(errorVectors[i]); } free(errorVectors); decoder_free(decoderPtr); stream_free(streamPtr); dictionary_free(dictionaryPtr); } printf("Time = %f\n", time_total); TM_SHUTDOWN(); P_MEMORY_SHUTDOWN(); GOTO_SIM(); thread_shutdown(); MAIN_RETURN(0); }
XPT_DumpStats(XPTArena *arena) { PRINT_STATS(arena); }