Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > Vthread > Vthread__Best_Effort_Msg__Bench
changeset 21:08b37152b48d tip
cleanup
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Tue, 13 Mar 2012 19:09:11 +0100 |
| parents | 29b273cf3b1f |
| children | |
| files | main.c |
| diffstat | 1 files changed, 9 insertions(+), 12 deletions(-) [+] |
line diff
1.1 --- a/main.c Tue Mar 13 12:25:48 2012 +0100 1.2 +++ b/main.c Tue Mar 13 19:09:11 2012 +0100 1.3 @@ -219,7 +219,7 @@ 1.4 if(msg == (BROADCAST_ACK) && threadData->broadcasterStatus == RECEIVING_ACK) 1.5 { 1.6 threadData->receivedACKs++; 1.7 - if(threadData->receivedACKs == NUM_CORES/2)//chose next broadcaster 1.8 + if(threadData->receivedACKs == NUM_CORES-2)//chose next broadcaster 1.9 { 1.10 do{ 1.11 receiverID = randomNumber(&seed1, &seed2) % NUM_CORES; 1.12 @@ -237,7 +237,7 @@ 1.13 threadData->terminate = TRUE; 1.14 return; 1.15 } 1.16 - // 1.17 + //I'm the next broadcaster! 1.18 threadData->broadcasterStatus = BROADCASTING; 1.19 } 1.20 1.21 @@ -247,8 +247,6 @@ 1.22 worker_TLF(void* _params, VirtProcr* animatingPr) 1.23 { 1.24 unsigned int msgCounter; 1.25 - unsigned int broadcaster; 1.26 - uint32_t wait_iterations; 1.27 WorkerParams* params = (WorkerParams*)_params; 1.28 unsigned int totalWorkCycles = 0, totalBadCycles = 0; 1.29 unsigned int totalSyncCycles = 0, totalBadSyncCycles = 0; 1.30 @@ -279,21 +277,18 @@ 1.31 msgHandler, 1.32 params); 1.33 1.34 - lossyCom__endpointID_t receiverID; 1.35 msgCounter = 0; 1.36 while(msgCounter <= num_msg_to_send) 1.37 { 1.38 - int i; 1.39 - 1.40 if(params->broadcasterStatus == BROADCASTING) 1.41 { 1.42 if(msgCounter == num_msg_to_send)//send termination msg 1.43 { 1.44 - lossyCom__sendMsg(&comEndpoint,BROADCAST_ID, TERMINATE); 1.45 + lossyCom__broadcastMsg(&comEndpoint, TERMINATE); 1.46 break; 1.47 }else{ //generate and send random message 1.48 params->receivedACKs = 0; 1.49 - lossyCom__sendMsg(&comEndpoint, BROADCAST_ID, BROADCAST); 1.50 + lossyCom__broadcastMsg(&comEndpoint, BROADCAST); 1.51 global_broadcast_counter++; 1.52 if(global_broadcast_counter % 1000 == 0){ 1.53 printf("broadcast count: %d\n", global_broadcast_counter); 1.54 @@ -320,6 +315,7 @@ 1.55 else {totalBadCycles += numCycles; } 1.56 #endif 1.57 1.58 + //wait for all threads to finish 1.59 barrier_wait(params->barrier, animatingPr); 1.60 1.61 params->totalWorkCycles = totalWorkCycles; 1.62 @@ -344,7 +340,7 @@ 1.63 /* this is run after the VMS is set up*/ 1.64 void benchmark(void *_params, VirtProcr *animatingPr) 1.65 { 1.66 - int i, cpuID, idx; 1.67 + int i; 1.68 struct barrier_t barr; 1.69 BenchParams *params; 1.70 1.71 @@ -368,12 +364,13 @@ 1.72 // init random number generator for wait and msg content 1.73 seed1 = rand()%1000; 1.74 seed2 = rand()%1000; 1.75 - 1.76 + 1.77 +#ifdef MEASURE_PERF 1.78 //save cycles before execution of threads, to get total exe cycles 1.79 measurement_t *startExeCycles, *endExeCycles; 1.80 startExeCycles = params->startExeCycles; 1.81 1.82 -#ifdef MEASURE_PERF 1.83 + 1.84 int nread = read(cycles_counter_main_fd, &(startExeCycles->cycles), 1.85 sizeof(startExeCycles->cycles)); 1.86 if(nread<0) perror("Error reading cycles counter");
