static inline BLASULONG run_bench(BLASULONG address, long size) { BLASULONG original, *p; BLASULONG start, stop, min; int iter, i, count; min = (BLASULONG)-1; original = *(BLASULONG *)(address + size - PAGESIZE); *(BLASULONG *)(address + size - PAGESIZE) = (BLASULONG)address; for (iter = 0; iter < BENCH_ITERATION; iter ++ ) { p = (BLASULONG *)address; count = size / PAGESIZE; start = rpcc(); for (i = 0; i < count; i ++) { p = (BLASULONG *)(*p); } stop = rpcc(); if (min > stop - start) min = stop - start; } *(BLASULONG *)(address + size - PAGESIZE + 0) = original; *(BLASULONG *)(address + size - PAGESIZE + 8) = (BLASULONG)p; return min; }
int32 host_pclk(int32 dummy) { int32 mhz = 0; #if (__ALPHA_OSF1__) int32 i, j, k, besti, bestj, diff; uint32 rpcc_start, rpcc_end; struct rusage start, stop; float64 t; memset(&start, 0, sizeof(struct rusage)); memset(&stop, 0, sizeof(struct rusage)); getrusage(RUSAGE_SELF, &start); rpcc_start = rpcc(); /* Consume some cpu cycles; dummy to forced compiler not to optimize loop away */ dummy &= 0x7fffffff; dummy |= 0x70000000; for (i = 1; i < 100000000; i++) if (i > dummy) return (i); rpcc_end = rpcc(); getrusage(RUSAGE_SELF, &stop); t = (stop.ru_utime.tv_sec - start.ru_utime.tv_sec) + ((stop.ru_utime.tv_usec - start.ru_utime.tv_usec) * 0.000001); mhz = ((rpcc_end - rpcc_start) / t) * 0.000001 + 0.5; diff = (int32) 0x7fffffff; for (i = 100; i <= 1000; i += 100) { for (j = 1; j <= 10; j++) { k = i / j - mhz; if (k < 0) k = -k; if (k < diff) { diff = k; besti = i; bestj = j; } } } mhz = besti / bestj; E_INFO("%d ticks in %.3f sec; machine clock rate = %d MHz\n", rpcc_end - rpcc_start, t, mhz); #endif return mhz; }
void stop_timer() { long rpcc_end = rpcc(); rpcc_start &= 0xffffffff; /* rpcc is 32bit value. */ rpcc_end &= 0xffffffff; if (rpcc_end > rpcc_start) { rpcc_cumulative += (rpcc_end - rpcc_start); } else { /* counter wrapped round. */ rpcc_cumulative += 0x100000000 - rpcc_start + rpcc_end; } }
void start_timer() { rpcc_start = rpcc(); }
/* * Like udptrial except we deal with the streamedness of tcp. */ void tcptrial( int socket, char *sndbuf, char *rcvbuf, int cacheflush, struct trial *datapt ) { struct timeval now, then; long timediff; int i, cc; struct sockaddr_in sin; int resid; char *bp; long start, stop; /* * Compute cache flush overhead, then do the trial. */ if (cacheflush) { gettimeofday(&then, 0); for (i = 0; i < pcount; i++) { cache_flush((caddr_t)&first_global, (caddr_t)&last_global) cache_flush((caddr_t)tcptrial, (caddr_t)main); } gettimeofday(&now, 0); { long v1, v2; v1 = (now.tv_sec * 1000) + (now.tv_usec / 1000); v2 = (then.tv_sec * 1000) + (then.tv_usec / 1000); timediff = v1 - v2; } } else timediff = 0; datapt->cache_overhead = timediff; gettimeofday(&then, 0); start = rpcc(); for (i = 0; i < pcount; i++) { if (cacheflush) { cache_flush((caddr_t)&first_global, (caddr_t)&last_global) cache_flush((caddr_t)tcptrial, (caddr_t)main); } /* * Send the packet to server. */ bp = sndbuf; resid = dcount; while (resid) { cc = write (socket, bp, resid); if (cc < 0) { perror("write"); exit(1); } resid -= cc; bp += cc; } if (interactive) { char buf[4]; printf(">> sent %d bytes, hit return to continue\n"); fgets(buf, sizeof(buf), stdin); } if (sendonly) continue; /* * Receive reply. */ bp = rcvbuf; resid = dcount; while (resid) { cc = read (socket, bp, resid); if (cc < 0) { perror("read"); exit(1); } resid -= cc; bp += cc; } if (interactive) { char buf[4]; printf(">> received %d bytes, hit return to continue\n"); fgets(buf, sizeof(buf), stdin); } } stop = rpcc(); gettimeofday(&now, 0); { long v1, v2; v1 = (now.tv_sec * 1000) + (now.tv_usec / 1000); v2 = (then.tv_sec * 1000) + (then.tv_usec / 1000); datapt->elapsed_time = v1 - v2 - timediff; } datapt->elapsed_time = delta(start,stop); }
/* * Run a single udp trial. */ void udptrial( int socket, char *sndbuf, char *rcvbuf, int cacheflush, struct trial *datapt ) { long start,stop; struct timeval now, then; long timediff; int i, cc; struct sockaddr_in sin; /* * Compute cache flush overhead. */ if (cacheflush) { gettimeofday(&then, 0); for (i = 0; i < pcount; i++) { cache_flush((caddr_t)&first_global, (caddr_t)&last_global); cache_flush((caddr_t)udptrial, (caddr_t)tcptrial); } gettimeofday(&now, 0); { long v1, v2; v1 = (now.tv_sec * 1000) + (now.tv_usec / 1000); v2 = (then.tv_sec * 1000) + (then.tv_usec / 1000); timediff = v1 - v2; } } else timediff = 0; datapt->cache_overhead = timediff; start = rpcc(); /* gettimeofday(&then, 0); */ for (i = 0; i < pcount; i++) { if (cacheflush) { cache_flush((caddr_t)&first_global, (caddr_t)&last_global); cache_flush((caddr_t)udptrial, (caddr_t)tcptrial); } /* * Send the packet to server. */ cc = sendto (socket, sndbuf, dcount, 0, (struct sockaddr *)&sin_server, sizeof(sin_server)); if (cc < 0) { perror("sendto"); exit(1); } if (sendonly) continue; /* * Receive reply. */ cc = recv (socket, rcvbuf, dcount, 0); if (cc < 0) { perror("recv"); exit(1); } } stop = rpcc(); /* gettimeofday(&now, 0); */ #if 0 { long v1, v2; v1 = (now.tv_sec * 1000) + (now.tv_usec / 1000); v2 = (then.tv_sec * 1000) + (then.tv_usec / 1000); datapt->elapsed_time = v1 - v2 - timediff; } #endif datapt->elapsed_time = delta(start,stop); }