/************************************************************************************ * Micro Benchmark mbcss * ----------------------------- * File name: mbcss.c * Author : Yuanhua Yu * Date : 20/12/1999. * *------------------------------------------------------------------------------------- * * Function: Measuring the set size of Cache Level-I and Level-II * * Methods: Sequential array read access * * Condition: Running under Linux Operating System * * History: First version : 05/10/1999 * Second version: 20/12/1999 * *Parameters: STRIDE ---- intinial value of the stride : 8 (*4bytes) * STEP_START ---- initial value of the step : (1024*32) bytes * TOTAL_ACCESS ---- number of the accesses done : (32768*1024*16) * * Variable: arr_size ---- size of the accessed array in bytes * arr_item ---- arr_size = arr_size / (sizeof(ATYPE))(items) * step ---- increment of size of the array * *************************************************************************************/ #include #include #include #include #include #include #define STEP_START (8*1024) //bytes #define STRIDE 8 //*4 bytes #define TOTAL_ACCESS (1024*1024*32/2) //operations #define CACHE_SIZE_I (1024*16) //bytes #define CACHE_SIZE_II (1024*512) //bytes #define ATYPE long /*----------------------------------------------------------------------------------*/ int main(char **av, int ac) { volatile ATYPE *va; register ATYPE s1; register long i; unsigned long start_time, stop_time; long arr_size, arr_item, step; double time_cost, cost_per_op; FILE *fp; fp = fopen("Setsize_PIII500.dat","a+"); fprintf(fp,"--------- Measurement of Cache Set_size ----------\n"); fprintf(fp,"Array_size(bytes) Access_T(ns) \tTotal_T(s)\n"); printf("Step_size(byte) Access_T(ns) \tTotal_T(s)\n"); for (step=STEP_START; step <= 16; step *= 2) { fprintf(fp,"step = %d\n", step); for (arr_size=CACHE_SIZE_II/2; arr_size <= CACHE_SIZE_II*2; arr_size+=step) { arr_item = arr_size / (sizeof(ATYPE)); va = (ATYPE *) calloc(arr_item, sizeof(ATYPE)); for (i=0; i