Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Started the gpu model by adding the MSG_gpu_task_create function, also added a simple...
authorPedro Velho <pedro.velho@gmail.com>
Thu, 23 Feb 2012 00:46:57 +0000 (22:46 -0200)
committerPedro Velho <pedro.velho@gmail.com>
Thu, 23 Feb 2012 15:31:12 +0000 (13:31 -0200)
buildtools/Cmake/MakeExe.cmake
examples/msg/gpu/CMakeLists.txt [new file with mode: 0644]
examples/msg/gpu/test_MSG_gpu_task_create.c [new file with mode: 0644]
include/msg/datatypes.h
include/msg/msg.h
src/msg/msg_private.h
src/msg/msg_task.c

index 7857a74..5ad1fdd 100644 (file)
@@ -61,6 +61,8 @@ add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/pmm)
 \r
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/io)\r
 \r
+add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/gpu)\r
+\r
 if(HAVE_TRACING)\r
     add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/tracing)\r
 endif(HAVE_TRACING)\r
diff --git a/examples/msg/gpu/CMakeLists.txt b/examples/msg/gpu/CMakeLists.txt
new file mode 100644 (file)
index 0000000..c09c794
--- /dev/null
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 2.6)
+
+set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
+
+add_executable(test_MSG_gpu_task_create "test_MSG_gpu_task_create.c")
+
+### Add definitions for compile
+target_link_libraries(test_MSG_gpu_task_create simgrid m )
+
diff --git a/examples/msg/gpu/test_MSG_gpu_task_create.c b/examples/msg/gpu/test_MSG_gpu_task_create.c
new file mode 100644 (file)
index 0000000..05d34bf
--- /dev/null
@@ -0,0 +1,36 @@
+/* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* 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 <stdio.h>
+#include <stdlib.h>
+#include "msg/msg.h"
+#include "xbt/log.h"
+#include "xbt/asserts.h"
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test,
+                             "Messages specific for GPU msg example");
+
+
+/** Main function */
+int main(int argc, char *argv[])
+{
+  MSG_error_t res = MSG_OK;
+
+  MSG_global_init(&argc, argv);
+
+  m_gpu_task_t mytask = NULL;
+
+  mytask = MSG_gpu_task_create("testTask", 2000.0, 20.0, 20.0);
+
+
+
+  MSG_clean();
+
+  if (res == MSG_OK)
+    return 0;
+  else
+    return 1;
+}                               /* end_of_main */
index 70d1d30..099e21f 100644 (file)
@@ -78,6 +78,31 @@ typedef struct m_task {
   @{ */
 typedef struct m_task *m_task_t;
 
+
+/*************** Begin GPU ***************/
+typedef struct simdata_gpu_task *simdata_gpu_task_t;
+
+/** @brief GPU task datatype
+    @ingroup m_datatypes_management_details */
+typedef struct m_gpu_task {
+  char *name;                   /**< @brief task name if any */
+  simdata_gpu_task_t simdata;       /**< @brief simulator data */
+#ifdef HAVE_TRACING
+  long long int counter;        /* task unique identifier for instrumentation */
+  char *category;               /* task category for instrumentation */
+#endif
+} s_m_gpu_task_t;
+
+/** @brief GPU task datatype
+    @ingroup m_datatypes_management
+
+    A <em>task</em> may then be defined by a <em>computing
+    amount</em>, a <em>dispatch latency</em> and a <em>collect latency</em>.
+    \see m_task_management
+  @{ */
+typedef struct m_gpu_task *m_gpu_task_t;
+/*************** End GPU ***************/
+
 /**
  * \brief @brief Communication action
  * \ingroup m_datatypes_management
index 07dcf2c..8eafcb6 100644 (file)
@@ -120,6 +120,10 @@ XBT_PUBLIC(int) MSG_process_is_suspended(m_process_t process);
 XBT_PUBLIC(m_task_t) MSG_task_create(const char *name,
                                      double compute_duration,
                                      double message_size, void *data);
+XBT_PUBLIC(m_gpu_task_t) MSG_gpu_task_create(const char *name,
+                                     double compute_duration,
+                                     double dispatch_latency,
+                                     double collect_latency);
 XBT_PUBLIC(m_task_t) MSG_parallel_task_create(const char *name,
                                               int host_nb,
                                               const m_host_t * host_list,
index b45fd87..3934c2c 100644 (file)
@@ -45,6 +45,16 @@ typedef struct simdata_task {
   double *comm_amount;
 } s_simdata_task_t;
 
+
+/*************** Begin GPU ***************/
+typedef struct simdata_gpu_task {
+  double computation_amount;    /* Computation size */
+  double dispatch_latency;
+  double collect_latency;
+  int isused;  /* Indicates whether the task is used in SIMIX currently */
+} s_simdata_gpu_task_t;
+/*************** End GPU ***************/
+
 /******************************* Process *************************************/
 
 typedef struct simdata_process {
index 6698d82..8f4e7fd 100644 (file)
@@ -78,6 +78,51 @@ m_task_t MSG_task_create(const char *name, double compute_duration,
   return task;
 }
 
+/*************** Begin GPU ***************/
+/** \ingroup m_task_management
+ * \brief Creates a new #m_gpu_task_t.
+
+ * A constructor for #m_gpu_task_t taking four arguments and returning
+   a pointer to the new created GPU task.
+
+ * \param name a name for the object. It is for user-level information
+   and can be NULL.
+
+ * \param compute_duration a value of the processing amount (in flop)
+   needed to process this new task. If 0, then it cannot be executed with
+   MSG_gpu_task_execute(). This value has to be >=0.
+
+ * \param dispatch_latency time in seconds to load this task on the GPU
+
+ * \param collect_latency time in seconds to transfer result from the GPU
+   back to the CPU (host) when done
+
+ * \see m_gpu_task_t
+ * \return The new corresponding object.
+ */
+m_gpu_task_t MSG_gpu_task_create(const char *name, double compute_duration,
+                         double dispatch_latency, double collect_latency)
+{
+  m_gpu_task_t task = xbt_new(s_m_gpu_task_t, 1);
+  simdata_gpu_task_t simdata = xbt_new(s_simdata_gpu_task_t, 1);
+  task->simdata = simdata;
+  /* Task structure */
+  task->name = xbt_strdup(name);
+
+  /* Simulator Data */
+  simdata->computation_amount = compute_duration;
+  simdata->dispatch_latency   = dispatch_latency;
+  simdata->collect_latency    = collect_latency;
+
+#ifdef HAVE_TRACING
+  //FIXME
+  TRACE_msg_gpu_task_create(task);
+#endif
+
+  return task;
+}
+/*************** End GPU ***************/
+
 /** \ingroup m_task_management
  * \brief Return the user data of a #m_task_t.
  *