From d86f7572616237eed19917756c960b5bb9ee75f3 Mon Sep 17 00:00:00 2001 From: Manoel Campos Date: Sat, 24 Oct 2026 21:25:40 -0300 Subject: [PATCH] Use CoreCapacity instead of PE lists and the Processor API (cloudsimplus#595) - Hosts and VMs are created with a CoreCapacity. - getPesNumber()/getMips() on Hosts and VMs use the machine Processor. - Cloudlet.getPesNumber() is now getRequiredCores(). - Rename *_PES constants to *_CORES. Co-Authored-By: Claude Opus 5.5 --- .../benchmarks/MemoryFootprintBenchmark.java | 18 ++++++------ .../benchmarks/SimulationTimeBenchmark.java | 28 ++++++++----------- .../CloudletToVmMappingSolutionBenchmark.java | 3 +- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/cloudsimplus/benchmarks/MemoryFootprintBenchmark.java b/src/main/java/org/cloudsimplus/benchmarks/MemoryFootprintBenchmark.java index 2595b3e..12ed5a9 100644 --- a/src/main/java/org/cloudsimplus/benchmarks/MemoryFootprintBenchmark.java +++ b/src/main/java/org/cloudsimplus/benchmarks/MemoryFootprintBenchmark.java @@ -25,7 +25,7 @@ import org.cloudsimplus.cloudlets.CloudletSimple; import org.cloudsimplus.hosts.HostSimple; -import org.cloudsimplus.resources.PeSimple; +import org.cloudsimplus.resources.CoreCapacity; import org.cloudsimplus.vms.VmSimple; import java.lang.management.ManagementFactory; @@ -79,15 +79,15 @@ public final class MemoryFootprintBenchmark { private static final int GC_CALLS = 3; private static final double VM_MIPS = 1000; - private static final long VM_PES = 1; + private static final long VM_CORES = 1; - private static final double PE_MIPS = 1000; + private static final double HOST_CORE_MIPS = 1000; private static final long HOST_RAM = 4096; private static final long HOST_BW = 10_000; private static final long HOST_STORAGE = 100_000; private static final long CLOUDLET_LENGTH = 10_000; - private static final int CLOUDLET_PES = 1; + private static final int CLOUDLET_CORES = 1; private static final MemoryMXBean MEMORY = ManagementFactory.getMemoryMXBean(); @@ -107,18 +107,18 @@ public static void main(final String[] args) { } private static VmSimple newVm(final int index) { - return new VmSimple(VM_MIPS, VM_PES); + return new VmSimple(new CoreCapacity(VM_CORES, VM_MIPS)); } - /// Creates a Host with a single PE. - /// The PE is included in the measured size, but it's the same before and after the change. + /// Creates a Host with a single CPU core. + /// The Host Processor is included in the measured size. private static HostSimple newHost(final int index) { - return new HostSimple(HOST_RAM, HOST_BW, HOST_STORAGE, List.of(new PeSimple(PE_MIPS))); + return new HostSimple(HOST_RAM, HOST_BW, HOST_STORAGE, new CoreCapacity(HOST_CORE_MIPS)); } /// Creates a Cloudlet with the default utilization models. private static CloudletSimple newCloudlet(final int index) { - return new CloudletSimple(CLOUDLET_LENGTH, CLOUDLET_PES); + return new CloudletSimple(CLOUDLET_LENGTH, CLOUDLET_CORES); } /// {@return the median heap (in bytes) retained by each object created by a given function} diff --git a/src/main/java/org/cloudsimplus/benchmarks/SimulationTimeBenchmark.java b/src/main/java/org/cloudsimplus/benchmarks/SimulationTimeBenchmark.java index 386254f..5c5c73f 100755 --- a/src/main/java/org/cloudsimplus/benchmarks/SimulationTimeBenchmark.java +++ b/src/main/java/org/cloudsimplus/benchmarks/SimulationTimeBenchmark.java @@ -32,8 +32,7 @@ import org.cloudsimplus.datacenters.DatacenterSimple; import org.cloudsimplus.hosts.Host; import org.cloudsimplus.hosts.HostSimple; -import org.cloudsimplus.resources.Pe; -import org.cloudsimplus.resources.PeSimple; +import org.cloudsimplus.resources.CoreCapacity; import org.cloudsimplus.util.Log; import org.cloudsimplus.util.TimeUtil; import org.cloudsimplus.utilizationmodels.UtilizationModelDynamic; @@ -60,13 +59,13 @@ public class SimulationTimeBenchmark { public static final int SIMULATIONS = 4; public static final int HOSTS_INCREMENT = 100; public static final int INITIAL_HOSTS_NUMBER = 100; - private static final int HOST_PES = 64; + private static final int HOST_CORES = 64; - private static final int VM_PES = 1; + private static final int VM_CORES = 1; /// Value used to multiply the number of VMs to get the number of Cloudlets. private static final int VMS_MULTIPLIER = 55; - private static final int CLOUDLET_PES = 1; + private static final int CLOUDLET_CORES = 1; private static final int CLOUDLET_LENGTH = 1000; private final int hostsNumber; @@ -139,22 +138,17 @@ private Datacenter createDatacenter() { } private Host createHost() { - final List peList = new ArrayList<>(HOST_PES); - //List of Host's CPUs (Processing Elements, PEs) - for (int i = 0; i < HOST_PES; i++) { - //Uses a PeProvisionerSimple by default to provision PEs for VMs - peList.add(new PeSimple(1000)); - } + final var cpuCapacity = new CoreCapacity(HOST_CORES, 1000); - final long ram = 4096*HOST_PES; //in Megabytes - final long bw = 100000*HOST_PES; //in Megabits/s - final long storage = 1000000*HOST_PES; //in Megabytes + final long ram = 4096*HOST_CORES; //in Megabytes + final long bw = 100000*HOST_CORES; //in Megabits/s + final long storage = 1000000*HOST_CORES; //in Megabytes /* Uses ResourceProvisionerSimple by default for RAM and BW provisioning and VmSchedulerSpaceShared for VM scheduling. */ - return new HostSimple(ram, bw, storage, peList); + return new HostSimple(ram, bw, storage, cpuCapacity); } /// Creates a list of VMs. @@ -162,7 +156,7 @@ private List createVms() { final List list = new ArrayList<>(vmsNumber); for (int i = 0; i < vmsNumber; i++) { //Uses a CloudletSchedulerTimeShared by default to schedule Cloudlets - final Vm vm = new VmSimple(1000, VM_PES); + final Vm vm = new VmSimple(new CoreCapacity(VM_CORES, 1000)); vm.setRam(512).setBw(1000).setSize(10000); list.add(vm); } @@ -178,7 +172,7 @@ private List createCloudlets() { final UtilizationModelDynamic utilizationModel = new UtilizationModelDynamic(0.5); for (int i = 0; i < cloudletsNumber; i++) { - final Cloudlet cloudlet = new CloudletSimple(CLOUDLET_LENGTH, CLOUDLET_PES, utilizationModel); + final Cloudlet cloudlet = new CloudletSimple(CLOUDLET_LENGTH, CLOUDLET_CORES, utilizationModel); cloudlet.setSizes(1024); list.add(cloudlet); } diff --git a/src/main/java/org/cloudsimplus/heuristics/CloudletToVmMappingSolutionBenchmark.java b/src/main/java/org/cloudsimplus/heuristics/CloudletToVmMappingSolutionBenchmark.java index 7c2395c..cd33cd1 100755 --- a/src/main/java/org/cloudsimplus/heuristics/CloudletToVmMappingSolutionBenchmark.java +++ b/src/main/java/org/cloudsimplus/heuristics/CloudletToVmMappingSolutionBenchmark.java @@ -25,6 +25,7 @@ import org.cloudsimplus.cloudlets.CloudletSimple; import org.cloudsimplus.distributions.UniformDistr; +import org.cloudsimplus.resources.CoreCapacity; import org.cloudsimplus.utilizationmodels.UtilizationModel; import org.cloudsimplus.vms.VmSimple; import org.openjdk.jmh.annotations.*; @@ -62,7 +63,7 @@ private CloudletToVmMappingSolution createInstance() { IntStream.range(0, 100).forEach(i -> result.bindCloudletToVm( new CloudletSimple(i, 1, 1).setUtilizationModel(um), - new VmSimple(i, 1000, 1)) + new VmSimple(i, new CoreCapacity(1, 1000))) ); return result;