C program optimization
  • Introduction
  • Measurement
    • Use perf to Measure Cache Miss and TLB Miss
  • Program optimization techniques
    • Branch Prediction Friendliness
    • Loop Unrolling
    • Turning Random Access to Sequential Access
  • References
Powered by GitBook
On this page

Was this helpful?

Measurement

PreviousIntroductionNextUse perf to Measure Cache Miss and TLB Miss

Last updated 2 months ago

Was this helpful?

This part briefly describes how to measure cache misses and TLB misses using .

Important Note:

Please run perf on department linux9 server. VM can NOT fully support perf statistics even though perf can be installed on VM successfully.

You should have been familiar with command-line interface and thus can connect to linux9 using the following command (when connected to CSE VPN):

ssh <YOUR_CSE_ACCOUNT>@linux9.cse.cuhk.edu.hk

But as an alternative, you can follow the steps below to connect to the department linux9 servers using GUI.

  • Download a SSH client and connect to the linux9 server. Here we use putty as an example.

The hostname is in the form of "username@linux9.cse.cuhk.edu.hk" where "username" should be replaced by your own CSE account.

  • Enter your password and you can connect to the department linux9 server.

  • Remember to add -std=c11 when compiling your program, as the GCC version is a bit old on linux9. Also turn off the compiler optimization to see a more obvious gap. For example:

gcc -std=c11 -O0 -o helloworld helloworld.c
perf