Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot//simgrid/simgrid
authorMarion Guthmuller <marion.guthmuller@loria.fr>
Wed, 23 May 2012 09:47:40 +0000 (11:47 +0200)
committerMarion Guthmuller <marion.guthmuller@loria.fr>
Wed, 23 May 2012 09:47:40 +0000 (11:47 +0200)
13 files changed:
CMakeLists.txt
ChangeLog
NEWS
buildtools/Cmake/PrintArgs.cmake
examples/platforms/cluster_and_one_host.xml
src/include/surf/surf.h
src/msg/msg_gos.c
src/surf/cpu_cas01.c
src/surf/network.c
src/surf/network_constant.c
src/surf/surf.c
src/surf/surf_action.c
src/surf/surf_private.h

index aa4fb63..978d2d0 100644 (file)
@@ -14,11 +14,11 @@ set(CMAKE_EXE_LINKER_FLAGS "" CACHE TYPE INTERNAL FORCE)
 # 3.5.9{1,2} -> beta{1,2}
 # 3.5.9{3,4,5} -> rc{1,2,3}
 # 3.6.{0,1,2} -> release 3.6, 3.6.1, 3.6.2
-# 3.7.0
+# 3.7.{0,1} -> release 3.7, 3.7.1
 
 set(SIMGRID_VERSION_MAJOR "3")
 set(SIMGRID_VERSION_MINOR "7")
-set(SIMGRID_VERSION_PATCH "0")
+set(SIMGRID_VERSION_PATCH "1")
 
 if(${SIMGRID_VERSION_PATCH} EQUAL "0")
        set(release_version "${SIMGRID_VERSION_MAJOR}.${SIMGRID_VERSION_MINOR}")
index 020a6a8..9f534a9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+SimGrid (3.7.1) NOT RELEASED; urgency=low
+
+  (to complete)
+
+ -- $date Da SimGrid team <simgrid-devel@lists.gforge.inria.fr>
+
 SimGrid (3.7) stable; urgency=low
 
   The "spring cleanups (before the next Big Project kicks in)" release.
@@ -182,7 +188,6 @@ SimGrid (3.6.2) stable; urgency=low
 
  -- Wed Oct  5 15:51:01 CEST 2011 Da SimGrid team <simgrid-devel@lists.gforge.inria.fr>
 
-
 SimGrid (3.6.1) stable; urgency=low
 
  The "Oops, we broke Macs too" release
diff --git a/NEWS b/NEWS
index c0e3866..34d2dc6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+                    _               _____ _____ _
+__   _____ _ __ ___(_) ___  _ __   |___ /|___  / |
+\ \ / / _ \ '__/ __| |/ _ \| '_ \    |_ \   / /| |
+ \ V /  __/ |  \__ \ | (_) | | | |  ___) | / /_| |
+  \_/ \___|_|  |___/_|\___/|_| |_| |____(_)_/(_)_|
+
+(to complete)
                     _               ____  _____
 __   _____ _ __ ___(_) ___  _ __   |___ /|___  |
 \ \ / / _ \ '__/ __| |/ _ \| '_ \    |_ \   / /
index 5b9912f..5db6d71 100644 (file)
 if(enable_print_message)
-       message("")
-       message("________________________________________________________________________________")
-       message("________________________________________________________________________________ DEBUG")
-       message("CMAKE_HOME_DIRECTORY : ${CMAKE_HOME_DIRECTORY}")
-       message("")
-       message("SIZEOF_MAX :                   ${SIZEOF_MAX}")
-       message("PTH_STACKGROWTH                ${PTH_STACKGROWTH}")
-       message("need_getline                   ${need_getline}")
-       message("need_asprintf                  ${simgrid_need_asprintf}")
-       message("need_vasprintf                 ${simgrid_need_vasprintf}")
-       message("PREFER_PORTABLE_SNPRINTF       ${PREFER_PORTABLE_SNPRINTF}")
-       message("HAVE_VA_COPY                   ${HAVE_VA_COPY}")
-       message("GRAS_BIGENDIAN                 ${GRAS_BIGENDIAN}")
-       message("GRAS_ARCH val                  ${val_big}")
-       message("GRAS_ARCH_32_BITS              ${GRAS_ARCH_32_BITS}")
-       message("PRINTF_NULL_WORKING            ${PRINTF_NULL_WORKING}")
-       message("")
-       message("\#define pth_skaddr_makecontext(skaddr,sksize) (${makecontext_addr})")
-       message("\#define pth_sksize_makecontext(skaddr,sksize) (${makecontext_size})")
-       message("\#define __VA_COPY_USE         ${__VA_COPY_USE}")
-       message("mcsc                           ${mcsc}")
-       message("")
-       message("HAVE_PTHREAD_CREATE            ${pthread}")
-       message("HAVE_SEM_INIT                  ${HAVE_SEM_INIT_LIB}")
-       message("HAVE_SEM_TIMEDWAIT             ${HAVE_SEM_TIMEDWAIT_LIB}")
-       message("HAVE_MUTEX_TIMEDLOCK           ${HAVE_MUTEX_TIMEDLOCK_LIB}")
-       message("HAVE_POSIX_GETTIME             ${HAVE_POSIX_GETTIME}")
-       message("")
-       message("TIME_WITH_SYS_TIME             ${TIME_WITH_SYS_TIME}")
-       message("STDC_HEADERS                   ${STDC_HEADERS}")
-       message("HAVE_PTHREAD_H                 ${HAVE_PTHREAD_H}")
-       message("HAVE_VALGRIND_VALGRIND_H       ${HAVE_VALGRIND_VALGRIND_H}")
-       message("HAVE_SOCKET_H                  ${HAVE_SOCKET_H}")
-       message("HAVE_SYS_SOCKET_H              ${HAVE_SYS_SOCKET_H}")
-       message("HAVE_STAT_H                    ${HAVE_STAT_H}")
-       message("HAVE_SYS_STAT_H                ${HAVE_SYS_STAT_H}")
-       message("HAVE_WINDOWS_H                 ${HAVE_WINDOWS_H}")
-       message("HAVE_WINSOCK_H                     ${HAVE_WINSOCK_H}")
-       message("HAVE_WINSOCK2_H                ${HAVE_WINSOCK2_H}")
-       message("HAVE_ERRNO_H                   ${HAVE_ERRNO_H}")
-       message("HAVE_UNISTD_H                  ${HAVE_UNISTD_H}")
-       message("HAVE_EXECINFO_H                ${HAVE_EXECINFO_H}")
-       message("HAVE_SIGNAL_H                  ${HAVE_SIGNAL_H}")
-       message("HAVE_SYS_TIME_H                ${HAVE_SYS_TIME_H}")
-       message("HAVE_TIME_H                    ${HAVE_TIME_H}")
-       message("HAVE_DLFCN_H                   ${HAVE_DLFCN_H}")
-       message("HAVE_INTTYPES_H                        ${HAVE_INTTYPES_H}")
-       message("HAVE_MEMORY_H                  ${HAVE_MEMORY_H}")
-       message("HAVE_STDLIB_H                  ${HAVE_STDLIB_H}")
-       message("HAVE_STRINGS_H                 ${HAVE_STRINGS_H}")
-       message("HAVE_STRING_H                  ${HAVE_STRING_H}")
-       message("HAVE_STDIO_H           ${HAVE_STDIO_H}")
+  message("")
+  message("______________________________________________________________________")
+  message("______________________________________________________________________ DEBUG")
+  message("CMAKE_HOME_DIRECTORY ........: ${CMAKE_HOME_DIRECTORY}")
+  message("")
+  message("SIZEOF_MAX ..................: ${SIZEOF_MAX}")
+  message("PTH_STACKGROWTH .............: ${PTH_STACKGROWTH}")
+  message("need_getline ................: ${need_getline}")
+  message("need_asprintf ...............: ${simgrid_need_asprintf}")
+  message("need_vasprintf ..............: ${simgrid_need_vasprintf}")
+  message("PREFER_PORTABLE_SNPRINTF ....: ${PREFER_PORTABLE_SNPRINTF}")
+  message("HAVE_VA_COPY ................: ${HAVE_VA_COPY}")
+  message("GRAS_BIGENDIAN ..............: ${GRAS_BIGENDIAN}")
+  message("GRAS_ARCH val ...............: ${val_big}")
+  message("GRAS_ARCH_32_BITS ...........: ${GRAS_ARCH_32_BITS}")
+  message("PRINTF_NULL_WORKING .........: ${PRINTF_NULL_WORKING}")
+  message("")
+  message("\#define pth_skaddr_makecontext(skaddr,sksize) (${makecontext_addr})")
+  message("\#define pth_sksize_makecontext(skaddr,sksize) (${makecontext_size})")
+  message("\#define __VA_COPY_USE          ${__VA_COPY_USE}")
+  message("mcsc ........................: ${mcsc}")
+  message("")
+  message("HAVE_PTHREAD_CREATE .........: ${pthread}")
+  message("HAVE_SEM_INIT ...............: ${HAVE_SEM_INIT_LIB}")
+  message("HAVE_SEM_TIMEDWAIT ..........: ${HAVE_SEM_TIMEDWAIT_LIB}")
+  message("HAVE_MUTEX_TIMEDLOCK ........: ${HAVE_MUTEX_TIMEDLOCK_LIB}")
+  message("HAVE_POSIX_GETTIME ..........: ${HAVE_POSIX_GETTIME}")
+  message("")
+  message("TIME_WITH_SYS_TIME ..........: ${TIME_WITH_SYS_TIME}")
+  message("STDC_HEADERS ................: ${STDC_HEADERS}")
+  message("HAVE_PTHREAD_H ..............: ${HAVE_PTHREAD_H}")
+  message("HAVE_VALGRIND_VALGRIND_H ....: ${HAVE_VALGRIND_VALGRIND_H}")
+  message("HAVE_SOCKET_H ...............: ${HAVE_SOCKET_H}")
+  message("HAVE_SYS_SOCKET_H ...........: ${HAVE_SYS_SOCKET_H}")
+  message("HAVE_STAT_H .................: ${HAVE_STAT_H}")
+  message("HAVE_SYS_STAT_H .............: ${HAVE_SYS_STAT_H}")
+  message("HAVE_WINDOWS_H ..............: ${HAVE_WINDOWS_H}")
+  message("HAVE_WINSOCK_H ..............: ${HAVE_WINSOCK_H}")
+  message("HAVE_WINSOCK2_H .............: ${HAVE_WINSOCK2_H}")
+  message("HAVE_ERRNO_H ................: ${HAVE_ERRNO_H}")
+  message("HAVE_UNISTD_H ...............: ${HAVE_UNISTD_H}")
+  message("HAVE_EXECINFO_H .............: ${HAVE_EXECINFO_H}")
+  message("HAVE_SIGNAL_H ...............: ${HAVE_SIGNAL_H}")
+  message("HAVE_SYS_TIME_H .............: ${HAVE_SYS_TIME_H}")
+  message("HAVE_TIME_H .................: ${HAVE_TIME_H}")
+  message("HAVE_DLFCN_H ................: ${HAVE_DLFCN_H}")
+  message("HAVE_INTTYPES_H .............: ${HAVE_INTTYPES_H}")
+  message("HAVE_MEMORY_H ...............: ${HAVE_MEMORY_H}")
+  message("HAVE_STDLIB_H ...............: ${HAVE_STDLIB_H}")
+  message("HAVE_STRINGS_H ..............: ${HAVE_STRINGS_H}")
+  message("HAVE_STRING_H ...............: ${HAVE_STRING_H}")
+  message("HAVE_STDIO_H ................: ${HAVE_STDIO_H}")
 
