Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix msg-start-kill-time
authorPaul Bédaride <paul.bedaride@gmail.com>
Fri, 11 Oct 2013 14:54:36 +0000 (16:54 +0200)
committerPaul Bédaride <paul.bedaride@gmail.com>
Fri, 11 Oct 2013 14:54:36 +0000 (16:54 +0200)
21 files changed:
.cproject
src/include/surf/surf.h
src/simix/smx_host.c
src/simix/smx_network.c
src/simix/smx_smurf_private.h
src/surf/cpu.hpp
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/cpu_ti.cpp
src/surf/network.cpp
src/surf/surf.cpp
src/surf/surf.hpp
src/surf/surf_interface.cpp
src/surf/surf_routing_cluster.cpp
src/surf/surf_routing_cluster.hpp [new file with mode: 0644]
src/surf/surf_routing_full.hpp
src/surf/surf_routing_generic.hpp
src/surf/surf_routing_private.h
src/surf/workstation.cpp
src/surf/workstation_ptask_L07.cpp
testsuite/surf/surf_usage.c

index 2d167a8..1db3612 100644 (file)
--- a/.cproject
+++ b/.cproject
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 5.0.0?>
-
-<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage2">
+<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
        <storageModule moduleId="org.eclipse.cdt.core.settings">
        <storageModule moduleId="org.eclipse.cdt.core.settings">
-               <cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1353180652">
-                       <storageModule externalCElementFile="cdt.managedbuild.toolchain.gnu.base.1353180652_org.eclipse.cdt.core.settings" id="cdt.managedbuild.toolchain.gnu.base.1353180652" name="Default"/>
-                       <storageModule externalCElementFile="cdt.managedbuild.toolchain.gnu.base.1353180652_cdtBuildSystem" version="4.0.0"/>
-                       <storageModule externalCElementFile="cdt.managedbuild.toolchain.gnu.base.1353180652_org.eclipse.cdt.core.externalSettings"/>
+               <cconfiguration id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.1628373792">
+                       <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.1628373792" moduleId="org.eclipse.cdt.core.settings" name="Build (GNU)">
+                               <externalSettings/>
+                               <extensions>
+                                       <extension id="org.eclipse.cdt.core.MachO64" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                               </extensions>
+                       </storageModule>
+                       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+                               <configuration buildProperties="" description="" id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.1628373792" name="Build (GNU)" parent="org.eclipse.cdt.build.core.emptycfg">
+                                       <folderInfo id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.1628373792.978950279" name="/" resourcePath="">
+                                               <toolChain id="org.eclipse.linuxtools.cdt.autotools.core.toolChain.451718623" name="org.eclipse.linuxtools.cdt.autotools.core.toolChain" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolChain">
+                                                       <targetPlatform id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.targetPlatform.2070619552" isAbstract="false" name="GNU Autotools Target Platform" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.targetPlatform"/>
+                                                       <builder buildPath="${workspace_loc:/simgrid}/build" id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder.1564602718" keepEnvironmentInBuildfile="false" managedBuildOn="false" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.builder"/>
+                                                       <tool id="org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure.2013870946" name="configure" superClass="org.eclipse.linuxtools.cdt.autotools.core.gnu.toolchain.tool.configure">
+                                                               <option id="org.eclipse.linuxtools.cdt.autotools.core.option.configure.name.1303771952" name="Name" superClass="org.eclipse.linuxtools.cdt.autotools.core.option.configure.name" value="org.eclipse.linuxtools.cdt.autotools.core.toolChain.1628373792" valueType="string"/>
+                                                       </tool>
+                                                       <tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen.1873998201" name="autogen.sh" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.autogen"/>
+                                                       <tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc.1609982557" name="GCC C Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gcc">
+                                                               <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.673666909" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+                                                       </tool>
+                                                       <tool id="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp.129357715" name="GCC C++ Compiler" superClass="org.eclipse.linuxtools.cdt.autotools.core.toolchain.tool.gpp">
+                                                               <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1566467247" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
+                                                       </tool>
+                                               </toolChain>
+                                       </folderInfo>
+                               </configuration>
+                       </storageModule>
+                       <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
                </cconfiguration>
        </storageModule>
                </cconfiguration>
        </storageModule>
-       <storageModule moduleId="org.eclipse.cdt.core.pathentry">
-               <pathentry kind="mac" name="main" path="" value="smpi_simulated_main"/>
-               <pathentry include="/usr/include/lua5.1" kind="inc" path="" system="true"/>
-               <pathentry include="/usr/include" kind="inc" path="" system="true"/>
-               <pathentry base-path="simgrid" include="include" kind="inc" path="" system="true"/>
-               <pathentry base-path="simgrid" include="src/include" kind="inc" path="" system="true"/>
-               <pathentry base-path="simgrid" include="src" kind="inc" path="" system="true"/>
-               <pathentry excluding="**/CMakeFiles/" kind="out" path=""/>
-               <pathentry kind="src" path=""/>
-       </storageModule>
        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
-               <project id="simgrid.null.697056024" name="simgrid"/>
+               <project id="simgrid.null.1460982030" name="simgrid"/>
+       </storageModule>
+       <storageModule moduleId="scannerConfiguration">
+               <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
        </storageModule>
        </storageModule>
+       <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
        <storageModule moduleId="refreshScope" versionNumber="2">
        <storageModule moduleId="refreshScope" versionNumber="2">
-               <configuration configurationName="Default">
+               <configuration configurationName="Build (GNU)">
                        <resource resourceType="PROJECT" workspacePath="/simgrid"/>
                </configuration>
        </storageModule>
                        <resource resourceType="PROJECT" workspacePath="/simgrid"/>
                </configuration>
        </storageModule>
-       <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
-       <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
-       <storageModule moduleId="scannerConfiguration">
-               <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
-               <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-                       <buildOutputProvider>
-                               <openAction enabled="true" filePath=""/>
-                               <parser enabled="true"/>
-                       </buildOutputProvider>
-                       <scannerInfoProvider id="specsFile">
-                               <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="/usr/bin/gcc" useDefault="true"/>
-                               <parser enabled="true"/>
-                       </scannerInfoProvider>
-               </profile>
-               <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-                       <buildOutputProvider>
-                               <openAction enabled="true" filePath=""/>
-                               <parser enabled="true"/>
-                       </buildOutputProvider>
-                       <scannerInfoProvider id="makefileGenerator">
-                               <runAction arguments="-f ${project_name}_scd.mk" command="/usr/bin/make" useDefault="true"/>
-                               <parser enabled="true"/>
-                       </scannerInfoProvider>
-               </profile>
-               <scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1353180652;cdt.managedbuild.toolchain.gnu.base.1353180652.1797514135;cdt.managedbuild.tool.gnu.c.compiler.base.2037544368;cdt.managedbuild.tool.gnu.c.compiler.input.1851803849">
-                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
-                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-                               <buildOutputProvider>
-                                       <openAction enabled="true" filePath=""/>
-                                       <parser enabled="true"/>
-                               </buildOutputProvider>
-                               <scannerInfoProvider id="specsFile">
-                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="/usr/bin/gcc" useDefault="true"/>
-                                       <parser enabled="true"/>
-                               </scannerInfoProvider>
-                       </profile>
-                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-                               <buildOutputProvider>
-                                       <openAction enabled="true" filePath=""/>
-                                       <parser enabled="true"/>
-                               </buildOutputProvider>
-                               <scannerInfoProvider id="makefileGenerator">
-                                       <runAction arguments="-f ${project_name}_scd.mk" command="/usr/bin/make" useDefault="true"/>
-                                       <parser enabled="true"/>
-                               </scannerInfoProvider>
-                       </profile>
-               </scannerConfigBuildInfo>
-               <scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.base.1353180652;cdt.managedbuild.toolchain.gnu.base.1353180652.1797514135;cdt.managedbuild.tool.gnu.cpp.compiler.base.1129818443;cdt.managedbuild.tool.gnu.cpp.compiler.input.500761747">
-                       <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
-                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-                               <buildOutputProvider>
-                                       <openAction enabled="true" filePath=""/>
-                                       <parser enabled="true"/>
-                               </buildOutputProvider>
-                               <scannerInfoProvider id="specsFile">
-                                       <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="/usr/bin/gcc" useDefault="true"/>
-                                       <parser enabled="true"/>
-                               </scannerInfoProvider>
-                       </profile>
-                       <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-                               <buildOutputProvider>
-                                       <openAction enabled="true" filePath=""/>
-                                       <parser enabled="true"/>
-                               </buildOutputProvider>
-                               <scannerInfoProvider id="makefileGenerator">
-                                       <runAction arguments="-f ${project_name}_scd.mk" command="/usr/bin/make" useDefault="true"/>
-                                       <parser enabled="true"/>
-                               </scannerInfoProvider>
-                       </profile>
-               </scannerConfigBuildInfo>
-       </storageModule>
 </cproject>
 </cproject>
