Пример #1
0
// Construct a dynamic configuration descriptor
// This really needs dynamic endpoint allocation etc
uint32_t USBDeviceClass::sendConfiguration(uint32_t maxlen)
{
	uint32_t total = 0;
	// Count and measure interfaces
	_dry_run = true;
	uint8_t interfaces = SendInterfaces(&total);

	_Pragma("pack(1)")
	ConfigDescriptor config = D_CONFIG((uint16_t)(total + sizeof(ConfigDescriptor)), interfaces);
	_Pragma("pack()")

	//	Now send them
	_dry_run = false;

	if (maxlen == sizeof(ConfigDescriptor)) {
		sendControl(&config, sizeof(ConfigDescriptor));
		return true;
	}

	total = 0;

	packMessages(true);
	sendControl(&config, sizeof(ConfigDescriptor));
	SendInterfaces(&total);
	packMessages(false);

	return true;
}
Пример #2
0
int main( void )
{
  // WCC frequently has problems with locating the _Pragmas,
  // therfore we had to introduce this blocker variable to be
  // able to place the Pragmas.
  volatile int blocker;
  int In = fib( 10 );
  _Pragma( "marker recursivecall" )
  _Pragma( "flowrestriction 1*fib <= 177*recursivecall" )
  return blocker;
}
Пример #3
0
float my_sqrtf(float val)
{
  float x = val/10;

  float dx;

  float diff;
  float min_tol = 0.00001f;

  int i, flag;

  flag = 0;
  if (val == 0 ) x = 0;
  else {
    _Pragma("loopbound min 19 max 19");
    for (i=1;i<20;i++)
      {
	if (!flag) {
	  dx = (val - (x*x)) / (2.0f * x);
	  x = x + dx;
	  diff = val - (x*x);
          
	  if (my_fabs(diff) <= min_tol) flag = 1;
	}
	else 
	  x =x;
        
      }
  }
  return (x);
}
Пример #4
0
void bli_memsys_reinit( cntx_t* cntx )
{
#ifdef BLIS_ENABLE_OPENMP
	_Pragma( "omp critical (mem)" )
#endif
#ifdef BLIS_ENABLE_PTHREADS
	pthread_mutex_lock( &mem_manager_mutex );
#endif

	// BEGIN CRITICAL SECTION
	{
		// If for some reason the memory pools have not yet been
		// initialized (unlikely), we emulate the body of bli_memsys_init().
		if ( bli_memsys_is_init == FALSE )
		{
			// Initialize the global membrk_t object and its memory pools.
			bli_membrk_init( cntx, &global_membrk );

			// After initialization, mark the API as initialized.
			bli_memsys_is_init = TRUE;
		}
		else
		{
			// Reinitialize the global membrk_t object's memory pools.
			bli_membrk_reinit_pools( cntx, &global_membrk );
		}
	}
	// END CRITICAL SECTION

#ifdef BLIS_ENABLE_PTHREADS
	pthread_mutex_unlock( &mem_manager_mutex );
#endif
}
Пример #5
0
void duff_copy( char *to, char *from, int count )
{
  int n = ( count + 7 ) / 8;

  _Pragma( "marker outside" )

  switch ( count % 8 ) {

    case 0:
      do {
        *to++ = *from++;
      case 7:
        *to++ = *from++;
      case 6:
        *to++ = *from++;
      case 5:
        *to++ = *from++;
      case 4:
        *to++ = *from++;
      case 3:
        *to++ = *from++;
      case 2:
        *to++ = *from++;
      case 1:
        _Pragma( "marker inside" )
        *to++ = *from++;


      } while ( --n > 0 );
  }
  _Pragma( "flowrestriction 1*inside <= 6*outside" )
}
Пример #6
0
void bli_memsys_finalize( void )
{
	// If the initialization flag is FALSE, we know the API is already
	// uninitialized, so we can return early.
	if ( bli_memsys_is_init == FALSE ) return;

#ifdef BLIS_ENABLE_OPENMP
	_Pragma( "omp critical (mem)" )
#endif
#ifdef BLIS_ENABLE_PTHREADS
	pthread_mutex_lock( &mem_manager_mutex );
#endif

	// BEGIN CRITICAL SECTION
	{
		// Here, we test the initialization flag again. NOTE: THIS IS NOT
		// REDUNDANT. This additional test is needed so that other threads
		// that may be waiting to acquire the lock do not perform any
		// finalization actions once they are finally allowed into this
		// critical section.
		if ( bli_memsys_is_init == TRUE )
		{
			// Finalize the global membrk_t object and its memory pools.
			bli_membrk_finalize( &global_membrk );

			// After finalization, mark the API as uninitialized.
			bli_memsys_is_init = FALSE;
		}
	}
	// END CRITICAL SECTION

#ifdef BLIS_ENABLE_PTHREADS
	pthread_mutex_unlock( &mem_manager_mutex );
#endif
}
Пример #7
0
void Initialize(float *Array)
{
  register int i;

  _Pragma("loopbound min 1000 max 1000");
  for (i=0; i < MAX; i++)
   Array [i] = i + RandomInteger ()/8095.0f;
}
Пример #8
0
static float select_select( unsigned long k, unsigned long n )
{
    unsigned long i, ir, j, l, mid;
    float a, temp;
    int flag, flag2;

    l = 0;
    ir = n - 1;
    flag = flag2 = 0;
    _Pragma( "loopbound min 1 max 20" )
    while ( !flag ) {
        if ( ir <= l + 1 ) {
            if ( ir == l + 1 )
                if ( select_arr[ ir ] < select_arr[ l ] ) {
                    SWAP( select_arr[ l ], select_arr[ ir ] );
                }
            flag = 1;
        } else {
            if ( !flag ) {
                mid = ( l + ir ) >> 1;
                SWAP( select_arr[ mid ], select_arr[ l + 1 ] );
                if ( select_arr[ l ] > select_arr[ ir ] ) {
                    SWAP( select_arr[ l ], select_arr[ ir ] );
                }
                if ( select_arr[ l + 1 ] > select_arr[ ir ] ) {
                    SWAP( select_arr[ l + 1 ], select_arr[ ir ] );
                }
                if ( select_arr[ l ] > select_arr[ l + 1 ] ) {
                    SWAP( select_arr[ l ], select_arr[ l + 1 ] );
                }
                i = l + 1;
                j = ir;
                a = select_arr[ l + 1 ];
                _Pragma( "loopbound min 1 max 9" )
                flag2 = 0;
                while ( !flag2 ) {
                    i++;
                    _Pragma( "loopbound min 0 max 18" )
                    while ( select_arr[ i ] < a ) i++;
                    j--;
                    _Pragma( "loopbound min 0 max 18" )
                    while ( select_arr[ j ] > a ) j--;
                    if ( j < i ) flag2 = 1;
                    if ( !flag2 ) {
                        SWAP( select_arr[ i ], select_arr[ j ] );
                    }
                }

                select_arr[ l + 1 ] = select_arr[ j ];
                select_arr[ j ] = a;

                if ( j >= k )
                    ir = j - 1;
                if ( j <= k )
                    l = i;
            }
        }
    }
Пример #9
0
/*FUNCTION**********************************************************************
 *
 * Function Name : OSA_InstallIntHandler
 * Description   : This function is used to install interrupt handler.
 *
 *END**************************************************************************/
void OSA_InstallIntHandler(uint32_t IRQNumber, void (*handler)(void))
{

#if defined ( __IAR_SYSTEMS_ICC__ )
    _Pragma ("diag_suppress = Pm138")
#endif
    InstallIRQHandler((IRQn_Type)IRQNumber, (uint32_t)handler);
#if defined ( __IAR_SYSTEMS_ICC__ )
    _Pragma ("diag_remark = PM138")
#endif
}
Пример #10
0
void Calc_Sum_Mean(float *Array, float *Sum,  float *Mean)
{
   int i;

   *Sum = 0;
   _Pragma("loopbound min 1000 max 1000");
   for (i = 0; i < MAX; i++) {
      *Sum += Array[i];
   }
   *Mean = *Sum / MAX;
}
Пример #11
0
void Calc_Var_Stddev(float *Array, float Mean, float *Var, float *Stddev)
{
   int i;
   float diffs;

   diffs = 0.0f;
   _Pragma("loopbound min 1000 max 1000");
   for (i = 0; i < MAX; i++) {
      diffs += Square(Array[i] - Mean);
   }
   *Var = diffs/MAX;
   *Stddev = my_sqrtf(*Var);
}
Пример #12
0
bool prime (uint n) {
  uint i;
  if (even (n))
      return (n == 2);
  _Pragma("loopbound min 73 max 357")
  __llvm_pcmarker(0);
  for (i = 3; i * i <= n; i += 2) { 
      __llvm_pcmarker(1);
      if (divides (i, n)) /* ai: loop here min 0 max 357 end; */
          return 0; 
  }
  return (n > 1);
}
Пример #13
0
int main(void)
{
  /** Initialize array "a" with data **/
  int i;
  
  _Pragma( "loopbound min 32 max 32" )
  for (i = 0; i < 32; i++) {
    a[i] = (32 - i);
  }
  
  /** When called with parameters lo = 0, cnt = a.length() and dir =
  * ASCENDING, procedure bitonicSort sorts the whole array a. **/
  _Pragma( "marker recSort" )
  bitonicSort(0, 32, ASCENDING);
  _Pragma( "flowrestriction 1*bitonicSort <= 63*recSort" )

  /** Loop through array, printing out each element **/
  _Pragma( "loopbound min 32 max 32" )
  for (i = 0; i < 32; i++) {
  }
  
  return 0;
}
EConvertQueryResult ConvertRaycastResults(bool& OutHasValidBlockingHit, const UWorld* World, int32 NumHits, PxRaycastHit* Hits, float CheckLength, const PxFilterData& QueryFilter, TArray<FHitResult>& OutHits, const FVector& StartLoc, const FVector& EndLoc, bool bReturnFaceIndex, bool bReturnPhysMat)
{
#if PLATFORM_LINUX	// to narrow down OR-24947
	_Pragma("clang optimize off");
#endif // PLATFORM_LINUX

	OutHits.Reserve(OutHits.Num() + NumHits);
	EConvertQueryResult ConvertResult = EConvertQueryResult::Valid;
	bool bHadBlockingHit = false;

	PxTransform PStartTM(U2PVector(StartLoc));
	for(int32 i=0; i<NumHits; i++)
	{
		FHitResult& NewResult = OutHits[OutHits.Emplace()];
		const PxRaycastHit& PHit = Hits[i];

		if (ConvertQueryImpactHit(World, PHit, NewResult, CheckLength, QueryFilter, StartLoc, EndLoc, NULL, PStartTM, bReturnFaceIndex, bReturnPhysMat) == EConvertQueryResult::Valid)
		{
			bHadBlockingHit |= NewResult.bBlockingHit;
		}
		else
		{
			// Reject invalid result (this should be rare). Remove from the results.
			OutHits.Pop(/*bAllowShrinking=*/ false);
			ConvertResult = EConvertQueryResult::Invalid;
		}
	}

	// Sort results from first to last hit
	OutHits.Sort( FCompareFHitResultTime() );
	OutHasValidBlockingHit = bHadBlockingHit;
	return ConvertResult;

#if PLATFORM_LINUX	// to narrow down OR-24947
	_Pragma("clang optimize on");
#endif // PLATFORM_LINUX
}
Пример #15
0
void Calc_LinCorrCoef(float *ArrayA, float *ArrayB, float MeanA, float MeanB /*, Coef*/)
{
   int i;
   float numerator, Aterm, Bterm;

   numerator = 0.0f;
   Aterm = Bterm = 0.0f;
   _Pragma("loopbound min 1000 max 1000");
   for (i = 0; i < MAX; i++) {
      numerator += (ArrayA[i] - MeanA) * (ArrayB[i] - MeanB);
      Aterm += Square(ArrayA[i] - MeanA);
      Bterm += Square(ArrayB[i] - MeanB);
   }

   /* Coef used globally */
   Coef = numerator / (my_sqrtf(Aterm) * my_sqrtf(Bterm));
}
Пример #16
0
void bli_memsys_init( void )
{
	cntx_t cntx;

	// If the initialization flag is TRUE, we know the API is already
	// initialized, so we can return early.
	if ( bli_memsys_is_init == TRUE ) return;

	// Create and initialize a context for gemm so we have something
	// to pass into bli_membrk_init_pools().
	bli_gemm_cntx_init( &cntx );

#ifdef BLIS_ENABLE_OPENMP
	_Pragma( "omp critical (mem)" )
#endif
#ifdef BLIS_ENABLE_PTHREADS
	pthread_mutex_lock( &mem_manager_mutex );
#endif

	// BEGIN CRITICAL SECTION
	{
		// Here, we test the initialization flag again. NOTE: THIS IS NOT
		// REDUNDANT. This additional test is needed so that other threads
		// that may be waiting to acquire the lock do not perform any
		// initialization actions once they are finally allowed into this
		// critical section.
		if ( bli_memsys_is_init == FALSE )
		{
			// Initialize the global membrk_t object and its memory pools.
			bli_membrk_init( &cntx, &global_membrk );

			// After initialization, mark the API as initialized.
			bli_memsys_is_init = TRUE;
		}
	}
	// END CRITICAL SECTION

#ifdef BLIS_ENABLE_PTHREADS
	pthread_mutex_unlock( &mem_manager_mutex );
#endif

	// Finalize the temporary gemm context.
	bli_gemm_cntx_finalize( &cntx );
}
Пример #17
0
//'Normal' barrier for openmp
//barrier routine taken from art of multicore programming
void bli_thrcomm_barrier( thrcomm_t* communicator, dim_t t_id )
{
	if( communicator == NULL || communicator->n_threads == 1 )
		return;
	bool_t my_sense = communicator->barrier_sense;
	dim_t my_threads_arrived;

	_Pragma( "omp atomic capture" )
		my_threads_arrived = ++(communicator->barrier_threads_arrived);

	if ( my_threads_arrived == communicator->n_threads )
	{
		communicator->barrier_threads_arrived = 0;
		communicator->barrier_sense = !communicator->barrier_sense;
	}
	else
	{
		volatile bool_t* listener = &communicator->barrier_sense;
		while ( *listener == my_sense ) {}
	}
}
Пример #18
0
void bli_thrcomm_tree_barrier( barrier_t* barack )
{
	int my_signal = barack->signal;
	int my_count;

	_Pragma( "omp atomic capture" )
		my_count = barack->count--;

	if ( my_count == 1 )
	{
		if ( barack->dad != NULL )
		{
			bli_thrcomm_tree_barrier( barack->dad );
		}
		barack->count = barack->arity;
		barack->signal = !barack->signal;
	}
	else
	{
		volatile int* listener = &barack->signal;
		while ( *listener == my_signal ) {}
	}
}
Пример #19
0
			typename soa::table_traits<C>::table_reference first,		\
			typename soa::table_traits<CN>::table_reference... rest){ \
		__VA_ARGS__														\
		  for (size_t i=start; i<end; ++i)								\
			apply_tuple(f, std::forward_as_tuple(first[i], rest[i]...)); \
	  }, first, rest...);												\
  }