-       message("")
-       message("HAVE_GETTIMEOFDAY              ${HAVE_GETTIMEOFDAY}")
-       message("HAVE_USLEEP                    ${HAVE_USLEEP}")
-       message("HAVE_GETDTABLESIZE             ${HAVE_GETDTABLESIZE}")
-       message("HAVE_SYSCONF                   ${HAVE_SYSCONF}")
-       message("HAVE_READV                     ${HAVE_READV}")
-       message("HAVE_POPEN                     ${HAVE_POPEN}")
-       message("HAVE_SIGNAL                    ${HAVE_SIGNAL}")
-       message("HAVE_MAKECONTEXT               ${HAVE_MAKECONTEXT}")
-       message("HAVE_SNPRINTF                  ${HAVE_SNPRINTF}")
-       message("HAVE_VSNPRINTF                 ${HAVE_VSNPRINTF}")
-       message("HAVE_ASPRINTF                  ${HAVE_ASPRINTF}")
-       message("HAVE_VASPRINTF                 ${HAVE_VASPRINTF}")
-       message("HAVE_MMAP                      ${HAVE_MMAP}")
-       message("")
-       message("CONTEXT_THREADS                ${CONTEXT_THREADS}")
-       message("CONTEXT_UCONTEXT       ${CONTEXT_UCONTEXT}")
-       message("________________________________________________________________________________")
-       message("________________________________________________________________________________ DEBUG END")
-       message("")
+  message("")
+  message("HAVE_GETTIMEOFDAY ...........: ${HAVE_GETTIMEOFDAY}")
+  message("HAVE_USLEEP .................: ${HAVE_USLEEP}")
+  message("HAVE_GETDTABLESIZE ..........: ${HAVE_GETDTABLESIZE}")
+  message("HAVE_SYSCONF ................: ${HAVE_SYSCONF}")
+  message("HAVE_READV ..................: ${HAVE_READV}")
+  message("HAVE_POPEN ..................: ${HAVE_POPEN}")
+  message("HAVE_SIGNAL .................: ${HAVE_SIGNAL}")
+  message("HAVE_MAKECONTEXT ............: ${HAVE_MAKECONTEXT}")
+  message("HAVE_SNPRINTF ...............: ${HAVE_SNPRINTF}")
+  message("HAVE_VSNPRINTF ..............: ${HAVE_VSNPRINTF}")
+  message("HAVE_ASPRINTF ...............: ${HAVE_ASPRINTF}")
+  message("HAVE_VASPRINTF ..............: ${HAVE_VASPRINTF}")
+  message("HAVE_MMAP ...................: ${HAVE_MMAP}")
+  message("")
+  message("CONTEXT_THREADS .............: ${CONTEXT_THREADS}")
+  message("CONTEXT_UCONTEXT ............: ${CONTEXT_UCONTEXT}")
+  message("______________________________________________________________________")
+  message("______________________________________________________________________ DEBUG END")
+  message("")
 endif(enable_print_message)
 
 message("\nConfiguration of package `simgrid' on arch (=${GRAS_THISARCH}):")
-message("           BUILDNAME :        ${BUILDNAME}")
-message("           SITE      :        ${SITE}")
-message("           Release   :        simgrid-${release_version}")
+message("        BUILDNAME ...........: ${BUILDNAME}")
+message("        SITE ................: ${SITE}")
+message("        Release .............: simgrid-${release_version}")
 message("")
