Changeset 42 for trunk/lib/sse_simd.h


Ignore:
Timestamp:
Feb 11, 2008, 7:53:48 AM (11 years ago)
Author:
cameron
Message:

lib_simd: refactored allocation, bitstream_scan

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/sse_simd.h

    r34 r42  
    1 
    21/*  Idealized SIMD Operations with SSE versions
    32    Copyright (C) 2006, 2007, 2008, Robert D. Cameron
     
    663662}
    664663
    665 
    666 /* Scans for a 1 as long as it takes.  Use a sentinel to fence. */
    667 static inline int bitstream_scan(SIMD_type * stream, int bit_posn) {
    668   unsigned long * bitstream_ptr = (unsigned long *) (((intptr_t) stream) + bit_posn/8);
    669   unsigned long bitstream_slice = *bitstream_ptr & (-1L << bit_posn % 8);
    670   int base_posn;
    671   if (bitstream_slice == 0) {
    672     do {
    673       bitstream_ptr++;
    674       bitstream_slice = *bitstream_ptr;
    675     } while (bitstream_slice == 0);
    676   }
    677   base_posn = 8*((intptr_t) bitstream_ptr - (intptr_t) stream);
    678   return base_posn + __builtin_ctzl(bitstream_slice);
    679 }
    680 
    681 // static inline int bitstream_scan(SIMD_type * stream, int bit_posn) {
    682 //   unsigned long * bitstream_ptr = (unsigned long *) (((intptr_t) stream) + bit_posn/8);
    683 //   unsigned long bitstream_slice = *bitstream_ptr >> bit_posn % 8;
    684 //   int base_posn = bit_posn;
    685 //   if (bitstream_slice == 0) {
    686 //     do {
    687 //       bitstream_ptr++;
    688 //       bitstream_slice = *bitstream_ptr;
    689 //     } while (bitstream_slice == 0);
    690 //     base_posn = 8*((intptr_t) bitstream_ptr - (intptr_t) stream);
    691 //   }
    692 //   return base_posn + __builtin_ctzl(bitstream_slice);
    693 // }
    694 
    695 static inline int bitstream_scan0(SIMD_type * stream) {
    696   unsigned long * bitstream_ptr = (unsigned long *) stream;
    697   unsigned long bitstream_slice = *bitstream_ptr;
    698   int base_posn = 0;
    699   while (bitstream_slice == 0) {
    700     bitstream_ptr++;
    701     bitstream_slice = *bitstream_ptr;
    702 #ifdef BITSTREAM_SCAN_ACCUM_POSN
    703     base_posn += 8 * sizeof(unsigned long);
    704 #endif
    705   }
    706 #ifndef BITSTREAM_SCAN_ACCUM_POSN
    707   base_posn = 8*((intptr_t) bitstream_ptr - (intptr_t) stream);
    708 #endif
    709   return base_posn + __builtin_ctzl(bitstream_slice);
    710 }
    711 
    712 #endif
     664#endif
Note: See TracChangeset for help on using the changeset viewer.