From: Pedro Velho Date: Thu, 23 Feb 2012 00:46:57 +0000 (-0200) Subject: Started the gpu model by adding the MSG_gpu_task_create function, also added a simple... X-Git-Tag: exp_20120308~23^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/28e551b6fecfd104b32673d6a420fbd997f20539 Started the gpu model by adding the MSG_gpu_task_create function, also added a simple test file test_MSG_gpu_task_create.c to test this functionallity. --- diff --git a/buildtools/Cmake/MakeExe.cmake b/buildtools/Cmake/MakeExe.cmake index 7857a74c11..5ad1fddeb0 100644 --- a/buildtools/Cmake/MakeExe.cmake +++ b/buildtools/Cmake/MakeExe.cmake @@ -61,6 +61,8 @@ add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/pmm) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/io) +add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/gpu) + if(HAVE_TRACING) add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/msg/tracing) endif(HAVE_TRACING) diff --git a/examples/msg/gpu/CMakeLists.txt b/examples/msg/gpu/CMakeLists.txt new file mode 100644 index 0000000000..c09c79482b --- /dev/null +++ b/examples/msg/gpu/CMakeLists.txt @@ -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 index 0000000000..05d34bfc88 --- /dev/null +++ b/examples/msg/gpu/test_MSG_gpu_task_create.c @@ -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 +#include +#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 */ diff --git a/include/msg/datatypes.h b/include/msg/datatypes.h index 70d1d302db..099e21fe25 100644 --- a/include/msg/datatypes.h +++ b/include/msg/datatypes.h @@ -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 task may then be defined by a computing + amount, a dispatch latency and a collect latency. + \see m_task_management + @{ */ +typedef struct m_gpu_task *m_gpu_task_t; +/*************** End GPU ***************/ + /** * \brief @brief Communication action * \ingroup m_datatypes_management diff --git a/include/msg/msg.h b/include/msg/msg.h index 07dcf2c527..8eafcb667b 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -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, diff --git a/src/msg/msg_private.h b/src/msg/msg_private.h index b45fd87399..3934c2c213 100644 --- a/src/msg/msg_private.h +++ b/src/msg/msg_private.h @@ -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 { diff --git a/src/msg/msg_task.c b/src/msg/msg_task.c index 6698d82373..8f4e7fd122 100644 --- a/src/msg/msg_task.c +++ b/src/msg/msg_task.c @@ -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. *