-message("       Compiler: c++ :        ${CMAKE_CXX_COMPILER}")
-message("              version:        ${COMPILER_CXX_VERSION}")
-message("       Compiler: c   :        ${CMAKE_C_COMPILER}")
-message("              version:        ${COMPILER_C_VERSION}")
+message("        Compiler: c++ .......: ${CMAKE_CXX_COMPILER}")
+message("                version .....: ${COMPILER_CXX_VERSION}")
+message("        Compiler: c .........: ${CMAKE_C_COMPILER}")
+message("                version .....: ${COMPILER_C_VERSION}")
 message("")
-message("             CFlags  :        ${CMAKE_C_FLAGS}")      
-message("             CPPFlags:        ${CMAKE_CXX_FLAGS}")
+message("        CFlags ..............: ${CMAKE_C_FLAGS}")
+message("        CPPFlags ............: ${CMAKE_CXX_FLAGS}")
 message("")
 if(NOT APPLE AND NOT WIN32)
-message("      Compile Gtnets :        ${HAVE_GTNETS}")
-message("      Compile NS-3   :        ${HAVE_NS3}")
-message("      Gtnets path    :        ${gtnets_path}")
-message("      NS-3 path      :        ${ns3_path}")
+  message("        Compile Gtnets ......: ${HAVE_GTNETS}")
+  message("        Compile NS-3 ........: ${HAVE_NS3}")
+  message("        Gtnets path .........: ${gtnets_path}")
+  message("        NS-3 path ...........: ${ns3_path}")
 endif(NOT APPLE AND NOT WIN32)
-message("      Compile Lua    :        ${HAVE_LUA}")
-message("      Compile Smpi   :        ${enable_smpi}")
-message("      Compile Static :        ${enable_lib_static}")
+message("        Compile Lua .........: ${HAVE_LUA}")
+message("        Compile Smpi ........: ${enable_smpi}")
+message("        Compile Static ......: ${enable_lib_static}")
 message("")
-message("      Maintainer mode:        ${enable_maintainer_mode}")
-message("      Supernovae mode:        ${enable_supernovae}")
-message("      Model checking :        ${enable_model-checking}")
-message("      Tracing mode   :        ${enable_tracing}")
-message("      Jedule  mode   :        ${enable_jedule}")
-message("      Latency bound  :        ${enable_latency_bound_tracking}")
-message("        Graphviz mode  :        ${HAVE_GRAPHVIZ}")
+message("        Maintainer mode .....: ${enable_maintainer_mode}")
+message("        Supernovae mode .....: ${enable_supernovae}")
+message("        Model checking ......: ${enable_model-checking}")
+message("        Tracing mode ........: ${enable_tracing}")
+message("        Jedule  mode ........: ${enable_jedule}")
+message("        Latency bound .......: ${enable_latency_bound_tracking}")
+message("        Graphviz mode .......: ${HAVE_GRAPHVIZ}")
 message("")
-message("      Simgrid dependencies:   ${SIMGRID_DEP}")
-message("      Gras dependencies   :   ${GRAS_DEP}")
-message("      Smpi dependencies   :   ${SMPI_DEP}")
+message("        Simgrid dependencies : ${SIMGRID_DEP}")
+message("        Gras dependencies ...: ${GRAS_DEP}")
+message("        Smpi dependencies ...: ${SMPI_DEP}")
 message("")
-message("      INSTALL_PREFIX:         ${CMAKE_INSTALL_PREFIX}")
+message("        INSTALL_PREFIX ......: ${CMAKE_INSTALL_PREFIX}")
 
 exec_program("${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/Testing/Notes/" OUTPUT_VARIABLE OKIDOKI)
 file(WRITE ${PROJECT_BINARY_DIR}/Testing/Notes/Build  "SVN version : ${SVN_VERSION}\n")
 file(APPEND ${PROJECT_BINARY_DIR}/Testing/Notes/Build "Release     : simgrid-${release_version}\n")
 file(APPEND ${PROJECT_BINARY_DIR}/Testing/Notes/Build "Pipol user  : $ENV{PIPOL_USER}\n")
 file(APPEND ${PROJECT_BINARY_DIR}/Testing/Notes/Build "Pipol image : $ENV{PIPOL_IMAGE}\n")
index a789fcb..67a9430 100644 (file)
@@ -1,24 +1,20 @@
 <?xml version='1.0'?>
 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
-
 <platform version="3">
-<AS  id="AS0"  routing="bob">
-    
-  <cluster id="my_cluster_1" prefix="c-" suffix=""
-               radical="0-1"   power="1000000000"    bw="125000000"     lat="5E-5"
-        router_id="router1"/>
+ <AS id="AS0"  routing="Full">   
+  <cluster id="my_cluster_1" prefix="c-" suffix=".me"
+          radical="0-1" power="1000000000" bw="125000000" lat="5E-5"
+           router_id="router1"/>
 
- <AS id="AS1" routing="none">
 <AS id="AS1" routing="none">
     <host id="host1" power="1000000000"/>
- </AS>
 </AS>
 
   <link id="link1" bandwidth="100000" latency="0.01"/>
   
   <ASroute src="my_cluster_1" dst="AS1"
-    gw_src="router1"
-    gw_dst="host1">
+    gw_src="router1" gw_dst="host1">
     <link_ctn id="link1"/>
   </ASroute>
-  
-</AS>
+ </AS>
 </platform>
index 0ec928d..23ab220 100644 (file)
@@ -316,6 +316,8 @@ typedef struct surf_model {
   int (*get_latency_limited) (surf_action_t action);     /**< Return 1 if action is limited by latency, 0 otherwise */
 #endif
 
+  void (*gap_remove) (surf_action_lmm_t action);
+
   surf_model_private_t model_private;
 
   union extension {
index 3582956..c0cce18 100644 (file)
@@ -1033,7 +1033,7 @@ MSG_task_put_with_timeout(m_task_t task, m_host_t dest,
               && (channel < msg_global->max_channel), "Invalid channel %d",
               channel);
 
-  XBT_DEBUG("MSG_task_put_with_timout: Trying to send a task to '%s'", dest->smx_host->name);
+  XBT_DEBUG("MSG_task_put_with_timout: Trying to send a task to '%s'", SIMIX_host_get_name(dest->smx_host));
   return
       MSG_mailbox_put_with_timeout(MSG_mailbox_get_by_channel
                                    (dest, channel), task, timeout);
index 60a7b7f..7025ee5 100644 (file)
@@ -139,116 +139,9 @@ static int cpu_resource_used(void *resource)
                              ((cpu_Cas01_t) resource)->constraint);
 }
 
