Changeset 471
 Timestamp:
 Jul 12, 2010, 10:35:37 AM (9 years ago)
 Location:
 proto/u16u8
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

proto/u16u8/src/u16u8.c
r470 r471 6 6 #include <sys/types.h> 7 7 #include <sys/stat.h> 8 #include "lib/lib_simd.h" 9 #define min(x,y) ((x) <(y) ?(x) :(y) ) \ 8 9 #include "../lib/lib_simd.h" 10 #include "../lib/block_carry.h" 10 11 11 12 typedef SIMD_type BytePack; … … 14 15 15 16 // Profiling 17 #define BUFFER_PROFILING 18 #include "../lib/perflib/perfsec.h" 16 19 17 20 #ifdef BUFFER_PROFILING 18 #include "../Profiling/BOM_Profiler.c"19 21 BOM_Table * transcode_timer; 20 22 #endif … … 192 194 } 193 195 194 #define double_int64_adc(x1, x2, y1, y2, rslt1, rslt2, carry) \195 __asm__ ("sahf\n\t" \196 "adc %[e1], %[z1]\n\t" \197 "adc %[e2], %[z2]\n\t" \198 "lahf\n\t" \199 : [z1] "=r" (rslt1), [z2] "=r" (rslt2), [carryflag] "=a" (carry) \200 : "[z1]" (x1), "[z2]" (x2), \201 [e1] "r" (y1), [e2] "r" (y2), \202 "[carryflag]" (carry) \203 : "cc")204 205 #define adc128(first, second, carry, sum) \206 do\207 {\208 union {__m128i bitblock;\209 uint64_t int64[2];} rslt;\210 \211 union {__m128i bitblock;\212 uint64_t int64[2];} x;\213 \214 union {__m128i bitblock;\215 uint64_t int64[2];} y;\216 \217 x.bitblock = first;\218 y.bitblock = second;\219 \220 double_int64_adc(x.int64[0], x.int64[1], y.int64[0], y.int64[1], rslt.int64[0], rslt.int64[1], carry);\221 sum = rslt.bitblock;\222 }while(0)223 224 #define double_int64_sbb(x1, x2, y1, y2, rslt1, rslt2, carry) \225 __asm__ ("sahf\n\t" \226 "sbb %[e1], %[z1]\n\t" \227 "sbb %[e2], %[z2]\n\t" \228 "lahf\n\t" \229 : [z1] "=r" (rslt1), [z2] "=r" (rslt2), [carryflag] "=a" (carry) \230 : "[z1]" (x1), "[z2]" (x2), \231 [e1] "r" (y1), [e2] "r" (y2), \232 "[carryflag]" (carry) \233 : "cc")234 235 236 #define sbb128(first, second, carry, sum) \237 do\238 { union {__m128i bitblock;\239 uint64_t int64[2];} rslt;\240 \241 union {__m128i bitblock;\242 uint64_t int64[2];} x;\243 \244 union {__m128i bitblock;\245 uint64_t int64[2];} y;\246 \247 x.bitblock = first;\248 y.bitblock = second;\249 \250 double_int64_sbb(x.int64[0], x.int64[1], y.int64[0], y.int64[1], \251 rslt.int64[0], rslt.int64[1], carry);\252 sum = rslt.bitblock;\253 }while(0)254 196 255 197 … … 258 200 void u16u8(char ** targetbuf, const char * targetlimit, const UChar ** srcbuf, const UChar * srclimit, UErrorCode * err){ 259 201 260 int carry1=0; 261 int carry0=0; 262 int carry2=0; 263 BitBlock hcarry; 202 BitBlock hcarry; 264 203 BitBlock array_u16l__4_; 265 204 BitBlock array_u16h__4_; … … 357 296 BitBlock Temp9; 358 297 BitBlock Temp8; 298 CarryType carry1 = Carry0; 299 CarryType carry0 = Carry0; 300 CarryType carry2 = Carry0; 359 301 360 302 … … 378 320 int pos = 0; 379 321 380 int units_read = 0; 322 intptr_t units_remaining = 0; 323 intptr_t units_read = 0; 381 324 382 325 bool error_found = false; 383 326 int err_pos; 384 327 385 328 386 329 387 330 do { 388 331 389 332 U16 = (BytePack *)(*srcbuf); 390 units_read = min(srclimit(*srcbuf),BLOCK_SIZE); 391 392 if(units_read < BLOCK_SIZE){ 393 endmask = sisd_sll(simd_const_1(1),sisd_from_int(units_read)); 333 units_remaining = srclimit(*srcbuf); 334 335 if(units_remaining < BLOCK_SIZE){ 336 endmask = sisd_sll(simd_const_1(1),sisd_from_int((int) units_remaining)); 337 units_read = units_remaining; 338 394 339 // ((uint16_t *) U16)[units_read/2] = 0; 395 340 } 396 else endmask = simd_const_1(0); 397 341 else { 342 endmask = simd_const_1(0); 343 units_read = BLOCK_SIZE; 344 } 398 345 399 346 for (int i=0; i< 8; i++){ … … 444 391 strct_u16__utf8_2_ = simd_andc(above_0x7F,above_0x7FF); 445 392 strct_u16__ASCII_ = simd_andc(AllOne,above_0x7F); 446 ad c128(strct_u16__hsurrogate_,strct_u16__hsurrogate_, carry0, Temp10);393 advance_with_carry(strct_u16__hsurrogate_, carry0, Temp10); 447 394 strct_u16__error_ = simd_xor(Temp10,strct_u16__lsurrogate_); 448 395 efghi_i = simd_andc(AllOne,array_u16l__1_); … … 478 425 Temp23 = simd_and(strct_u16__utf8_3_,array_u16h__4_); 479 426 Temp24 = simd_or(strct_u16__hsurrogate_,Temp23); 480 ad c128(array_u16l__6_,array_u16l__6_, carry1, Temp25);427 advance_with_carry(array_u16l__6_, carry1, Temp25); 481 428 Temp26 = simd_and(strct_u16__lsurrogate_,Temp25); 482 429 array_u8_butlast__2_ = simd_or(Temp24,Temp26); 483 430 Temp27 = simd_and(u8_2or3,array_u16h__5_); 484 431 Temp28 = simd_or(strct_u16__hsurrogate_,Temp27); 485 ad c128(array_u16l__7_,array_u16l__7_, carry2, Temp29);432 advance_with_carry(array_u16l__7_, carry2, Temp29); 486 433 Temp30 = simd_and(strct_u16__lsurrogate_,Temp29); 487 434 array_u8_butlast__3_ = simd_or(Temp28,Temp30); … … 671 618 } 672 619 673 // fclose(infile); 674 // fclose(outfile); 620 fclose(outfile); 675 621 676 622 
proto/u16u8/template.c
r464 r471 9 9 #include "../lib/lib_simd.h" 10 10 #include "../lib/block_carry.h" 11 12 13 #define min(x,y) ((x) <(y) ?(x) :(y) ) \14 11 15 12 typedef SIMD_type BytePack; … … 224 221 int pos = 0; 225 222 226 int units_read = 0; 223 intptr_t units_remaining = 0; 224 intptr_t units_read = 0; 227 225 228 226 bool error_found = false; … … 234 232 235 233 U16 = (BytePack *)(*srcbuf); 236 units_read = min(srclimit(*srcbuf),BLOCK_SIZE); 237 238 if(units_read < BLOCK_SIZE){ 239 endmask = sisd_sll(simd_const_1(1),sisd_from_int(units_read)); 234 units_remaining = srclimit(*srcbuf); 235 236 if(units_remaining < BLOCK_SIZE){ 237 endmask = sisd_sll(simd_const_1(1),sisd_from_int((int) units_remaining)); 238 units_read = units_remaining; 239 240 240 // ((uint16_t *) U16)[units_read/2] = 0; 241 241 } 242 else endmask = simd_const_1(0); 243 242 else { 243 endmask = simd_const_1(0); 244 units_read = BLOCK_SIZE; 245 } 244 246 245 247 for (int i=0; i< 8; i++){ … … 439 441 } 440 442 441 // fclose(infile); 442 // fclose(outfile); 443 fclose(outfile); 443 444 444 445
Note: See TracChangeset
for help on using the changeset viewer.