1 /* Copyright (c) 2016-2020. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
8 import org.simgrid.msg.Host;
9 import org.simgrid.msg.HostFailureException;
10 import org.simgrid.msg.HostNotFoundException;
11 import org.simgrid.msg.Msg;
12 import org.simgrid.msg.Process;
13 import org.simgrid.msg.Task;
14 import org.simgrid.msg.TaskCancelledException;
16 /* This class is a process in charge of running the test. It creates and starts the VMs, and fork processes within VMs */
17 public class PstateRunner extends Process {
19 public class DVFS extends Process {
20 public DVFS (Host host, String name) {
25 public void main(String[] strings) throws HostNotFoundException, HostFailureException, TaskCancelledException {
26 double workload = 100E6;
28 Host host = getHost();
30 int nb = host.getPstatesCount();
31 Msg.info("Count of Processor states="+ nb);
33 double currentPeak = host.getCurrentPowerPeak();
34 Msg.info("Current power peak=" + currentPeak);
37 Task task1 = new Task("t1", workload, 0);
40 double taskTime = Msg.getClock();
41 Msg.info("Task1 simulation time: "+ taskTime);
44 if ((newPstate >= nb) || (newPstate < 0)){
45 Msg.info("Cannot set pstate "+newPstate+"%d, host supports only "+nb+" pstates.");
49 double peakAt = host.getPowerPeakAt(newPstate);
50 Msg.info("Changing power peak value to "+peakAt+" (at index "+newPstate+")");
52 host.setPstate(newPstate);
54 currentPeak = host.getCurrentPowerPeak();
55 Msg.info("Current power peak="+ currentPeak);
58 new Task("t1", workload, 0).execute();
60 taskTime = Msg.getClock() - taskTime;
61 Msg.info("Task2 simulation time: "+ taskTime);
63 // Verify the default pstate is set to 0
64 host = Host.getByName("MyHost2");
65 int nb2 = host.getPstatesCount();
66 Msg.info("Count of Processor states="+ nb2);
68 double currentPeak2 = host.getCurrentPowerPeak();
69 Msg.info("Current power peak=" + currentPeak2);
73 PstateRunner(Host host, String name, String[] args) {
74 super(host, name, args);
78 public void main(String[] strings) throws HostNotFoundException, HostFailureException {
80 new DVFS (Host.getByName("MyHost1"), "dvfs_test").start();
81 new DVFS (Host.getByName("MyHost2"), "dvfs_test").start();