-static void cpu_update_action_remaining_lazy(surf_action_cpu_Cas01_t action, double now)
-{
-  double delta = 0.0;
-
-  xbt_assert(GENERIC_ACTION(action).state_set == surf_cpu_model->states.running_action_set,
-      "You're updating an action that is not running.");
-
-    /* bogus priority, skip it */
-  xbt_assert(GENERIC_ACTION(action).priority > 0,
-      "You're updating an action that seems suspended.");
-
-  delta = now - GENERIC_LMM_ACTION(action).last_update;
-  if (GENERIC_ACTION(action).remains > 0) {
-    XBT_DEBUG("Updating action(%p): remains was %lf, last_update was: %lf", action,
-        GENERIC_ACTION(action).remains,
-        GENERIC_LMM_ACTION(action).last_update);
-    double_update(&(GENERIC_ACTION(action).remains),
-        GENERIC_LMM_ACTION(action).last_value * delta);
-
-#ifdef HAVE_TRACING
-    if (TRACE_is_enabled()) {
-      cpu_Cas01_t cpu =
-          lmm_constraint_id(lmm_get_cnst_from_var
-              (surf_cpu_model->model_private->maxmin_system,
-                  GENERIC_LMM_ACTION(action).variable, 0));
-      TRACE_surf_host_set_utilization(cpu->generic_resource.name,
-          ((surf_action_t)action)->category,
-          GENERIC_LMM_ACTION(action).last_value,
-          GENERIC_LMM_ACTION(action).last_update,
-          now - GENERIC_LMM_ACTION(action).last_update);
-    }
-#endif
-    XBT_DEBUG("Updating action(%p): remains is now %lf", action,
-    GENERIC_ACTION(action).remains);
-  }
-  GENERIC_LMM_ACTION(action).last_update = now;
-  GENERIC_LMM_ACTION(action).last_value = lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable);
-}
-
 static double cpu_share_resources_lazy(double now)
 {
-  surf_action_cpu_Cas01_t action = NULL;
-  double min = -1;
-  double value;
-
-  XBT_DEBUG
-      ("Before share resources, the size of modified actions set is %d",
-       xbt_swag_size(surf_cpu_model->model_private->modified_set));
-
-  lmm_solve(surf_cpu_model->model_private->maxmin_system);
-
-  XBT_DEBUG
-      ("After share resources, The size of modified actions set is %d",
-       xbt_swag_size(surf_cpu_model->model_private->modified_set));
-
-  while((action = xbt_swag_extract(surf_cpu_model->model_private->modified_set))) {
-    int max_dur_flag = 0;
-
-    if (GENERIC_ACTION(action).state_set !=
-        surf_cpu_model->states.running_action_set)
-      continue;
-
-    /* bogus priority, skip it */
-    if (GENERIC_ACTION(action).priority <= 0)
-      continue;
-
-    cpu_update_action_remaining_lazy(action,now);
-
-    min = -1;
-    value = lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable);
-    if (value > 0) {
-      if (GENERIC_ACTION(action).remains > 0) {
-        value = GENERIC_ACTION(action).remains / value;
-        min = now + value;
-      } else {
-        value = 0.0;
-        min = now;
-      }
-    }
-
-    if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION)
-        && (min == -1
-            || GENERIC_ACTION(action).start +
-            GENERIC_ACTION(action).max_duration < min)) {
-      min = GENERIC_ACTION(action).start +
-          GENERIC_ACTION(action).max_duration;
-      max_dur_flag = 1;
-    }
-
-    XBT_DEBUG("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
-        GENERIC_ACTION(action).start, now + value,
-        GENERIC_ACTION(action).max_duration);
-
-    if (min != -1) {
-      surf_action_lmm_heap_remove(surf_cpu_model->model_private->action_heap,(surf_action_lmm_t)action);
-      surf_action_lmm_heap_insert(surf_cpu_model->model_private->action_heap,(surf_action_lmm_t)action, min, max_dur_flag ? MAX_DURATION : NORMAL);
-      XBT_DEBUG("Insert at heap action(%p) min %lf now %lf", action, min,
-                now);
-    } else DIE_IMPOSSIBLE;
-  }
-
-  //hereafter must have already the min value for this resource model
-  if (xbt_heap_size(surf_cpu_model->model_private->action_heap) > 0)
-    min = xbt_heap_maxkey(surf_cpu_model->model_private->action_heap) - now;
-  else
-    min = -1;
-
-  XBT_DEBUG("The minimum with the HEAP %lf", min);
-
-  return min;
+  return generic_share_resources_lazy(now, surf_cpu_model);
 }
 
 static double cpu_share_resources_full(double now)
@@ -264,94 +157,12 @@ static double cpu_share_resources_full(double now)
 
 static void cpu_update_actions_state_lazy(double now, double delta)
 {
-  surf_action_cpu_Cas01_t action;
-  while ((xbt_heap_size(surf_cpu_model->model_private->action_heap) > 0)
-         && (double_equals(xbt_heap_maxkey(surf_cpu_model->model_private->action_heap), now))) {
-    action = xbt_heap_pop(surf_cpu_model->model_private->action_heap);
-    XBT_DEBUG("Action %p: finish", action);
-    GENERIC_ACTION(action).finish = surf_get_clock();
-#ifdef HAVE_TRACING
-    if (TRACE_is_enabled()) {
-      cpu_Cas01_t cpu =
-          lmm_constraint_id(lmm_get_cnst_from_var
-                            (surf_cpu_model->model_private->maxmin_system,
-                             GENERIC_LMM_ACTION(action).variable, 0));
-      TRACE_surf_host_set_utilization(cpu->generic_resource.name,
-                                      ((surf_action_t)action)->category,
-                                      lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable),
-                                      GENERIC_LMM_ACTION(action).last_update,
-                                      now - GENERIC_LMM_ACTION(action).last_update);
-    }
-#endif
-    /* set the remains to 0 due to precision problems when updating the remaining amount */
-    GENERIC_ACTION(action).remains = 0;
-    surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
-    surf_action_lmm_heap_remove(surf_cpu_model->model_private->action_heap,(surf_action_lmm_t)action); //FIXME: strange call since action was already popped
-  }
-#ifdef HAVE_TRACING
-  if (TRACE_is_enabled()) {
-    //defining the last timestamp that we can safely dump to trace file
-    //without losing the event ascending order (considering all CPU's)
-    double smaller = -1;
-    xbt_swag_t running_actions = surf_cpu_model->states.running_action_set;
-    xbt_swag_foreach(action, running_actions) {
-        if (smaller < 0) {
-          smaller = GENERIC_LMM_ACTION(action).last_update;
-          continue;
-        }
-        if (GENERIC_LMM_ACTION(action).last_update < smaller) {
-          smaller = GENERIC_LMM_ACTION(action).last_update;
-        }
-    }
-    if (smaller > 0) {
-      TRACE_last_timestamp_to_dump = smaller;
-    }
-  }
-#endif
-  return;
+  generic_update_actions_state_lazy(now, delta, surf_cpu_model);
 }
 
 static void cpu_update_actions_state_full(double now, double delta)
 {
-  surf_action_cpu_Cas01_t action = NULL;
-  surf_action_cpu_Cas01_t next_action = NULL;
-  xbt_swag_t running_actions = surf_cpu_model->states.running_action_set;
-  xbt_swag_foreach_safe(action, next_action, running_actions) {
-#ifdef HAVE_TRACING
-    if (TRACE_is_enabled()) {
-      cpu_Cas01_t x =
-          lmm_constraint_id(lmm_get_cnst_from_var
-                            (surf_cpu_model->model_private->maxmin_system,
-                             GENERIC_LMM_ACTION(action).variable, 0));
-
-      TRACE_surf_host_set_utilization(x->generic_resource.name,
-                                      ((surf_action_t)action)->category,
-                                      lmm_variable_getvalue(GENERIC_LMM_ACTION(action).
-                                       variable),
-                                      now - delta,
-                                      delta);
-      TRACE_last_timestamp_to_dump = now - delta;
-    }
-#endif
-    double_update(&(GENERIC_ACTION(action).remains),
-                  lmm_variable_getvalue(GENERIC_LMM_ACTION(action).
-                                        variable) * delta);
-    if (GENERIC_LMM_ACTION(action).generic_action.max_duration !=
-        NO_MAX_DURATION)
-      double_update(&(GENERIC_ACTION(action).max_duration), delta);
-    if ((GENERIC_ACTION(action).remains <= 0) &&
-        (lmm_get_variable_weight(GENERIC_LMM_ACTION(action).variable) >
-         0)) {
-      GENERIC_ACTION(action).finish = surf_get_clock();
-      surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
-    } else if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION) &&
-               (GENERIC_ACTION(action).max_duration <= 0)) {
-      GENERIC_ACTION(action).finish = surf_get_clock();
-      surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
-    }
-  }
-
-  return;
+  generic_update_actions_state_full(now, delta, surf_cpu_model);
 }
 
 static void cpu_update_resource_state(void *id,
@@ -475,17 +286,6 @@ static surf_action_t cpu_action_sleep(void *cpu, double duration)
   return (surf_action_t) action;
 }
 
