-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added cache testing to valgrind example
- Loading branch information
Showing
2 changed files
with
61 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,40 @@ | |||
Run this line to see errors in this code. | Compile each program without optimization first. | ||
|
|||
For simpleTest.cc, run this line to see errors in this code. | |||
|
|||
:: | |||
|
|||
valgrind --track-origins=yes --leak-check=full ./simpleTest 300 300 | |||
|
|||
|
|||
We also have a cache test line. Run this line to see the cache errors. | |||
|
|||
:: | |||
|
|||
valgrind --tool=cachegrind ./a.out 0 1000 100000 | |||
|
|||
There are two paths in this code. If the first input is 1, it runs a cache-sensitive version of the loop. | |||
If it is 0, it runs a cache-insensitive version. | |||
|
|||
FYI: on the Trieste lab machines, this is what cache looks like: | |||
|
|||
:: | |||
|
|||
guy ~>dmesg | grep cache | |||
CPU: L1 I cache: 32K, L1 D cache: 32K | |||
CPU: L2 cache: 6144K | |||
CPU: L1 I cache: 32K, L1 D cache: 32K | |||
CPU: L2 cache: 6144K | |||
|
|||
You can run the same command to see cache on your linux machine. Another way to see the exact cache setup that | |||
valgrind found is the following: | |||
|
|||
:: | |||
|
|||
cg_annotate --auto=yes cachegrind.out.21960 | |||
|
|||
Note that your cachegrind.out will have a different number. This command is also handy because it shows which functions caused cache | |||
misses. | |||
|
|||
|
|||
|
|
||
valgrind --track-origins=yes --leak-check=full ./a.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters