Computer Abstractions and Technology: Performance II Lecture Notes PDF

Summary

These lecture notes cover Computer Abstractions and Technology, focusing on performance aspects. The document discusses different types of time, measurement techniques, and various timer functions like gettimeofday(), clock_gettime(), and getrusage(). It also touches upon the Time Stamp Counter (TSC) and provides code examples. The document is suitable for Computer Architecture students.

Full Transcript

Computer Abstractions and Technology : Performance II 471029: Introduction to Computer Architecture 4th Lecture Disclaimer: Slides are mainly based on COD 5th textbook and also developed in part by Profs. Dohyung Kim @ KNU and Computer architecture course @ KAIST and SKKU...

Computer Abstractions and Technology : Performance II 471029: Introduction to Computer Architecture 4th Lecture Disclaimer: Slides are mainly based on COD 5th textbook and also developed in part by Profs. Dohyung Kim @ KNU and Computer architecture course @ KAIST and SKKU 1 Execution time  Three are different types of time  Elapsed time (aka wall-clock time)  Based on realtime clock (coutiguously running)  Includes time spent in all other activities  CPU time (aka virtual process time)  Time when process is executing (CPU is active) user time and system time (can mean different things)   Does not include time when process is inherently waiting  Parallel execution time  Multi-core & Multi-thread execution environment  Runs whenever any parallel part is executing  Need to define a global time bases  We’ll talk about it later 2 How can we measure execution time for a specific program? or task? 3 Timer: gettimeofday()  UNIX function  Returns wall-clock time in seconds and microseconds  Actual resolution is hardware-dependent  Base value is 00:00 UTC, January 1, 1970  Some implementations also return the timezone #include struct timeval tv; double walltime; gettimeofday(&tv, NULL); walltime = tv.tv_sec + tv.tv_usec * 1.0e-6; 4 Timer: clock_gettime()  POSIX function  For clock_id CLOCK_REALTIME returns wall-clock time in seconds and nanoseconds  More clocks may be implemented but are not standardized  Actual resolution is hardware-dependent #include struct timespec tv; double walltime; Clock_gettime(CLOCK_REALTIME, &tv); walltime = tv.tv_sec + tv.tv_nsec * 1.0e-9; 5 Timer: getrusage()  UNIX function  Provides a variety of different information  Including user time, system time, memory usage, page faults, etc.  Information provided system-dependent! #include struct rusage ru; double usrtime; int memused; getrusage(RUSAGE_SELF, &ru); usrtime = ru.ru_utime.tv_sec + ru.ru_utime.tv_usec * 1.0e-6; memused = ru.ru_maxrss; 6 Timer: TSC(Time Stamp Counter)  H/W counter  Count the clock cycle (or tick)  RDTSC instructions on x86 (return in EDX:EAX) #include #include uint32_t tickl, tickh; asm volatile (“rdtsc”: “=a”(tickl), “=d”(tickh)); // ((uint64_t)tickh

Use Quizgecko on...
Browser
Browser