finished timing
This commit is contained in:
		
							parent
							
								
									fde2d37407
								
							
						
					
					
						commit
						0732946b25
					
				| 
						 | 
				
			
			@ -8,10 +8,10 @@
 | 
			
		|||
 | 
			
		||||
#define LINE_SIZE 64
 | 
			
		||||
// [1.2] TODO: Uncomment the following lines and fill in the correct size
 | 
			
		||||
//#define L1_SIZE TODO
 | 
			
		||||
//#define L2_SIZE TODO
 | 
			
		||||
//#define L3_SIZE TODO
 | 
			
		||||
//#define BUFF_SIZE TODO
 | 
			
		||||
#define L1_SIZE 768*1024
 | 
			
		||||
#define L2_SIZE 16*1024*1024
 | 
			
		||||
#define L3_SIZE 64*1024*1024
 | 
			
		||||
#define BUFF_SIZE 16*1024*1024
 | 
			
		||||
 
 | 
			
		||||
int main (int ac, char **av) {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -37,7 +37,7 @@ int main (int ac, char **av) {
 | 
			
		|||
 | 
			
		||||
    // [1.2] TODO: Uncomment the following line to allocate a buffer of a size
 | 
			
		||||
    // of your chosing. This will help you measure the latencies at L2 and L3.
 | 
			
		||||
    //volatile uint8_t *eviction_buffer = (uint8_t *)malloc(BUFF_SIZE);
 | 
			
		||||
    volatile uint8_t *eviction_buffer = (uint8_t *)malloc(BUFF_SIZE);
 | 
			
		||||
 | 
			
		||||
    // Example: Measure L1 access latency, store results in l1_latency array
 | 
			
		||||
    for (int i=0; i<SAMPLES; i++){
 | 
			
		||||
| 
						 | 
				
			
			@ -53,17 +53,45 @@ int main (int ac, char **av) {
 | 
			
		|||
    // [1.2] TODO: Measure DRAM Latency, store results in dram_latency array
 | 
			
		||||
    // ======
 | 
			
		||||
    //
 | 
			
		||||
    for (int i=0; i<SAMPLES; i++){
 | 
			
		||||
        // Step 1: bring the target cache line into DRAM
 | 
			
		||||
        clflush((void *)target_buffer);
 | 
			
		||||
 | 
			
		||||
        // Step 2: measure the access latency
 | 
			
		||||
        dram_latency[i] = measure_one_block_access_time((uint64_t)target_buffer);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // ======
 | 
			
		||||
    // [1.2] TODO: Measure L2 Latency, store results in l2_latency array
 | 
			
		||||
    // ======
 | 
			
		||||
    //
 | 
			
		||||
    for (int i=0; i<SAMPLES; i++){
 | 
			
		||||
        // Step 1: bring the target cache line into L1 by simply accessing
 | 
			
		||||
        //         the line
 | 
			
		||||
        tmp = target_buffer[0];
 | 
			
		||||
        for(int j=0; j<L1_SIZE/LINE_SIZE; j++){
 | 
			
		||||
            tmp = eviction_buffer[j*LINE_SIZE];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Step 2: measure the access latency
 | 
			
		||||
        l2_latency[i] = measure_one_block_access_time((uint64_t)target_buffer);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // ======
 | 
			
		||||
    // [1.2] TODO: Measure L3 Latency, store results in l3_latency array
 | 
			
		||||
    // ======
 | 
			
		||||
    //
 | 
			
		||||
    for (int i=0; i<SAMPLES; i++){
 | 
			
		||||
        // Step 1: bring the target cache line into L1 by simply accessing
 | 
			
		||||
        //         the line
 | 
			
		||||
        tmp = target_buffer[0];
 | 
			
		||||
        for(int j=0; j<L2_SIZE/LINE_SIZE; j++){
 | 
			
		||||
            tmp = eviction_buffer[j*LINE_SIZE];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Step 2: measure the access latency
 | 
			
		||||
        l3_latency[i] = measure_one_block_access_time((uint64_t)target_buffer);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Print the results to the screen
 | 
			
		||||
    // When compile to main and used by `make run`,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,9 +4,9 @@
 | 
			
		|||
 | 
			
		||||
| Cache | Cache Line Size | Total Size | Associativity | Number of Sets | Raw Latency |
 | 
			
		||||
| ----- | --------------- | ---------- | ------------- | -------------- | ----------- |
 | 
			
		||||
| L1-D  | 64              |            |               |                |             |
 | 
			
		||||
| L2    |                 |            |               |                |             |
 | 
			
		||||
| L3    |                 |            |               |                |             |
 | 
			
		||||
| L1-D  | 64              | 768K       | 12            | 1K             |             |
 | 
			
		||||
| L2    | 64              | 16M        | 16            | 16K            |             |
 | 
			
		||||
| L3    | 64              | 64M        | 16            | 64K            |             |
 | 
			
		||||
 | 
			
		||||
## 1-3
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue