# HG changeset patch # User Merten Sach # Date 1323235066 -3600 # Node ID 5d3b5e58456e325009300a03dd688333fb78d46e # Parent b2a84bc2b2743c6c5f3f7a2880b422a63357a28c Working version, uses TSC for inner loop -- appears more stable diff -r b2a84bc2b274 -r 5d3b5e58456e src/Application/main.c --- a/src/Application/main.c Mon Nov 28 23:58:58 2011 +0100 +++ b/src/Application/main.c Wed Dec 07 06:17:46 2011 +0100 @@ -119,12 +119,17 @@ -struct WorkerParamsStr{ - struct barrier_t* barrier; - uint64_t totalWorkCycles; -}; +typedef struct + { struct barrier_t* barrier; + uint64_t totalWorkCycles; + uint64_t totalBadCycles; + uint64_t totalSyncCycles; + uint64_t totalBadSyncCycles; + uint64 numGoodSyncs; + uint64 numGoodTasks; + } +WorkerParams; -typedef struct WorkerParamsStr WorkerParams; typedef struct { measurement_t *startExeCycles; @@ -136,7 +141,7 @@ char __ProgrammName[] = "overhead_test"; char __DataSet[255]; -int repetitions, workload_size, num_threads; +int outer_iters, inner_iters, num_threads; size_t chunk_size = 0; int cycles_counter_fd[NUM_CORES]; @@ -161,47 +166,72 @@ } while (0) //macro magic for scoping -void worker_TLF(void* _params, VirtProcr* animatingPr) +double +worker_TLF(void* _params, VirtProcr* animatingPr) { int i,o; - WorkerParams* params = (struct WorkerParamsStr*)_params; - unsigned int totalWorkCycles = 0; - unsigned int workspace1=0; + WorkerParams* params = (WorkerParams*)_params; + unsigned int totalWorkCycles = 0, totalBadCycles = 0; + unsigned int totalSyncCycles = 0, totalBadSyncCycles = 0; + unsigned int workspace1=0, numGoodSyncs = 0, numGoodTasks = 0; double workspace2=0.0; int32 privateMutex = VPThread__make_mutex(animatingPr); int cpuid = sched_getcpu(); - - for(o=0; ototalWorkCycles = totalWorkCycles; - //printf("Cycles: %lu on CPU %lu\n", totalWorkCycles, cpuid); + params->totalBadCycles = totalBadCycles; + params->numGoodTasks = numGoodTasks; + params->totalSyncCycles = totalSyncCycles; + params->totalBadSyncCycles = totalBadSyncCycles; + params->numGoodSyncs = numGoodSyncs; +/* + params->totalSyncCycles = VMS__give_num_plugin_cycles(); + params->totalBadSyncCycles = 0; + params->numGoodSyncs = VMS__give_num_plugin_animations(); +*/ //Wait for all threads to end @@ -209,9 +239,9 @@ //Shutdown worker VPThread__dissipate_thread(animatingPr); - //below printfs never reached --> there for gcc - printf("%d", workspace1); //This is to prevent gcc from optimizing out the - printf("%f", workspace2); //two workspace variables + + //below return never reached --> there for gcc + return (workspace1 + workspace2); //to prevent gcc from optimizing work out } @@ -232,33 +262,22 @@ workerParamsArray[i].barrier = &barr; } - //printf("just before first counter read, inside benchmark\n"); - //save cycles before execution of threads, to get total exe cycles measurement_t *startExeCycles, *endExeCycles; startExeCycles = params->startExeCycles; - //endExeCycles = params->endExeCycles; - - //printf("finished first counter read, inside benchmark\n"); - //create all threads - for(i=0; icycles), sizeof(startExeCycles->cycles)); - if(nread<0) - { perror("Error reading cycles counter"); + if(nread<0) perror("Error reading cycles counter"); + + //create (which starts running) all threads + for(i=0; icycles), \ - sizeof(endExeCycles->cycles)); - // if(nread<0){ - // perror("Error reading cycles counter"); + //endBarrierCycles read in barrier_wait()! Merten, email me if want to chg params->endExeCycles->cycles = barr.endBarrierCycles.cycles; @@ -283,10 +302,6 @@ int main(int argc, char **argv) { int i; - measurement_t startExeCycles, endExeCycles; - BenchParams *benchParams; - - benchParams = malloc(sizeof(BenchParams)); //set global static variables, based on cmd-line args for(i=1; istartExeCycles = &startExeCycles; + benchParams->endExeCycles = &endExeCycles; + workerParamsArray = (WorkerParams *)malloc( (num_threads + 1) * sizeof(WorkerParams) ); if(workerParamsArray == NULL ) printf("error mallocing worker params array\n"); - workerParamsArray[0].totalWorkCycles = 0; - - benchParams->startExeCycles = &startExeCycles; - benchParams->endExeCycles = &endExeCycles; - + //This is the transition to the VMS runtime VPThread__create_seed_procr_and_do_work( &benchmark, benchParams ); - uint64_t totalWorkCyclesAcrossCores = 0; + uint64_t totalWorkCyclesAcrossCores = 0, totalBadCyclesAcrossCores = 0; + uint64_t totalSyncCyclesAcrossCores = 0, totalBadSyncCyclesAcrossCores = 0; for(i=0; i