index 117e7bb..d67c9f9 100644 (file)
@@ -87,10 +87,9 @@ typedef CpuModel *surf_cpu_model_t;
 typedef WorkstationModel *surf_workstation_model_t;
 typedef NetworkCm02Model *surf_network_model_t;
 
 typedef WorkstationModel *surf_workstation_model_t;
 typedef NetworkCm02Model *surf_network_model_t;
 
-typedef Resource *surf_resource_t;
-typedef ResourceLmm *surf_resource_lmm_t;
+typedef xbt_dictelm_t surf_resource_t;
+typedef Resource *surf_cpp_resource_t;
 typedef WorkstationCLM03 *surf_workstation_CLM03_t;
 typedef WorkstationCLM03 *surf_workstation_CLM03_t;
-typedef xbt_dictelm_t surf_workstation_t;
 typedef NetworkCm02Link *surf_network_link_t;
 typedef Cpu *surf_cpu_t;
 
 typedef NetworkCm02Link *surf_network_link_t;
 typedef Cpu *surf_cpu_t;
 
@@ -318,27 +317,26 @@ surf_action_t surf_workstation_model_execute_parallel_task(surf_workstation_mode
                                             double *computation_amount,
                                             double *communication_amount,
                                             double rate);
                                             double *computation_amount,
                                             double *communication_amount,
                                             double rate);
-surf_action_t surf_workstation_model_communicate(surf_workstation_model_t model, surf_workstation_t src, surf_workstation_t dst, double size, double rate);
-xbt_dynar_t surf_workstation_model_get_route(surf_workstation_model_t model, surf_workstation_t src, surf_workstation_t dst);
+surf_action_t surf_workstation_model_communicate(surf_workstation_model_t model, surf_resource_t src, surf_resource_t dst, double size, double rate);
+xbt_dynar_t surf_workstation_model_get_route(surf_workstation_model_t model, surf_resource_t src, surf_resource_t dst);
 surf_action_t surf_network_model_communicate(surf_network_model_t model, sg_routing_edge_t src, sg_routing_edge_t dst, double size, double rate);
 surf_action_t surf_network_model_communicate(surf_network_model_t model, sg_routing_edge_t src, sg_routing_edge_t dst, double size, double rate);
-const char *surf_resource_name(surf_resource_t resource);
-xbt_dict_t surf_resource_get_properties(surf_resource_t resource);
-e_surf_resource_state_t surf_resource_get_state(surf_resource_t resource);
-double surf_workstation_get_speed(surf_workstation_t resource, double load);
-double surf_workstation_get_available_speed(surf_workstation_t resource);
-int surf_workstation_get_core(surf_workstation_t resource);
-surf_action_t surf_workstation_execute(surf_workstation_t resource, double size);
-surf_action_t surf_workstation_sleep(surf_workstation_t resource, double duration);
-surf_action_t surf_workstation_open(surf_workstation_t workstation, const char* mount, const char* path);
-surf_action_t surf_workstation_close(surf_workstation_t workstation, surf_file_t fd);
-const char *surf_cpu_name(surf_cpu_t resource);
-surf_action_t surf_cpu_execute(surf_cpu_t cpu, double size);
-surf_action_t surf_cpu_sleep(surf_cpu_t cpu, double duration);
-int surf_workstation_unlink(surf_workstation_t workstation, surf_file_t fd);
-surf_action_t surf_workstation_ls(surf_workstation_t workstation, const char* mount, const char *path);
-size_t surf_workstation_get_size(surf_workstation_t workstation, surf_file_t fd);
-surf_action_t surf_workstation_read(surf_workstation_t resource, void *ptr, size_t size, surf_file_t fd);
-surf_action_t surf_workstation_write(surf_workstation_t resource, const void *ptr, size_t size, surf_file_t fd);
+const char *surf_resource_name(surf_cpp_resource_t resource);
+xbt_dict_t surf_resource_get_properties(surf_cpp_resource_t resource);
+e_surf_resource_state_t surf_resource_get_state(surf_cpp_resource_t resource);
+double surf_workstation_get_speed(surf_resource_t resource, double load);
+double surf_workstation_get_available_speed(surf_resource_t resource);
+int surf_workstation_get_core(surf_resource_t resource);
+surf_action_t surf_workstation_execute(surf_resource_t resource, double size);
+surf_action_t surf_workstation_sleep(surf_resource_t resource, double duration);
+surf_action_t surf_workstation_open(surf_resource_t workstation, const char* mount, const char* path);
+surf_action_t surf_workstation_close(surf_resource_t workstation, surf_file_t fd);
+surf_action_t surf_cpu_execute(surf_resource_t cpu, double size);
+surf_action_t surf_cpu_sleep(surf_resource_t cpu, double duration);
+int surf_workstation_unlink(surf_resource_t workstation, surf_file_t fd);
+surf_action_t surf_workstation_ls(surf_resource_t workstation, const char* mount, const char *path);
+size_t surf_workstation_get_size(surf_resource_t workstation, surf_file_t fd);
+surf_action_t surf_workstation_read(surf_resource_t resource, void *ptr, size_t size, surf_file_t fd);
+surf_action_t surf_workstation_write(surf_resource_t resource, const void *ptr, size_t size, surf_file_t fd);
 int surf_network_link_is_shared(surf_network_link_t link);
 double surf_network_link_get_bandwidth(surf_network_link_t link);
 double surf_network_link_get_latency(surf_network_link_t link);
 int surf_network_link_is_shared(surf_network_link_t link);
 double surf_network_link_get_bandwidth(surf_network_link_t link);
 double surf_network_link_get_latency(surf_network_link_t link);
index bece28b..5e130a4 100644 (file)
@@ -500,7 +500,7 @@ void SIMIX_execution_finish(smx_action_t action)
     }
     /* check if the host is down */
 
     }
     /* check if the host is down */
 
