6 int main(int argc, char *argv[])
14 if (MPI_Init(&argc, &argv) != MPI_SUCCESS) {
15 printf("MPI initialization failed!\n");
19 MPI_Comm_rank(MPI_COMM_WORLD, &rank); /* Get id of this process */
21 pstates = smpi_get_host_nb_pstates();
26 "[%.6f] [rank %d] Pstates: %d; Powers: %.0f",
27 MPI_Wtime(), rank, pstates, smpi_get_host_power_peak_at(0));
33 for (i = 1; i < pstates; i++) {
34 x = snprintf(s, sz, ", %.0f", smpi_get_host_power_peak_at(i));
41 printf("%s%s\n", buf, (sz ? "" : " [...]"));
43 for (i = 0; i < pstates; i++) {
44 smpi_set_host_power_peak_at(i);
45 printf("[%.6f] [rank %d] Current pstate: %d; Current power: %.0f\n",
46 MPI_Wtime(), rank, i, smpi_get_host_current_power_peak());
48 SMPI_SAMPLE_FLOPS(1e9) {
49 /* imagine here some code running for 1e9 flops... */
52 printf("[%.6f] [rank %d] Energy consumed: %g Joules.\n",
53 MPI_Wtime(), rank, smpi_get_host_consumed_energy());
56 return MPI_Finalize();