use of es.bsc.compss.scheduler.multiobjective.types.MOProfile in project compss by bsc-wdc.
the class MOResourceScheduler method rescheduleTasks.
@SuppressWarnings("unchecked")
public List<Gap> rescheduleTasks(LocalOptimizationState state, PriorityQueue<AllocatableAction> rescheduledActions) {
this.runActionsCost = 0;
this.runActionsEnergy = 0;
for (int coreId = 0; coreId < CoreManager.getCoreCount(); coreId++) {
for (int implId = 0; implId < CoreManager.getNumberCoreImplementations(coreId); implId++) {
MOProfile profile = (MOProfile) this.getProfile(coreId, implId);
runActionsEnergy += profile.getPower() * profile.getExecutionCount() * profile.getAverageExecutionTime();
runActionsCost += profile.getPrice() * profile.getExecutionCount() * profile.getAverageExecutionTime();
}
}
/*
*
* ReadyActions contains those actions that have no dependencies with other actions scheduled on the node, but
* they have data dependencies with tasks on other resources. They are sorted by the expected time when these
* dependencies will be solved.
*
* SelectableActions contains those actions that have no data dependencies with other actions but they wait for
* resources to be released.
*
* Running actions contains a list of Actions that are executing or potentially executing at the moment.
*
* All Actions that need to be rescheduled have the onOptimization and scheduled flags on.
*
* Those actions that are running or could potentially be started ( no dependencies with other actions in the
* resource) are already locked to avoid their start without being on the runningActions set.
*/
Gap gap = state.peekFirstGap();
ResourceDescription gapResource = gap.getResources();
PriorityQueue<SchedulingEvent> schedulingQueue = new PriorityQueue<>();
// For every running action we create a start event on their real start timeStamp
for (AllocatableAction action : state.getRunningActions()) {
manageRunningAction(action, state);
MOSchedulingInformation actionDSI = (MOSchedulingInformation) action.getSchedulingInfo();
schedulingQueue.offer(new SchedulingEvent.End(actionDSI.getExpectedEnd(), action));
}
while (state.areRunnableActions() && !gapResource.isDynamicUseless()) {
AllocatableAction top = state.getMostPrioritaryRunnableAction();
state.replaceAction(top);
if (state.canActionRun()) {
state.removeMostPrioritaryRunnableAction();
// Start the current action
MOSchedulingInformation topDSI = (MOSchedulingInformation) top.getSchedulingInfo();
topDSI.lock();
topDSI.clearPredecessors();
manageRunningAction(top, state);
if (tryToLaunch(top)) {
schedulingQueue.offer(new SchedulingEvent.End(topDSI.getExpectedEnd(), top));
}
} else {
break;
}
}
while (!schedulingQueue.isEmpty() || state.areActionsToBeRescheduled()) {
while (!schedulingQueue.isEmpty()) {
SchedulingEvent e = schedulingQueue.poll();
/*
* Start Event: - sets the expected start and end times - adds resource dependencies with the previous
* actions - if there's a gap before the dependency -tries to fill it with other tasks - if all the
* resources released by the predecessor are used later - the action is unlocked
*
* End Event:
*
*/
List<SchedulingEvent> result = e.process(state, (MOResourceScheduler<WorkerResourceDescription>) this, rescheduledActions);
for (SchedulingEvent r : result) {
schedulingQueue.offer(r);
}
}
if (state.areActionsToBeRescheduled()) {
AllocatableAction topAction = state.getEarliestActionToBeRescheduled();
MOSchedulingInformation topActionDSI = (MOSchedulingInformation) topAction.getSchedulingInfo();
topActionDSI.lock();
topActionDSI.setToReschedule(false);
schedulingQueue.offer(new SchedulingEvent.Start(topActionDSI.getExpectedStart(), topAction));
}
}
for (Gap g : state.getGaps()) {
state.removeTmpGap(g);
}
this.pendingActionsCost = state.getTotalCost();
this.pendingActionsEnergy = state.getTotalEnergy();
this.implementationsCount = state.getImplementationsCount();
this.expectedEndTimeRunning = state.getEndRunningTime();
this.runningImplementationsCount = state.getRunningImplementations();
this.runningActionsEnergy = state.getRunningEnergy();
this.runningActionsCost = state.getRunningCost();
this.resourceBlockingAction = state.getResourceBlockingAction();
this.dataBlockingAction = state.getDataBlockingAction();
return state.getGaps();
}
use of es.bsc.compss.scheduler.multiobjective.types.MOProfile in project compss by bsc-wdc.
the class MOResourceSchedulerTest method testAllSetCopy.
@Test
public void testAllSetCopy() {
MOResourceScheduler<MethodResourceDescription> rs = new MOResourceScheduler<MethodResourceDescription>(worker, new JSONObject("{\"idlePower\": " + SET_IDLE_POWER + ", \"idlePrice\": " + SET_IDLE_PRICE + ", \"implementations\":{\"ClassA.methodA\":" + SET_PROFILE + "," + "\"ClassB.methodA\":" + SET_PROFILE + "," + "\"ClassA.methodB\":" + SET_PROFILE + "}}"), null);
JSONObject jo = rs.toJSONObject();
rs = new MOResourceScheduler<MethodResourceDescription>(worker, jo, null);
for (int coreId = 0; coreId < CoreManager.getCoreCount(); coreId++) {
List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
for (Implementation impl : impls) {
MOProfile p = (MOProfile) rs.getProfile(impl);
try {
checkSetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on all set test");
}
}
}
if (rs.getIdlePower() != SET_IDLE_POWER) {
fail("Invalid idle Power for copy test");
}
if (rs.getIdlePrice() != SET_IDLE_PRICE) {
fail("Invalid idle Price for copy test");
}
}
use of es.bsc.compss.scheduler.multiobjective.types.MOProfile in project compss by bsc-wdc.
the class MOResourceOptimizer method createResourceForComponent.
private Resource<?> createResourceForComponent(CloudInstanceTypeDescription citd, CloudImageDescription cid) {
Resource<?> r = new Resource<>(null);
MOCloudTypeProfile moCloudTypeProf = (MOCloudTypeProfile) getCloudTypeProfile(citd);
r.idlePower = moCloudTypeProf.getIdlePower();
r.idlePrice = moCloudTypeProf.getIdlePrice();
MethodResourceDescription rd = citd.getResourceDescription();
r.capacity = new int[CoreManager.getCoreCount()];
r.profiles = new MOProfile[CoreManager.getCoreCount()];
for (int coreId = 0; coreId < CoreManager.getCoreCount(); coreId++) {
List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
MOProfile[] profiles = new MOProfile[impls.size()];
for (int i = 0; i < impls.size(); i++) {
profiles[i] = (MOProfile) moCloudTypeProf.getImplProfiles(coreId, impls.get(i).getImplementationId());
}
Implementation impl = getBestImplementation(impls, profiles);
r.capacity[coreId] = rd.canHostSimultaneously((MethodResourceDescription) impl.getRequirements());
r.profiles[coreId] = (MOProfile) moCloudTypeProf.getImplProfiles(coreId, impl.getImplementationId());
}
r.startTime = cid.getCreationTime() * 1000;
r.clear();
return r;
}
use of es.bsc.compss.scheduler.multiobjective.types.MOProfile in project compss by bsc-wdc.
the class MOResourceOptimizer method reduceResourceForComponent.
private Resource<?> reduceResourceForComponent(Resource<?> excludedWorker, CloudMethodResourceDescription reduction) {
Resource<?> clone = new Resource<>(excludedWorker.worker);
clone.idlePower = excludedWorker.idlePower;
clone.idlePrice = excludedWorker.idlePrice;
clone.capacity = new int[excludedWorker.capacity.length];
System.arraycopy(excludedWorker.capacity, 0, clone.capacity, 0, excludedWorker.capacity.length);
clone.startTime = excludedWorker.startTime;
clone.startEnergy = excludedWorker.startEnergy;
clone.startCost = excludedWorker.startCost;
clone.time = excludedWorker.time;
clone.counts = excludedWorker.counts;
Map<CloudInstanceTypeDescription, int[]> composition = reduction.getTypeComposition();
for (Map.Entry<CloudInstanceTypeDescription, int[]> component : composition.entrySet()) {
CloudInstanceTypeDescription type = component.getKey();
int count = component.getValue()[0];
MethodResourceDescription rd = type.getResourceDescription();
MOCloudTypeProfile moCloudTypeProf = (MOCloudTypeProfile) getCloudTypeProfile(type);
clone.idlePower -= moCloudTypeProf.getIdlePower() * count;
clone.idlePrice -= moCloudTypeProf.getIdlePrice() * count;
for (int coreId = 0; coreId < CoreManager.getCoreCount(); coreId++) {
List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
MOProfile[] profiles = new MOProfile[impls.size()];
for (int i = 0; i < impls.size(); i++) {
profiles[i] = (MOProfile) moCloudTypeProf.getImplProfiles(coreId, impls.get(i).getImplementationId());
}
Implementation impl = getBestImplementation(impls, profiles);
clone.capacity[coreId] -= rd.canHostSimultaneously((MethodResourceDescription) impl.getRequirements()) * count;
}
}
return clone;
}
use of es.bsc.compss.scheduler.multiobjective.types.MOProfile in project compss by bsc-wdc.
the class MOResourceScheduler method manageRunningAction.
private void manageRunningAction(AllocatableAction action, LocalOptimizationState state) {
Implementation impl = action.getAssignedImplementation();
MOSchedulingInformation actionDSI = (MOSchedulingInformation) action.getSchedulingInfo();
// Set start Time
Long startTime = action.getStartTime();
long start;
if (startTime != null) {
start = startTime - state.getId();
} else {
start = 0;
}
actionDSI.setExpectedStart(start);
// Set End Time
MOProfile p = (MOProfile) getProfile(impl);
long endTime = start;
if (p != null) {
endTime += p.getAverageExecutionTime();
}
if (endTime < 0) {
endTime = 0;
}
actionDSI.setExpectedEnd(endTime);
actionDSI.clearPredecessors();
actionDSI.clearSuccessors();
actionDSI.setToReschedule(false);
state.runningAction(impl, p, endTime);
}
Aggregations