-    if (surf_resource_get_state((surf_resource_t)surf_workstation_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
+    if (surf_resource_get_state(surf_workstation_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) {
       simcall->issuer->context->iwannadie = 1;
     }
 
       simcall->issuer->context->iwannadie = 1;
     }
 
@@ -517,7 +517,7 @@ void SIMIX_post_host_execute(smx_action_t action)
 {
   if (action->type == SIMIX_ACTION_EXECUTE && /* FIMXE: handle resource failure
                                                * for parallel tasks too */
 {
   if (action->type == SIMIX_ACTION_EXECUTE && /* FIMXE: handle resource failure
                                                * for parallel tasks too */
-      surf_resource_get_state((surf_resource_t)surf_workstation_resource_priv(action->execution.host)) == SURF_RESOURCE_OFF) {
+      surf_resource_get_state(surf_workstation_resource_priv(action->execution.host)) == SURF_RESOURCE_OFF) {
     /* If the host running the action failed, notice it so that the asking
      * process can be killed if it runs on that host itself */
     action->state = SIMIX_FAILED;
     /* If the host running the action failed, notice it so that the asking
      * process can be killed if it runs on that host itself */
     action->state = SIMIX_FAILED;
index 046791a..2868ad6 100644 (file)
@@ -729,7 +729,7 @@ void SIMIX_pre_comm_wait(smx_simcall_t simcall, smx_action_t action, double time
   if (action->state != SIMIX_WAITING && action->state != SIMIX_RUNNING) {
     SIMIX_comm_finish(action);
   } else { /* if (timeout >= 0) { we need a surf sleep action even when there is no timeout, otherwise surf won't tell us when the host fails */
   if (action->state != SIMIX_WAITING && action->state != SIMIX_RUNNING) {
     SIMIX_comm_finish(action);
   } else { /* if (timeout >= 0) { we need a surf sleep action even when there is no timeout, otherwise surf won't tell us when the host fails */
-    sleep = surf_workstation_sleep(surf_workstation_resource_priv(simcall->issuer->smx_host), timeout);
+    sleep = surf_workstation_sleep(simcall->issuer->smx_host, timeout);
     surf_action_set_data(sleep, action);
 
     if (simcall->issuer == action->comm.src_proc)
     surf_action_set_data(sleep, action);
 
     if (simcall->issuer == action->comm.src_proc)
index c5ed371..104a78e 100644 (file)
 #define SIMCALL_WITH_RESULT_BEGIN(name, type, field, ...) simcall->result.field =
 #define SIMCALL_WITHOUT_RESULT_BEGIN(name, type, field)
 #define SIMCALL_RESULT_BEGIN_(name, type, ...)\
 #define SIMCALL_WITH_RESULT_BEGIN(name, type, field, ...) simcall->result.field =
 #define SIMCALL_WITHOUT_RESULT_BEGIN(name, type, field)
 #define SIMCALL_RESULT_BEGIN_(name, type, ...)\
-        MAYBE3(,##__VA_ARGS__, SIMCALL_WITH_RESULT_BEGIN, SIMCALL_WITHOUT_RESULT_BEGIN, SIMCALL_WITHOUT_RESULT_BEGIN)\
+        MAYBE3(,##__VA_ARGS__, SIMCALL_WITH_RESULT_BEGIN, SIMCALL_WITH_RESULT_BEGIN, SIMCALL_WITHOUT_RESULT_BEGIN)\
        (name, type, __VA_ARGS__)
 #define SIMCALL_RESULT_BEGIN(answer, res) answer(SIMCALL_RESULT_BEGIN_ res)
 
        (name, type, __VA_ARGS__)
 #define SIMCALL_RESULT_BEGIN(answer, res) answer(SIMCALL_RESULT_BEGIN_ res)
 
 #define SIMCALL_WITH_FUNC_SIMCALL(name, type, field) smx_simcall_t simcall = 
 #define SIMCALL_WITHOUT_FUNC_SIMCALL(name, type, field)
 #define SIMCALL_FUNC_SIMCALL_(name, type, ...)\
 #define SIMCALL_WITH_FUNC_SIMCALL(name, type, field) smx_simcall_t simcall = 
 #define SIMCALL_WITHOUT_FUNC_SIMCALL(name, type, field)
 #define SIMCALL_FUNC_SIMCALL_(name, type, ...)\
-        MAYBE3(,##__VA_ARGS__, SIMCALL_WITH_FUNC_SIMCALL, SIMCALL_WITHOUT_FUNC_SIMCALL, SIMCALL_WITHOUT_FUNC_SIMCALL)\
+        MAYBE3(,##__VA_ARGS__, SIMCALL_WITH_FUNC_SIMCALL, SIMCALL_WITH_FUNC_SIMCALL, SIMCALL_WITHOUT_FUNC_SIMCALL)\
        (name, type, __VA_ARGS__)
 #define SIMCALL_FUNC_SIMCALL(res) SIMCALL_FUNC_SIMCALL_ res
 
        (name, type, __VA_ARGS__)
 #define SIMCALL_FUNC_SIMCALL(res) SIMCALL_FUNC_SIMCALL_ res
 
index c734738..cebc48c 100644 (file)
@@ -41,8 +41,8 @@ class Cpu : virtual public Resource {
 public:
   Cpu(){};
   Cpu(CpuModelPtr model, const char* name, xbt_dict_t properties) : Resource(model, name, properties) {};
 public:
   Cpu(){};
   Cpu(CpuModelPtr model, const char* name, xbt_dict_t properties) : Resource(model, name, properties) {};
-  virtual CpuActionPtr execute(double size)=0;
-  virtual CpuActionPtr sleep(double duration)=0;
+  virtual ActionPtr execute(double size)=0;
+  virtual ActionPtr sleep(double duration)=0;
   int getCore();
   double getSpeed(double load);
   double getAvailableSpeed();
   int getCore();
   double getSpeed(double load);
   double getAvailableSpeed();
index c1eedce..f1e3be1 100644 (file)
@@ -59,7 +59,8 @@ void surf_cpu_model_init_Cas01()
 
 CpuCas01Model::CpuCas01Model() : CpuModel("cpu")
 {
 
 CpuCas01Model::CpuCas01Model() : CpuModel("cpu")
 {
-  CpuCas01ActionLmm action;
+  ActionPtr action;
+  ActionLmmPtr actionlmm;
 
   char *optim = xbt_cfg_get_string(_sg_cfg_set, "cpu/optim");
   int select = xbt_cfg_get_boolean(_sg_cfg_set, "cpu/maxmin_selective_update");
 
   char *optim = xbt_cfg_get_string(_sg_cfg_set, "cpu/optim");
   int select = xbt_cfg_get_boolean(_sg_cfg_set, "cpu/maxmin_selective_update");
@@ -80,7 +81,7 @@ CpuCas01Model::CpuCas01Model() : CpuModel("cpu")
   }
 
   cpu_running_action_set_that_does_not_need_being_checked =
   }
 
   cpu_running_action_set_that_does_not_need_being_checked =
-      xbt_swag_new(xbt_swag_offset(action, p_stateHookup));
+      xbt_swag_new(xbt_swag_offset(*action, p_stateHookup));
 
   if (p_updateMechanism == UM_LAZY) {
        shareResources = &CpuCas01Model::shareResourcesLazy;
 
   if (p_updateMechanism == UM_LAZY) {
        shareResources = &CpuCas01Model::shareResourcesLazy;
@@ -99,21 +100,7 @@ CpuCas01Model::CpuCas01Model() : CpuModel("cpu")
   if (p_updateMechanism == UM_LAZY) {
     p_actionHeap = xbt_heap_new(8, NULL);
     xbt_heap_set_update_callback(p_actionHeap,  surf_action_lmm_update_index_heap);
   if (p_updateMechanism == UM_LAZY) {
     p_actionHeap = xbt_heap_new(8, NULL);
     xbt_heap_set_update_callback(p_actionHeap,  surf_action_lmm_update_index_heap);
-    ActionLmmPtr _actionlmm;
-    CpuCas01ActionLmmPtr _actioncpu;
-    int j = xbt_swag_offset(*_actionlmm, p_actionListHookup);
-    int k = xbt_swag_offset(*_actioncpu, p_actionListHookup);
-    j = ((char *)&( (*_actionlmm).p_actionListHookup ) - (char *)(_actionlmm));
-    k = ((char *)&( (*_actioncpu).p_actionListHookup ) - (char *)(_actioncpu));
-    void *toto = &(*_actionlmm).p_actionListHookup;
-    void *tata = _actionlmm;
-    ActionLmm aieu;
-    ActionLmmPtr actionBase = &aieu;
-    void *actionBaseVoid = actionBase;
-    void *actionBaseCVoid = static_cast<void*>(actionBase);
-    ActionLmmPtr actionBaseVoidBase = (ActionLmmPtr)actionBaseVoid;
-    ActionLmmPtr actionBaseCVoidCBase = static_cast<ActionLmmPtr>(actionBaseCVoid);
-    p_modifiedSet = xbt_swag_new(xbt_swag_offset(*_actionlmm, p_actionListHookup));
+    p_modifiedSet = xbt_swag_new(xbt_swag_offset(*actionlmm, p_actionListHookup));
     p_maxminSystem->keep_track = p_modifiedSet;
   }
 }
     p_maxminSystem->keep_track = p_modifiedSet;
   }
 }
@@ -158,9 +145,9 @@ CpuCas01LmmPtr CpuCas01Model::createResource(const char *name, double power_peak
   xbt_assert(core > 0, "Invalid number of cores %d", core);
 
   cpu = new CpuCas01Lmm(this, name, power_peak, power_scale, power_trace, core, state_initial, state_trace, cpu_properties);
   xbt_assert(core > 0, "Invalid number of cores %d", core);
 
   cpu = new CpuCas01Lmm(this, name, power_peak, power_scale, power_trace, core, state_initial, state_trace, cpu_properties);
-  xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
+  xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
 
 
-  return (CpuCas01LmmPtr) xbt_lib_get_elm_or_null(host_lib, name);;
+  return (CpuCas01LmmPtr) xbt_lib_get_elm_or_null(host_lib, name);
 }
 
 double CpuCas01Model::shareResourcesFull(double now)
 }
 
 double CpuCas01Model::shareResourcesFull(double now)
@@ -287,7 +274,7 @@ void CpuCas01Lmm::updateState(tmgr_trace_event_t event_type, double value, doubl
   return;
 }
 
   return;
 }
 
-CpuActionPtr CpuCas01Lmm::execute(double size)
+ActionPtr CpuCas01Lmm::execute(double size)
 {
 
   XBT_IN("(%s,%g)", m_name, size);
 {
 
   XBT_IN("(%s,%g)", m_name, size);
@@ -311,13 +298,13 @@ CpuActionPtr CpuCas01Lmm::execute(double size)
   return action;
 }
 
   return action;
 }
 
-CpuActionPtr CpuCas01Lmm::sleep(double duration)
+ActionPtr CpuCas01Lmm::sleep(double duration)
 {
   if (duration > 0)
     duration = MAX(duration, MAXMIN_PRECISION);
 
   XBT_IN("(%s,%g)", m_name, duration);
 {
   if (duration > 0)
     duration = MAX(duration, MAXMIN_PRECISION);
 
   XBT_IN("(%s,%g)", m_name, duration);
-  CpuCas01ActionLmmPtr action = (CpuCas01ActionLmmPtr) execute(1.0);
+  CpuCas01ActionLmmPtr action = dynamic_cast<CpuCas01ActionLmmPtr>(execute(1.0));
 
   // FIXME: sleep variables should not consume 1.0 in lmm_expand
   action->m_maxDuration = duration;
 
   // FIXME: sleep variables should not consume 1.0 in lmm_expand
   action->m_maxDuration = duration;
@@ -337,7 +324,7 @@ CpuActionPtr CpuCas01Lmm::sleep(double duration)
     // this is necessary for a variable with weight 0 since such
     // variables are ignored in lmm and we need to set its max_duration
     // correctly at the next call to share_resources
     // this is necessary for a variable with weight 0 since such
     // variables are ignored in lmm and we need to set its max_duration
     // correctly at the next call to share_resources
-    xbt_swag_insert_at_head(action, surf_cpu_model->p_modifiedSet);
+    xbt_swag_insert_at_head(static_cast<ActionLmmPtr>(action), surf_cpu_model->p_modifiedSet);
   }
 
   XBT_OUT();
   }
 
   XBT_OUT();
index 17895d5..779a350 100644 (file)
@@ -43,8 +43,8 @@ public:
         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
        xbt_dict_t properties) ;
   void updateState(tmgr_trace_event_t event_type, double value, double date);
         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
        xbt_dict_t properties) ;
   void updateState(tmgr_trace_event_t event_type, double value, double date);
-  CpuActionPtr execute(double size);
-  CpuActionPtr sleep(double duration);
+  ActionPtr execute(double size);
+  ActionPtr sleep(double duration);
 
   bool isUsed();
 
 
   bool isUsed();
 
@@ -58,4 +58,5 @@ class CpuCas01ActionLmm: public CpuActionLmm {
 public:
   CpuCas01ActionLmm() {};
   CpuCas01ActionLmm(ModelPtr model, double cost, bool failed): Action(model, cost, failed), CpuActionLmm(model, cost, failed) {};
 public:
   CpuCas01ActionLmm() {};
   CpuCas01ActionLmm(ModelPtr model, double cost, bool failed): Action(model, cost, failed), CpuActionLmm(model, cost, failed) {};
+
 };
 };
index e4b500a..e312e6e 100644 (file)
@@ -410,7 +410,7 @@ CpuTiModel::~CpuTiModel()
   xbt_lib_foreach(host_lib, cursor, key, cpu){
     if(cpu[SURF_CPU_LEVEL])
     {
   xbt_lib_foreach(host_lib, cursor, key, cpu){
     if(cpu[SURF_CPU_LEVEL])
     {
-        CpuTiPtr CPU = (CpuTiPtr) cpu[SURF_CPU_LEVEL];
+        CpuTiPtr CPU = dynamic_cast<CpuTiPtr>(static_cast<ResourcePtr>(cpu[SURF_CPU_LEVEL]));
         xbt_swag_free(CPU->p_actionSet);
         delete CPU->p_availTrace;
     }
         xbt_swag_free(CPU->p_actionSet);
         delete CPU->p_availTrace;
     }
@@ -456,7 +456,7 @@ CpuTiPtr CpuTiModel::createResource(const char *name,
               name);
   CpuTiPtr cpu = new CpuTi(this, name, powerPeak, powerScale, powerTrace,
                           core, stateInitial, stateTrace, cpuProperties);
               name);
   CpuTiPtr cpu = new CpuTi(this, name, powerPeak, powerScale, powerTrace,
                           core, stateInitial, stateTrace, cpuProperties);
-  xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
+  xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
   return (CpuTiPtr) xbt_lib_get_elm_or_null(host_lib, name);
 }
 
   return (CpuTiPtr) xbt_lib_get_elm_or_null(host_lib, name);
 }
 
index e01213e..4065da6 100644 (file)
@@ -252,7 +252,7 @@ NetworkCm02Model::NetworkCm02Model() : NetworkCm02Model("network"){
 }
 
 NetworkCm02Model::NetworkCm02Model(string name) : Model(name){
 }
 
 NetworkCm02Model::NetworkCm02Model(string name) : Model(name){
-  NetworkCm02ActionLmmPtr comm;
+  ActionLmmPtr comm;
 
   char *optim = xbt_cfg_get_string(_sg_cfg_set, "network/optim");
   int select =
 
   char *optim = xbt_cfg_get_string(_sg_cfg_set, "network/optim");
   int select =
@@ -284,7 +284,7 @@ NetworkCm02Model::NetworkCm02Model(string name) : Model(name){
   if (p_updateMechanism == UM_LAZY) {
        p_actionHeap = xbt_heap_new(8, NULL);
        xbt_heap_set_update_callback(p_actionHeap, surf_action_lmm_update_index_heap);
   if (p_updateMechanism == UM_LAZY) {
        p_actionHeap = xbt_heap_new(8, NULL);
        xbt_heap_set_update_callback(p_actionHeap, surf_action_lmm_update_index_heap);
-       p_modifiedSet = xbt_swag_new(xbt_swag_offset((*comm), p_actionListHookup));
+       p_modifiedSet = xbt_swag_new(xbt_swag_offset(*comm, p_actionListHookup));
        p_maxminSystem->keep_track = p_modifiedSet;
   }
 }
        p_maxminSystem->keep_track = p_modifiedSet;
   }
 }
@@ -430,7 +430,8 @@ NetworkCm02ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEd
 
   bandwidth_bound = -1.0;
   if (sg_weight_S_parameter > 0) {
 
   bandwidth_bound = -1.0;
   if (sg_weight_S_parameter > 0) {
-    xbt_dynar_foreach(route, i, link) {
+    xbt_dynar_foreach(route, i, _link) {
+      link = static_cast<NetworkCm02LinkLmmPtr>(static_cast<NetworkCm02LinkPtr>(_link));
       action->m_weight +=
          sg_weight_S_parameter /
          (link->p_power.peak * link->p_power.scale);
       action->m_weight +=
          sg_weight_S_parameter /
          (link->p_power.peak * link->p_power.scale);
index f0aac77..fdfc793 100644 (file)
@@ -328,7 +328,7 @@ static XBT_INLINE void routing_asr_prop_free(void *p)
 
 static XBT_INLINE void surf_cpu_free(void *r)
 {
 
 static XBT_INLINE void surf_cpu_free(void *r)
 {
-  delete static_cast<CpuPtr>(r);
+  delete dynamic_cast<CpuPtr>(static_cast<ResourcePtr>(r));
 }
 
 static XBT_INLINE void surf_link_free(void *r)
 }
 
 static XBT_INLINE void surf_link_free(void *r)
@@ -338,7 +338,7 @@ static XBT_INLINE void surf_link_free(void *r)
 
 static XBT_INLINE void surf_workstation_free(void *r)
 {
 
 static XBT_INLINE void surf_workstation_free(void *r)
 {
-  delete static_cast<WorkstationCLM03Ptr>(r);
+  delete dynamic_cast<WorkstationCLM03Ptr>(static_cast<ResourcePtr>(r));
 }
 
 
 }
 
 
@@ -460,9 +460,9 @@ double Model::shareResources(double now)
 {
   //FIXME: set the good function once and for all
   if (p_updateMechanism == UM_LAZY)
 {
   //FIXME: set the good function once and for all
   if (p_updateMechanism == UM_LAZY)
-       shareResourcesLazy(now);
+       return shareResourcesLazy(now);
   else if (p_updateMechanism == UM_FULL)
   else if (p_updateMechanism == UM_FULL)
-       shareResourcesFull(now);
+       return shareResourcesFull(now);
   else
        xbt_die("Invalid cpu update mechanism!");
 }
   else
        xbt_die("Invalid cpu update mechanism!");
 }
@@ -483,7 +483,7 @@ double Model::shareResourcesLazy(double now)
       ("After share resources, The size of modified actions set is %d",
        xbt_swag_size(p_modifiedSet));
 
       ("After share resources, The size of modified actions set is %d",
        xbt_swag_size(p_modifiedSet));
 
-  while((action = (ActionLmmPtr) xbt_swag_extract(p_modifiedSet))) {
+  while((action = static_cast<ActionLmmPtr>(xbt_swag_extract(p_modifiedSet)))) {
     int max_dur_flag = 0;
 
     if (action->p_stateSet != p_runningActionSet)
     int max_dur_flag = 0;
 
     if (action->p_stateSet != p_runningActionSet)
@@ -787,6 +787,8 @@ Action::Action(ModelPtr model, double cost, bool failed):
   #ifdef HAVE_TRACING
     p_category = NULL;
   #endif
   #ifdef HAVE_TRACING
     p_category = NULL;
   #endif
+  p_stateHookup.prev = 0;
+  p_stateHookup.next = 0;
   if (failed)
     p_stateSet = p_model->p_failedActionSet;
   else
   if (failed)
     p_stateSet = p_model->p_failedActionSet;
   else
index ac59e13..89ed8ef 100644 (file)
@@ -186,10 +186,10 @@ public:
   void turnOff();
   void setName(string name);
   const char *getName();
   void turnOff();
   void setName(string name);
   const char *getName();
-  xbt_dict_t getProperties();
+  virtual xbt_dict_t getProperties();
 
   ModelPtr getModel() {return p_model;};
 
   ModelPtr getModel() {return p_model;};
-  e_surf_resource_state_t getState();
+  virtual e_surf_resource_state_t getState();
   void printModel() { std::cout << p_model->getName() << "<<plop"<<std::endl;};
   void *p_resource;
   const char *m_name;
   void printModel() { std::cout << p_model->getName() << "<<plop"<<std::endl;};
   void *p_resource;
   const char *m_name;
@@ -230,6 +230,7 @@ public:
   virtual ~Action();
   
   s_xbt_swag_hookup_t p_stateHookup;
   virtual ~Action();
   
   s_xbt_swag_hookup_t p_stateHookup;
+
   e_surf_action_state_t getState(); /**< get the state*/
   void setState(e_surf_action_state_t state); /**< Change state*/
   double getStartTime(); /**< Return the start time of an action */
   e_surf_action_state_t getState(); /**< get the state*/
   void setState(e_surf_action_state_t state); /**< Change state*/
   double getStartTime(); /**< Return the start time of an action */
@@ -296,8 +297,14 @@ void surf_action_lmm_update_index_heap(void *action, int i);
 
 class ActionLmm: virtual public Action {
 public:
 
 class ActionLmm: virtual public Action {
 public:
-  ActionLmm() : m_suspended(false) {};
-  ActionLmm(ModelPtr model, double cost, bool failed) : m_suspended(false) {};
+  ActionLmm() : m_suspended(false) {
+       p_actionListHookup.prev = 0;
+       p_actionListHookup.next = 0;
+  };
+  ActionLmm(ModelPtr model, double cost, bool failed) : m_suspended(false) {
+       p_actionListHookup.prev = 0;
+       p_actionListHookup.next = 0;
+  };
 
   virtual void updateRemainingLazy(double now);
   void heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat);
 
   virtual void updateRemainingLazy(double now);
   void heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat);
@@ -315,7 +322,6 @@ public:
   void gapRemove();
 
   lmm_variable_t p_variable;
   void gapRemove();
 
   lmm_variable_t p_variable;
-  //bool m_suspended;
   s_xbt_swag_hookup_t p_actionListHookup;
   int m_indexHeap;
   double m_lastUpdate;
   s_xbt_swag_hookup_t p_actionListHookup;
   int m_indexHeap;
   double m_lastUpdate;
index e4f4d0d..96da59f 100644 (file)
@@ -10,6 +10,14 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_kernel);
  *********/
 extern double NOW;
 
  *********/
 extern double NOW;
 
+static CpuPtr get_casted_cpu(surf_resource_t resource){
+  return dynamic_cast<CpuPtr>(static_cast<ResourcePtr>(surf_cpu_resource_priv(resource)));
+}
+
+static WorkstationCLM03Ptr get_casted_workstation(surf_resource_t resource){
+  return dynamic_cast<WorkstationCLM03Ptr>(static_cast<ResourcePtr>(surf_workstation_resource_priv(resource)));
+}
+
 char *surf_routing_edge_name(sg_routing_edge_t edge){
   return edge->p_name;
 }
 char *surf_routing_edge_name(sg_routing_edge_t edge){
   return edge->p_name;
 }
@@ -27,8 +35,8 @@ void surf_presolve(void)
   double next_event_date = -1.0;
   tmgr_trace_event_t event = NULL;
   double value = -1.0;
   double next_event_date = -1.0;
   tmgr_trace_event_t event = NULL;
   double value = -1.0;
-  surf_resource_t resource = NULL;
-  surf_model_t model = NULL;
+  ResourcePtr resource = NULL;
+  ModelPtr model = NULL;
   unsigned int iter;
 
   XBT_DEBUG
   unsigned int iter;
 
   XBT_DEBUG
@@ -73,8 +81,8 @@ double surf_solve(double max_date)
   double next_event_date = -1.0;
   double model_next_action_end = -1.0;
   double value = -1.0;
   double next_event_date = -1.0;
   double model_next_action_end = -1.0;
   double value = -1.0;
-  surf_resource_t resource = NULL;
-  surf_model_t model = NULL;
+  ResourcePtr resource = NULL;
+  ModelPtr model = NULL;
   tmgr_trace_event_t event = NULL;
   unsigned int iter;
 
   tmgr_trace_event_t event = NULL;
   unsigned int iter;
 
@@ -217,84 +225,80 @@ surf_action_t surf_workstation_model_execute_parallel_task(surf_workstation_mode
                                             double *computation_amount,
                                             double *communication_amount,
                                             double rate){
                                             double *computation_amount,
                                             double *communication_amount,
                                             double rate){
-  return model->executeParallelTask(workstation_nb, workstation_list, computation_amount, communication_amount, rate);
+  return static_cast<ActionPtr>(model->executeParallelTask(workstation_nb, workstation_list, computation_amount, communication_amount, rate));
 }
 
 }
 
-surf_action_t surf_workstation_model_communicate(surf_workstation_model_t model, surf_workstation_CLM03_t src, surf_workstation_CLM03_t dst, double size, double rate){
-  model->communicate(src, dst, size, rate);
+surf_action_t surf_workstation_model_communicate(surf_workstation_model_t model, surf_resource_t src, surf_resource_t dst, double size, double rate){
+  return model->communicate(get_casted_workstation(src), get_casted_workstation(dst), size, rate);
 }
 
 xbt_dynar_t surf_workstation_model_get_route(surf_workstation_model_t model,
 }
 
 xbt_dynar_t surf_workstation_model_get_route(surf_workstation_model_t model,
-                                                    surf_workstation_t src, surf_workstation_t dst){
-  return model->getRoute((WorkstationCLM03Ptr)surf_workstation_resource_priv(src),(WorkstationCLM03Ptr)surf_workstation_resource_priv(dst));
+                                                    surf_resource_t src, surf_resource_t dst){
+  return model->getRoute(get_casted_workstation(src), get_casted_workstation(dst));
 }
 
 surf_action_t surf_network_model_communicate(surf_network_model_t model, sg_routing_edge_t src, sg_routing_edge_t dst, double size, double rate){
   model->communicate(src, dst, size, rate);
 }
 
 }
 
 surf_action_t surf_network_model_communicate(surf_network_model_t model, sg_routing_edge_t src, sg_routing_edge_t dst, double size, double rate){
   model->communicate(src, dst, size, rate);
 }
 
-const char *surf_resource_name(surf_resource_t resource){
+const char *surf_resource_name(surf_cpp_resource_t resource){
   return resource->m_name;
 }
 
   return resource->m_name;
 }
 
-xbt_dict_t surf_resource_get_properties(surf_resource_t resource){
+xbt_dict_t surf_resource_get_properties(surf_cpp_resource_t resource){
   return resource->m_properties;
 }
 
   return resource->m_properties;
 }
 
-e_surf_resource_state_t surf_resource_get_state(surf_resource_t resource){
+e_surf_resource_state_t surf_resource_get_state(surf_cpp_resource_t resource){
   return resource->getState();
 }
 
   return resource->getState();
 }
 
-surf_action_t surf_workstation_sleep(surf_workstation_t resource, double duration){
-  return ((surf_workstation_CLM03_t)surf_workstation_resource_priv(resource))->sleep(duration);
+surf_action_t surf_workstation_sleep(surf_resource_t resource, double duration){
+  return get_casted_workstation(resource)->sleep(duration);
 }
 
 }
 
-double surf_workstation_get_speed(surf_workstation_t resource, double load){
-  return ((surf_workstation_CLM03_t)surf_workstation_resource_priv(resource))->getSpeed(load);
+double surf_workstation_get_speed(surf_resource_t resource, double load){
+  return get_casted_workstation(resource)->getSpeed(load);
 }
 
 }
 
-double surf_workstation_get_available_speed(surf_workstation_t resource){
-  return ((surf_workstation_CLM03_t)surf_workstation_resource_priv(resource))->getAvailableSpeed();
+double surf_workstation_get_available_speed(surf_resource_t resource){
+  return get_casted_workstation(resource)->getAvailableSpeed();
 }
 
 }
 
-int surf_workstation_get_core(surf_workstation_t resource){
-  return ((surf_workstation_CLM03_t)surf_workstation_resource_priv(resource))->getCore();
+int surf_workstation_get_core(surf_resource_t resource){
+  return get_casted_workstation(resource)->getCore();
 }
 
 }
 
-surf_action_t surf_workstation_execute(surf_workstation_t resource, double size){
-  return ((surf_workstation_CLM03_t)surf_workstation_resource_priv(resource))->execute(size);
+surf_action_t surf_workstation_execute(surf_resource_t resource, double size){
+  return get_casted_workstation(resource)->execute(size);
 }
 
 }
 
-surf_action_t surf_workstation_communicate(surf_workstation_t workstation_src, surf_workstation_t workstation_dst, double size, double rate){
-  return surf_workstation_model->communicate((surf_workstation_CLM03_t)surf_workstation_resource_priv(workstation_src),(surf_workstation_CLM03_t)surf_workstation_resource_priv(workstation_dst), size, rate);
+surf_action_t surf_workstation_open(surf_resource_t workstation, const char* mount, const char* path){
+  return get_casted_workstation(workstation)->open(mount, path);
 }
 
 }
 
-surf_action_t surf_workstation_open(surf_workstation_t workstation, const char* mount, const char* path){
-  return ((surf_workstation_CLM03_t)surf_workstation_resource_priv(workstation))->open(mount, path);
+surf_action_t surf_workstation_close(surf_resource_t workstation, surf_file_t fd){
+  return get_casted_workstation(workstation)->close(fd);
 }
 
 }
 
-surf_action_t surf_workstation_close(surf_workstation_t workstation, surf_file_t fd){
-  return ((surf_workstation_CLM03_t)surf_workstation_resource_priv(workstation))->close(fd);
+int surf_workstation_unlink(surf_resource_t workstation, surf_file_t fd){
+  return get_casted_workstation(workstation)->unlink(fd);
 }
 
 }
 
-int surf_workstation_unlink(surf_workstation_t workstation, surf_file_t fd){
-  return ((surf_workstation_CLM03_t)surf_workstation_resource_priv(workstation))->unlink(fd);
+surf_action_t surf_workstation_ls(surf_resource_t workstation, const char* mount, const char *path){
+  return get_casted_workstation(workstation)->ls(mount, path);
 }
 
 }
 
-surf_action_t surf_workstation_ls(surf_workstation_t workstation, const char* mount, const char *path){
-  return ((surf_workstation_CLM03_t)surf_workstation_resource_priv(workstation))->ls(mount, path);
+size_t surf_workstation_get_size(surf_resource_t workstation, surf_file_t fd){
+  return get_casted_workstation(workstation)->getSize(fd);
 }
 
 }
 
-size_t surf_workstation_get_size(surf_workstation_t workstation, surf_file_t fd){
-  return ((surf_workstation_CLM03_t)surf_workstation_resource_priv(workstation))->getSize(fd);
+surf_action_t surf_workstation_read(surf_resource_t resource, void *ptr, size_t size, surf_file_t fd){
+  return get_casted_workstation(resource)->read(ptr, size, fd);
 }
 
 }
 
-surf_action_t surf_workstation_read(surf_workstation_t resource, void *ptr, size_t size, surf_file_t fd){
-  return ((surf_workstation_CLM03_t)surf_workstation_resource_priv(resource))->read(ptr, size, fd);
-}
-
-surf_action_t surf_workstation_write(surf_workstation_t resource, const void *ptr, size_t size, surf_file_t fd){
-  return ((surf_workstation_CLM03_t)surf_workstation_resource_priv(resource))->write(ptr, size, fd);
+surf_action_t surf_workstation_write(surf_resource_t resource, const void *ptr, size_t size, surf_file_t fd){
+  return get_casted_workstation(resource)->write(ptr, size, fd);
 }
 
 int surf_network_link_is_shared(surf_network_link_t link){
 }
 
 int surf_network_link_is_shared(surf_network_link_t link){
@@ -309,16 +313,12 @@ double surf_network_link_get_latency(surf_network_link_t link){
   return link->getLatency();
 }
 
   return link->getLatency();
 }
 
-const char *surf_cpu_name(surf_cpu_t resource){
-  return resource->m_name;
-}
-
-surf_action_t surf_cpu_execute(surf_cpu_t cpu, double size){
-  return cpu->execute(size);
+surf_action_t surf_cpu_execute(surf_resource_t cpu, double size){
+  return get_casted_cpu(cpu)->execute(size);
 }
 
 }
 
-surf_action_t surf_cpu_sleep(surf_cpu_t cpu, double duration){
-  return cpu->sleep(duration);
+surf_action_t surf_cpu_sleep(surf_resource_t cpu, double duration){
+  return get_casted_cpu(cpu)->sleep(duration);
 }
 
 double surf_action_get_start_time(surf_action_t action){
 }
 
 double surf_action_get_start_time(surf_action_t action){
index 9358cd3..12ecc7a 100644 (file)
+/* Copyright (c) 2009, 2010, 2011. The SimGrid Team.
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "surf_routing_cluster.hpp"
 #include "surf_routing_private.h"
 
 extern "C" {
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf");
 }
 
 #include "surf_routing_private.h"
 
 extern "C" {
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf");
 }
 
+/* This routing is specifically setup to represent clusters, aka homogeneous sets of machines
+ * Note that a router is created, easing the interconnexion with the rest of the world.
+ */
+
 AS_t model_cluster_create(void)
 {
 AS_t model_cluster_create(void)
 {
-//FIXME:
+  return new AsCluster();
+}
+
+/* Creation routing model functions */
+AsCluster::AsCluster() : AsNone()
+{
+  /*result->get_route_and_latency = cluster_get_route_and_latency;
+  result->finalize = model_cluster_finalize;
+  result->get_graph = cluster_get_graph;
+  result->parse_AS = cluster_parse_AS;
+  result->parse_PU = cluster_parse_PU;*/
+}
+
+/* Business methods */
+void AsCluster::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t route, double *lat)
+{
+  s_surf_parsing_link_up_down_t info;
+  XBT_VERB("cluster_get_route_and_latency from '%s'[%d] to '%s'[%d]",
+            src->p_name, src->m_id, dst->p_name, dst->m_id);
+
+  if (src->p_rcType != SURF_NETWORK_ELEMENT_ROUTER) {    // No specific link for router
+    info = xbt_dynar_get_as(p_linkUpDownList, src->m_id, s_surf_parsing_link_up_down_t);
+
+    if((src->m_id == dst->m_id) && info.loopback_link  ){
+      xbt_dynar_push_as(route->link_list, void *, info.loopback_link);
+      if (lat)
+        *lat += static_cast<NetworkCm02LinkPtr>(info.loopback_link)->getLatency();
+      return;
+    }
+
+
+    if (info.limiter_link)          // limiter for sender
+      xbt_dynar_push_as(route->link_list, void *, info.limiter_link);
+
+    if (info.link_up) {         // link up
+      xbt_dynar_push_as(route->link_list, void *, info.link_up);
+      if (lat)
+        *lat += static_cast<NetworkCm02LinkPtr>(info.link_up)->getLatency();
+    }
+  }
+
+  if (p_backbone) {
+    xbt_dynar_push_as(route->link_list, void *, p_backbone);
+    if (lat)
+      *lat += static_cast<NetworkCm02LinkPtr>(p_backbone)->getLatency();
+  }
+
+  if (dst->p_rcType != SURF_NETWORK_ELEMENT_ROUTER) {    // No specific link for router
+    info =
+        xbt_dynar_get_as(p_linkUpDownList, dst->m_id, s_surf_parsing_link_up_down_t);
+    if (info.link_down) {       // link down
+      xbt_dynar_push_as(route->link_list, void *, info.link_down);
+      if (lat)
+        *lat += static_cast<NetworkCm02LinkPtr>(info.link_down)->getLatency();
+    }
+
+    if (info.limiter_link)          // limiter for receiver
+      xbt_dynar_push_as(route->link_list, void *, info.limiter_link);
+
+  }
+}
+
+void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
+{
+  int isrc;
+  int table_size = xbt_dynar_length(p_indexNetworkElm);
+
+  RoutingEdgePtr src;
+  xbt_node_t current, previous, backboneNode = NULL, routerNode;
+  s_surf_parsing_link_up_down_t info;
+
+  xbt_assert(p_router,"Malformed cluster");
+
+  /* create the router */
+  char *link_name = p_router->p_name;
+  routerNode = new_xbt_graph_node(graph, link_name, nodes);
+
+  if(p_backbone) {
+    const char *link_nameR = p_backbone->m_name;
+    backboneNode = new_xbt_graph_node(graph, link_nameR, nodes);
+
+    new_xbt_graph_edge(graph, routerNode, backboneNode, edges);
+  }
+
+  for (isrc = 0; isrc < table_size; isrc++) {
+    src = xbt_dynar_get_as(p_indexNetworkElm, isrc, RoutingEdgePtr);
+
+    if (src->p_rcType != SURF_NETWORK_ELEMENT_ROUTER) {
+      previous = new_xbt_graph_node(graph, src->p_name, nodes);
+
+      info = xbt_dynar_get_as(p_linkUpDownList, src->m_id, s_surf_parsing_link_up_down_t);
+
+      if (info.link_up) {     // link up
+
+        const char *link_name = ((ResourcePtr) info.link_up)->m_name;
+        current = new_xbt_graph_node(graph, link_name, nodes);
+        new_xbt_graph_edge(graph, previous, current, edges);
+
+        if (p_backbone) {
+          new_xbt_graph_edge(graph, current, backboneNode, edges);
+        } else {
+          new_xbt_graph_edge(graph, current, routerNode, edges);
+        }
+
+      }
+
+      if (info.link_down) {    // link down
+        const char *link_name = ((ResourcePtr) info.link_down)->m_name;
+        current = new_xbt_graph_node(graph, link_name, nodes);
+        new_xbt_graph_edge(graph, previous, current, edges);
+
+        if (p_backbone) {
+          new_xbt_graph_edge(graph, current, backboneNode, edges);
+        } else {
+          new_xbt_graph_edge(graph, current, routerNode, edges);
+        }
+      }
+    }
+
+  }
+}
+
+int AsCluster::parsePU(RoutingEdgePtr elm) {
+  XBT_DEBUG("Load process unit \"%s\"", elm->p_name);
+  xbt_dynar_push_as(p_indexNetworkElm, RoutingEdgePtr, elm);
+  return xbt_dynar_length(p_indexNetworkElm)-1;
+}
+
+int AsCluster::parseAS(RoutingEdgePtr elm) {
+  XBT_DEBUG("Load Autonomous system \"%s\"", elm->p_name);
+  xbt_dynar_push_as(p_indexNetworkElm, RoutingEdgePtr, elm);
+  return xbt_dynar_length(p_indexNetworkElm)-1;
 }
 }
+
+
diff --git a/src/surf/surf_routing_cluster.hpp b/src/surf/surf_routing_cluster.hpp
new file mode 100644 (file)
index 0000000..c3e8871
--- /dev/null
@@ -0,0 +1,44 @@
+#include "surf_routing_none.hpp"
+#include "network.hpp"
+
+#ifndef SURF_ROUTING_CLUSTER_HPP_
+#define SURF_ROUTING_CLUSTER_HPP_
+
+/***********
+ * Classes *
+ ***********/
+class AsCluster;
+typedef AsCluster *AsClusterPtr;
+
+
+/* ************************************************** */
+/* **************  Cluster ROUTING   **************** */
+
+class AsCluster: public AsNone {
+public:
+  AsCluster();
+
+  void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
+  //xbt_dynar_t getOneLinkRoutes();
+  //void parseRoute(sg_platf_route_cbarg_t route);
+  //void parseASroute(sg_platf_route_cbarg_t route);
+
+  void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
+  //sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat);
+
+  /* The parser calls the following functions to inform the routing models
+   * that a new element is added to the AS currently built.
+   *
+   * Of course, only the routing model of this AS is informed, not every ones */
+  int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */
+  int parseAS(RoutingEdgePtr elm);
+
+  //virtual void parseBypassroute(sg_platf_route_cbarg_t e_route)=0;
+
+  NetworkCm02LinkPtr p_backbone;
+  void *p_loopback;
+  RoutingEdgePtr p_router;
+};
+
+
+#endif /* SURF_ROUTING_CLUSTER_HPP_ */
index f820a32..e3500c7 100644 (file)
@@ -15,7 +15,6 @@ public:
 
   AsFull();
   ~AsFull();
 
   AsFull();
   ~AsFull();
-  int test(){return 1;};
 
   void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
   xbt_dynar_t getOneLinkRoutes();
 
   void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
   xbt_dynar_t getOneLinkRoutes();
index 756460b..7c99e58 100644 (file)
@@ -10,7 +10,6 @@ class AsGeneric : public AsNone {
 public:
   AsGeneric();
   ~AsGeneric();
 public:
   AsGeneric();
   ~AsGeneric();
-  int test(){return 2;};
 
   virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
   virtual xbt_dynar_t getOneLinkRoutes();
 
   virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
   virtual xbt_dynar_t getOneLinkRoutes();
index 59ae1e6..7673961 100644 (file)
@@ -64,14 +64,6 @@ AsPtr model_floyd_create(void);  /* create structures for floyd routing model */
 void model_floyd_end(AsPtr as);      /* finalize the creation of floyd routing model */
 void model_floyd_parse_route(AsPtr rc, sg_platf_route_cbarg_t route);
 
 void model_floyd_end(AsPtr as);      /* finalize the creation of floyd routing model */
 void model_floyd_parse_route(AsPtr rc, sg_platf_route_cbarg_t route);
 
-/* ************************************************** */
-/* **************  Cluster ROUTING   **************** */
-class AsCluster : public As {
-  void *p_backbone;
-  void *p_loopback;
-  RoutingEdgePtr router;
-};
-
 AsPtr model_cluster_create(void);      /* create structures for cluster routing model */
 
 /* ************************************************** */
 AsPtr model_cluster_create(void);      /* create structures for cluster routing model */
 
 /* ************************************************** */
index 763323b..069500c 100644 (file)
@@ -61,9 +61,9 @@ WorkstationCLM03Ptr WorkstationModel::createResource(string name){
   WorkstationCLM03Ptr workstation = new WorkstationCLM03(surf_workstation_model, name.c_str(), NULL,
                  (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name.c_str(), ROUTING_STORAGE_HOST_LEVEL),
                  (RoutingEdgePtr)xbt_lib_get_or_null(host_lib, name.c_str(), ROUTING_HOST_LEVEL),
   WorkstationCLM03Ptr workstation = new WorkstationCLM03(surf_workstation_model, name.c_str(), NULL,
                  (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name.c_str(), ROUTING_STORAGE_HOST_LEVEL),
                  (RoutingEdgePtr)xbt_lib_get_or_null(host_lib, name.c_str(), ROUTING_HOST_LEVEL),
-                 (CpuPtr)xbt_lib_get_or_null(host_lib, name.c_str(), SURF_CPU_LEVEL));
+                 dynamic_cast<CpuPtr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(host_lib, name.c_str(), SURF_CPU_LEVEL))));
   XBT_DEBUG("Create workstation %s with %ld mounted disks", name.c_str(), xbt_dynar_length(workstation->p_storage));
   XBT_DEBUG("Create workstation %s with %ld mounted disks", name.c_str(), xbt_dynar_length(workstation->p_storage));
-  xbt_lib_set(host_lib, name.c_str(), SURF_WKS_LEVEL, workstation);
+  xbt_lib_set(host_lib, name.c_str(), SURF_WKS_LEVEL, static_cast<ResourcePtr>(workstation));
   return workstation;
 }
 
   return workstation;
 }
 
@@ -116,7 +116,7 @@ xbt_dynar_t WorkstationModel::getRoute(WorkstationCLM03Ptr src, WorkstationCLM03
 }
 
 ActionPtr WorkstationModel::communicate(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst, double size, double rate){
 }
 
 ActionPtr WorkstationModel::communicate(WorkstationCLM03Ptr src, WorkstationCLM03Ptr dst, double size, double rate){
-  surf_network_model->communicate(src->p_netElm, dst->p_netElm, size, rate);
+  return surf_network_model->communicate(src->p_netElm, dst->p_netElm, size, rate);
 }
 
 
 }
 
 
index 8b2688c..4bf426f 100644 (file)
@@ -275,7 +275,7 @@ WorkstationCLM03Ptr WorkstationL07Model::createCpuResource(const char *name, dou
       lmm_constraint_new(ptask_maxmin_system, cpu,
                          cpu->m_powerCurrent * cpu->p_power.scale);
 
       lmm_constraint_new(ptask_maxmin_system, cpu,
                          cpu->m_powerCurrent * cpu->p_power.scale);
 
-  xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, cpu);
+  xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, static_cast<ResourcePtr>(cpu));
 
   return cpu;//FIXME:xbt_lib_get_elm_or_null(host_lib, name);
 }
 
   return cpu;//FIXME:xbt_lib_get_elm_or_null(host_lib, name);
 }
index fd40b25..ab011c2 100644 (file)
@@ -63,13 +63,13 @@ void test(char *platform)
   cpuB = surf_cpu_resource_by_name("Cpu B");
 
   /* Let's check that those two processors exist */
   cpuB = surf_cpu_resource_by_name("Cpu B");
 
   /* Let's check that those two processors exist */
-  XBT_DEBUG("%s : %p", surf_cpu_name(surf_cpu_resource_priv(cpuA)), cpuA);
-  XBT_DEBUG("%s : %p", surf_cpu_name(surf_cpu_resource_priv(cpuB)), cpuB);
-  surf_cpu_resource_priv(cpuA);
+  XBT_DEBUG("%s : %p", surf_resource_name(surf_cpu_resource_priv(cpuA)), cpuA);
+  XBT_DEBUG("%s : %p", surf_resource_name(surf_cpu_resource_priv(cpuB)), cpuB);
+
   /* Let's do something on it */
   /* Let's do something on it */
-  actionA = surf_cpu_execute(surf_cpu_resource_priv(cpuA), 1000.0);
-  actionB = surf_cpu_execute(surf_cpu_resource_priv(cpuB), 1000.0);
-  actionC = surf_cpu_sleep(surf_cpu_resource_priv(cpuB), 7.32);
+  actionA = surf_cpu_execute(cpuA, 1000.0);
+  actionB = surf_cpu_execute(cpuB, 1000.0);
+  actionC = surf_cpu_sleep(cpuB, 7.32);
 
   /* Use whatever calling style you want... */
   stateActionA = surf_action_get_state(actionA);     /* When you know actionA model type */
 
   /* Use whatever calling style you want... */
   stateActionA = surf_action_get_state(actionA);     /* When you know actionA model type */