/************************************************************************************* * Microbench Benchmark: mbcedpp * ------------------------------------------ * Filename: mbcedpp.c * Author : Yuanhua Yu * Date : 25/12/1999 *------------------------------------------------------------------------------------- * * Function: 1.Measuring capacity and associativity of Level-I and Level-II cache * * 2.Measuring effective data path parallelism of Level-I and Level-II cache * * Condition: Running under the Linux operating system * * Methods: 1. Dependent sequential array read but wait for the address * 2. Dependent sequential array read without waiting * * History: 10/10/1999 First version * 25/10/1999 Second version * 25/12/1999 Third version * * Parameters: TOTAL_ACCESS----- control the number of operations : (4096*4096*32) * ARR_SIZE_0 ----- array size starts(bytes) : 1024 * ARR_SIZE_1 ----- array size ends(bytes)-mode 1 : 32768 * ARR_SIZE_2 ----- array size ends(bytes)-mode 2 : 4194304 * ARR_STEP ----- step of array size increment(bytes): 1024 * STRIDE ----- distance between to accessed items : 8/16 (items) * NUM_WAYS ----- number of circular access sequences: 4 * STEP_MODE --- increment mode of the array size : 0/1 * * Variable: arr_size --- size of the accessed array in bytes * arr_item --- arr_size = arr_size / (sizeof(ATYPE))(items) * ****************************************************************************************/ #include #include #include #include #include #include #define TOTAL_ACCESS (4096*4096*16) #define STRIDE 8 #define NUM_WAYS 1 #define ARR_SIZE_0 1024 #define ARR_SIZE_1 (1024*64) #define ARR_SIZE_2 (1024*1024*8) #define ARR_STEP 1024 #define STEP_MODE 1 #define ATYPE long /*----------------------------------------------------------------------------------*/ int main(char **av, int ac) { long i,j,arr_size,arr_item; volatile ATYPE *va; #if NUM_WAYS == 1 register ATYPE s1; #elif NUM_WAYS == 2 register ATYPE s1, s2; #elif NUM_WAYS == 3 register ATYPE s1, s2, s3; #elif NUM_WAYS == 4 register ATYPE s1, s2, s3, s4; #elif NUM_WAYS == 5 register ATYPE s1, s2, s3, s4,s5; #elif NUM_WAYS == 6 register ATYPE s1, s2, s3, s4,s5,s6; #endif unsigned long start_time,stop_time; double time_cost, cost_per_op; FILE *fp; fp = fopen("Edpp_PIII.dat","a+"); fprintf(fp,"--------- Measurement of Cache Capacity -----------\n"); fprintf(fp,"\n Manchine: PIII-500"); fprintf(fp,"\nStride(bytes): %d", STRIDE*sizeof(ATYPE)); fprintf(fp," Method: dependent_nowait"); fprintf(fp,"\n-----------------------------------------------------\n"); fprintf(fp,"ARR_SIZE(byte) Access_T(ns)\tTotal_T(s) %d\n", NUM_WAYS); printf("ARR_SIZE(byte) Access_T(ns)\tTotal_T(s)\n"); #if STEP_MODE == 0 for(arr_size=ARR_SIZE_0;arr_size<=ARR_SIZE_1;arr_size+=ARR_STEP) #elif STEP_MODE == 1 for(arr_size=ARR_SIZE_0;arr_size<=ARR_SIZE_2;arr_size=arr_size*2) #endif { arr_item = arr_size / (sizeof(ATYPE)); va = (ATYPE *)calloc(arr_item, sizeof(ATYPE)); for(i=0; i