1 /* Copyright (c) 2013-2014. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
10 #include <smpi/smpi.h>
12 int main(int argc, char *argv[])
20 if (MPI_Init(&argc, &argv) != MPI_SUCCESS) {
21 fprintf(stderr, "MPI initialization failed!\n");
25 MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* Get id of this process */
27 pstates = smpi_get_host_nb_pstates();
32 "[%.6f] [rank %d] Pstates: %d; Powers: %.0f",
33 MPI_Wtime(), rank, pstates, smpi_get_host_power_peak_at(0));
39 for (i = 1; i < pstates; i++) {
40 x = snprintf(s, sz, ", %.0f", smpi_get_host_power_peak_at(i));
47 fprintf(stderr, "%s%s\n", buf, (sz ? "" : " [...]"));
49 for (i = 0; i < pstates; i++) {
50 smpi_set_host_power_peak_at(i);
51 fprintf(stderr, "[%.6f] [rank %d] Current pstate: %d; Current power: %.0f\n",
52 MPI_Wtime(), rank, i, smpi_get_host_current_power_peak());
54 SMPI_SAMPLE_FLOPS(1e9) {
55 /* imagine here some code running for 1e9 flops... */
58 fprintf(stderr, "[%.6f] [rank %d] Energy consumed: %g Joules.\n",
59 MPI_Wtime(), rank, smpi_get_host_consumed_energy());
62 return MPI_Finalize();