-static double cpu_action_get_remains(surf_action_t action)
-{
-  XBT_IN("(%p)", action);
-  /* update remains before return it */
-  if (surf_cpu_model->model_private->update_mechanism == UM_LAZY)
-    cpu_update_action_remaining_lazy((surf_action_cpu_Cas01_t)action,
-        surf_get_clock());
-  XBT_OUT();
-  return action->remains;
-}
-
 static e_surf_resource_state_t cpu_get_state(void *cpu)
 {
   return ((cpu_Cas01_t) cpu)->state_current;
@@ -580,7 +380,7 @@ static void surf_cpu_model_init_internal()
 #ifdef HAVE_TRACING
   surf_cpu_model->set_category = surf_action_set_category;
 #endif
-  surf_cpu_model->get_remains = cpu_action_get_remains;
+  surf_cpu_model->get_remains = surf_action_get_remains;
 
   surf_cpu_model->extension.cpu.execute = cpu_execute;
   surf_cpu_model->extension.cpu.sleep = cpu_action_sleep;
index b37ff55..99d03be 100644 (file)
@@ -55,8 +55,6 @@ int sg_network_crosstraffic = 0;
 
 xbt_dict_t gap_lookup = NULL;
 
-static void net_update_action_remaining_lazy(surf_action_network_CM02_t action, double now);
-
 /******************************************************************************/
 /*                           Factors callbacks                                */
 /******************************************************************************/
@@ -156,7 +154,6 @@ static double (*bandwidth_constraint_callback) (double, double, double) =
 
 static void (*gap_append) (double, const link_CM02_t,
                            surf_action_network_CM02_t) = NULL;
-static void (*gap_remove) (surf_action_network_CM02_t) = NULL;
 
 static void *net_create_resource(const char *name,
                                  double bw_initial,
@@ -308,51 +305,6 @@ int net_get_link_latency_limited(surf_action_t action)
 }
 #endif
 
-double net_action_get_remains(surf_action_t action)
-{
-  XBT_IN("(%p)", action);
-  /* update remains before return it */
-  if (surf_network_model->model_private->update_mechanism == UM_LAZY)      /* update remains before return it */
-    net_update_action_remaining_lazy((surf_action_network_CM02_t)action,
-        surf_get_clock());
-  XBT_OUT();
-  return action->remains;
-}
-
-static void net_update_action_remaining_lazy(surf_action_network_CM02_t action, double now)
-{
-  double delta = 0.0;
-
-  if (GENERIC_LMM_ACTION(action).suspended != 0)
-    return;
-
-  delta = now - GENERIC_LMM_ACTION(action).last_update;
-
-  double_update(&(((surf_action_t)action)->remains),
-      GENERIC_LMM_ACTION(action).last_value * delta);
-
-  if (((surf_action_t)action)->max_duration != NO_MAX_DURATION)
-    double_update(&(((surf_action_t)action)->max_duration), delta);
-
-  if ((((surf_action_t)action)->remains <= 0) &&
-      (lmm_get_variable_weight(GENERIC_LMM_ACTION(action).variable) > 0)) {
-    ((surf_action_t)action)->finish = surf_get_clock();
-    surf_network_model->action_state_set((surf_action_t) action,
-        SURF_ACTION_DONE);
-
-    surf_action_lmm_heap_remove(surf_network_model->model_private->action_heap,(surf_action_lmm_t)action);
-  } else if (((((surf_action_t)action)->max_duration != NO_MAX_DURATION)
-      && (((surf_action_t)action)->max_duration <= 0))) {
-    ((surf_action_t)action)->finish = surf_get_clock();
-    surf_network_model->action_state_set((surf_action_t) action,
-        SURF_ACTION_DONE);
-    surf_action_lmm_heap_remove(surf_network_model->model_private->action_heap,(surf_action_lmm_t)action);
-  }
-
-  GENERIC_LMM_ACTION(action).last_update = now;
-  GENERIC_LMM_ACTION(action).last_value = lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable);
-}
-
 static double net_share_resources_full(double now)
 {
   s_surf_action_lmm_t s_action;
@@ -389,208 +341,17 @@ static double net_share_resources_full(double now)
 
 static double net_share_resources_lazy(double now)
 {
-  surf_action_network_CM02_t action = NULL;
-  double min = -1;
-  double value;
-
-  XBT_DEBUG
-      ("Before share resources, the size of modified actions set is %d",
-       xbt_swag_size(surf_network_model->model_private->modified_set));
-
-  lmm_solve(surf_network_model->model_private->maxmin_system);
-
-  XBT_DEBUG
-      ("After share resources, The size of modified actions set is %d",
-       xbt_swag_size(surf_network_model->model_private->modified_set));
-
-  while((action = xbt_swag_extract(surf_network_model->model_private->modified_set))) {
-    int max_dur_flag = 0;
-
-    if (GENERIC_ACTION(action).state_set !=
-        surf_network_model->states.running_action_set)
-      continue;
-
-    /* bogus priority, skip it */
-    if (GENERIC_ACTION(action).priority <= 0)
-      continue;
-
-    net_update_action_remaining_lazy(action,now);
-
-    min = -1;
-    value = lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable);
-    if (value > 0) {
-      if (GENERIC_ACTION(action).remains > 0) {
-        value = GENERIC_ACTION(action).remains / value;
-        min = now + value;
-      } else {
-        value = 0.0;
-        min = now;
-      }
-    }
-
-    if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION)
-        && (min == -1
-            || GENERIC_ACTION(action).start +
-            GENERIC_ACTION(action).max_duration < min)) {
-      min = GENERIC_ACTION(action).start +
-          GENERIC_ACTION(action).max_duration;
-      max_dur_flag = 1;
-    }
-
-    XBT_DEBUG("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
-              GENERIC_ACTION(action).start, now + value,
-              GENERIC_ACTION(action).max_duration);
-
-    if (min != -1) {
-      surf_action_lmm_heap_remove(surf_network_model->model_private->action_heap,(surf_action_lmm_t)action);
-      surf_action_lmm_heap_insert(surf_network_model->model_private->action_heap,(surf_action_lmm_t)action, min, max_dur_flag ? MAX_DURATION : NORMAL);
-      XBT_DEBUG("Insert at heap action(%p) min %lf now %lf", action, min,
-                now);
-    } else DIE_IMPOSSIBLE;
-  }
-
-  //hereafter must have already the min value for this resource model
-  if (xbt_heap_size(surf_network_model->model_private->action_heap) > 0)
-    min = xbt_heap_maxkey(surf_network_model->model_private->action_heap) - now;
-  else
-    min = -1;
-
-  XBT_DEBUG("The minimum with the HEAP %lf", min);
-
-  return min;
+  return generic_share_resources_lazy(now, surf_network_model);
 }
 
 static void net_update_actions_state_full(double now, double delta)
 {
-  double deltap = 0.0;
-  surf_action_network_CM02_t action = NULL;
-  surf_action_network_CM02_t next_action = NULL;
-  xbt_swag_t running_actions =
-      surf_network_model->states.running_action_set;
-  /*
-     xbt_swag_t failed_actions =
-     surf_network_model->states.failed_action_set;
-   */
-
-  xbt_swag_foreach_safe(action, next_action, running_actions) {
-    deltap = delta;
-    if (action->latency > 0) {
-      if (action->latency > deltap) {
-        double_update(&(action->latency), deltap);
-        deltap = 0.0;
-      } else {
-        double_update(&(deltap), action->latency);
-        action->latency = 0.0;
-      }
-      if ((action->latency == 0.0) && !(GENERIC_LMM_ACTION(action).suspended))
-        lmm_update_variable_weight(surf_network_model->model_private->maxmin_system, GENERIC_LMM_ACTION(action).variable,
-                                   action->weight);
-    }
-#ifdef HAVE_TRACING
-    if (TRACE_is_enabled()) {
-      int n = lmm_get_number_of_cnst_from_var(surf_network_model->model_private->maxmin_system, GENERIC_LMM_ACTION(action).variable);
-      unsigned int i;
-      for (i = 0; i < n; i++){
-        lmm_constraint_t constraint = lmm_get_cnst_from_var(surf_network_model->model_private->maxmin_system,
-                                                            GENERIC_LMM_ACTION(action).variable,
-                                                            i);
-        link_CM02_t link = lmm_constraint_id(constraint);
-        TRACE_surf_link_set_utilization(link->lmm_resource.generic_resource.name,
-                                        ((surf_action_t)action)->category,
-                                        (lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable)*
-                                        lmm_get_cnst_weight_from_var(surf_network_model->model_private->maxmin_system,
-                                            GENERIC_LMM_ACTION(action).variable,
-                                            i)),
-                                        now - delta,
-                                        delta);
-      }
-    }
-#endif
-    if (!lmm_get_number_of_cnst_from_var
-        (surf_network_model->model_private->maxmin_system, GENERIC_LMM_ACTION(action).variable)) {
-      /* There is actually no link used, hence an infinite bandwidth.
-       * This happens often when using models like vivaldi.
-       * In such case, just make sure that the action completes immediately.
-       */
-      double_update(&(GENERIC_ACTION(action).remains),
-                    GENERIC_ACTION(action).remains);
-    }
-    double_update(&(GENERIC_ACTION(action).remains),
-                  lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable) * deltap);
-    if (((surf_action_t)action)->max_duration != NO_MAX_DURATION)
-      double_update(&(((surf_action_t)action)->max_duration), delta);
-
-    if ((GENERIC_ACTION(action).remains <= 0) &&
-        (lmm_get_variable_weight(GENERIC_LMM_ACTION(action).variable) > 0)) {
-      ((surf_action_t)action)->finish = surf_get_clock();
-      surf_network_model->action_state_set((surf_action_t) action,
-                                           SURF_ACTION_DONE);
-
-      if (gap_remove)
-        gap_remove(action);
-    } else if ((((surf_action_t)action)->max_duration != NO_MAX_DURATION)
-               && (((surf_action_t)action)->max_duration <= 0)) {
-      ((surf_action_t)action)->finish = surf_get_clock();
-      surf_network_model->action_state_set((surf_action_t) action,
-                                           SURF_ACTION_DONE);
-      if (gap_remove)
-        gap_remove(action);
-    }
-  }
-
-  return;
+  generic_update_actions_state_full(now, delta, surf_network_model);
 }
 
 static void net_update_actions_state_lazy(double now, double delta)
 {
-  surf_action_network_CM02_t action = NULL;
-
-  while ((xbt_heap_size(surf_network_model->model_private->action_heap) > 0)
-         && (double_equals(xbt_heap_maxkey(surf_network_model->model_private->action_heap), now))) {
-    action = xbt_heap_pop(surf_network_model->model_private->action_heap);
-    XBT_DEBUG("Action %p: finish", action);
-    GENERIC_ACTION(action).finish = surf_get_clock();
-#ifdef HAVE_TRACING
-    if (TRACE_is_enabled()) {
-      int n = lmm_get_number_of_cnst_from_var(surf_network_model->model_private->maxmin_system, GENERIC_LMM_ACTION(action).variable);
-      unsigned int i;
-      for (i = 0; i < n; i++){
-        lmm_constraint_t constraint = lmm_get_cnst_from_var(surf_network_model->model_private->maxmin_system,
-                                                            GENERIC_LMM_ACTION(action).variable,
-                                                            i);
-        link_CM02_t link = lmm_constraint_id(constraint);
-        TRACE_surf_link_set_utilization(link->lmm_resource.generic_resource.name,
-                                        ((surf_action_t)action)->category,
-                                        (lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable)*
-                                            lmm_get_cnst_weight_from_var(surf_network_model->model_private->maxmin_system,
-                                                GENERIC_LMM_ACTION(action).variable,
-                                                i)),
-                                        GENERIC_LMM_ACTION(action).last_update,
-                                        now - GENERIC_LMM_ACTION(action).last_update);
-      }
-    }
-#endif
-
-    // if I am wearing a latency hat
-    if (GENERIC_LMM_ACTION(action).hat == LATENCY) {
-      lmm_update_variable_weight(surf_network_model->model_private->maxmin_system, GENERIC_LMM_ACTION(action).variable,
-                                 action->weight);
-      surf_action_lmm_heap_remove(surf_network_model->model_private->action_heap,(surf_action_lmm_t)action);
-      GENERIC_LMM_ACTION(action).last_update = surf_get_clock();
-
-      // if I am wearing a max_duration or normal hat
-    } else if (GENERIC_LMM_ACTION(action).hat == MAX_DURATION ||
-        GENERIC_LMM_ACTION(action).hat == NORMAL) {
-      // no need to communicate anymore
-      // assume that flows that reached max_duration have remaining of 0
-      GENERIC_ACTION(action).remains = 0;
-      ((surf_action_t)action)->finish = surf_get_clock();
-      surf_network_model->action_state_set((surf_action_t) action,
-                                           SURF_ACTION_DONE);
-      surf_action_lmm_heap_remove(surf_network_model->model_private->action_heap,(surf_action_lmm_t)action);
-    }
-  }
-  return;
+  generic_update_actions_state_lazy(now, delta, surf_network_model);
 }
 
 static void net_update_resource_state(void *id,
@@ -929,10 +690,11 @@ static void smpi_gap_append(double size, const link_CM02_t link,
   }
 }
 
