Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add the MSG function controlling CPU affinity
authorTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Thu, 24 Oct 2013 10:15:55 +0000 (12:15 +0200)
committerTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Thu, 24 Oct 2013 10:15:55 +0000 (12:15 +0200)
include/msg/msg.h
src/msg/msg_gos.c
src/msg/msg_private.h
src/msg/msg_task.c

index 73123a7..bda2f18 100644 (file)
@@ -215,6 +215,7 @@ XBT_PUBLIC(msg_error_t) MSG_task_execute(msg_task_t task);
 XBT_PUBLIC(msg_error_t) MSG_parallel_task_execute(msg_task_t task);
 XBT_PUBLIC(void) MSG_task_set_priority(msg_task_t task, double priority);
 XBT_PUBLIC(void) MSG_task_set_bound(msg_task_t task, double bound);
+XBT_PUBLIC(void) MSG_task_set_affinity(msg_task_t task, msg_host_t host, unsigned long mask);
 
 XBT_PUBLIC(msg_error_t) MSG_process_sleep(double nb_sec);
 
index e8112ed..8042c21 100644 (file)
@@ -86,7 +86,9 @@ msg_error_t MSG_parallel_task_execute(msg_task_t task)
                                               p_simdata->m_host,
                                               simdata->computation_amount,
                                               simdata->priority,
-                                              simdata->bound);
+                                              simdata->bound,
+                                              simdata->affinity_mask
+                                              );
 
     }
 #ifdef HAVE_TRACING
index 109ebbc..611a026 100644 (file)
@@ -33,6 +33,7 @@ typedef struct simdata_task {
   double priority;
   double bound; /* Capping for CPU resource */
   double rate;  /* Capping for network resource */
+  unsigned long affinity_mask; /* CPU affinity */
   int isused;  /* Indicates whether the task is used in SIMIX currently */
   int host_nb;                  /* ==0 if sequential task; parallel task if not */
   /*******  Parallel Tasks Only !!!! *******/
index d95b180..a35198a 100644 (file)
@@ -63,6 +63,7 @@ msg_task_t MSG_task_create(const char *name, double compute_duration,
   simdata->source = NULL;
   simdata->priority = 1.0;
   simdata->bound = 0;
+  simdata->affinity_mask = 0;
   simdata->rate = -1.0;
   simdata->isused = 0;
 
@@ -460,3 +461,18 @@ void MSG_task_set_bound(msg_task_t task, double bound)
     simcall_host_execution_set_bound(task->simdata->compute,
                                       task->simdata->bound);
 }
+
+
+/** \ingroup m_task_management
+ * \brief Changes the CPU affinity of a computation task.
+ *
+ */
+void MSG_task_set_affinity(msg_task_t task, msg_host_t host, unsigned long mask)
+{
+  xbt_assert(task, "Invalid parameter");
+  xbt_assert(task->simdata, "Invalid parameter");
+
+  task->simdata->affinity_mask = mask;
+  if (task->simdata->compute)
+    simcall_host_execution_set_affinity(task->simdata->compute, host, mask);
+}