package test.appProfConverter.dcworms; import java.util.HashMap; import java.util.Map; import schedframe.resources.computing.ComputingResource; import schedframe.resources.computing.Core; import schedframe.resources.computing.Node; import schedframe.resources.computing.profiles.energy.power.PState; import schedframe.resources.units.PEUnit; import schedframe.resources.units.ProcessingElements; import schedframe.resources.units.ResourceUnit; import schedframe.resources.units.ResourceUnitName; import schedframe.resources.units.StandardResourceUnitName; public class HardwareProfile { public String componentId; public Processor proc; public Memory mem; public Network net; public HardwareProfile(Map resources) { PEUnit peUnit = (PEUnit) resources.get(StandardResourceUnitName.PE); schedframe.resources.computing.Processor processor = null; Node node = null; int cores = 0; if(peUnit instanceof ProcessingElements){ ProcessingElements pes = (ProcessingElements) peUnit; for (ComputingResource compResource : pes) { if(compResource instanceof Core) { Core core = (Core) compResource; processor = core.getProcessor(); node = processor.getNode(); cores = pes.getAmount(); break; } else if (compResource instanceof schedframe.resources.computing.Processor) { processor = (schedframe.resources.computing.Processor) compResource; node = processor.getNode(); cores = processor.getCores().size(); break; } } } this.componentId = node.getResourceCharacteristic().getParameters().get("product").get(0).getContent(); double maxClockSpeed = Double.valueOf(processor.getResourceCharacteristic().getParameters().get("speed").get(0).getContent()); PhaseState pstates[] = new PhaseState[processor.getPowerInterface().getSupportedPStates().size()]; Map pstate_map = new HashMap(); int i = 0; for (String pStateName: processor.getPowerInterface().getSupportedPStates().keySet()) { PState pState = processor.getPowerInterface().getSupportedPStates().get(pStateName); PhaseState ps = new PhaseState(i, pState.getFrequency(), pState.getVoltage(), pState.getLoadPowerUsage().get(25.0), pState.getLoadPowerUsage().get(100.0)); pstates[i] = ps; pstate_map.put(ps.frequency, ps); } this.proc = new Processor(maxClockSpeed, cores, pstates, pstate_map); int capacity = 0; schedframe.resources.units.Memory memory; try { memory = (schedframe.resources.units.Memory) resources.get(StandardResourceUnitName.PE); capacity = memory.getAmount(); } catch (Exception e) { try { memory = node.getMemory(); capacity = memory.getAmount(); } catch (NoSuchFieldException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } } this.mem = new Memory(capacity); this.net = new Network(1000); } public HardwareProfile(Node node) { this.componentId = node.getResourceCharacteristic().getParameters().get("product").get(0).getContent(); schedframe.resources.computing.Processor processor = node.getProcessors().get(0); double maxClockSpeed = Double.valueOf(processor.getResourceCharacteristic().getParameters().get("speed").get(0).getContent()); int cores = processor.getCores().size(); PhaseState pstates[] = new PhaseState[processor.getPowerInterface().getSupportedPStates().size()]; Map pstate_map = new HashMap(); int i = 0; for (String pStateName: processor.getPowerInterface().getSupportedPStates().keySet()) { PState pState = processor.getPowerInterface().getSupportedPStates().get(pStateName); PhaseState ps = new PhaseState(i, pState.getFrequency(), pState.getVoltage(), pState.getLoadPowerUsage().get(25.0), pState.getLoadPowerUsage().get(100.0)); pstates[i] = ps; pstate_map.put(ps.frequency, ps); } this.proc = new Processor(maxClockSpeed, cores, pstates, pstate_map); int capacity = 0; schedframe.resources.units.Memory memory; try { memory = node.getMemory(); capacity = memory.getAmount(); } catch (NoSuchFieldException e) { // TODO Auto-generated catch block e.printStackTrace(); } this.mem = new Memory(capacity); this.net = new Network(1000); } }