12a13 > #include 26a28 > unsigned int times; 28d29 < unsigned int times; 41c42 < unsigned int sizes[256][256]; //262KB --- > //unsigned int sizes[256][256]; //262KB 50c51 < unsigned int times; --- > //unsigned int times; 52a54,55 > unsigned int times; > //char filler[8]; 60d62 < char *string; 61a64,66 > char *string; > //unsigned int sub; > //char filler[8]; 104c109 < int num2=0; --- > register int num2=0; 110c115,116 < const unsigned int stop_byte = file_bytes-table[num1].len; --- > //const unsigned int stop_byte = file_bytes-table[num1].len; > const unsigned int stop_byte = file_bytes-table[num1].len-128; 114c120,142 < unsigned char first_char=0; --- > int prefetch_a[128]; > int prefetch_b[8]; > //int prefetch_id=0; > //unsigned int prefetch_id_a[]= {0, 0, 0, 0}; > //char prefetch_id_b[4]; > //unsigned char prefetch_c[16]; > unsigned int pre_int=0; > unsigned int pre_count=0; > int pre_ret=0; > /* > register unsigned char prefetch_a; > register unsigned char prefetch_b; > > register unsigned char prefetch_c; > register unsigned char prefetch_d; > register unsigned char prefetch_e; > register unsigned char prefetch_f; > register unsigned char prefetch_g; > register unsigned char prefetch_h; > */ > > > register unsigned char first_char=0; 130c158,179 < char index[2][256][256]; --- > //num3 = sysconf(_SC_PAGESIZE); > //printf("pagesize: %d\n", num3); > > //char *index[256][256]; > > char *index; > > if(member_length>5){ > index = malloc(sizeof(char)*65536*2); > //for(num3=0; num3<256; num3++){ > // for(num4=0; num4<256; num4++){ > // index[num3][num4]=malloc(sizeof(char)*2); > // } > //} > }else{ > index = malloc(sizeof(char)*65536); > //for(num3=0; num3<256; num3++){ > // for(num4=0; num4<256; num4++){ > // index[num3][num4]=malloc(sizeof(char)); > // } > //} > } 142a192 > 145d194 < 148a198,201 > unsigned int sizes[256][256]; > > //unsigned int exclusion[32768]; > 157a211 > /* 168,169c222,224 < num3 = 256*(12+num4); < num7 = num4 - num2; --- > */ > num3 = 256*(sizeof(struct buffer_structure)+member_length+1); > // num7 = num4 - num2; 175,176c230,231 < //num4=floor(262144/num3); < num4=floor(131072/num3); --- > num4=floor(262144/num3); > //num4=floor(131072/num3); 178c233 < --- > /* 191a247,248 > */ > //num5=floor(917504/num3); 193c250,252 < num5=floor(524288/num3); --- > num3 = 256*(sizeof(struct common_structure)+member_length+1); > num5=floor(786432/num3); > //num5=floor(524288/num3); 215a275,277 > //printf("buff: %lu comm: %lu\n", sizeof(struct buffer_structure), sizeof(struct common_structure)); > //printf("charptr: %lu int: %lu\n", sizeof(char *), sizeof(int) ); > 216a279,282 > > //buffer[num3] = memalign (16, b_members*sizeof(struct buffer_structure)); > //common[num3] = memalign (16, c_members*sizeof(struct common_structure)); > //posix_memalign(&var, 64, 8) 220a287,293 > //buffer_id[num3] = memalign (64, b_members*sizeof(unsigned int)); > //common_id[num3] = memalign (64, c_members*sizeof(unsigned int)); > //buffer_open[num3] = memalign (64, b_members*sizeof(int)); > //common_open[num3] = memalign (64, c_members*sizeof(int)); > > > 227c300,301 < buffer[num3][num4].string = malloc(table[num1].len*sizeof(char)+num7); --- > //buffer[num3][num4].string = memalign (32, table[num1].len*sizeof(char)); > buffer[num3][num4].string = malloc(table[num1].len*sizeof(char)); 231c305,306 < common[num3][num4].string = malloc(table[num1].len*sizeof(char)+num6); --- > //common[num3][num4].string = memalign (32, table[num1].len*sizeof(char)); > common[num3][num4].string = malloc(table[num1].len*sizeof(char)); 236,237c311,312 < cache_sizes[0] = 256*b_members*( sizeof(struct buffer_structure)+sizeof(unsigned int)+sizeof(int)+(table[num1].len*sizeof(char)+num7) ); < cache_sizes[1] = 256*c_members*( sizeof(struct common_structure)+sizeof(unsigned int)+sizeof(int)+(table[num1].len*sizeof(char)+num6) ); --- > cache_sizes[0] = 256*b_members*( sizeof(struct buffer_structure)+sizeof(unsigned int)+sizeof(int)+(table[num1].len*sizeof(char)) ); > cache_sizes[1] = 256*c_members*( sizeof(struct common_structure)+sizeof(unsigned int)+sizeof(int)+(table[num1].len*sizeof(char)) ); 242c317,318 < unique_id[num3]=malloc(sizeof(unsigned int)*16); --- > //unique_id[num3] = memalign (16, sizeof(unsigned int)*16); > unique_id[num3]=malloc(sizeof(unsigned int)*4); 244c320,323 < unique_id[num3][0]=15; --- > unique_id[num3][0]=3; > for(num4=0; num4<256; num4++){ > sizes[num3][num4] = 1; > } 256,258d334 < for(num4=0; num4<256; num4++){ < index[0][num3][num4]=0; < } 261c337,342 < index[1][num3][num4]=0; --- > index[num3*256+num4]=0; > index[65536+num3*256+num4]=0; > } > }else{ > for(num4=0; num4<256; num4++){ > index[num3*256+num4]=0; 283c364 < unique_id[num3][0]=15; --- > unique_id[num3][0]=3; 285a367,372 > for(num3=0; num3<8; num3++){ > prefetch_b[num3] = num7; > } > //for(num3=0; num3<128; num3++){ > // prefetch_a[num3]=0; > //} 289a377,397 > //fill a page 16bytes at a time > for(num3=0; num3<121; num3+=8){ > prefetch_a[num3] = (unsigned char)mem_file[num2+num3]; > prefetch_a[num3+1] = (unsigned char)mem_file[num2+num3+1]; > prefetch_a[num3+2] = (unsigned char)mem_file[num2+num3+2]; > prefetch_a[num3+3] = (unsigned char)mem_file[num2+num3+3]; > > prefetch_a[num3+4] = (unsigned char)mem_file[num2+num3+4]; > prefetch_a[num3+5] = (unsigned char)mem_file[num2+num3+5]; > prefetch_a[num3+6] = (unsigned char)mem_file[num2+num3+6]; > prefetch_a[num3+7] = (unsigned char)mem_file[num2+num3+7]; > /* > prefetch_a[num3+8] = (unsigned char)mem_file[num2+num3+8]; > prefetch_a[num3+9] = (unsigned char)mem_file[num2+num3+9]; > prefetch_a[num3+10] = (unsigned char)mem_file[num2+num3+10]; > prefetch_a[num3+11] = (unsigned char)mem_file[num2+num3+11]; > prefetch_a[num3+12] = (unsigned char)mem_file[num2+num3+12]; > prefetch_a[num3+13] = (unsigned char)mem_file[num2+num3+13]; > prefetch_a[num3+14] = (unsigned char)mem_file[num2+num3+14]; > prefetch_a[num3+15] = (unsigned char)mem_file[num2+num3+15]; > */ 291,293d398 < first_char = (unsigned char)mem_file[num2]; < if(first_char != num7){ < goto found; 294a400,499 > //printf("here 1\n"); > //parse page for num7 matches > for(num3=0; num3<121; num3+=8){ > > if(prefetch_a[num3] == prefetch_b[0]){ > prefetch_a[num3]=-1; > } > if(prefetch_a[num3+1] == prefetch_b[1]){ > prefetch_a[num3+1]=-1; > } > if(prefetch_a[num3+2] == prefetch_b[2]){ > prefetch_a[num3+2]=-1; > } > if(prefetch_a[num3+3] == prefetch_b[3]){ > prefetch_a[num3+3]=-1; > } > > if(prefetch_a[num3+4] == prefetch_b[4]){ > prefetch_a[num3+4]=-1; > } > if(prefetch_a[num3+5] == prefetch_b[5]){ > prefetch_a[num3+5]=-1; > } > if(prefetch_a[num3+6] == prefetch_b[6]){ > prefetch_a[num3+6]=-1; > } > if(prefetch_a[num3+7] == prefetch_b[7]){ > prefetch_a[num3+7]=-1; > } > /* > if(prefetch_a[num3+8] == prefetch_b[8]){ > prefetch_a[num3+8]=-1; > } > if(prefetch_a[num3+9] == prefetch_b[9]){ > prefetch_a[num3+9]=-1; > } > if(prefetch_a[num3+10] == prefetch_b[10]){ > prefetch_a[num3+10]=-1; > } > if(prefetch_a[num3+11] == prefetch_b[11]){ > prefetch_a[num3+11]=-1; > } > if(prefetch_a[num3+12] == prefetch_b[12]){ > prefetch_a[num3+12]=-1; > } > if(prefetch_a[num3+13] == prefetch_b[13]){ > prefetch_a[num3+13]=-1; > } > if(prefetch_a[num3+14] == prefetch_b[14]){ > prefetch_a[num3+14]=-1; > } > if(prefetch_a[num3+15] == prefetch_b[15]){ > prefetch_a[num3+15]=-1; > } > > */ > } > > //printf("here 2\n"); > pre_int=num2; > > //for(pre_count=0; pre_count<4096; pre_count++){ > > pre_count=0; > first_char = num7; > while(pre_count<125){ > > if(prefetch_a[pre_count] == -1){ > num2=pre_int+pre_count; > pre_ret=1; > goto proceed; > } > pre_a: > pre_count++; > if(prefetch_a[pre_count] == -1){ > num2=pre_int+pre_count; > pre_ret=2; > goto proceed; > } > pre_b: > pre_count++; > if(prefetch_a[pre_count] == -1){ > num2=pre_int+pre_count; > pre_ret=3; > goto proceed; > } > pre_c: > pre_count++; > if(prefetch_a[pre_count] == -1){ > num2=pre_int+pre_count; > pre_ret=4; > goto proceed; > } > pre_d: > pre_count++; > } > > goto found; > > proceed: 295a501,503 > > //first_char = (unsigned char)mem_file[num2]; > //sec_char = (unsigned char)mem_file[num2+1]; 308c516 < if(!index[1][a_char][b_char]){ --- > if(!index[sec_char*256+last_char] || !index[65536+a_char*256+b_char]){ 311c519,521 < --- > //for(num3=0; num3<4; num3++){ > // prefetch_id_a[num3] = id; > //} 317c527,532 < } --- > if(!index[sec_char*256+last_char]){ > goto no_search; > } > //for(num3=0; num3<4; num3++){ > // prefetch_id_a[num3] = id; > //} 319,320d533 < if(!index[0][sec_char][last_char]){ < goto no_search; 322a536,539 > //if(!index[0][sec_char][last_char]){ > // goto no_search; > //} > 342c559,573 < goto found; --- > //goto found; > //goto next_member; > if(pre_ret == 1){ > goto pre_a; > } > if(pre_ret == 2){ > goto pre_b; > } > if(pre_ret == 3){ > goto pre_c; > } > if(pre_ret == 4){ > goto pre_d; > } > 396c627,641 < goto found; --- > //goto found; > //goto next_member; > if(pre_ret == 1){ > goto pre_a; > } > if(pre_ret == 2){ > goto pre_b; > } > if(pre_ret == 3){ > goto pre_c; > } > if(pre_ret == 4){ > goto pre_d; > } > 429,430d673 < < 431a675,677 > > //prefetch_id = num5 % 4; > //prefetch_id = floor(num3 / 4); 433a680,683 > //while(num3>3){ > //for(num3=1; num3+3 //while(prefetch_id > 0){ > //for(prefetch_id = floor(num5 / 4); prefetch_id > 0; prefetch_id--){ 435,450d684 < < //for(num3=num6; num3>num6-3; num3--){ < < /* < for(num6=0; num6<4; num6++){ < if(unique_id[last_char][num3-num6] == id){ < goto id_match; < } < next1: < ; < } < num3-=4; < //num6=num3; < } < */ < 452c686,689 < num6=0; --- > //if(prefetch_id_b[0]){ > num6=0; > //num3=prefetch_id; > //prefetch_id_b[0]=0; 454,459d690 < //for( num4=1; num4 < search_offset; num4++){ < //if( mem_file[num2+num4] != table[num1].member[first_char][last_char][num3].series[num4]){ < // goto next1; < // } < //} < //goto match_found; 463,464c694,695 < if(unique_id[last_char][num3] == id){ < //num3--; --- > if(unique_id[last_char][num3-1] == id){ > //if(prefetch_id_b[1]){ 465a697 > //num3=prefetch_id+1; 467,472d698 < //for( num4=1; num4 < search_offset; num4++){ < //if( mem_file[num2+num4] != table[num1].member[first_char][last_char][num3].series[num4]){ < // goto next2; < // } < //} < //goto match_found; 476,477c702,703 < if(unique_id[last_char][num3] == id){ < //num3--; --- > if(unique_id[last_char][num3-2] == id){ > //if(prefetch_id_b[2]){ 478a705 > //num3=prefetch_id+2; 480,485d706 < //for( num4=1; num4 < search_offset; num4++){ < //if( mem_file[num2+num4] != table[num1].member[first_char][last_char][num3].series[num4]){ < // goto next3; < // } < //} < //goto match_found; 489,490c710,711 < if(unique_id[last_char][num3] == id){ < //num3--; --- > if(unique_id[last_char][num3-3] == id){ > //if(prefetch_id_b[3]){ 491a713 > //num3=prefetch_id+3; 493,498d714 < //for( num4=1; num4 < search_offset; num4++){ < //if( mem_file[num2+num4] != table[num1].member[first_char][last_char][num3].series[num4]){ < // goto next4; < // } < //} < //goto match_found; 501a718 > //prefetch_id--; 504,505c721,722 < < --- > //prefetch_id = num5 % 4; > num6=4; 507,518c724,731 < if(unique_id[last_char][num3] == id){ < num6=4; < goto id_match; < //for( num4=1; num4 < search_offset; num4++){ < // if( mem_file[num2+num4] != table[num1].member[first_char][last_char][num3].series[num4]){ < // goto next5; < // } < //} < //goto match_found; < } < next5: < num3--; --- > //while(num3 if(unique_id[last_char][num3] == id){ > //num6=4; > goto id_match; > } > next5: > num3--; > //} 526,531d738 < //num6=1; < //match_found: < //; < < < //for( num4=1; num4 < search_offset; num4++){ 587c794,808 < goto found; --- > //goto found; > //goto next_member; > if(pre_ret == 1){ > goto pre_a; > } > if(pre_ret == 2){ > goto pre_b; > } > if(pre_ret == 3){ > goto pre_c; > } > if(pre_ret == 4){ > goto pre_d; > } > 591,592c812,825 < goto found; < --- > //goto found; > //goto next_member; > if(pre_ret == 1){ > goto pre_a; > } > if(pre_ret == 2){ > goto pre_b; > } > if(pre_ret == 3){ > goto pre_c; > } > if(pre_ret == 4){ > goto pre_d; > } 593a827 > 604c838 < index[0][sec_char][last_char]=1; --- > //index[0][sec_char][last_char]=1; 606c840,843 < index[1][a_char][b_char]=1; --- > index[sec_char*256+last_char]=1; > index[65536+a_char*256+b_char]=1; > }else{ > index[sec_char*256+last_char]=1; 622,625c859,862 < if(table[num1].sizes[first_char][last_char] == num5){ < table[num1].member[first_char][last_char]=realloc(table[num1].member[first_char][last_char],sizeof(struct translation_structure) * (table[num1].sizes[first_char][last_char]+1+3) ); < //index.unique_id[sec_char]=realloc(index.unique_id[sec_char], sizeof(unsigned int) * (table[num1].sizes[first_char][sec_char]+1+3) ); < table[num1].sizes[first_char][last_char]+=3; --- > if(sizes[first_char][last_char] == num5){ > table[num1].member[first_char][last_char]=realloc(table[num1].member[first_char][last_char],sizeof(struct translation_structure) * (sizes[first_char][last_char]+1+3) ); > //index.unique_id[sec_char]=realloc(index.unique_id[sec_char], sizeof(unsigned int) * (table[num1]sizes[first_char][sec_char]+1+3) ); > sizes[first_char][last_char]+=3; 633,634c870,872 < unique_id[last_char]=realloc(unique_id[last_char], sizeof(unsigned int)*(unique_id[last_char][0]+6) ); < unique_id[last_char][0]+=5; --- > //unique_id[last_char] = memalign (16, sizeof(unsigned int)*(unique_id[last_char][0]+6)); > unique_id[last_char]=realloc(unique_id[last_char], sizeof(unsigned int)*(unique_id[last_char][0]+4) ); > unique_id[last_char][0]+=3; 651c889 < index[0][last_char][last_char]=1; --- > //index[0][last_char][last_char]=1; 653c891,894 < index[1][a_char][b_char]=1; --- > index[sec_char*256+last_char]=1; > index[65536+a_char*256+b_char]=1; > }else{ > index[sec_char*256+last_char]=1; 659c900,903 < num2++; --- > num2=pre_int+pre_count; > //num2=pre_int+4096; > //num2+=4; > //num2+=member_length+1; 669,671c913,915 < if(table[num1].sizes[first_char][num3] == num5){ < table[num1].member[first_char][num3]=realloc(table[num1].member[first_char][num3], sizeof(struct translation_structure) * (table[num1].sizes[first_char][num3]+1+3) ); < table[num1].sizes[first_char][num3]+=3; --- > if(sizes[first_char][num3] == num5){ > table[num1].member[first_char][num3]=realloc(table[num1].member[first_char][num3], sizeof(struct translation_structure) * (sizes[first_char][num3]+1+3) ); > sizes[first_char][num3]+=3; 713c957 < patterns_freed+=(table[num1].sizes[num2][num3]+1); --- > patterns_freed+=(sizes[num2][num3]+1); 757c1001,1007 < printf("\t\trecent: %u(%.02lfKB) common: %u(%.02lfKB) index: %.02lfKB\n",b_members, cache_sizes[0]/1024, c_members, cache_sizes[1]/1024, (double)sizeof(char)*256*256*2/1024); --- > if(member_length>5){ > num3=2; > }else{ > num3=1; > } > > printf("\t\trecent: %u(%.02lfKB) common: %u(%.02lfKB) index: %.02lfKB\n",b_members, cache_sizes[0]/1024, c_members, cache_sizes[1]/1024, (double)sizeof(char)*256*256*num3/1024); 879c1129 < table[num1].sizes[num2][num3]=1; --- > // table[num1].sizes[num2][num3]=1;