/************************************************************************************ * Micro Benchmark mbcsb * ----------------------------- * File name: mbcsb.c * Author : Yuanhua Yu * Date : 20/12/1999. * *------------------------------------------------------------------------------------- * * Function: Measuring the subblock 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_START ---- intinial value of the stride : 1 (*4bytes) * STRIDE_END ---- max value of the stride : 1024 (*4bytes) * TOTAL_ACCESS ---- number of the accesses done : (32768*1024*16) * * Variable: cache_size ---- capacity of the Level-I or Level-II cache in KB * arr_size ---- size of the array accessed; * arr_item ---- number of elements in the array accessed; * stride ---- increment of stride * *************************************************************************************/ #include #include #include #include #include #include #define STRIDE_START 1 //*4 bytes #define STRIDE_END 1024 //*4 bytes #define TOTAL_ACCESS (1024*1024*32/4) //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, stride; double time_cost, cost_per_op; FILE *fp; fp = fopen("Subblocksize.dat","a+"); fprintf(fp,"--------- Measurement of Cache Subblock 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"); arr_size = 4*CACHE_SIZE_II; arr_item = arr_size / sizeof(ATYPE); va = (ATYPE *)calloc(arr_item,sizeof(ATYPE)); for (stride=STRIDE_START; stride