#include "utility.h" #ifndef VISUAL #define PRINT_FUNC print_results_plaintext #else #define PRINT_FUNC print_results_for_visualization #endif #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 int main (int ac, char **av) { // create 4 arrays to store the latency numbers // the arrays are initialized to 0 uint64_t dram_latency[SAMPLES] = {0}; uint64_t l1_latency[SAMPLES] = {0}; uint64_t l2_latency[SAMPLES] = {0}; uint64_t l3_latency[SAMPLES] = {0}; // A temporary variable we can use to load addresses uint8_t tmp; // Allocate a buffer of LINE_SIZE Bytes // The volatile keyword tells the compiler to not put this variable into a // register -- it should always try to be loaded from memory / cache. volatile uint8_t *target_buffer = (uint8_t *)malloc(LINE_SIZE); if (NULL == target_buffer) { perror("Unable to malloc"); return EXIT_FAILURE; } // [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); // Example: Measure L1 access latency, store results in l1_latency array for (int i=0; i