Beispiel #1
0
description weights::get_description() const {
  std::stringstream ss;

  // Construct description object
  description desc(get_name());

  // Dimensions
  const auto& dims = get_dims();
  ss.str(std::string{});
  ss.clear();
  for (size_t i = 0; i < dims.size(); ++i) {
    ss << (i > 0 ? "x" : "") << dims[i];
  }
  desc.add("Dimensions", ss.str());

  // Optimizer
  if (m_optimizer != nullptr) {
    desc.add(m_optimizer->get_description());
  }

  // Initializer
  if (m_initializer != nullptr) {
    desc.add(m_initializer->get_description());
  }

  // Freeze state
  if (is_frozen()) {
    desc.add("Frozen");
  }

  return desc;
}
Beispiel #2
0
bool memory_sub_session::unfreeze()
{
    if (!is_frozen())
        return true;

    d_assert(!*parent->frozen.get(), "Unfreezing sub session while parent session still frozen");

    scoped_lock pl(parent->mutex);
    scoped_lock l(mutex);
    if (unfrozen_threads_count == 0)
    {
        if (parent->ram_allocated_bytes + allocated_bytes > parent->ram_limit_bytes)
            return false;

        parent->ram_allocated_bytes += allocated_bytes;
        pl.unlock();

        for (std::map<byte*, std::pair<size_t, int> >::const_iterator i = allocs.begin(); i != allocs.end(); ++i)
        {
            if (posix_madvise(i->first, i->second.first, i->second.second))
                LOG(ERROR, "madvise error on unfreezing\n");
        }
    }

    ++unfrozen_threads_count;
    *frozen.get() = false;

    return true;
}
Beispiel #3
0
void machine_t::send_bootup_signal()
{
  log_debug() ;
  if (is_frozen())
  {
    log_debug("skipping send_bootup_signal() because the machine is frozen") ;
    return ;
  }
  ticker_t tick = calculate_bootup() ;
  int32_t next_bootup = 0 ;
  if(tick.is_valid())
    next_bootup = tick.value() ;

  int32_t next_non_boot_event = 0;
  tick = state_queued->next_event_without_bootflag();
  if (tick.is_valid())
    next_non_boot_event = tick.value();

  log_debug("signalled_bootup=%d, next_bootup=%d", signalled_bootup, next_bootup) ;
  log_debug("signalled_event=%d, next_event=%d", signalled_non_boot_event, next_non_boot_event);
  if((signalled_bootup < 0 || signalled_bootup != next_bootup)
     || (signalled_non_boot_event < 0 || signalled_non_boot_event != next_non_boot_event)) {
    emit next_bootup_event(signalled_bootup = next_bootup, signalled_non_boot_event = next_non_boot_event);
  }
  log_debug() ;
}
void
meta_surface_actor_process_damage (MetaSurfaceActor *self,
                                   int x, int y, int width, int height)
{
  MetaSurfaceActorPrivate *priv = self->priv;

  if (is_frozen (self))
    {
      /* The window is frozen due to an effect in progress: we ignore damage
       * here on the off chance that this will stop the corresponding
       * texture_from_pixmap from being update.
       *
       * needs_damage_all tracks that some unknown damage happened while the
       * window was frozen so that when the window becomes unfrozen we can
       * issue a full window update to cover any lost damage.
       *
       * It should be noted that this is an unreliable mechanism since it's
       * quite likely that drivers will aim to provide a zero-copy
       * implementation of the texture_from_pixmap extension and in those cases
       * any drawing done to the window is always immediately reflected in the
       * texture regardless of damage event handling.
       */
      priv->needs_damage_all = TRUE;
      return;
    }

  META_SURFACE_ACTOR_GET_CLASS (self)->process_damage (self, x, y, width, height);
}
Beispiel #5
0
void memory_session::end()
{
    if (memory_session::current_sub_session.get() && memory_session::current_sub_session.get()->get_parent() == this)
        memory_session::current_sub_session.reset();

    if (frozen.get())
    {
        if (!is_frozen())
            freeze();
    }
}
Beispiel #6
0
bool
SkinMeme::compute_delt()
{
   static bool debug = ::debug || Config::get_var_bool("DEBUG_SKIN_MEMES",false);

   _delt = Wvec::null();

   if (is_frozen())
      return false;

   if (!is_tracking()) {
      err_msg("SkinMeme::compute_delt: not tracking, can't proceed");
      return false;
   }

   if (!is_boss()) {
      err_adv(debug, "SkinMeme::compute_delt: non-boss; bailing...");
      track_to_target(loc());
      return false;
   }

   Wpt cur = loc();
   Wpt centroid = vert()->qr_centroid();

   static const double bw = Config::get_var_dbl("SKIN_SMOOTH_CENTROID_WEIGHT",0.5);
   Wpt target = interp(cur, centroid, bw);

   // Target is where we want to be, but we'll settle for
   // somewhere on the skeleton surface that is as close as
   // possible.
   Wpt tp;
   if (track_to_target(target, tp)) {
//      double d = target.dist(tp);
//      Wpt new_loc = target + norm() * (fabs(_h) - d);
//      Wpt new_loc = tp + ((target - tp).normalized() * fabs(_h));

      // XXX - hack
      // can we figure this out, one day, soon??
      Wpt new_loc;
      if (is_border(track_simplex())) {
         new_loc = tp + track_norm()*_h;
      } else {
         new_loc = tp + ((target - tp).normalized() * fabs(_h));
      }

      _delt = new_loc - cur;
      return true;
   }

   err_adv(debug, "SkinMeme::compute_delt: track to target failed");
   return false;
}
Beispiel #7
0
void memory_sub_session::hint(void* pointer, memory_advice advice)
{
    byte * const ptr = reinterpret_cast<byte*> (pointer);

    scoped_lock l(mutex);
    d_assert(allocs.find(ptr) != allocs.end());
    if (!is_small_alloc(ptr))
    {
        allocs[ptr].second = advice;

        if (!is_frozen())
        {
            if (posix_madvise(pointer, allocs[ptr].first, advice))
                LOG(WARN, "madvise error on processing hint\n");
        }
    }
}
Beispiel #8
0
HitResponse
BadGuy::collision_bullet(Bullet& bullet, const CollisionHit& hit)
{
  if (is_frozen()) {
    if (bullet.get_type() == FIRE_BONUS) {
      // fire bullet thaws frozen badguys
      unfreeze();
      bullet.remove_me();
      return ABORT_MOVE;
    } else {
      // other bullets ricochet
      bullet.ricochet(*this, hit);
      return FORCE_MOVE;
    }
  }
  else if (is_ignited()) {
    if (bullet.get_type() == ICE_BONUS) {
      // ice bullets extinguish ignited badguys
      extinguish();
      bullet.remove_me();
      return ABORT_MOVE;
    } else {
      // other bullets are absorbed by ignited badguys
      bullet.remove_me();
      return FORCE_MOVE;
    }
  }
  else if (bullet.get_type() == FIRE_BONUS && is_flammable()) {
    // fire bullets ignite flammable badguys
    ignite();
    bullet.remove_me();
    return ABORT_MOVE;
  }
  else if (bullet.get_type() == ICE_BONUS && is_freezable()) {
    // ice bullets freeze freezable badguys
    freeze();
    bullet.remove_me();
    return ABORT_MOVE;
  }
  else {
    // in all other cases, bullets ricochet
    bullet.ricochet(*this, hit);
    return FORCE_MOVE;
  }
}
Beispiel #9
0
void memory_session::unfreeze()
{
    if (!is_frozen())
        return;

    scoped_lock l(mutex);
    d_assert(unfrozen_threads_count >= 0);
    if (unfrozen_threads_count == 0)
    {
        memory_manager::instance->reserve_ram_bytes(ram_limit_bytes, &unfreeze_condition, 0, total_limit_bytes);

        ++unfrozen_threads_count;
        *frozen.get() = false;

        const bool res = default_sub_session->unfreeze();
        r_assert(res, "Default sub session unfreezing failed on session unfreezing");
    }
}
Beispiel #10
0
void memory_sub_session::begin()
{
    activate();

    if (!frozen.get())
    {
        scoped_lock l(mutex);
        frozen.reset(new bool(unfrozen_threads_count == 0));

        if (!is_frozen())
        {
            if (unfrozen_threads_count == -1)
                unfrozen_threads_count = 1;
            else
                ++unfrozen_threads_count;
        }
    }
}
Beispiel #11
0
DictionaryDatum
Node::get_status_base()
{
  DictionaryDatum dict = get_status_dict_();

  assert( dict.valid() );

  // add information available for all nodes
  ( *dict )[ names::local ] = is_local();
  ( *dict )[ names::model ] = LiteralDatum( get_name() );

  // add information available only for local nodes
  if ( is_local() )
  {
    ( *dict )[ names::global_id ] = get_gid();
    ( *dict )[ names::frozen ] = is_frozen();
    ( *dict )[ names::node_uses_wfr ] = node_uses_wfr();
    ( *dict )[ names::thread ] = get_thread();
    ( *dict )[ names::vp ] = get_vp();
    if ( parent_ )
    {
      ( *dict )[ names::parent ] = parent_->get_gid();

      // LIDs are only sensible for nodes with parents.
      // Add 1 as we count lids internally from 0, but from
      // 1 in the user interface.
      ( *dict )[ names::local_id ] = get_lid() + 1;
    }
  }

  ( *dict )[ names::thread_local_id ] = get_thread_lid();
  ( *dict )[ names::supports_precise_spikes ] = is_off_grid();

  // This is overwritten with a corresponding value in the
  // base classes for stimulating and recording devices, and
  // in other special node classes
  ( *dict )[ names::element_type ] = LiteralDatum( names::neuron );

  // now call the child class' hook
  get_status( dict );

  assert( dict.valid() );
  return dict;
}
Beispiel #12
0
bool memory_session::timed_unfreeze(const boost::system_time& abs_time)
{
    if (!is_frozen())
        return true;

    scoped_lock l(mutex);
    d_assert(unfrozen_threads_count >= 0);
    if (unfrozen_threads_count == 0)
    {
        if (!memory_manager::instance->timed_reserve_ram_bytes(ram_limit_bytes, &unfreeze_condition, abs_time, 0, total_limit_bytes))
            return false;

        ++unfrozen_threads_count;
        *frozen.get() = false;

        const bool res = default_sub_session->unfreeze();
        r_assert(res, "Default sub session unfreezing failed on session unfreezing");
    }

    return true;
}
Beispiel #13
0
void memory_session::freeze()
{
    if (is_frozen())
        return;

    scoped_lock l(mutex);

    d_assert(unfrozen_threads_count >= 1);

    --unfrozen_threads_count;
    *frozen.get() = true;

    for (std::set<memory_sub_session*>::const_iterator i = sub_sessions.begin(); i != sub_sessions.end(); ++i)
    {
        (*i)->freeze();
    }

    d_assert(unfrozen_threads_count >= 0);
    if (unfrozen_threads_count == 0)
    {
        memory_manager::instance->free_ram_bytes(ram_limit_bytes);
    }
}
Beispiel #14
0
void memory_sub_session::freeze()
{
    if (is_frozen())
        return;

    scoped_lock l(mutex);
    --unfrozen_threads_count;
    *frozen.get() = true;

    if (unfrozen_threads_count == 0)
    {
        for (std::map<byte*, std::pair<size_t, int> >::const_iterator i = allocs.begin(); i != allocs.end(); ++i)
        {
            if (posix_madvise(i->first, i->second.first, POSIX_MADV_DONTNEED))
                LOG(WARN, "madvise error on freezing\n");
        }

        l.unlock();

        scoped_lock pl(parent->mutex);
        parent->ram_allocated_bytes -= allocated_bytes;
    }
}
Beispiel #15
0
bool
SkinMeme::track_to_target(CWpt& target, Wpt& near_pt)
{
   // Do a local search to find the closest point to 'target' on the
   // tracked surface. Do the search starting from our own track
   // simplex, and then repeat the search starting from each track
   // simplex that can be borrowed from our SkinMeme neighbors. In the
   // end take the one that yielded the closest result, and store the
   // corresponding track simplex.

   if (is_frozen())
      return is_tracking();

   Wvec near_bc;
   Bsimplex* track_sim = update_tracker(
      target, get_local_trackers(), near_pt, near_bc
      );

   // Record the result, even if unsuccessful:
   set(track_sim, near_bc);

   return (track_simplex() != 0);
}
Beispiel #16
0
 virtual DataType* copy() const {
   return new UserType(keyspace_, type_name_, fields_.entries(), is_frozen());
 }
Beispiel #17
0
 virtual DataType* copy() const {
   return new TupleType(types_, is_frozen());
 }
Beispiel #18
0
 virtual DataType* copy() const {
   return new CollectionType(value_type(), types_, is_frozen());
 }