Six important experimental LAB4 of Csapp

Source: Internet
Author: User

Csapp && lab4


Experimental materials:

http://download.csdn.net/detail/u011368821/7926305


Experimental instruction book:

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 is the source code differences among the Java implementations?

The data types of the SRC DST are different. One is int another time integer

(touching the conscience says, so far, I just love to C,java only wrote Hello world ... There is no good answer to this question .


2. Pick a single pair of results the most surprised you. What's it about the results? surprised? (That's,
From the pairs of measurement results, pick one pair whose relationship are least what do you would has
guessed.)


multiple comparisons have found that an integer type of program takes longer than an int type program!


3. [Optional Extra Credit] None of the These programs appear to actually does anything, so one are tempted to optimize
them by simply eliminating all code (resulting in an empty main ()). Is that a correct optimization? Related to
That, try compiling the C program, with and without optimization, and then time running it:


I think omitting the main parameter does not optimize the program (personal view)

You need to copy the code from the book and run the test yourself, according to the experiment Guide.

#include <stdio.h> #define SIZE 10000int Main () {int I,j,k;int sum = 1;for (i = 0;i < SIZE; i++) {for (j = 0;j < SI ze;j++) {for (k = 0;k < size;k++) {sum =-sum;}}} printf ("Hello world!\n");p rintf ("Sum is%d\n", sum); return 0;}


Feel the Intel i5 8G RAM configuration is not moving

Anyway, I waited for a long time to get out of the results, to pursue the meaning of this thing is not big, next station





Part ii:inferring Mystery Cache geometries


This experiment is based on the cache of the sixth chapter of the Csapp, the fifth section, not clear that the cache does not play


Instructions


Specifically, each of the These "processors" is provided as a object file (. o file) against which you'll 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-cache-test-skel.c which, when linked with one of the these cache object files , would determine and then output the cache size, associativity, and block size. Some of the provided object files are named and this information (e.g. CACHE_64C_2A_16B.O) is a KB capacity, 2-way set -associative cache with 16B blocks) to help you check the your work. There is also 4 Mystery cache object files, whose parameters you must discover on your own.


You can assume that the mystery caches has sizes that is powers of 2 and use a least recently used replacement policy.


You cannot assume anything else about the cache parameters except what can infer from the cache size. Finally, the mystery caches is all pretty realistic on their geometries, so use this fact to sanity check your results.




Your Tasks


The 3 functions in CACHE-TEST-SKEL.C which has a/* 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 in the third one for a long time, here in particular to thank Chenbo Li, is to see his GitHub I was freed ...

Release the first, after a period of time to give an analysis:)


/* YOUR NAME herecse 351-winter 2013Lab 4-mystery cachesmystery Cache Geometries:mystery0:block size = bytes Cache size = 262144 bytes associativity = 1mystery1:block size = 8 bytes Cache size = 16384 bytes Associat ivity = 4mystery2:block size = Bytes Cache size = 65536 bytes associativity = 16mystery3:block size = 2 b Ytes Cache size = 131072 bytes associativity = 2*/#include <stdlib.h> #include <stdio.h> #include "mystery -cache.h "/* * Note:when using Access_cache () You don't need to provide a" real "memory * addresses. You can use any convenient integer value as a memory address, * should not being able to cause a segmentation fault by PR Oviding 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;p ossible_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 is initialized, but the parameters'll be is ignored by the mystery caches, as they is 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 Govid (also translated) British 1906 canvas oil painting 40.60x30.50 cm
This piece of work is precisely the classical beauty of the classic dress that is gifted by the grace, and relies on the feminine image of the marble. The audience through the thin like organdy clothing, saw the maiden's beauty. The appearance of teenage lovely makes people's imagination. Watching this piece, there is a feeling of looking up monument, this is the painter's intention to arrange.








Six important experimental LAB4 of Csapp

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.