Search in sources :

Example 6 with AllocatableAction

use of es.bsc.es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.

the class PriorityActionSetTest method testInitialScheduling.

@SuppressWarnings("unchecked")
@Test
public void testInitialScheduling() throws BlockedActionException, UnassignedActionException {
    PriorityActionSet<FakeProfile, FakeResourceDescription, FakeImplementation> pas = new PriorityActionSet<>(new Comparator<AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>>() {

        @Override
        public int compare(AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation> o1, AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation> o2) {
            return Long.compare(o1.getId(), o2.getId());
        }
    });
    PriorityQueue<AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>> peeks;
    FakeAllocatableAction action1 = new FakeAllocatableAction(fao, 1, 0, CoreManager.getCoreImplementations(0));
    ((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action1.getSchedulingInfo()).setToReschedule(true);
    pas.offer(action1);
    if (action1 != pas.peek()) {
        fail(action1 + " expected to be the most prioritary action and " + pas.peek() + " was.");
    }
    FakeAllocatableAction action2 = new FakeAllocatableAction(fao, 1, 0, CoreManager.getCoreImplementations(0));
    ((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action2.getSchedulingInfo()).setToReschedule(true);
    pas.offer(action2);
    if (action1 != pas.peek()) {
        fail(action1 + " expected to be the most prioritary action and " + pas.peek() + " was.");
    }
    FakeAllocatableAction action3 = new FakeAllocatableAction(fao, 3, 0, null);
    ((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action3.getSchedulingInfo()).setToReschedule(true);
    pas.offer(action3);
    if (action1 != pas.peek()) {
        fail(action1 + " expected to be the most prioritary action and " + pas.peek() + " was.");
    }
    peeks = pas.peekAll();
    AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>[] expectedPeeks = new AllocatableAction[] { action1, action3 };
    Verifiers.verifyPriorityActions(peeks, expectedPeeks);
    FakeAllocatableAction action4 = new FakeAllocatableAction(fao, 4, 0, CoreManager.getCoreImplementations(1));
    ((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action4.getSchedulingInfo()).setToReschedule(true);
    pas.offer(action4);
    peeks = pas.peekAll();
    expectedPeeks = new AllocatableAction[] { action1, action3, action4 };
    Verifiers.verifyPriorityActions(peeks, expectedPeeks);
    AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation> action = pas.poll();
    if (action1 != action) {
        fail(action1 + " expected to be the most prioritary action and " + action + " was.");
    }
    peeks = pas.peekAll();
    expectedPeeks = new AllocatableAction[] { action2, action3, action4 };
    Verifiers.verifyPriorityActions(peeks, expectedPeeks);
    action = pas.poll();
    if (action2 != action) {
        fail(action2 + " expected to be the most prioritary action and " + action + " was.");
    }
    peeks = pas.peekAll();
    expectedPeeks = new AllocatableAction[] { action3, action4 };
    Verifiers.verifyPriorityActions(peeks, expectedPeeks);
    action = pas.poll();
    if (action3 != action) {
        fail(action3 + " expected to be the most prioritary action and " + action + " was.");
    }
    peeks = pas.peekAll();
    expectedPeeks = new AllocatableAction[] { action4 };
    Verifiers.verifyPriorityActions(peeks, expectedPeeks);
    action = pas.poll();
    if (action4 != action) {
        fail(action4 + " expected to be the most prioritary action and " + action + " was.");
    }
    peeks = pas.peekAll();
    expectedPeeks = new AllocatableAction[] {};
    Verifiers.verifyPriorityActions(peeks, expectedPeeks);
    FakeAllocatableAction action5 = new FakeAllocatableAction(fao, 5, 0, CoreManager.getCoreImplementations(1));
    ((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action5.getSchedulingInfo()).setToReschedule(true);
    FakeAllocatableAction action6 = new FakeAllocatableAction(fao, 6, 0, CoreManager.getCoreImplementations(1));
    ((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action6.getSchedulingInfo()).setToReschedule(true);
    pas.offer(action6);
    action = pas.peek();
    if (action6 != action) {
        fail(action6 + " expected to be the most prioritary action and " + action + " was.");
    }
    pas.offer(action5);
    action = pas.peek();
    if (action5 != action) {
        fail(action5 + " expected to be the most prioritary action and " + action + " was.");
    }
}
Also used : FakeProfile(es.bsc.es.bsc.compss.scheduler.types.fake.FakeProfile) FakeImplementation(es.bsc.es.bsc.compss.scheduler.types.fake.FakeImplementation) FakeResourceDescription(es.bsc.es.bsc.compss.scheduler.types.fake.FakeResourceDescription) AllocatableAction(es.bsc.es.bsc.compss.scheduler.types.AllocatableAction) FakeAllocatableAction(es.bsc.es.bsc.compss.scheduler.types.fake.FakeAllocatableAction) PriorityActionSet(es.bsc.es.bsc.compss.scheduler.types.PriorityActionSet) FullGraphSchedulingInformation(es.bsc.es.bsc.compss.scheduler.fullGraphScheduler.FullGraphSchedulingInformation) FakeAllocatableAction(es.bsc.es.bsc.compss.scheduler.types.fake.FakeAllocatableAction) Test(org.junit.Test)

Example 7 with AllocatableAction

use of es.bsc.es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.

the class ScheduleOptimizer method move.

private boolean move(AllocatableAction<P, T, I> action, OptimizationWorker<P, T, I> donor, OptimizationWorker<P, T, I> receiver) {
    LinkedList<AllocatableAction<P, T, I>> dataPreds = action.getDataPredecessors();
    long dataAvailable = 0;
    try {
        for (AllocatableAction<P, T, I> dataPred : dataPreds) {
            FullGraphSchedulingInformation<P, T, I> dsi = (FullGraphSchedulingInformation<P, T, I>) dataPred.getSchedulingInfo();
            dataAvailable = Math.max(dataAvailable, dsi.getExpectedEnd());
        }
    } catch (ConcurrentModificationException cme) {
        dataAvailable = 0;
        dataPreds = action.getDataPredecessors();
    }
    I bestImpl = null;
    long bestTime = Long.MAX_VALUE;
    LinkedList<I> impls = action.getCompatibleImplementations(receiver.getResource());
    for (I impl : impls) {
        Profile p = receiver.getResource().getProfile(impl);
        long avgTime = p.getAverageExecutionTime();
        if (avgTime < bestTime) {
            bestTime = avgTime;
            bestImpl = impl;
        }
    }
    FullGraphSchedulingInformation<P, T, I> dsi = (FullGraphSchedulingInformation<P, T, I>) action.getSchedulingInfo();
    long currentEnd = dsi.getExpectedEnd();
    if (bestImpl != null && currentEnd > receiver.getResource().getLastGapExpectedStart() + bestTime) {
        unschedule(action);
        schedule(action, bestImpl, receiver);
        return true;
    }
    return false;
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException) AllocatableAction(es.bsc.es.bsc.compss.scheduler.types.AllocatableAction) Profile(es.bsc.es.bsc.compss.scheduler.types.Profile)

Aggregations

AllocatableAction (es.bsc.es.bsc.compss.scheduler.types.AllocatableAction)7 FullGraphSchedulingInformation (es.bsc.es.bsc.compss.scheduler.fullGraphScheduler.FullGraphSchedulingInformation)5 PriorityActionSet (es.bsc.es.bsc.compss.scheduler.types.PriorityActionSet)5 FakeAllocatableAction (es.bsc.es.bsc.compss.scheduler.types.fake.FakeAllocatableAction)5 FakeImplementation (es.bsc.es.bsc.compss.scheduler.types.fake.FakeImplementation)5 FakeProfile (es.bsc.es.bsc.compss.scheduler.types.fake.FakeProfile)5 FakeResourceDescription (es.bsc.es.bsc.compss.scheduler.types.fake.FakeResourceDescription)5 LinkedList (java.util.LinkedList)4 PriorityQueue (java.util.PriorityQueue)4 BlockedActionException (es.bsc.es.bsc.compss.scheduler.exceptions.BlockedActionException)3 InvalidSchedulingException (es.bsc.es.bsc.compss.scheduler.exceptions.InvalidSchedulingException)3 UnassignedActionException (es.bsc.es.bsc.compss.scheduler.exceptions.UnassignedActionException)3 HashMap (java.util.HashMap)3 Profile (es.bsc.es.bsc.compss.scheduler.types.Profile)2 Test (org.junit.Test)2 ResourceDescription (es.bsc.compss.types.resources.ResourceDescription)1 WorkerResourceDescription (es.bsc.compss.types.resources.WorkerResourceDescription)1 Gap (es.bsc.es.bsc.compss.scheduler.types.Gap)1 ConcurrentModificationException (java.util.ConcurrentModificationException)1