/********************************************************************** Initialization routine. Allocates space for the various arrays and initializes them. Input: None Output: None Side effects: Allocates space for the arrays and initializes the array locations. **********************************************************************/ void init_sacopt(void) { unsigned i; TWO_PWR_N = (ONE << N); MAX_DEPTH = B-A; TWO_POWER_MAX_DEPTH = (ONE << MAX_DEPTH); SET_MASK = ((ONE << A) - 1); DIFF_SET_MASK = ((ONE << MAX_DEPTH) - 1); SET_SIZE = WORD_SIZE*TWO_PWR_N; BASE_CACHE_SIZE = (ONE<<A)*SET_SIZE; next_save_time = SAVE_INTERVAL; tag_arr = calloc((TWO * (ONE << B) * TWO_PWR_N), sizeof(unsigned)); if (!tag_arr) fatal("out of virtual memory"); prty_arr = calloc((TWO * (ONE << B) * TWO_PWR_N), sizeof(unsigned)); if (!prty_arr) fatal("out of virtual memory"); all_hit_flag = calloc((ONE << A), sizeof(short)); if (!all_hit_flag) fatal("out of virtual memory"); hits = idim2 ((MAX_DEPTH + 2), (TWO_PWR_N)); slot = calloc((ONE << B), sizeof(struct hash_table)); if (!slot) fatal("out of virtual memory"); slot_flag = calloc((ONE << B), sizeof(short)); if (!slot_flag) fatal("out of virtual memory"); for (i=0; i < (TWO * (ONE << B) * TWO_PWR_N); i++) { tag_arr[i] = 0xffffffff; prty_arr[i] = (5-MAXINT); } time_of_next_clean = CLEAN_INTERVAL; }
/********************************************************************* Initialization routine. Input: None Output: None Side effects: Allocates space for the various arrays and initializes them. *********************************************************************/ void init_dmvl(void) { int i; unsigned depth, k; unsigned st, t; MIN_LINE_SZ = A; MAX_LINE_SZ = B; CACHE_SZ = C; NO_LINES = MAX_LINE_SZ - MIN_LINE_SZ + 1; MAX_SET_SZ = (CACHE_SZ - MIN_LINE_SZ); MIN_SET_SZ = (CACHE_SZ - MAX_LINE_SZ); TAG_MASK = (( ONE << CACHE_SZ) - ONE ); TAG_SET1_MASK = ((ONE << MAX_LINE_SZ) - ONE); tag_arr = idim2((ONE << MIN_SET_SZ), (ONE << (NO_LINES-1))); set_arr = idim2((ONE << MIN_SET_SZ), (ONE << (NO_LINES-1))); hits_arr = idim2((NO_LINES), (NO_LINES)); lm_arr = calloc((ONE << (NO_LINES - 1)), sizeof(int)); if (!lm_arr) fatal("out of virtual memory"); hits = calloc((MAX_LINE_SZ+1), sizeof(int)); if (!hits) fatal("out of virtual memory"); for (i=0; i < (ONE<<MIN_SET_SZ); i++) { set_arr[i][0] = 0; tag_arr[i][0] = SUB_ZERO; for (depth= 1; depth < NO_LINES; depth++) { st = ONE << (depth-1); t = ONE << (NO_LINES - depth); set_arr[i][st] = ONE << (NO_LINES-depth-1); tag_arr[i][st] = SUB_ZERO; for (k=1; k<st; k++) { set_arr[i][st+k] = set_arr[i][st+k-1] + t; tag_arr[i][st+k] = SUB_ZERO; } } } t = ONE; st = NO_LINES - 1; for (i=0; i < (ONE << (NO_LINES - 1)); i++) { if (t > (unsigned)i) lm_arr[i] = st; else { t <<= ONE; st -= 1; lm_arr[i] = st; } } rtag_arr = tag_arr; rset_arr = set_arr; rhits_arr = hits_arr; next_save_time = SAVE_INTERVAL; RTAG_MASK=TAG_MASK; RMAX_LINE_SZ=MAX_LINE_SZ; RCACHE_SZ=CACHE_SZ; RTAG_SET1_MASK=TAG_SET1_MASK; RMIN_LINE_SZ=MIN_LINE_SZ; RNO_LINES=NO_LINES; }
/********************************************************************** Initialization routine. Allocates space for the various arrays and initializes them. Input: None Output: None Side effects: Allocates space for the arrays and initializes the array locations. **********************************************************************/ void init_saclru(void) { unsigned i, j, k, l; unsigned init_value; unsigned *arr_ptr, *slot_ptr; next_save_time = SAVE_INTERVAL; TWO_PWR_N = (ONE << N); MAX_DEPTH = B-A; TWO_POWER_MAX_DEPTH = (ONE << MAX_DEPTH); SET_MASK = ((ONE << A) - 1); DIFF_SET_MASK = ((ONE << MAX_DEPTH) - 1); BASE = (TWO_PWR_N+1); SIZE_OF_TREE = (TWO_POWER_MAX_DEPTH * TWO * BASE); arr = calloc(((ONE << A)*TWO_POWER_MAX_DEPTH*TWO*BASE), sizeof(int)); if (!arr) fatal("out of virtual memory"); BASE_PWR_MAX_DEPTH_PLUS_ONE = power(BASE, MAX_DEPTH+1); if ((BASE_PWR_MAX_DEPTH_PLUS_ONE * sizeof(unsigned)) < MEM_AVAIL_HITARR) { hitarr = calloc(BASE_PWR_MAX_DEPTH_PLUS_ONE, sizeof(int)); if (!hitarr) fatal("out of virtual memory"); } base_pwr_array = calloc((MAX_DEPTH+1), sizeof(unsigned)); if (!base_pwr_array) fatal("out of virtual memory"); rm_arr = calloc((TWO_POWER_MAX_DEPTH), sizeof(unsigned)); if (!rm_arr) fatal("out of virtual memory"); sac_hits = idim2((TWO_PWR_N), (MAX_DEPTH + 2)); for (i=0; i < ONE << A; i++) { arr_ptr = arr + i * SIZE_OF_TREE; init_value = B80000000; slot_ptr = arr_ptr; *slot_ptr = 1; for (l=1; l<=TWO_PWR_N; l++) *(slot_ptr + l) = init_value; ++init_value; for (j=1; j <= MAX_DEPTH; j++) { for (k=((ONE << j) - 1); k < (((ONE << j) - 1) + (ONE << (j-1))); k++) { *(arr_ptr + (k*(TWO_PWR_N+1))) = TWO_PWR_N+1; } for (k= (((ONE << j) - 1) + (ONE << (j-1))); k < ((ONE << (j+1)) - 1); k++) { slot_ptr = arr_ptr + (k * (TWO_PWR_N+1)); *slot_ptr = 1; for (l=1; l<=TWO_PWR_N; l++) *(slot_ptr + l) = init_value; ++init_value; } } } rm_arr[0] = MAX_DEPTH; for (i=1; i < (ONE << MAX_DEPTH); i++) { for (j=0; j<=MAX_DEPTH; j++) { if (i & (ONE << j)) { rm_arr[i] = j; break; } } } j = 1; for (i=0; i<=MAX_DEPTH; i++) { base_pwr_array[i] = j; j *= BASE; } depths = calloc((MAX_DEPTH+1), sizeof(unsigned)); if (!depths) fatal("out of virtual memory"); for (i=0;i<=MAX_DEPTH;i++) depths[i] = 0; }