Changeset 736


Ignore:
Timestamp:
Nov 29, 2010, 10:53:25 PM (9 years ago)
Author:
ksherdy
Message:

Add parallel prefix parity method, high bit mask, low bit mask, sisd_add/simd_add_128.

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/sse_simd.h

    r628 r736  
    4242
    4343/*  Specific constants. */
     44#define sisd_low_bit_mask  _mm_set_epi32(0x00000000, 0x00000000, 0x00000000, 0x00000001)
     45#define sisd_high_bit_mask _mm_set_epi32(0x80000000, 0x00000000, 0x00000000, 0x00000000)
     46
    4447#define simd_himask_2 _mm_set1_epi32(0xAAAAAAAA)
    4548#define simd_himask_4 _mm_set1_epi32(0xCCCCCCCC)
     
    5154#define simd_himask_128 _mm_set_epi32(-1,-1,0,0)
    5255
     56#define simd_lomask_128 _mm_set_epi32(0,0,-1,-1)
    5357/* Idealized operations with direct implementation by built-in
    5458   operations for various target architectures. */
     
    491495#endif
    492496
     497#ifndef simd_add_128
     498
     499static inline SIMD_type simd_add_128(SIMD_type v1, SIMD_type v2) {
     500        SIMD_type temp = simd_add_64(v1,v2);
     501        SIMD_type carry_mask = simd_or(simd_and(v1, v2), simd_and(simd_xor(v1, v2), simd_not(temp)));
     502        SIMD_type carry = sisd_slli(simd_and(carry_mask, simd_lomask_128),1);
     503        return simd_if(simd_lomask_128, temp, simd_add_64(temp, carry));
     504}
     505#endif
     506
    493507#ifndef simd_pack_2_xx
    494508#define simd_pack_2_xx(v1, v2) simd_pack_2(v1, v2)
     
    659673}
    660674
    661 #endif
    662 
     675/* Prints the SIMD register representation of a SIMD value. */
     676static void print_simd_register(const char * var_name, SIMD_type v);
     677
     678/*
     679   Returns parallel-prefix XOR (parity) mask based on parity of the arguments parity_1 and parity_mask.
     680   
     681   parity_1 - parity of 1 bit fields
     682   parity_2 - parity of 2 bit fields
     683   .
     684   .
     685   parity_128 - parity of 128 bit fields (register width).
     686   
     687   parity_mask - mask of all 1's or all 0's,
     688                 Under the block-by-block processing model, a mask of all 1's => odd parity in the previous block, all 0's => even parity.
     689   
     690*/
     691static inline SIMD_type bitblock_parallel_prefix_parity(SIMD_type parity_1, SIMD_type parity_mask) {
     692 
     693  SIMD_type parity_2 = simd_xor(crt_blk, sisd_slli(parity_1,1));
     694  SIMD_type parity_4 = simd_xor(parity_2, sisd_slli(parity_2,2));
     695  SIMD_type parity_8 = simd_xor(parity_4, sisd_slli(parity_4,4)); 
     696  SIMD_type parity_16 = simd_xor(parity_8, sisd_slli(parity_8,8));
     697  SIMD_type parity_32 = simd_xor(parity_16, sisd_slli(parity_16,16));
     698  SIMD_type parity_64 = simd_xor(parity_32, sisd_slli(parity_32,32));
     699  SIMD_type parity_128 = simd_xor(parity_64, sisd_slli(parity_64,64));
     700
     701  /*
     702  print_simd_register("crt_blk",crt_blk); 
     703  print_simd_register("parity_2",parity_2); 
     704  print_simd_register("parity_4",parity_4);   
     705  print_simd_register("parity_8",parity_8);   
     706  print_simd_register("parity_16",parity_16); 
     707  print_simd_register("parity_32",parity_32);
     708  print_simd_register("parity_64",parity_64); 
     709  print_simd_register("parity_128",parity_128); 
     710  print_simd_register("parity_mask",parity_mask); 
     711  */
     712 
     713  return simd_xor(parity_128, parity_mask);
     714}
     715
     716#endif
     717
  • trunk/lib/sse_simd_t.h

    r615 r736  
    810810  return (int) sisd_to_int(cts_128);
    811811}
    812 #endif
    813 
     812
     813#endif
     814
Note: See TracChangeset for help on using the changeset viewer.