# HG changeset patch # User kshalle # Date 1322521138 -3600 # Node ID b2a84bc2b2743c6c5f3f7a2880b422a63357a28c # Parent 28650a4df2b96093d24ffb8b36ebfc4fa1358e2c working version of exe time vs task size diff -r 28650a4df2b9 -r b2a84bc2b274 src/Application/main.c --- a/src/Application/main.c Mon Nov 21 21:39:03 2011 +0100 +++ b/src/Application/main.c Mon Nov 28 23:58:58 2011 +0100 @@ -61,6 +61,11 @@ #endif //======================== Defines ========================= +typedef struct perfData measurement_t; +struct perfData{ + uint64 cycles; + uint64 instructions; +}; const char *usage = { "Usage: malloc_test [options]\n" @@ -78,6 +83,8 @@ int nthreads; int32 mutex; int32 cond; + measurement_t endBarrierCycles; + }; typedef struct barrier_t barrier; @@ -89,13 +96,18 @@ barr->cond = VPThread__make_cond(barr->mutex, animatingPr); } +int cycles_counter_main_fd; void inline barrier_wait(barrier *barr, VirtProcr *animatingPr) { int i; VPThread__mutex_lock(barr->mutex, animatingPr); barr->counter++; if(barr->counter == barr->nthreads) - { barr->counter = 0; + { + read(cycles_counter_main_fd, &(barr->endBarrierCycles.cycles), \ + sizeof(barr->endBarrierCycles.cycles)); + + barr->counter = 0; for(i=0; i < barr->nthreads; i++) VPThread__cond_signal(barr->cond, animatingPr); } @@ -105,18 +117,20 @@ VPThread__mutex_unlock(barr->mutex, animatingPr); } -struct perfData{ - uint64 cycles; - uint64 instructions; + + +struct WorkerParamsStr{ + struct barrier_t* barrier; + uint64_t totalWorkCycles; }; -typedef struct perfData measurement_t; +typedef struct WorkerParamsStr WorkerParams; -struct input_t{ - struct barrier_t* barrier; - uint64 totalWorkCycles; -}; - +typedef struct + { measurement_t *startExeCycles; + measurement_t *endExeCycles; + } +BenchParams; //======================== Globals ========================= char __ProgrammName[] = "overhead_test"; @@ -126,9 +140,10 @@ size_t chunk_size = 0; int cycles_counter_fd[NUM_CORES]; -int cycles_counter_main_fd; struct perf_event_attr* hw_event; +WorkerParams *workerParamsArray; + //======================== App Code ========================= /* * Workload @@ -146,13 +161,13 @@ } while (0) //macro magic for scoping -void work(void* input, VirtProcr* animatingPr) +void worker_TLF(void* _params, VirtProcr* animatingPr) { int i,o; - struct input_t* in = (struct input_t*)input; + WorkerParams* params = (struct WorkerParamsStr*)_params; unsigned int totalWorkCycles = 0; - unsigned int workspace1; - double workspace2; + unsigned int workspace1=0; + double workspace2=0.0; int32 privateMutex = VPThread__make_mutex(animatingPr); int cpuid = sched_getcpu(); @@ -185,12 +200,12 @@ VPThread__mutex_unlock(privateMutex, animatingPr); } - in->totalWorkCycles = totalWorkCycles; - printf("Cycles: %lu on CPU %lu\n", totalWorkCycles, cpuid); + params->totalWorkCycles = totalWorkCycles; + //printf("Cycles: %lu on CPU %lu\n", totalWorkCycles, cpuid); //Wait for all threads to end - barrier_wait(in->barrier, animatingPr); + barrier_wait(params->barrier, animatingPr); //Shutdown worker VPThread__dissipate_thread(animatingPr); @@ -199,46 +214,55 @@ printf("%f", workspace2); //two workspace variables } + /* this is run after the VMS is set up*/ -void benchmark(void *in, VirtProcr *animatingPr) +void benchmark(void *_params, VirtProcr *animatingPr) { int i, cpuID; - struct input_t input[num_threads]; - struct barrier_t barr; + struct barrier_t barr; + BenchParams *params; + + params = (BenchParams *)_params; + barrier_init(&barr, num_threads+1, animatingPr); - - - + //prepare input for(i=0; istartExeCycles; + //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"); + } //wait for all threads to finish barrier_wait(&barr, animatingPr); //accumulated cycles of all cores - nread = read(cycles_counter_main_fd,&(endBenchTime.cycles), - sizeof(endBenchTime.cycles)); - if(nread<0){ - perror("Error reading cycles counter"); - } + // nread = read(cycles_counter_main_fd, &(endExeCycles->cycles), \ + sizeof(endExeCycles->cycles)); + // if(nread<0){ + // perror("Error reading cycles counter"); + params->endExeCycles->cycles = barr.endBarrierCycles.cycles; + +/* uint64_t overallWorkCycles = 0; for(i=0; istartExeCycles = &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; + for(i=0; i