Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
implement simix_comm_testany properly
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 7 Dec 2010 12:16:38 +0000 (12:16 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 7 Dec 2010 12:16:38 +0000 (12:16 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9053 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/simix/network_private.h
src/simix/smurf_private.h
src/simix/smx_network.c
src/simix/smx_smurf.c
src/simix/smx_user.c

index 845eba2..721bc91 100644 (file)
@@ -40,6 +40,7 @@ void SIMIX_pre_comm_wait(smx_req_t req);
 void SIMIX_pre_comm_waitany(smx_req_t req);
 void SIMIX_post_comm(smx_action_t action);
 void SIMIX_pre_comm_test(smx_req_t req);
+void SIMIX_pre_comm_testany(smx_req_t req);
 void SIMIX_comm_cancel(smx_action_t action);
 double SIMIX_comm_get_remains(smx_action_t action);
 e_smx_state_t SIMIX_comm_get_state(smx_action_t action);
index 09050f9..c031459 100644 (file)
@@ -50,6 +50,7 @@ typedef enum {
   REQ_COMM_WAITANY,
   REQ_COMM_WAIT,
   REQ_COMM_TEST,
+  REQ_COMM_TESTANY,
   REQ_COMM_GET_REMAINS,
   REQ_COMM_GET_STATE,
   REQ_COMM_GET_DATA,
@@ -311,6 +312,11 @@ typedef struct s_smx_req {
     } comm_test;
 
     struct {
+      xbt_dynar_t comms;
+      int result;
+    } comm_testany;
+
+    struct {
       smx_action_t comm;
       double result;
     } comm_get_remains;
index 3c36832..47e52a0 100644 (file)
@@ -341,6 +341,22 @@ void SIMIX_pre_comm_test(smx_req_t req)
   }
 }
 
+void SIMIX_pre_comm_testany(smx_req_t req)
+{
+  unsigned int cursor;
+  smx_action_t action;
+  req->comm_testany.result = -1;
+  xbt_dynar_foreach(req->comm_testany.comms,cursor,action) {
+    if (action->state != SIMIX_WAITING && action->state != SIMIX_RUNNING) {
+      req->comm_testany.result = cursor;
+      xbt_fifo_push(action->request_list, req);
+      SIMIX_comm_finish(action);
+      break;
+    }
+  }
+  SIMIX_request_answer(req);
+}
+
 void SIMIX_pre_comm_waitany(smx_req_t req)
 {
   smx_action_t action;
index 55d6ba1..b6c476d 100644 (file)
@@ -346,6 +346,10 @@ void SIMIX_request_pre(smx_req_t req)
       SIMIX_pre_comm_test(req);
       break;
 
+    case REQ_COMM_TESTANY:
+      SIMIX_pre_comm_testany(req);
+      break;
+
     case REQ_COMM_GET_REMAINS:
       req->comm_get_remains.result = 
         SIMIX_comm_get_remains(req->comm_get_remains.comm);
index 5f28f0f..cb83fd9 100644 (file)
@@ -667,12 +667,11 @@ int SIMIX_req_comm_testany(xbt_dynar_t comms)
   if (xbt_dynar_length(comms)==0)
     return -1;
 
-  WARN0("SIMIX_comm_testany is not implemented yet. Using waitany instead. This changes the semantic...");
-  req.call = REQ_COMM_WAITANY;
-  req.comm_waitany.comms = comms;
+  req.call = REQ_COMM_TESTANY;
+  req.comm_testany.comms = comms;
 
   SIMIX_request_push(&req);
-  return req.comm_waitany.result;
+  return req.comm_testany.result;
 }
 
 void SIMIX_req_comm_wait(smx_action_t comm, double timeout)