Six important CSAPP experiments lab4 and csapplab4
CSAPP & lab4
Lab materials:
Http://download.csdn.net/detail/u011368821/7926305
Lab guide:
Http://download.csdn.net/detail/u011368821/7926323
Lab environment:
Linux 3.13.11
Ubuntu 14.0
Part I: An Experiment in C and Java
Q & A Answer these questions:
1. What are the source code differences among the two Java implementations?
The src dst data types of the two are different. One is int and the other is Integer.
(In my conscience, so far, I only love C. java has only written hello world... I cannot give a very beautiful answer to this question .)
2. Pick a single pair of results that most surprised you. What is it about the results that surprised you? (That is,
From the 32 pairs of measurement results, pick one pair whose relationship is least like what you wowould have
Guessed .)
After many comparisons, we found that Integer programs are longer time consuming than int programs!
3. [Optional extra credit] None of these programs appear to actually do anything, so one is tempted to optimize
Them by simply eliminating all code (resulting in an empty main (). Is that a correct optimization? Related
That, try compiling this C program, with and without optimization, and then time running it:
In my opinion, omitting the main parameter will not optimize the program)
Here we need to copy a piece of code from the book according to the tutorial guide and compile and run the test on our own.
#include <stdio.h>#define SIZE 10000int main(){int i,j,k;int sum = 1;for(i = 0;i < SIZE; i++){for(j = 0;j < SIZE;j++){for(k = 0;k < SIZE;k++){sum = -sum;}}}//printf("Hello world!\n");printf("Sum is %d\n",sum);return 0;}
The configuration of intel i5 8g ram does not work.
Anyway, I have waited for a long time to get the result. It doesn't make much sense to investigate this stuff. next station
Part II: Inferring Mystery Cache Geometries
This experiment is based on the cache in Chapter 6 and section 5 of CSAPP.
Instructions
Specifically, each of these "processors" is provided as an object file (. o file) against which you will link your code. see the file mystery-cache.h for documentation of the function interface that these object files export.
Your job is to fill in the function stubs in cache-test-skel.c which, when linked with one of these cache object files, will determine and then output the cache size, associativity, and block size. some of the provided object files are named with this information (e.g. cache_64c_2a_16b.o is a 64 KB capacity, 2 way set associative cache with 16B blocks) to help you check your work. there are also 4 mystery cache object files, whose parameters you must discover on your own.
You can assume that the mystery caches have sizes that are powers of 2 and use a least recently used replacement policy.
You cannot assume anything else about the cache parameters parameter t what you can infer from the cache size. finally, the mystery caches are all pretty realistic in their geometries, so use this fact to sanity check your results.
Your Tasks
Complete the 3 functions in cache-test-skel.c which have/* your code goes here */comments in them.
Additionally, determine the geometry of each of the four mystery caches and list these in a comment, along with your name, at the top of your modified cache-test-skel.c.
I have been stuck for a long time in my third project. Here I would like to thank Chenbo Li for reading his github...
First release the question, and then give an analysis after a period of time :)
/* YOUR NAME HERECSE 351 - Winter 2013Lab 4 - Mystery CachesMystery Cache Geometries:mystery0: block size = 64 bytes cache size = 262144 bytes associativity = 1mystery1: block size = 8 bytes cache size = 16384 bytes associativity = 4mystery2: block size = 16 bytes cache size = 65536 bytes associativity = 16mystery3: block size = 2 bytes cache size = 131072 bytes associativity = 2*/#include <stdlib.h>#include <stdio.h>#include "mystery-cache.h"/* * NOTE: When using access_cache() you do not need to provide a "real" memory * addresses. You can use any convenient integer value as a memory address, * you should not be able to cause a segmentation fault by providing a memory * address out of your programs address space as the argument to access_cache. *//* Returns the size (in B) of each block in the cache.*/int get_block_size(void) {int block_counter = 0;flush_cache();access_cache(0);for(block_counter = 0; access_cache(block_counter);block_counter++){} return block_counter;}/* Returns the size (in B) of the cache.*/int get_cache_size(int block_size) {int possible_cache_size;int tmp = 0;flush_cache();for(possible_cache_size = 1; 1 ;possible_cache_size<<=1){for(tmp = 0;tmp <= possible_cache_size;tmp += block_size){access_cache(tmp);}if(!access_cache(0)){break;}}return possible_cache_size;}/* Returns the associativity of the cache.*/int get_cache_assoc(int cache_size) {int tmp = cache_size;int addr = 0;flush_cache();for(addr = 0; 1; addr += cache_size){access_cache(addr);for(tmp = 0;tmp <= addr;tmp += cache_size){if(!access_cache(tmp)){return addr/cache_size;}}}return -1;}int main(void) { int size; int assoc; int block_size; /* The cache needs to be initialized, but the parameters will be ignored by the mystery caches, as they are hard coded. You can test your geometry paramter discovery routines by calling cache_init() w/ your own size and block size values. */ cache_init(0,0); block_size=get_block_size(); size=get_cache_size(block_size); assoc=get_cache_assoc(size); printf("Cache block size: %d bytes\n", block_size); printf("Cache size: %d bytes\n", size); printf("Cache associativity: %d\n", assoc); return EXIT_SUCCESS;}
Classical Mercedes (translated by Gve) canvas oil painting 1906x30. 40.60 in the UK in 50 cm
This work is exactly the classic beauty that Jude is good at describing. It depends on the female image on marble. The audience saw the beauty of the girl through thin clothes. The elegant appearance of a girl is fascinating. Watching this work has a feeling of looking up on the monument, which is the intention of the painter.