Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[xbt/surf] Change the costly heapremove+heapinsert used in share resource lazy algorithm.
[simgrid.git] / src / surf / surf_interface.cpp
index cc093ad..6de2b62 100644 (file)
@@ -583,8 +583,7 @@ double Model::shareResourcesLazy(double now)
         action->getMaxDuration());
 
     if (min != -1) {
-      action->heapRemove(p_actionHeap);
-      action->heapInsert(p_actionHeap, min, max_dur_flag ? MAX_DURATION : NORMAL);
+      action->heapUpdate(p_actionHeap, min, max_dur_flag ? MAX_DURATION : NORMAL);
       XBT_DEBUG("Insert at heap action(%p) min %f now %f", action, min,
                 now);
     } else DIE_IMPOSSIBLE;
@@ -672,10 +671,12 @@ void Model::updateActionsState(double now, double delta)
 
 void Model::updateActionsStateLazy(double /*now*/, double /*delta*/)
 {
+ THROW_UNIMPLEMENTED;
 }
 
 void Model::updateActionsStateFull(double /*now*/, double /*delta*/)
 {
+  THROW_UNIMPLEMENTED;
 }
 
 /************
@@ -1006,6 +1007,16 @@ void Action::heapRemove(xbt_heap_t heap)
   }
 }
 
+void Action::heapUpdate(xbt_heap_t heap, double key, enum heap_action_type hat)
+{
+  m_hat = hat;
+  if (m_indexHeap >= 0) {
+    xbt_heap_update(heap, m_indexHeap, key);
+  }else{
+    xbt_heap_push(heap, this, key);
+  }
+}
+
 /* added to manage the communication action's heap */
 void surf_action_lmm_update_index_heap(void *action, int i) {
   ((ActionPtr)action)->updateIndexHeap(i);