Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use a mallocator for SIMIX actions
[simgrid.git] / src / simix / smx_user.c
index 91921ef..5fd7b60 100644 (file)
@@ -279,7 +279,7 @@ void SIMIX_req_host_execution_set_priority(smx_action_t execution, double priori
 }
 
 /**
- * \brief Waits for the completion of an execution action.
+ * \brief Waits for the completion of an execution action and destroy it.
  *
  * \param execution The execution action
  */
@@ -296,8 +296,9 @@ e_smx_state_t SIMIX_req_host_execution_wait(smx_action_t execution)
 /**
  * \brief Creates and runs a new SIMIX process.
  *
- * The structure and the corresponding threada are created and put in the list of ready processes.
+ * The structure and the corresponding thread are created and put in the list of ready processes.
  *
+ * \param process the process created will be stored in this pointer
  * \param name a name for the process. It is for user-level information and can be NULL.
  * \param code the main function of the process
  * \param data a pointer to any data one may want to attach to the new object. It is for user-level information and can be NULL.
@@ -306,18 +307,18 @@ e_smx_state_t SIMIX_req_host_execution_wait(smx_action_t execution)
  * \param argc first argument passed to \a code
  * \param argv second argument passed to \a code
  * \param properties the properties of the process
- * \return The new process
  */
-smx_process_t SIMIX_req_process_create(const char *name,
-                                   xbt_main_func_t code,
-                                   void *data,
-                                   const char *hostname,
-                                   int argc, char **argv,
-                                   xbt_dict_t properties)
+void SIMIX_req_process_create(smx_process_t *process, const char *name,
+                              xbt_main_func_t code,
+                              void *data,
+                              const char *hostname,
+                              int argc, char **argv,
+                              xbt_dict_t properties)
 {
   smx_req_t req = SIMIX_req_mine();
 
   req->call = REQ_PROCESS_CREATE;
+  req->process_create.process = process;
   req->process_create.name = name;
   req->process_create.code = code;
   req->process_create.data = data;
@@ -326,7 +327,6 @@ smx_process_t SIMIX_req_process_create(const char *name,
   req->process_create.argv = argv;
   req->process_create.properties = properties;
   SIMIX_request_push();
-  return req->process_create.result;
 }
 
 /** \brief Kills a SIMIX process.
@@ -374,6 +374,8 @@ void SIMIX_req_process_change_host(smx_process_t process, const char *source, co
  */
 void SIMIX_req_process_suspend(smx_process_t process)
 {
+  xbt_assert0(process, "Invalid parameters");
+
   smx_req_t req = SIMIX_req_mine();
 
   req->call = REQ_PROCESS_SUSPEND;
@@ -565,12 +567,18 @@ void SIMIX_req_rdv_destroy(smx_rdv_t rdv)
 smx_rdv_t SIMIX_req_rdv_get_by_name(const char *name)
 {
   xbt_assert0(name != NULL, "Invalid parameter for SIMIX_req_rdv_get_by_name (name is NULL)");
-  smx_req_t req = SIMIX_req_mine();
 
+  /* FIXME: this is a horrible lost of performance, so we hack it out by
+   * skipping the request (for now). It won't work on distributed but
+   * probably we will change MSG for that. */
+/*
+  smx_req_t req = SIMIX_req_mine();
   req->call = REQ_RDV_GEY_BY_NAME;
   req->rdv_get_by_name.name = name;
   SIMIX_request_push();
-  return req->rdv_get_by_name.result;
+  return req->rdv_get_by_name.result;*/
+
+  return SIMIX_rdv_get_by_name(name);
 }
 
 /**
@@ -610,7 +618,8 @@ smx_action_t SIMIX_req_rdv_get_head(smx_rdv_t rdv)
 
 smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
                               void *src_buff, size_t src_buff_size,
-                              int (*match_fun)(void *, void *), void *data)
+                              int (*match_fun)(void *, void *), void *data,
+                              int detached)
 {
   smx_req_t req = SIMIX_req_mine();
 
@@ -624,6 +633,7 @@ smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
   req->comm_isend.src_buff_size = src_buff_size;
   req->comm_isend.match_fun = match_fun;
   req->comm_isend.data = data;
+  req->comm_isend.detached = detached;
 
   SIMIX_request_push();
   return req->comm_isend.result;
@@ -649,12 +659,19 @@ smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_bu
 
 void SIMIX_req_comm_destroy(smx_action_t comm)
 {
+  xbt_assert0(comm, "Invalid parameter");
+
+  /* FIXME remove this request type: comms are auto-destroyed now,
+   * but what happens with unfinished comms? */
+
+  /*
   smx_req_t req = SIMIX_req_mine();
 
   req->call = REQ_COMM_DESTROY;
   req->comm_destroy.comm = comm;
 
   SIMIX_request_push();
+  */
 }
 
 void SIMIX_req_comm_cancel(smx_action_t comm)
@@ -781,50 +798,6 @@ void *SIMIX_req_comm_get_dst_data(smx_action_t comm)
   return req->comm_get_dst_data.result;
 }
 
-void *SIMIX_req_comm_get_src_buff(smx_action_t comm)
-{
-  smx_req_t req = SIMIX_req_mine();
-
-  req->call = REQ_COMM_GET_SRC_BUFF;
-  req->comm_get_src_buff.comm = comm;
-
-  SIMIX_request_push();
-  return req->comm_get_src_buff.result;
-}
-
-void *SIMIX_req_comm_get_dst_buff(smx_action_t comm)
-{
-  smx_req_t req = SIMIX_req_mine();
-
-  req->call = REQ_COMM_GET_DST_BUFF;
-  req->comm_get_dst_buff.comm = comm;
-
-  SIMIX_request_push();
-  return req->comm_get_dst_buff.result;
-}
-
-size_t SIMIX_req_comm_get_src_buff_size(smx_action_t comm)
-{
-  smx_req_t req = SIMIX_req_mine();
-
-  req->call = REQ_COMM_GET_SRC_BUFF_SIZE;
-  req->comm_get_src_buff_size.comm = comm;
-
-  SIMIX_request_push();
-  return req->comm_get_src_buff_size.result;
-}
-
-size_t SIMIX_req_comm_get_dst_buff_size(smx_action_t comm)
-{
-  smx_req_t req = SIMIX_req_mine();
-
-  req->call = REQ_COMM_GET_DST_BUFF_SIZE;
-  req->comm_get_dst_buff_size.comm = comm;
-
-  SIMIX_request_push();
-  return req->comm_get_dst_buff_size.result;
-}
-
 smx_process_t SIMIX_req_comm_get_src_proc(smx_action_t comm)
 {
   smx_req_t req = SIMIX_req_mine();