From 444b3487fdce26571d25a82b1fb835c8c15e550f Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 6 Nov 2013 17:01:43 +0100 Subject: [PATCH] Export DVFS functionality for smpi (experimental). --- buildtools/Cmake/DefinePackages.cmake | 1 + include/smpi/smpi.h | 6 +++ src/smpi/smpi_dvfs.c | 61 +++++++++++++++++++++++++++ src/smpi/smpi_global.c | 3 +- 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 src/smpi/smpi_dvfs.c diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index 2e41e3d8ef..abc3963962 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -104,6 +104,7 @@ set(SMPI_SRC src/smpi/smpi_c99.c src/smpi/smpi_coll.c src/smpi/smpi_comm.c + src/smpi/smpi_dvfs.c src/smpi/smpi_global.c src/smpi/smpi_group.c src/smpi/smpi_mpi.c diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index 99977449c9..3901734b77 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -685,6 +685,12 @@ XBT_PUBLIC(void) smpi_exit(int); XBT_PUBLIC(void) smpi_execute_flops(double flops); XBT_PUBLIC(void) smpi_execute(double duration); +XBT_PUBLIC(double) smpi_get_host_power_peak_at(int pstate_index); +XBT_PUBLIC(double) smpi_get_host_current_power_peak(void); +XBT_PUBLIC(int) smpi_get_host_nb_pstates(void); +XBT_PUBLIC(void) smpi_set_host_power_peak_at(int pstate_index); +XBT_PUBLIC(double) smpi_get_host_consumed_energy(void); + XBT_PUBLIC(unsigned int) smpi_sleep(unsigned int secs); XBT_PUBLIC(int) smpi_gettimeofday(struct timeval *tv); XBT_PUBLIC(unsigned long long) smpi_rastro_resolution (void); diff --git a/src/smpi/smpi_dvfs.c b/src/smpi/smpi_dvfs.c new file mode 100644 index 0000000000..b5aee9afa5 --- /dev/null +++ b/src/smpi/smpi_dvfs.c @@ -0,0 +1,61 @@ +/* Copyright (c) 2013. 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 "xbt/log.h" +#include "simgrid/simix.h" +#include "smpi/smpi.h" + +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_dvfs, smpi, + "Logging specific to SMPI (experimental DVFS support)"); + +/** + * \brief Return the speed of the processor (in flop/s) at a given pstate + * + * \param pstate_index pstate to test + * \return Returns the processor speed associated with pstate_index + */ +double smpi_get_host_power_peak_at(int pstate_index) +{ + return simcall_host_get_power_peak_at(SIMIX_host_self(), pstate_index); +} + +/** + * \brief Return the current speed of the processor (in flop/s) + * + * \return Returns the current processor speed + */ +double smpi_get_host_current_power_peak(void) +{ + return simcall_host_get_current_power_peak(SIMIX_host_self()); +} + +/** + * \brief Return the number of pstates defined for host + */ +int smpi_get_host_nb_pstates(void) +{ + return simcall_host_get_nb_pstates(SIMIX_host_self()); +} + +/** + * \brief Sets the speed of the processor (in flop/s) at a given pstate + * + * \param pstate_index pstate to switch to + */ +void smpi_set_host_power_peak_at(int pstate_index) +{ + simcall_host_set_power_peak_at(SIMIX_host_self(), pstate_index); +} + +/** + * \brief Return the total energy consumed by a host (in Joules) + * + * \return Returns the consumed energy + */ +double smpi_get_host_consumed_energy(void) +{ + return simcall_host_get_consumed_energy(SIMIX_host_self()); +} diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index bfd7ba1276..b5b05afe04 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -407,14 +407,15 @@ int smpi_main(int (*realmain) (int argc, char *argv[]), int argc, char *argv[]) XBT_LOG_CONNECT(smpi_base); XBT_LOG_CONNECT(smpi_bench); XBT_LOG_CONNECT(smpi_coll); + XBT_LOG_CONNECT(smpi_colls); XBT_LOG_CONNECT(smpi_comm); + XBT_LOG_CONNECT(smpi_dvfs); XBT_LOG_CONNECT(smpi_group); XBT_LOG_CONNECT(smpi_kernel); XBT_LOG_CONNECT(smpi_mpi); XBT_LOG_CONNECT(smpi_mpi_dt); XBT_LOG_CONNECT(smpi_pmpi); XBT_LOG_CONNECT(smpi_replay); - XBT_LOG_CONNECT(smpi_colls); #ifdef HAVE_TRACING TRACE_global_init(&argc, argv); -- 2.20.1