1 /* ----------------------------------------------------------------------------
2 * This file was automatically generated by SWIG (http://www.swig.org).
5 * Do not make changes to this file unless you know what you are doing--modify
6 * the SWIG interface file instead.
7 * ----------------------------------------------------------------------------- */
9 package org.simgrid.surf;
12 * A generic resource for the cpu component
16 public class Cpu extends Resource {
17 private long swigCPtr;
19 protected Cpu(long cPtr, boolean cMemoryOwn) {
20 super(SurfJNI.Cpu_SWIGUpcast(cPtr), cMemoryOwn);
24 protected static long getCPtr(Cpu obj) {
25 return (obj == null) ? 0 : obj.swigCPtr;
28 protected void finalize() {
32 public synchronized void delete() {
36 SurfJNI.delete_Cpu(swigCPtr);
43 protected void swigDirectorDisconnect() {
48 public void swigReleaseOwnership() {
50 SurfJNI.Cpu_change_ownership(this, swigCPtr, false);
53 public void swigTakeOwnership() {
55 SurfJNI.Cpu_change_ownership(this, swigCPtr, true);
60 * A cpu constructor (using LMM)
69 public Cpu(Model model, String name, XbtDict props, LmmConstraint constraint, int core, double powerPeak, double powerScale) {
70 this(SurfJNI.new_Cpu__SWIG_0(Model.getCPtr(model), model, name, XbtDict.getCPtr(props), props, LmmConstraint.getCPtr(constraint), constraint, core, powerPeak, powerScale), true);
71 SurfJNI.Cpu_director_connect(this, swigCPtr, swigCMemOwn, true);
84 public Cpu(Model model, String name, XbtDict props, int core, double powerPeak, double powerScale) {
85 this(SurfJNI.new_Cpu__SWIG_1(Model.getCPtr(model), model, name, XbtDict.getCPtr(props), props, core, powerPeak, powerScale), true);
86 SurfJNI.Cpu_director_connect(this, swigCPtr, swigCMemOwn, true);
91 * @return The current power peak
93 public double getCurrentPowerPeak() {
94 return (getClass() == Cpu.class) ? SurfJNI.Cpu_getCurrentPowerPeak(swigCPtr, this) : SurfJNI.Cpu_getCurrentPowerPeakSwigExplicitCpu(swigCPtr, this);
99 * Execute some quantity of computation
100 * @param size The processing amount (in flop) needed to process
101 * @return A cpu action representing code execution
103 public CpuAction execute(double size) {
104 long cPtr = SurfJNI.Cpu_execute(swigCPtr, this, size);
105 return (CpuAction)Surf.getCpuDirector(cPtr);
110 * Make a process sleep for duration
111 * @param duration The number of seconds to sleep
112 * @return A cpu action representing sleeping
114 public CpuAction sleep(double duration) {
115 long cPtr = SurfJNI.Cpu_sleep(swigCPtr, this, duration);
116 return (CpuAction)Surf.getCpuDirector(cPtr);
121 * @return The number of cores on the cpu
123 public int getCore() {
124 return (getClass() == Cpu.class) ? SurfJNI.Cpu_getCore(swigCPtr, this) : SurfJNI.Cpu_getCoreSwigExplicitCpu(swigCPtr, this);
132 public double getSpeed(double load) {
133 return (getClass() == Cpu.class) ? SurfJNI.Cpu_getSpeed(swigCPtr, this, load) : SurfJNI.Cpu_getSpeedSwigExplicitCpu(swigCPtr, this, load);
140 public double getAvailableSpeed() {
141 return (getClass() == Cpu.class) ? SurfJNI.Cpu_getAvailableSpeed(swigCPtr, this) : SurfJNI.Cpu_getAvailableSpeedSwigExplicitCpu(swigCPtr, this);
146 * @param pstate_index index of power peak to get
147 * @return Power peak at index
149 public double getPowerPeakAt(int pstate_index) {
150 return SurfJNI.Cpu_getPowerPeakAt(swigCPtr, this, pstate_index);
155 * @return Number of power peak
157 public int getNbPstates() {
158 return SurfJNI.Cpu_getNbPstates(swigCPtr, this);
161 public void setPstate(int pstate_index) {
162 SurfJNI.Cpu_setPstate(swigCPtr, this, pstate_index);
167 * @param state The new state of the cpu
169 public void setState(ResourceState state) {
170 SurfJNI.Cpu_setState(swigCPtr, this, state.swigValue());