-static void smpi_gap_remove(surf_action_network_CM02_t action)
+static void smpi_gap_remove(surf_action_lmm_t lmm_action)
 {
   xbt_fifo_t fifo;
   size_t size;
+  surf_action_network_CM02_t action = (surf_action_network_CM02_t)(lmm_action);
 
   if (sg_sender_gap > 0.0 && action->sender.link_name
       && action->sender.fifo_item) {
@@ -986,7 +748,7 @@ static void surf_network_model_init_internal(void)
   surf_network_model->action_cancel = surf_action_cancel;
   surf_network_model->action_recycle = net_action_recycle;
 
-  surf_network_model->get_remains = net_action_get_remains;
+  surf_network_model->get_remains = surf_action_get_remains;
 
 #ifdef HAVE_LATENCY_BOUND_TRACKING
   surf_network_model->get_latency_limited = net_get_link_latency_limited;
@@ -1044,6 +806,8 @@ static void surf_network_model_init_internal(void)
         xbt_swag_new(xbt_swag_offset(comm, generic_lmm_action.action_list_hookup));
     surf_network_model->model_private->maxmin_system->keep_track = surf_network_model->model_private->modified_set;
   }
+
+  surf_network_model->gap_remove = NULL;
 }
 
 /************************************************************************/
@@ -1068,7 +832,7 @@ void surf_network_model_init_SMPI(void)
   bandwidth_factor_callback = &smpi_bandwidth_factor;
   bandwidth_constraint_callback = &smpi_bandwidth_constraint;
   gap_append = &smpi_gap_append;
