Changeset 34 for trunk


Ignore:
Timestamp:
Feb 10, 2008, 6:01:16 AM (12 years ago)
Author:
cameron
Message:

Altivec bitstream_scan, fake posix_memalign

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/altivec_simd.h

    r32 r34  
    11/*  Idealized SIMD Operations with Altivec, SSE and MMX versions
    2     Copyright (C) 2006, Robert D. Cameron
     2    Copyright (C) 2006, 2007, 2008, Robert D. Cameron
    33    Licensed to International Characters Inc.
    44       under the Academic Free License version 3.0.
    5        October 30, 2006 */
     5*/
    66
    77/*------------------------------------------------------------*/
     
    377377
    378378
    379 #endif
    380 
     379
     380/* Scans for a 1 as long as it takes.  Use a sentinel to fence. */
     381static inline int bitstream_scan(SIMD_type * stream, int bit_posn) {
     382  unsigned long * bitstream_ptr = (unsigned long *) (((intptr_t) stream) + bit_posn/8);
     383  unsigned long bitstream_slice = *bitstream_ptr & (-1L << bit_posn % 8);
     384  int base_posn;
     385  if (bitstream_slice == 0) {
     386    do {
     387      bitstream_ptr++;
     388      bitstream_slice = *bitstream_ptr;
     389    } while (bitstream_slice == 0);
     390  }
     391  base_posn = 8*((intptr_t) bitstream_ptr - (intptr_t) stream);
     392  return base_posn + __builtin_clzl(bitstream_slice);
     393}
     394
     395// static inline int bitstream_scan(SIMD_type * stream, int bit_posn) {
     396//   unsigned long * bitstream_ptr = (unsigned long *) (((intptr_t) stream) + bit_posn/8);
     397//   unsigned long bitstream_slice = *bitstream_ptr >> bit_posn % 8;
     398//   int base_posn = bit_posn;
     399//   if (bitstream_slice == 0) {
     400//     do {
     401//       bitstream_ptr++;
     402//       bitstream_slice = *bitstream_ptr;
     403//     } while (bitstream_slice == 0);
     404//     base_posn = 8*((intptr_t) bitstream_ptr - (intptr_t) stream);
     405//   }
     406//   return base_posn + __builtin_clzl(bitstream_slice);
     407// }
     408
     409static inline int bitstream_scan0(SIMD_type * stream) {
     410  unsigned long * bitstream_ptr = (unsigned long *) stream;
     411  unsigned long bitstream_slice = *bitstream_ptr;
     412  int base_posn = 0;
     413  while (bitstream_slice == 0) {
     414    bitstream_ptr++;
     415    bitstream_slice = *bitstream_ptr;
     416#ifdef BITSTREAM_SCAN_ACCUM_POSN
     417    base_posn += 8 * sizeof(unsigned long);
     418#endif
     419  }
     420#ifndef BITSTREAM_SCAN_ACCUM_POSN
     421  base_posn = 8*((intptr_t) bitstream_ptr - (intptr_t) stream);
     422#endif
     423  return base_posn + __builtin_clzl(bitstream_slice);
     424}
     425
     426/* Faked posix_memalign for PPC/MacOS X */
     427static inline int posix_memalign(void ** ptr, size_t align, size_t bytes) {
     428        if (align > 16) {
     429                printf("Alignment greater than 16 not supported.\n");
     430                exit(-1);
     431        }
     432        *ptr = (void *) new char[bytes];
     433        return 0;
     434}
     435
     436#endif
     437
  • trunk/lib/sse_simd.h

    r32 r34  
    11
    22/*  Idealized SIMD Operations with SSE versions
    3     Copyright (C) 2006, 2007, Robert D. Cameron
     3    Copyright (C) 2006, 2007, 2008, Robert D. Cameron
    44    Licensed to the public under the Open Software License 3.0.
    55    Licensed to International Characters Inc.
    66       under the Academic Free License version 3.0.
    77*/
    8 
    9 /*------------------------------------------------------------*/
    108#ifndef SSE_SIMD_H
    119#define SSE_SIMD_H
    1210
     11/*------------------------------------------------------------*/
    1312#include <limits.h>
    1413#ifndef LONG_BIT
     
    711710}
    712711
    713 
    714 #endif
     712#endif
Note: See TracChangeset for help on using the changeset viewer.