#endif

  namespace {
	template<class C> class _parallel_for_each {
	public:
#ifndef NOTBB
	  def_parallel_for_each(loop);
#ifdef __ICC
	  def_parallel_for_each(vector_loop, _Pragma("vector always"));
	  def_parallel_for_each(ivdep_loop, _Pragma("ivdep"));
	  def_parallel_for_each(vector_ivdep_loop, _Pragma("ivdep") _Pragma("vector always"));
	  def_parallel_for_each(simd_loop, _Pragma("simd"));
	  def_parallel_for_each(novector_loop, _Pragma("novector"));
#endif
#endif
#ifdef __cilk
	  def_cilk_parallel_for_each(cilk_loop);
#ifdef __ICC
	  def_cilk_parallel_for_each(cilk_vector_loop, _Pragma("vector always"));
	  def_cilk_parallel_for_each(cilk_ivdep_loop, _Pragma("ivdep"));
	  def_cilk_parallel_for_each(cilk_vector_ivdep_loop, _Pragma("ivdep") _Pragma("vector always"));
	  def_cilk_parallel_for_each(cilk_simd_loop, _Pragma("simd"));
	  def_cilk_parallel_for_each(cilk_novector_loop, _Pragma("novector"));
#endif
Пример #20
0
/*!
 ***********************************************************************
 * \return
 *    best SAD
 ***********************************************************************
 */
int intrapred_luma_16x16(struct img_par *img, //!< image parameters
                         int predmode)        //!< prediction mode
{
  int s0=0,s1,s2;

  int i,j;

  int ih,iv;
  int ib,ic,iaa;

//  imgpel **imgY=dec_picture->imgY;
//  int mb_nr=img->current_mb_nr;

  int up_avail, left_avail, left_up_avail;

  s1=s2=0;

//  for (i=0;i<17;i++)
//  {
//    getNeighbour(mb_nr, -1 ,  i-1 , 1, &left[i]);
//  }
  
 // getNeighbour(mb_nr, 0     ,  -1 , 1, &up);


  // Note: During simulation of complete benchmark, this
  // parameter was always 1 for the provided input sets.
  //if (!active_pps->constrained_intra_pred_flag)
  if (1)
  {
    up_avail   = up.available;
    left_avail = left[1].available;
    left_up_avail = left[0].available;
  }
/*
  else
  {
    up_avail      = up.available ? img->intra_block[up.mb_addr] : 0;
    _Pragma("loopbound min 16 max 16")
    for (i=1, left_avail=1; i<17;i++)
      left_avail  &= left[i].available ? img->intra_block[left[i].mb_addr]: 0;
    left_up_avail = left[0].available ? img->intra_block[left[0].mb_addr]: 0;
  }
*/
  switch (predmode)
  {
  case VERT_PRED_16:                       // vertical prediction from block above
    if (!up_avail)
//      error ("invalid 16x16 intra pred Mode VERT_PRED_16",500);
    _Pragma("loopbound min 16 max 16")
    for(j=0;j<MB_BLOCK_SIZE;j++)
      _Pragma("loopbound min 16 max 16")
      for(i=0;i<MB_BLOCK_SIZE;i++)
        img_mpr[i][j]=imgY[(up.pos_y)%100][(up.pos_x+i)%100];// store predicted 16x16 block
    break;

  case HOR_PRED_16:                        // horisontal prediction from left block
    if (!left_avail)
//      error ("invalid 16x16 intra pred Mode VERT_PRED_16",500);
    _Pragma("loopbound min 16 max 16")
    for(j=0;j<MB_BLOCK_SIZE;j++)
      _Pragma("loopbound min 16 max 16")
      for(i=0;i<MB_BLOCK_SIZE;i++)
        img_mpr[i][j]=imgY[(left[j+1].pos_y)%100][(left[j+1].pos_x)%100]; // store predicted 16x16 block
    break;

  case DC_PRED_16:                         // DC prediction
    s1=s2=0;
    _Pragma("loopbound min 16 max 16")
    for (i=0; i < MB_BLOCK_SIZE; i++)
    {
      if (up_avail)
        s1 += imgY[(up.pos_y)%100][(up.pos_x+i)%100];    // sum hor pix
      if (left_avail)
        s2 += imgY[(left[i+1].pos_y)%100][(left[i+1].pos_x)%100];    // sum vert pix
    }
    if (up_avail && left_avail)
      s0=(s1+s2+16)>>5;       // no edge
    if (!up_avail && left_avail)
      s0=(s2+8)>>4;              // upper edge
    if (up_avail && !left_avail)
      s0=(s1+8)>>4;              // left edge
    if (!up_avail && !left_avail)
      //s0=img->dc_pred_value;                            // top left corner, nothing to predict from
      s0=0;                            // top left corner, nothing to predict from
    _Pragma("loopbound min 16 max 16")
    for(i=0;i<MB_BLOCK_SIZE;i++)
      _Pragma("loopbound min 16 max 16")
      for(j=0;j<MB_BLOCK_SIZE;j++)
      {
        img_mpr[i][j]=s0;
      }
    break;
  case PLANE_16:// 16 bit integer plan pred
    if (!up_avail || !left_up_avail  || !left_avail)
//      error ("invalid 16x16 intra pred Mode PLANE_16",500);

    ih=0;
    iv=0;
    _Pragma("loopbound min 8 max 8")
    for (i=1;i<9;i++)
    {
      if (i<8)
        ih += i*(imgY[(up.pos_y)%100][(up.pos_x+7+i)%100] - imgY[(up.pos_y)%100][(up.pos_x+7-i)%100]);
      else
        ih += i*(imgY[(up.pos_y)%100][(up.pos_x+7+i)%100] - imgY[(left[0].pos_y)%100][(left[0].pos_x)%100]);

      iv += i*(imgY[(left[8+i].pos_y)%100][(left[8+i].pos_x)%100] - 
          imgY[(left[8-i].pos_y)%100][(left[8-i].pos_x)%100]);
    }
    ib=(5*ih+32)>>6;
    ic=(5*iv+32)>>6;

    iaa=16*(imgY[(up.pos_y)%100][(up.pos_x+15)%100]+imgY[(left[16].pos_y)%100][(left[16].pos_x)%100]);
    _Pragma("loopbound min 16 max 16")
    for (j=0;j< MB_BLOCK_SIZE;j++)
    {
      _Pragma("loopbound min 16 max 16")
      for (i=0;i< MB_BLOCK_SIZE;i++)
      {
        //img_mpr[i][j]=max(0,min((iaa+(i-7)*ib +(j-7)*ic + 16)>>5, img_max_imgpel_value));
        img_mpr[i][j]=max(0,min((iaa+(i-7)*ib +(j-7)*ic + 16)>>5, 500));
      }
    }// store plane prediction
    break;
    
  default:
    {                                    // indication of fault in bitstream,exit
      //printf("illegal 16x16 intra prediction mode input: %d\n",predmode);
      return SEARCH_SYNC;
    }
  }
  
  return DECODING_OK;
}
Пример #21
0
/* --------------------------------------------------------------------
  epic_reflect1() - Reflection through the edge pixels.  This is the right
  thing to do if you are subsampling by 2, since it maintains parity (even
  pixels positions remain even, odd ones remain odd). (note: procedure differs
  depending on f_or_e parameter).  */
void epic_reflect1( float *filt, int x_dim, int y_dim, int x_pos, int y_pos,
                    float *result, int f_or_e )
{
  int filt_sz = x_dim * y_dim;
  register int x_start = 0, y_start = 0, x_stop = x_dim, y_stop = filt_sz;
  register int y_filt, x_filt, y_edge, x_edge;
  register int x_base = ( x_pos > 0 ) ? ( x_dim - 1 ) : 0;
  register int y_base = ( y_pos > 0 ) ? ( x_dim * ( y_dim - 1 ) ) : 0;
  int x_edge_dist = ( x_pos > 0 ) ? ( x_pos - x_dim ) : ( ( x_pos < -1 ) ?
                    ( x_pos + 1 ) : 0 );
  int y_edge_dist = x_dim * ( ( y_pos > 0 ) ? ( y_pos - y_dim ) : ( (
                                y_pos < -1 ) ? ( y_pos + 1 ) : 0 ) );
  int i;
  int mx_pos = ( x_dim / 2 ) + 1;
  int my_pos = ( y_dim / 2 ) + 1;

  _Pragma( "loopbound min 15 max 15" )
  for ( i = 0; i < filt_sz; ++i ) result[i] = 0.0f;

  /* if EXPAND and filter is centered on image edge, do not reflect */
  if ( f_or_e IS EXPAND ) {
    if ( x_pos IS mx_pos ) x_stop = ( x_dim + 1 ) / 2;
    else
      if ( x_pos IS - mx_pos ) {
        x_start = x_dim / 2;
        x_edge_dist = 0;
      }

    if ( y_pos IS my_pos ) y_stop = x_dim * ( ( y_dim + 1 ) / 2 );
    else
      if ( y_pos IS - my_pos ) {
        y_start = x_dim * ( y_dim / 2 );
        y_edge_dist = 0;
      }
  }

  y_edge = y_edge_dist;
  /* reflect at boundary of image */
  _Pragma( "loopbound min 1 max 15" )
  for ( y_filt = y_start; y_filt < y_stop; y_filt += x_dim ) {
    x_edge = x_edge_dist;
    _Pragma( "loopbound min 1 max 15" )
    for ( x_filt = y_filt + x_start; x_filt < y_filt + x_stop; ++x_filt ) {
      result[abs( y_base - abs( y_edge ) ) + abs( x_base - abs( x_edge ) )]
      += filt[x_filt];
      ++x_edge;
    }
    y_edge += x_dim;
  }

  /* if EXPAND and filter is not centered on image edge, mult edge by 2 */
  if ( f_or_e IS EXPAND ) {
    if ( ( abs( x_pos ) ISNT mx_pos ) AND ( x_pos ISNT 0 ) )
      _Pragma( "loopbound min 0 max 0" )
      for ( y_filt = x_base; y_filt < filt_sz; y_filt += x_dim )
        result[y_filt] += result[y_filt];
    if ( ( abs( y_pos ) ISNT my_pos ) AND ( y_pos ISNT 0 ) )
      _Pragma( "loopbound min 0 max 0" )
      for ( x_filt = y_base; x_filt < y_base + x_dim; ++x_filt )
        result[x_filt] += result[x_filt];
  }
}
Пример #22
0
err_t bli_init( void )
{
	err_t r_val = BLIS_FAILURE;

	// If bli_is_init is TRUE, then we know without a doubt that
	// BLIS is presently initialized, and thus we can return early.
	if ( bli_is_init == TRUE ) return r_val;

	// NOTE: if bli_is_init is FALSE, we cannot be certain that BLIS
	// is ready to be initialized; it may be the case that a thread is
	// inside the critical section below and is already in the process
	// of initializing BLIS, but has not yet finished and updated
	// bli_is_init accordingly. This boolean asymmetry is important!

	// We enclose the bodies of bli_init() and bli_finalize() in a
	// critical section (both with the same name) so that they can be
	// safely called from multiple external (application) threads.
	// Note that while the conditional test for early return may reside
	// outside the critical section (as it should, for efficiency
	// reasons), the conditional test below MUST be within the critical
	// section to prevent a race condition of the type described above.

#ifdef BLIS_ENABLE_OPENMP
	_Pragma( "omp critical (init)" )
#endif
#ifdef BLIS_ENABLE_PTHREADS
	pthread_mutex_lock( &initialize_mutex );
#endif

	// BEGIN CRITICAL SECTION
	{

		// Proceed with initialization only if BLIS is presently uninitialized.
		// Since we bli_init() and bli_finalize() use the same named critical
		// section, we can be sure that no other thread is either (a) updating
		// bli_is_init, or (b) testing bli_is_init within the critical section
		// (for the purposes of deciding whether to perform the necessary
		// initialization subtasks).
		if ( bli_is_init == FALSE )
		{
			// Initialize various sub-APIs.
			bli_const_init();
			bli_error_init();
			bli_memsys_init();
			bli_ind_init();
			bli_thread_init();

			// After initialization is complete, mark BLIS as initialized.
			bli_is_init = TRUE;

			// Only the thread that actually performs the initialization will
			// return "success".
			r_val = BLIS_SUCCESS;
		}
	}
	// END CRITICAL SECTION

#ifdef BLIS_ENABLE_PTHREADS
	pthread_mutex_unlock( &initialize_mutex );
#endif

	return r_val;
}
Пример #23
0
	indexed_for_each_range												\
	  ([&f](size_t start, size_t end, size_t offset,					\
			typename soa::table_traits<C>::table_reference first,		\
			typename soa::table_traits<CN>::table_reference... rest){	\
		__VA_ARGS__														\
		  for (size_t i=start; i<end; ++i)								\
			apply_tuple(f, std::forward_as_tuple(offset+i, first[i], rest[i]...)); \
	  }, first, rest...);												\
  }

  namespace {
	template<class C> class _indexed_for_each {
	public:
	  def_indexed_for_each(loop);
#ifdef __ICC
	  def_indexed_for_each(vector_loop, _Pragma("vector always"));
	  def_indexed_for_each(ivdep_loop, _Pragma("ivdep"));
	  def_indexed_for_each(vector_ivdep_loop, _Pragma("ivdep") _Pragma("vector always"));
	  def_indexed_for_each(simd_loop, _Pragma("simd"));
	  def_indexed_for_each(novector_loop, _Pragma("novector"));
#endif
	};
  }

  template<typename F, class C, class... CN>
  inline void indexed_for_each(const F& f, C& first, CN&... rest)
  {
#ifdef __ICC
#pragma forceinline recursive
#endif
	_indexed_for_each<C>::loop(f, first, rest...);
Пример #24
0
static gboolean
read_config_file (const gchar *config_path,
                  guint *update_interval_days,
                  guint *randomized_delay_days)
{
  g_autoptr(EuuConfigFile) config = NULL;
  g_autoptr(GError) error = NULL;
  guint _update_interval_days;
  guint _randomized_delay_days;
  const gchar * const paths[] =
    {
      config_path,  /* typically CONFIG_FILE_PATH unless testing */
      OLD_CONFIG_FILE_PATH,
      LOCAL_CONFIG_FILE_PATH,
      STATIC_CONFIG_FILE_PATH,
      NULL
    };

  g_return_val_if_fail (update_interval_days != NULL, FALSE);

  /* Load the config files. */
  config = euu_config_file_new (paths, eos_updater_resources_get_resource (),
                                "/com/endlessm/Updater/config/eos-autoupdater.conf");

  last_automatic_step = (UpdateStep) euu_config_file_get_uint (config,
                                                               AUTOMATIC_GROUP,
                                                               LAST_STEP_KEY,
                                                               UPDATE_STEP_FIRST,
                                                               UPDATE_STEP_LAST,
                                                               &error);
  if (g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE))
    {
      warning (EOS_UPDATER_CONFIGURATION_ERROR_MSGID,
               "Specified last automatic step is not a valid step");
      return FALSE;
    }
  else if (error != NULL)
    {
      warning (EOS_UPDATER_CONFIGURATION_ERROR_MSGID,
               "Unable to read key '%s' in config file",
               LAST_STEP_KEY);
      return FALSE;
    }

  _update_interval_days = euu_config_file_get_uint (config, AUTOMATIC_GROUP,
                                                    INTERVAL_KEY, 0, G_MAXUINT,
                                                    &error);

  if (error != NULL)
    {
      warning (EOS_UPDATER_CONFIGURATION_ERROR_MSGID,
               "Unable to read key '%s' in config file",
               INTERVAL_KEY);
      return FALSE;
    }

  /* This should always be true, as the RHS is out of range for a guint (it’s
   * around 10^14 days, which should be a long enough update period for anyone).
   * We use G_MAXUINT64 rather than G_MAXUINT because the time calculation in
   * is_time_to_update() uses guint64 variables. */
_Pragma ("GCC diagnostic push")
_Pragma ("GCC diagnostic ignored \"-Wtype-limits\"")
  g_assert ((guint64) _update_interval_days <= G_MAXUINT64 / SEC_PER_DAY);
_Pragma ("GCC diagnostic pop")

  *update_interval_days = (guint) _update_interval_days;

  /* We use G_MAXINT32 as g_random_int_range() operates on gint32. */
  _randomized_delay_days = euu_config_file_get_uint (config, AUTOMATIC_GROUP,
                                                     RANDOMIZED_DELAY_KEY,
                                                     0, (G_MAXINT32 / SEC_PER_DAY) - 1,
                                                     &error);

  if (g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE))
    {
      warning (EOS_UPDATER_CONFIGURATION_ERROR_MSGID,
               "Specified randomized delay is less than zero or too large");
      return FALSE;
    }
  else if (error != NULL)
    {
      warning (EOS_UPDATER_CONFIGURATION_ERROR_MSGID,
               "Unable to read key '%s' in config file",
               RANDOMIZED_DELAY_KEY);
      return FALSE;
    }

  *randomized_delay_days = _randomized_delay_days;

  return TRUE;
}
Пример #25
0
size_t
mpz_out_raw (FILE *fp, mpz_srcptr x)
{
  mp_size_t   xsize, abs_xsize, bytes, i;
  mp_srcptr   xp;
  char        *tp, *bp;
  mp_limb_t   xlimb;
  int         zeros;
  size_t      tsize, ssize;

  xsize = SIZ(x);
  abs_xsize = ABS (xsize);
  bytes = (abs_xsize * GMP_NUMB_BITS + 7) / 8;
  tsize = ROUND_UP_MULTIPLE ((unsigned) 4, GMP_LIMB_BYTES) + bytes;

  tp = __GMP_ALLOCATE_FUNC_TYPE (tsize, char);
  bp = tp + ROUND_UP_MULTIPLE ((unsigned) 4, GMP_LIMB_BYTES);

  if (bytes != 0)
    {
      bp += bytes;
      xp = PTR (x);
      i = abs_xsize;

      if (GMP_NAIL_BITS == 0)
	{
	  /* reverse limb order, and byte swap if necessary */
#ifdef _CRAY
	  _Pragma ("_CRI ivdep");
#endif
	  do
	    {
	      bp -= GMP_LIMB_BYTES;
	      xlimb = *xp;
	      HTON_LIMB_STORE ((mp_ptr) bp, xlimb);
	      xp++;
	    }
	  while (--i > 0);

	  /* strip high zero bytes (without fetching from bp) */
	  count_leading_zeros (zeros, xlimb);
	  zeros /= 8;
	  bp += zeros;
	  bytes -= zeros;
	}
      else
	{
	  mp_limb_t  new_xlimb;
	  int        bits;
	  ASSERT_CODE (char *bp_orig = bp - bytes);

	  ASSERT_ALWAYS (GMP_NUMB_BITS >= 8);

	  bits = 0;
	  xlimb = 0;
	  for (;;)
	    {
	      while (bits >= 8)
		{
		  ASSERT (bp > bp_orig);
		  *--bp = xlimb & 0xFF;
		  xlimb >>= 8;
		  bits -= 8;
		}

	      if (i == 0)
		break;

	      new_xlimb = *xp++;
	      i--;
	      ASSERT (bp > bp_orig);
	      *--bp = (xlimb | (new_xlimb << bits)) & 0xFF;
	      xlimb = new_xlimb >> (8 - bits);
	      bits += GMP_NUMB_BITS - 8;
	    }

	  if (bits != 0)
	    {
	      ASSERT (bp > bp_orig);
	      *--bp = xlimb;
	    }

	  ASSERT (bp == bp_orig);
	  while (*bp == 0)
	    {
	      bp++;
	      bytes--;
	    }
	}
    }