-  gap_remove = &smpi_gap_remove;
+  surf_network_model->gap_remove = &smpi_gap_remove;
   net_define_callbacks();
   xbt_dynar_push(model_list, &surf_network_model);
   network_solve = lmm_solve;
index 57d8f55..e1be0fe 100644 (file)
@@ -200,7 +200,7 @@ void surf_network_model_init_Constant()
   surf_network_model->action_unref = netcste_action_unref;
   surf_network_model->action_cancel = netcste_action_cancel;
   surf_network_model->action_recycle = net_action_recycle;
-  surf_network_model->get_remains = net_action_get_remains;
+  surf_network_model->get_remains = surf_action_get_remains;
 #ifdef HAVE_LATENCY_BOUND_TRACKING
   surf_network_model->get_latency_limited = net_get_link_latency_limited;
 #endif
index f95c7b7..36980e1 100644 (file)
@@ -289,11 +289,78 @@ double generic_maxmin_share_resources(xbt_swag_t running_actions,
   return min;
 }
 
-void generic_update_action_remaining_lazy( surf_action_t action, double now)
+double generic_share_resources_lazy(double now, surf_model_t model)
 {
- // TODO merge for cpu and net
-}
+  surf_action_lmm_t action = NULL;
+  double min = -1;
+  double value;
+
+  XBT_DEBUG
+      ("Before share resources, the size of modified actions set is %d",
+       xbt_swag_size(model->model_private->modified_set));
+
+  lmm_solve(model->model_private->maxmin_system);
+
+  XBT_DEBUG
+      ("After share resources, The size of modified actions set is %d",
+       xbt_swag_size(model->model_private->modified_set));
 
