1 /* Copyright (c) 2016. 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.NativeException;
13 import org.simgrid.msg.Process;
14 import org.simgrid.msg.Task;
15 import org.simgrid.msg.TaskCancelledException;
17 /* This class is a process in charge of running the test. It creates and starts the VMs, and fork processes within VMs */
18 public class PstateRunner extends Process {
20 public class DVFS extends Process {
21 public DVFS (Host host, String name) {
26 public void main(String[] strings) throws HostNotFoundException, HostFailureException, TaskCancelledException {
27 double workload = 100E6;
29 Host host = getHost();
31 int nb = host.getPstatesCount();
32 Msg.info("Count of Processor states="+ nb);
34 double currentPeak = host.getCurrentPowerPeak();
35 Msg.info("Current power peak=" + currentPeak);
38 Task task1 = new Task("t1", workload, 0);
41 double taskTime = Msg.getClock();
42 Msg.info("Task1 simulation time: "+ taskTime);
45 if ((newPstate >= nb) || (newPstate < 0)){
46 Msg.info("Cannot set pstate "+newPstate+"%d, host supports only "+nb+" pstates.");
50 double peakAt = host.getPowerPeakAt(newPstate);
51 Msg.info("Changing power peak value to "+peakAt+" (at index "+newPstate+")");
53 host.setPstate(newPstate);
55 currentPeak = host.getCurrentPowerPeak();
56 Msg.info("Current power peak="+ currentPeak);
59 new Task("t1", workload, 0).execute();
61 taskTime = Msg.getClock() - taskTime;
62 Msg.info("Task2 simulation time: "+ taskTime);
64 // Verify the default pstate is set to 0
65 host = Host.getByName("MyHost2");
66 int nb2 = host.getPstatesCount();
67 Msg.info("Count of Processor states="+ nb2);
69 double currentPeak2 = host.getCurrentPowerPeak();
70 Msg.info("Current power peak=" + currentPeak2);
74 PstateRunner(Host host, String name, String[] args) throws NativeException {
75 super(host, name, args);
79 public void main(String[] strings) throws HostNotFoundException, HostFailureException {
81 new DVFS (Host.getByName("MyHost1"), "dvfs_test").start();
82 new DVFS (Host.getByName("MyHost2"), "dvfs_test").start();