Beispiel #1
0
/* ====================================================================
 *
 *  TI_RES_RES_Set_BB_Cycle_Count
 *
 *  See interface description
 *
 * ====================================================================
 */
void TI_RES_RES_Set_BB_Cycle_Count(
  TI_RES_RES  *res,
  INT          length
)
{
  INT  i;
  BOOL cyclic = TI_RES_RES_cyclic(res);

  if ( length > TI_RES_RES_alloc_size(res) ) {
    INT new_alloc_size = length * 2;
    TI_RES_RES_alloc_size(res) = new_alloc_size;

    TI_RES_RES_rrtab(res) = TYPE_MEM_POOL_ALLOC_N(SI_RRW,
					TI_RES_RES_pool(res),
					new_alloc_size);
    if ( cyclic ) {
      TI_RES_RES_uncommon_res_ids(res)
	= TYPE_MEM_POOL_ALLOC_N(SI_RESOURCE_ID_SET,
				TI_RES_RES_pool(res),
				new_alloc_size);
    }
  }

  TI_RES_RES_length(res) = length;

  /* Initialize the part of the table we will use
   */
  for ( i = 0; i < length; ++i ) {
    TI_RES_RES_rrtab(res)[i] = SI_RRW_Initial();
  }

  if ( cyclic ) {
    INT id;
    BS *si_ids = TI_RES_RES_si_ids(res);
    SI_RESOURCE_ID_SET *uncommon_res_ids = TI_RES_RES_uncommon_res_ids(res);
    INT common_length = MIN(TI_RES_RES_min_rr_length(res), length);

    /* For each cycle, compute the set of resources that not all the OPs in
     * the loop use in that cycle.  We do this by computing its complement --
     * the set of resources that all the OPs use in the cycle -- and then
     * complementing it in place.
     */

    /* Compute common resources into "uncommon_res_ids"
     *
     * NOTE: the following loop also initializes the "res_ids"
     * from common_length to the end of the vector. These
     * are by definition not common to all OPs, and we will leave
     * the setting unchanged in the following loops.
     */
    for ( i = 0; i < length; ++i ) {
      uncommon_res_ids[i] = SI_RESOURCE_ID_SET_Universe();
    }

    for ( id = BS_Choose(si_ids); id != BS_CHOOSE_FAILURE;
                                  id = BS_Choose_Next(si_ids,id)
    ) {
      const SI_RESOURCE_ID_SET* resource_ids_used
        = SI_ID_II_Cycle_Resource_Ids_Used(id,length);

      for ( i = 0; i < common_length; ++i ) {
        uncommon_res_ids[i]
          = SI_RESOURCE_ID_SET_Intersection(uncommon_res_ids[i],
                                            resource_ids_used[i]);
      }
    }

    /* Complement in place
     */
    for ( i = 0; i < common_length; ++i ) {
      uncommon_res_ids[i] =
        SI_RESOURCE_ID_SET_Complement(uncommon_res_ids[i]);
    }
  }
}
Beispiel #2
0
 *
 * ====================================================================
 */

_X_PROP_TYPE_ *
_X_PROP_CREATE_(
  INT32     universe_size,
  MEM_POOL *pool
)
{
  /* We allocate fixed size bit vector, preceeded by its size.
   * Round up size to words and add 1 for the size.
   */
  UINT32 words = (  (universe_size + _X_PROP_TYPE_SIZE_ - 1)
		  >> _X_PROP_TYPE_SIZE_LOG2_) + 1;
  _X_PROP_TYPE_ *prop = TYPE_MEM_POOL_ALLOC_N(_X_PROP_TYPE_, pool, words);
  if ( ! MEM_POOL_Zeroed(pool) ) bzero(prop, words * sizeof(_X_PROP_TYPE_));
  prop[0] = universe_size;
  return prop;
}


/* ====================================================================
 *
 *  X_PROP_Set
 *
 *  See interface description
 *
 * ====================================================================
 */