+  while((action = xbt_swag_extract(model->model_private->modified_set))) {
+    int max_dur_flag = 0;
+
+    if (action->generic_action.state_set !=
+        model->states.running_action_set)
+      continue;
+
+    /* bogus priority, skip it */
+    if (action->generic_action.priority <= 0)
+      continue;
+
+    generic_update_action_remaining_lazy(action,now);
+
+    min = -1;
+    value = lmm_variable_getvalue(action->variable);
+    if (value > 0) {
+      if (action->generic_action.remains > 0) {
+        value = action->generic_action.remains / value;
+        min = now + value;
+      } else {
+        value = 0.0;
+        min = now;
+      }
+    }
+
+    if ((action->generic_action.max_duration != NO_MAX_DURATION)
+        && (min == -1
+            || action->generic_action.start +
+            action->generic_action.max_duration < min)) {
+      min = action->generic_action.start +
+          action->generic_action.max_duration;
+      max_dur_flag = 1;
+    }
+
+    XBT_DEBUG("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
+        action->generic_action.start, now + value,
+        action->generic_action.max_duration);
+
+    if (min != -1) {
+      surf_action_lmm_heap_remove(model->model_private->action_heap,action);
+      surf_action_lmm_heap_insert(model->model_private->action_heap,action, min, max_dur_flag ? MAX_DURATION : NORMAL);
+      XBT_DEBUG("Insert at heap action(%p) min %lf now %lf", action, min,
+                now);
+    } else DIE_IMPOSSIBLE;
+  }
+
+  //hereafter must have already the min value for this resource model
+  if (xbt_heap_size(model->model_private->action_heap) > 0)
+    min = xbt_heap_maxkey(model->model_private->action_heap) - now;
+  else
+    min = -1;
+
+  XBT_DEBUG("The minimum with the HEAP %lf", min);
+
+  return min;
+}
 static XBT_INLINE void routing_asr_host_free(void *p)
 {
   sg_routing_edge_t elm = p;
index 7b96125..90d1878 100644 (file)
@@ -288,13 +288,275 @@ void surf_action_set_category(surf_action_t action,
 }
 #endif
 
+void generic_update_action_remaining_lazy( surf_action_lmm_t action, double now)
+{
+  double delta = 0.0;
+  surf_model_t model = action->generic_action.model_type;
+
+  if(model == surf_network_model)
+  {
+    if (action->suspended != 0)
+      return;
+  }
+  else
+  {
+    xbt_assert(action->generic_action.state_set == model->states.running_action_set,
+        "You're updating an action that is not running.");
+
+      /* bogus priority, skip it */
+    xbt_assert(action->generic_action.priority > 0,
+        "You're updating an action that seems suspended.");
+  }
+
+  delta = now - action->last_update;
+
+  if (action->generic_action.remains > 0) {
+    XBT_DEBUG("Updating action(%p): remains was %lf, last_update was: %lf", action, action->generic_action.remains, action->last_update);
+    double_update(&(action->generic_action.remains),
+        action->last_value * delta);
+
+#ifdef HAVE_TRACING
+    if (model == surf_cpu_model && TRACE_is_enabled()) {
+      surf_resource_t cpu =
+          lmm_constraint_id(lmm_get_cnst_from_var
+              (model->model_private->maxmin_system,
+                  action->variable, 0));
+      TRACE_surf_host_set_utilization(cpu->name,
+          action->generic_action.category,
+          action->last_value,
+          action->last_update,
+          now - action->last_update);
+    }
+#endif
+    XBT_DEBUG("Updating action(%p): remains is now %lf", action,
+        action->generic_action.remains);
+  }
+
+  if(model == surf_network_model)
+  {
+    if (((surf_action_t)action)->max_duration != NO_MAX_DURATION)
+      double_update(&(((surf_action_t)action)->max_duration), delta);
+
+    if ((((surf_action_t)action)->remains <= 0) &&
+        (lmm_get_variable_weight(action->variable) > 0)) {
+      ((surf_action_t)action)->finish = surf_get_clock();
+      model->action_state_set((surf_action_t) action,
+          SURF_ACTION_DONE);
+
+      surf_action_lmm_heap_remove(model->model_private->action_heap,(surf_action_lmm_t)action);
+    } else if (((((surf_action_t)action)->max_duration != NO_MAX_DURATION)
+        && (((surf_action_t)action)->max_duration <= 0))) {
+      ((surf_action_t)action)->finish = surf_get_clock();
+      model->action_state_set((surf_action_t) action,
+          SURF_ACTION_DONE);
+      surf_action_lmm_heap_remove(model->model_private->action_heap,(surf_action_lmm_t)action);
+    }
+  }
+
+  action->last_update = now;
+  action->last_value = lmm_variable_getvalue(action->variable);
+}
+
 double surf_action_get_remains(surf_action_t action)
 {
   XBT_IN("(%p)", action);
   surf_model_t model = action->model_type;
   /* update remains before return it */
   if (model->model_private->update_mechanism == UM_LAZY)      /* update remains before return it */
-    generic_update_action_remaining_lazy(action, surf_get_clock());
+    generic_update_action_remaining_lazy((surf_action_lmm_t)action, surf_get_clock());
   XBT_OUT();
   return action->remains;
 }
+
+void generic_update_actions_state_lazy(double now, double delta, surf_model_t model)
+{
+  surf_action_lmm_t action;
+  while ((xbt_heap_size(model->model_private->action_heap) > 0)
+         && (double_equals(xbt_heap_maxkey(model->model_private->action_heap), now))) {
+    action = xbt_heap_pop(model->model_private->action_heap);
+    XBT_DEBUG("Action %p: finish", action);
+    action->generic_action.finish = surf_get_clock();
+#ifdef HAVE_TRACING
+    if (TRACE_is_enabled()) {
+      if(model == surf_cpu_model){
+      surf_resource_t cpu =
+          lmm_constraint_id(lmm_get_cnst_from_var
+                            (model->model_private->maxmin_system,
+                             action->variable, 0));
+      TRACE_surf_host_set_utilization(cpu->name,
+                                      ((surf_action_t)action)->category,
+                                      lmm_variable_getvalue(action->variable),
+                                      action->last_update,
+                                      now - action->last_update);
+      }
+      else{
+        int n = lmm_get_number_of_cnst_from_var(model->model_private->maxmin_system, action->variable);
+        unsigned int i;
+        for (i = 0; i < n; i++){
+          lmm_constraint_t constraint = lmm_get_cnst_from_var(model->model_private->maxmin_system,
+                                                              action->variable,
+                                                              i);
+          link_CM02_t link = lmm_constraint_id(constraint);
+          TRACE_surf_link_set_utilization(link->lmm_resource.generic_resource.name,
+                                          ((surf_action_t)action)->category,
+                                          (lmm_variable_getvalue(action->variable)*
+                                              lmm_get_cnst_weight_from_var(model->model_private->maxmin_system,
+                                                  action->variable,
+                                                  i)),
+                                          action->last_update,
+                                          now - action->last_update);
+        }
+      }
+    }
+#endif
+
+    if(model == surf_cpu_model){
+      /* set the remains to 0 due to precision problems when updating the remaining amount */
+      action->generic_action.remains = 0;
+      surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
+      surf_action_lmm_heap_remove(model->model_private->action_heap,action); //FIXME: strange call since action was already popped
+    }
+    else{
+      // if I am wearing a latency hat
+      if (action->hat == LATENCY) {
+        lmm_update_variable_weight(model->model_private->maxmin_system, action->variable,
+            ((surf_action_network_CM02_t)(action))->weight);
+        surf_action_lmm_heap_remove(model->model_private->action_heap,action);
+        action->last_update = surf_get_clock();
+
+        // if I am wearing a max_duration or normal hat
+      } else if (action->hat == MAX_DURATION ||
+          action->hat == NORMAL) {
+        // no need to communicate anymore
+        // assume that flows that reached max_duration have remaining of 0
+        action->generic_action.remains = 0;
+        ((surf_action_t)action)->finish = surf_get_clock();
+        model->action_state_set((surf_action_t) action,
+                                             SURF_ACTION_DONE);
+        surf_action_lmm_heap_remove(model->model_private->action_heap,action);
+      }
+    }
+  }
+#ifdef HAVE_TRACING
+  if (TRACE_is_enabled() && model == surf_cpu_model) {
+    //defining the last timestamp that we can safely dump to trace file
+    //without losing the event ascending order (considering all CPU's)
+    double smaller = -1;
+    xbt_swag_t running_actions = model->states.running_action_set;
+    xbt_swag_foreach(action, running_actions) {
+        if (smaller < 0) {
+          smaller = action->last_update;
+          continue;
+        }
+        if (action->last_update < smaller) {
+          smaller = action->last_update;
+        }
+    }
+    if (smaller > 0) {
+      TRACE_last_timestamp_to_dump = smaller;
+    }
+  }
+#endif
+  return;
+}
+
+void generic_update_actions_state_full(double now, double delta, surf_model_t model)
+{
+  surf_action_lmm_t action = NULL;
+  surf_action_lmm_t next_action = NULL;
+  xbt_swag_t running_actions = model->states.running_action_set;
+
+  xbt_swag_foreach_safe(action, next_action, running_actions) {
+
+    if(model == surf_network_model)
+    {
+      double deltap = 0.0;
+      deltap = delta;
+      if (((surf_action_network_CM02_t)action)->latency > 0) {
+        if (((surf_action_network_CM02_t)action)->latency > deltap) {
+          double_update(&(((surf_action_network_CM02_t)action)->latency), deltap);
+          deltap = 0.0;
+        } else {
+          double_update(&(deltap), ((surf_action_network_CM02_t)action)->latency);
+          ((surf_action_network_CM02_t)action)->latency = 0.0;
+        }
+        if ((((surf_action_network_CM02_t)action)->latency == 0.0) && !(action->suspended))
+          lmm_update_variable_weight(model->model_private->maxmin_system, action->variable,
+              ((surf_action_network_CM02_t)action)->weight);
+      }
+  #ifdef HAVE_TRACING
+      if (TRACE_is_enabled()) {
+        int n = lmm_get_number_of_cnst_from_var(model->model_private->maxmin_system, action->variable);
+        unsigned int i;
+        for (i = 0; i < n; i++){
+          lmm_constraint_t constraint = lmm_get_cnst_from_var(model->model_private->maxmin_system,
+                                                              action->variable,
+                                                              i);
+          link_CM02_t link = lmm_constraint_id(constraint);
+          TRACE_surf_link_set_utilization(link->lmm_resource.generic_resource.name,
+                                          ((surf_action_t)action)->category,
+                                          (lmm_variable_getvalue(action->variable)*
+                                          lmm_get_cnst_weight_from_var(model->model_private->maxmin_system,
+                                              action->variable,
+                                              i)),
+                                          now - delta,
+                                          delta);
+        }
+      }
+  #endif
+      if (!lmm_get_number_of_cnst_from_var
+          (model->model_private->maxmin_system, action->variable)) {
+        /* There is actually no link used, hence an infinite bandwidth.
+         * This happens often when using models like vivaldi.
+         * In such case, just make sure that the action completes immediately.
+         */
+        double_update(&(action->generic_action.remains),
+                      action->generic_action.remains);
+      }
+    }
+    else
+    {
+#ifdef HAVE_TRACING
+      if (TRACE_is_enabled()) {
+        surf_resource_t x =
+            lmm_constraint_id(lmm_get_cnst_from_var
+                              (model->model_private->maxmin_system,
+                               action->variable, 0));
+
+        TRACE_surf_host_set_utilization(x->name,
+                                        ((surf_action_t)action)->category,
+                                        lmm_variable_getvalue(action->variable),
+                                        now - delta,
+                                        delta);
+        TRACE_last_timestamp_to_dump = now - delta;
+      }
+#endif
+    }
+
+    double_update(&(action->generic_action.remains),
+                  lmm_variable_getvalue(action->variable) * delta);
+
+
+    if (action->generic_action.max_duration != NO_MAX_DURATION)
+      double_update(&(action->generic_action.max_duration), delta);
+
+
+    if ((action->generic_action.remains <= 0) &&
+        (lmm_get_variable_weight(action->variable) > 0)) {
+      action->generic_action.finish = surf_get_clock();
+      surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
+
+      if (model->gap_remove && model == surf_network_model)
+        model->gap_remove(action);
+    } else if ((action->generic_action.max_duration != NO_MAX_DURATION) &&
+               (action->generic_action.max_duration <= 0)) {
+      action->generic_action.finish = surf_get_clock();
+      surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
+
+      if (model->gap_remove && model == surf_network_model)
+        model->gap_remove(action);
+    }
+  }
+
+  return;
+}
index 6fb1dc7..60a4e68 100644 (file)
@@ -62,7 +62,7 @@ double generic_maxmin_share_resources(xbt_swag_t running_actions,
                                       size_t offset,
                                       lmm_system_t sys,
                                       void (*solve) (lmm_system_t));
-void generic_update_action_remaining_lazy( surf_action_t action, double now);
+double generic_share_resources_lazy(double now, surf_model_t model);
 
 /* Generic functions common to all models */
 void surf_action_init(void);
@@ -92,6 +92,9 @@ void surf_action_set_category(surf_action_t action,
                                     const char *category);
 #endif
 double surf_action_get_remains(surf_action_t action);
+void generic_update_action_remaining_lazy( surf_action_lmm_t action, double now);
+void generic_update_actions_state_lazy(double now, double delta, surf_model_t model);
+void generic_update_actions_state_full(double now, double delta, surf_model_t model);
 
 FILE *surf_fopen(const char *name, const char *mode);