From cd69f8c66886ae218c6a9b38125b27fe157e6bb2 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 1 Nov 2014 22:25:06 +0100 Subject: [PATCH 1/1] Remove the 'TUTORIAL: New API' chunks This loads the code, and I'm not sure that it is of any help, actually. Adding a new API is rather uncommon, and the existing ones are clean enough to serve as an example, nowadays. --- buildtools/Cmake/DefinePackages.cmake | 17 ---- doc/doxygen/inside_extending.doc | 19 ---- include/msg/msg.h | 6 -- include/simgrid/simix.h | 5 - src/msg/msg_new_api.c | 22 ----- src/simix/simcalls.py | 7 -- src/simix/smx_global.c | 7 -- src/simix/smx_new_api.c | 135 -------------------------- src/simix/smx_new_api_private.h | 23 ----- src/simix/smx_popping_generated.c | 6 -- src/simix/smx_popping_generated.h | 1 - src/simix/smx_private.h | 15 --- src/simix/smx_process.c | 14 --- src/simix/smx_smurf.c | 7 -- src/simix/smx_smurf_private.h | 8 -- src/simix/smx_user.c | 25 +---- src/xbt/log.c | 2 - 17 files changed, 5 insertions(+), 314 deletions(-) delete mode 100644 src/msg/msg_new_api.c delete mode 100644 src/simix/smx_new_api.c delete mode 100644 src/simix/smx_new_api_private.h diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index 6c25f4071b..8da0636620 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -402,23 +402,6 @@ set(MSG_SRC src/msg/msg_vm.c ) -#* ****************************************************************************************** *# -#* TUTORIAL: New API *# - -set(MSG_SRC - ${MSG_SRC} - src/msg/msg_new_api.c - ) -set(EXTRA_DIST - ${EXTRA_DIST} - src/simix/smx_new_api_private.h - ) -set(SIMIX_SRC - ${SIMIX_SRC} - src/simix/smx_new_api.c -) -#* ****************************************************************************************** *# - set(SIMDAG_SRC src/simdag/instr_sd_task.c src/simdag/sd_daxloader.c diff --git a/doc/doxygen/inside_extending.doc b/doc/doxygen/inside_extending.doc index ba660ffb93..0f4e1c6c36 100644 --- a/doc/doxygen/inside_extending.doc +++ b/doc/doxygen/inside_extending.doc @@ -3,25 +3,6 @@ \tableofcontents -\section simgrid_dev_guide_api How to add a new MSG function? -Search for expression \"TUTORIAL: New API\". -\verbatim -user@caraja:~/workspace/simgrid/src$ cg "TUTORIAL: New API" - 0 msg/msg_new_api.c 15 /* TUTORIAL: New API*/ - 1 simix/smx_smurf.c 582 /* TUTORIAL: New API*/ - 2 simix/smx_smurf.c 616 /* TUTORIAL: New API*/ - 3 simix/smx_smurf_private.h 102 /* TUTORIAL: New API*/ - 4 simix/smx_smurf_private.h 629 /* TUTORIAL: New API*/ - 5 simix/smx_private.h 28 /* TUTORIAL: New API*/ - 6 simix/smx_private.h 101 /* TUTORIAL: New API*/ - 7 simix/smx_private.h 182 /* TUTORIAL: New API*/ - 8 simix/smx_global.c 454 /* TUTORIAL: New API*/ - 9 simix/smx_new_api.c 8 /* TUTORIAL: New API*/ -10 simix/smx_user.c 1684 /* TUTORIAL: New API*/ -11 simix/smx_new_api_private.h 8 /* TUTORIAL: New API*/ -12 simix/smx_process.c 338 /* TUTORIAL: New API*/ -\endverbatim - \section simgrid_dev_guide_model How to add a new model in surf? The figure below show the architecture of the SURF layer. This layer is composed of different kind of models representing the differents systems we want to diff --git a/include/msg/msg.h b/include/msg/msg.h index 5fceca3e31..55d9b3cde0 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -509,11 +509,5 @@ xbt_dynar_t MSG_vm_get_list_from_hosts(msg_dynar_t) /* Used only by the bindings -- unclean pimple, please ignore if you're not writing a binding */ XBT_PUBLIC(smx_context_t) MSG_process_get_smx_ctx(msg_process_t process); -/* ****************************************************************************************** */ -/* TUTORIAL: New API */ -/* Declare all functions for the API */ -/* ****************************************************************************************** */ -XBT_PUBLIC(int) MSG_new_API_fct(const char* param1, double param2); - SG_END_DECL() #endif diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 42b50d413f..8b54e3742d 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -531,10 +531,5 @@ XBT_PUBLIC(void *) simcall_mc_snapshot(void); XBT_PUBLIC(int) simcall_mc_compare_snapshots(void *s1, void *s2); XBT_PUBLIC(int) simcall_mc_random(int min, int max); -/************************** New API simcalls **********************************/ -/* TUTORIAL: New API */ -/******************************************************************************/ -XBT_PUBLIC(int) simcall_new_api_fct(const char* param1, double param2); - SG_END_DECL() #endif /* _SIMIX_SIMIX_H */ diff --git a/src/msg/msg_new_api.c b/src/msg/msg_new_api.c deleted file mode 100644 index 0bc6ba80e0..0000000000 --- a/src/msg/msg_new_api.c +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (c) 2004-2014. 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 "msg_private.h" -#include "xbt/log.h" - -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_new_API, msg, - "Logging specific to MSG (new_API)"); - - -/* ****************************************************************************************** */ -/* TUTORIAL: New API */ -/* All functions for the API */ -/* ****************************************************************************************** */ -int MSG_new_API_fct(const char* param1, double param2) -{ - int result = simcall_new_api_fct(param1, param2); - return result; -} diff --git a/src/simix/simcalls.py b/src/simix/simcalls.py index 825c1c340b..7781eb337b 100755 --- a/src/simix/simcalls.py +++ b/src/simix/simcalls.py @@ -265,7 +265,6 @@ SIMCALL_NONE, handle(fd, Simcall.enum, simcalls, simcalls_dict) fd.write(""" -SIMCALL_NEW_API_INIT, NUM_SIMCALLS } e_smx_simcall_t; """) @@ -322,12 +321,6 @@ NUM_SIMCALLS fd.write(' );\n'); fd.write(' break;\n'); fd.write('\n'); - fd.write(' /* ****************************************************************************************** */\n'); - fd.write(' /* TUTORIAL: New API */\n'); - fd.write(' /* ****************************************************************************************** */\n'); - fd.write(' case SIMCALL_NEW_API_INIT:\n'); - fd.write(' SIMIX_pre_new_api_fct(simcall);\n'); - fd.write(' break;\n'); fd.write(' }\n'); fd.write('}\n'); diff --git a/src/simix/smx_global.c b/src/simix/smx_global.c index 2ce8738ec1..b9dedde4c4 100644 --- a/src/simix/smx_global.c +++ b/src/simix/smx_global.c @@ -567,13 +567,6 @@ void SIMIX_display_process_status(void) case SIMIX_ACTION_IO: action_description = "I/O"; - break; - /* **************************************/ - /* TUTORIAL: New API */ - case SIMIX_ACTION_NEW_API: - action_description = "NEW API"; - /* **************************************/ - break; } XBT_INFO("Process %lu (%s@%s): waiting for %s action %p (%s) in state %d to finish", diff --git a/src/simix/smx_new_api.c b/src/simix/smx_new_api.c deleted file mode 100644 index f419842277..0000000000 --- a/src/simix/smx_new_api.c +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright (c) 2007-2010, 2012-2014. 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. */ - -/* ****************************************************************************************** */ -/* TUTORIAL: New API */ -/* ****************************************************************************************** */ -#include "smx_private.h" -#include "xbt/sysdep.h" -#include "xbt/log.h" -#include "xbt/dict.h" -#include "mc/mc.h" - -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_new_api, simix, - "Logging specific to SIMIX (new_api)"); - - -//SIMIX NEW MODEL INIT -void SIMIX_pre_new_api_fct(smx_simcall_t simcall) -{ - smx_action_t action = SIMIX_new_api_fct(simcall->issuer, - simcall->new_api.param1, - simcall->new_api.param2); - xbt_fifo_push(action->simcalls, simcall); - simcall->issuer->waiting_action = action; -} - -void SIMIX_post_new_api(smx_action_t action) -{ - xbt_fifo_item_t i; - smx_simcall_t simcall; - - xbt_fifo_foreach(action->simcalls,i,simcall,smx_simcall_t) { - switch (simcall->call) { - case SIMCALL_NEW_API_INIT: - simcall->new_api.result = 0; - break; - - default: - break; - } - } - - switch (surf_action_get_state(action->new_api.surf_new_api)) { - - case SURF_ACTION_FAILED: - action->state = SIMIX_FAILED; - break; - - case SURF_ACTION_DONE: - action->state = SIMIX_DONE; - break; - - default: - THROW_IMPOSSIBLE; - break; - } - - SIMIX_new_api_finish(action); -} - -smx_action_t SIMIX_new_api_fct(smx_process_t process, const char* param1, double param2) -{ - smx_action_t action; - smx_host_t host = process->smx_host; - - /* check if the host is active */ - if (surf_resource_get_state(surf_workstation_resource_priv(host)) != SURF_RESOURCE_ON) { - THROWF(host_error, 0, "Host %s failed, you cannot call this function", - sg_host_name(host)); - } - - action = xbt_mallocator_get(simix_global->action_mallocator); - action->type = SIMIX_ACTION_NEW_API; - action->name = NULL; -#ifdef HAVE_TRACING - action->category = NULL; -#endif - - // Called the function from the new model - //FIXME:CHECK WHAT TO DO action->new_api.surf_new_api = surf_workstation_model->extension.new_model.fct(); - - surf_action_set_data(action->new_api.surf_new_api, action); - XBT_DEBUG("Create NEW MODEL action %p", action); - - return action; -} - -void SIMIX_new_api_destroy(smx_action_t action) -{ - XBT_DEBUG("Destroy action %p", action); - if (action->new_api.surf_new_api) - surf_action_unref(action->new_api.surf_new_api); - xbt_mallocator_release(simix_global->action_mallocator, action); -} - -void SIMIX_new_api_finish(smx_action_t action) -{ - xbt_fifo_item_t item; - smx_simcall_t simcall; - - xbt_fifo_foreach(action->simcalls, item, simcall, smx_simcall_t) { - - switch (action->state) { - - case SIMIX_DONE: - /* do nothing, action done */ - break; - - case SIMIX_FAILED: - SMX_EXCEPTION(simcall->issuer, io_error, 0, "IO failed"); - break; - - case SIMIX_CANCELED: - SMX_EXCEPTION(simcall->issuer, cancel_error, 0, "Canceled"); - break; - - default: - xbt_die("Internal error in SIMIX_NEW_MODEL_finish: unexpected action state %d", - (int)action->state); - } - - if (surf_resource_get_state(surf_workstation_resource_priv(simcall->issuer->smx_host)) != SURF_RESOURCE_ON) { - simcall->issuer->context->iwannadie = 1; - } - - simcall->issuer->waiting_action = NULL; - SIMIX_simcall_answer(simcall); - } - - /* We no longer need it */ - SIMIX_new_api_destroy(action); -} diff --git a/src/simix/smx_new_api_private.h b/src/simix/smx_new_api_private.h deleted file mode 100644 index 2c1f78ffcd..0000000000 --- a/src/simix/smx_new_api_private.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (c) 2007-2010, 2012-2014. 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. */ - -/* ****************************************************************************************** */ -/* TUTORIAL: New API */ -/* ****************************************************************************************** */ -#ifndef _SIMIX_NEW_API_PRIVATE_H -#define _SIMIX_NEW_API_PRIVATE_H - -#include "simgrid/simix.h" -#include "smx_smurf_private.h" - -void SIMIX_pre_new_api_fct(smx_simcall_t simcall); -smx_action_t SIMIX_new_api_fct(smx_process_t process, const char* param1, double param2); - -void SIMIX_post_new_api(smx_action_t action); -void SIMIX_new_api_destroy(smx_action_t action); -void SIMIX_new_api_finish(smx_action_t action); - -#endif diff --git a/src/simix/smx_popping_generated.c b/src/simix/smx_popping_generated.c index e33bfdce04..03a18ea51e 100644 --- a/src/simix/smx_popping_generated.c +++ b/src/simix/smx_popping_generated.c @@ -780,11 +780,5 @@ case SIMCALL_MC_RANDOM: ); break; - /* ****************************************************************************************** */ - /* TUTORIAL: New API */ - /* ****************************************************************************************** */ - case SIMCALL_NEW_API_INIT: - SIMIX_pre_new_api_fct(simcall); - break; } } diff --git a/src/simix/smx_popping_generated.h b/src/simix/smx_popping_generated.h index 84c517243b..6d7a049264 100644 --- a/src/simix/smx_popping_generated.h +++ b/src/simix/smx_popping_generated.h @@ -151,7 +151,6 @@ SIMCALL_MC_COMPARE_SNAPSHOTS, SIMCALL_MC_RANDOM, #endif -SIMCALL_NEW_API_INIT, NUM_SIMCALLS } e_smx_simcall_t; \ No newline at end of file diff --git a/src/simix/smx_private.h b/src/simix/smx_private.h index b061c5da59..81c0fd9879 100644 --- a/src/simix/smx_private.h +++ b/src/simix/smx_private.h @@ -24,10 +24,6 @@ #include "smx_network_private.h" #include "smx_smurf_private.h" #include "smx_synchro_private.h" -/* ****************************************************************************************** */ -/* TUTORIAL: New API */ -/* ****************************************************************************************** */ -#include "smx_new_api_private.h" /* Define only for SimGrid benchmarking purposes */ //#define TIME_BENCH_PER_SR /* this aims at measuring the time spent in each scheduling round per each thread. The code is thus run in sequential to bench separately each SSR */ @@ -108,10 +104,6 @@ typedef enum { SIMIX_ACTION_SLEEP, SIMIX_ACTION_SYNCHRO, SIMIX_ACTION_IO, - /* ****************************************************************************************** */ - /* TUTORIAL: New API */ - /* ****************************************************************************************** */ - SIMIX_ACTION_NEW_API } e_smx_action_type_t; typedef enum { @@ -195,13 +187,6 @@ typedef struct s_smx_action { smx_host_t host; surf_action_t surf_io; } io; - - /* ****************************************************************************************** */ - /* TUTORIAL: New API */ - /* ****************************************************************************************** */ - struct { - surf_action_t surf_new_api; - } new_api; }; #ifdef HAVE_LATENCY_BOUND_TRACKING diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index adf8d9d4ed..ddc96427bf 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -367,13 +367,6 @@ void SIMIX_process_kill(smx_process_t process, smx_process_t issuer) { SIMIX_io_destroy(process->waiting_action); break; - /* **************************************/ - /* TUTORIAL: New API */ - case SIMIX_ACTION_NEW_API: - SIMIX_new_api_destroy(process->waiting_action); - break; - /* **************************************/ - } } if(!xbt_dynar_member(simix_global->process_to_run, &(process)) && process != issuer) { @@ -425,13 +418,6 @@ void SIMIX_process_throw(smx_process_t process, xbt_errcat_t cat, int value, con SIMIX_io_destroy(process->waiting_action); break; - /* **************************************/ - /* TUTORIAL: New API */ - case SIMIX_ACTION_NEW_API: - SIMIX_new_api_destroy(process->waiting_action); - break; - /* **************************************/ - } } process->waiting_action = NULL; diff --git a/src/simix/smx_smurf.c b/src/simix/smx_smurf.c index 49f3745ad0..64b588b21b 100644 --- a/src/simix/smx_smurf.c +++ b/src/simix/smx_smurf.c @@ -81,12 +81,5 @@ void SIMIX_simcall_exit(smx_action_t action) case SIMIX_ACTION_IO: SIMIX_post_io(action); break; - - /* ****************************************************************************************** */ - /* TUTORIAL: New API */ - /* ****************************************************************************************** */ - case SIMIX_ACTION_NEW_API: - SIMIX_post_new_api(action); - break; } } diff --git a/src/simix/smx_smurf_private.h b/src/simix/smx_smurf_private.h index 230d0cdbd7..7847b5f986 100644 --- a/src/simix/smx_smurf_private.h +++ b/src/simix/smx_smurf_private.h @@ -51,14 +51,6 @@ typedef struct s_smx_simcall { #endif union u_smx_scalar args[11]; union u_smx_scalar result; - union { - struct { - const char* param1; - double param2; - int result; - } new_api; - - }; } s_smx_simcall_t, *smx_simcall_t; #if HAVE_MC diff --git a/src/simix/smx_user.c b/src/simix/smx_user.c index 5717c2a482..2473945267 100644 --- a/src/simix/smx_user.c +++ b/src/simix/smx_user.c @@ -1470,39 +1470,24 @@ xbt_dict_t simcall_storage_get_content(smx_storage_t storage) return simcall_BODY_storage_get_content(storage); } + + #ifdef HAVE_MC -void *simcall_mc_snapshot(void) -{ +void *simcall_mc_snapshot(void) { return simcall_BODY_mc_snapshot(); } -int simcall_mc_compare_snapshots(void *s1, void *s2){ +int simcall_mc_compare_snapshots(void *s1, void *s2) { return simcall_BODY_mc_compare_snapshots(s1, s2); } -int simcall_mc_random(int min, int max) -{ +int simcall_mc_random(int min, int max) { return simcall_BODY_mc_random(min, max); } - #endif /* HAVE_MC */ -/* ****************************************************************************************** */ -/* TUTORIAL: New API */ -/* All functions for simcall */ -/* ****************************************************************************************** */ -int simcall_new_api_fct(const char* param1, double param2){ - smx_simcall_t simcall = SIMIX_simcall_mine(); - simcall->call = SIMCALL_NEW_API_INIT; - simcall->new_api.param1 = param1; - simcall->new_api.param2 = param2; - - SIMIX_simcall_push(simcall->issuer); - return simcall->new_api.result; -} - /* ************************************************************************** */ /** @brief returns a printable string representing a simcall */ diff --git a/src/xbt/log.c b/src/xbt/log.c index ce695aac07..3b59e3c4d6 100644 --- a/src/xbt/log.c +++ b/src/xbt/log.c @@ -651,7 +651,6 @@ static void xbt_log_connect_categories(void) XBT_LOG_CONNECT(msg_io); XBT_LOG_CONNECT(msg_kernel); XBT_LOG_CONNECT(msg_mailbox); - XBT_LOG_CONNECT(msg_new_API); XBT_LOG_CONNECT(msg_process); XBT_LOG_CONNECT(msg_synchro); XBT_LOG_CONNECT(msg_task); @@ -676,7 +675,6 @@ static void xbt_log_connect_categories(void) XBT_LOG_CONNECT(simix_io); XBT_LOG_CONNECT(simix_kernel); XBT_LOG_CONNECT(simix_network); - XBT_LOG_CONNECT(simix_new_api); XBT_LOG_CONNECT(simix_process); XBT_LOG_CONNECT(simix_smurf); XBT_LOG_CONNECT(simix_synchro); -- 2.20.1