Search in sources :

Example 11 with Implementation

use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.

the class ResourceSchedulerTest method testMethodAUpdatedNull.

@Test
public void testMethodAUpdatedNull() {
    ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodA\":" + SET_AND_UPDATED_PROFILE + "}}"), null);
    List<Implementation> impls = CoreManager.getCoreImplementations(0);
    for (Implementation impl : impls) {
        Profile p = rs.getProfile(impl);
        if (impl.getImplementationId() == 1) {
            try {
                checkUnsetProfile(p);
            } catch (CheckerException ce) {
                fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA updated-null test");
            }
        } else {
            try {
                this.checkSetAndIncreasedProfile(p);
            } catch (CheckerException ce) {
                fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA updated-null test");
            }
        }
    }
    impls = CoreManager.getCoreImplementations(1);
    for (Implementation impl : impls) {
        Profile p = rs.getProfile(impl);
        try {
            checkUnsetProfile(p);
        } catch (CheckerException ce) {
            fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA updated-null test");
        }
    }
}
Also used : JSONObject(org.json.JSONObject) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) ResourceScheduler(es.bsc.compss.components.impl.ResourceScheduler) Implementation(es.bsc.compss.types.implementations.Implementation) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) Test(org.junit.Test)

Example 12 with Implementation

use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.

the class MOScheduleOptimizer method move.

private boolean move(AllocatableAction action, OptimizationWorker donor, OptimizationWorker receiver) {
    LOGGER.debug(LOG_PREFIX + "Trying to move " + action + " from " + donor.getName() + " to " + receiver.getName());
    List<AllocatableAction> dataPreds = action.getDataPredecessors();
    long dataAvailable = 0;
    try {
        for (AllocatableAction dataPred : dataPreds) {
            MOSchedulingInformation dsi = (MOSchedulingInformation) dataPred.getSchedulingInfo();
            dataAvailable = Math.max(dataAvailable, dsi.getExpectedEnd());
        }
    } catch (ConcurrentModificationException cme) {
        dataAvailable = 0;
        dataPreds = action.getDataPredecessors();
    }
    Implementation bestImpl = null;
    List<Implementation> impls = action.getCompatibleImplementations(receiver.getResource());
    Score bestScore = null;
    for (Implementation impl : impls) {
        MOScore actionScore = MOScheduler.getActionScore(action);
        MOScore score = ((MOResourceScheduler<?>) (receiver.getResource())).generateMoveImplementationScore(action, null, impl, actionScore, (long) (OPTIMIZATION_THRESHOLD * 2.5));
        if (Score.isBetter(score, bestScore)) {
            bestImpl = impl;
            bestScore = score;
        }
    }
    Implementation currentImpl = action.getAssignedImplementation();
    MOScore actionScore = MOScheduler.getActionScore(action);
    LOGGER.debug(LOG_PREFIX + "Calculating score for current execution");
    MOScore currentScore = ((MOResourceScheduler<?>) (action.getAssignedResource())).generateCurrentImplementationScore(action, currentImpl, actionScore);
    LOGGER.debug(LOG_PREFIX + "Comparing scores: \n" + bestScore + "\n " + currentScore);
    if (bestImpl != null && Score.isBetter(bestScore, currentScore)) {
        try {
            LOGGER.debug(LOG_PREFIX + "Moving " + action + " from " + donor.getName() + " to " + receiver.getName());
            unscheduleFromWorker(action);
            scheduleOnWorker(action, bestImpl, receiver);
        } catch (ActionNotFoundException anfe) {
        // Action was already moved from the resource. Recompute Optimizations!!!
        }
        return true;
    } else {
        LOGGER.debug(LOG_PREFIX + "Action " + action + " not moved because new position is not better than actual");
    }
    return false;
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException) MOScore(es.bsc.compss.scheduler.multiobjective.types.MOScore) Score(es.bsc.compss.scheduler.types.Score) ActionNotFoundException(es.bsc.compss.scheduler.exceptions.ActionNotFoundException) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) Implementation(es.bsc.compss.types.implementations.Implementation) MOScore(es.bsc.compss.scheduler.multiobjective.types.MOScore)

Example 13 with Implementation

use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.

the class LocalOptimizationState method pollActionForGap.

public AllocatableAction pollActionForGap(Gap gap) {
    AllocatableAction gapAction = null;
    PriorityQueue<AllocatableAction> peeks = selectableActions.peekAll();
    // Get Main action to fill the gap
    while (!peeks.isEmpty() && gapAction == null) {
        AllocatableAction candidate = peeks.poll();
        // Check times
        MOSchedulingInformation candidateDSI = (MOSchedulingInformation) candidate.getSchedulingInfo();
        long start = candidateDSI.getExpectedStart();
        if (start > gap.getEndTime()) {
            continue;
        }
        Implementation impl = candidate.getAssignedImplementation();
        Profile p = worker.getProfile(impl);
        long expectedLength = p.getAverageExecutionTime();
        if ((gap.getEndTime() - gap.getInitialTime()) < expectedLength) {
            continue;
        }
        if ((start + expectedLength) > gap.getEndTime()) {
            continue;
        }
        // Check description
        if (gap.getResources().canHostDynamic(impl)) {
            selectableActions.removeFirst(candidate.getCoreId());
            gapAction = candidate;
        }
    }
    return gapAction;
}
Also used : MOSchedulingInformation(es.bsc.compss.scheduler.multiobjective.MOSchedulingInformation) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) Implementation(es.bsc.compss.types.implementations.Implementation) Profile(es.bsc.compss.scheduler.types.Profile)

Example 14 with Implementation

use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.

the class InitialSchedulingTest method setUpClass.

@BeforeClass
public static void setUpClass() {
    CoreManager.clear();
    CoreManager.registerNewCoreElement("fakeSignature00");
    CoreManager.registerNewCoreElement("fakeSignature10");
    CoreManager.registerNewCoreElement("fakeSignature20");
    FakeImplementation impl00 = new FakeImplementation(0, 0, new FakeResourceDescription(2));
    List<Implementation<?>> impls0 = new LinkedList<>();
    impls0.add(impl00);
    List<String> signatures0 = new LinkedList<>();
    signatures0.add("fakeSignature00");
    CoreManager.registerNewImplementations(0, impls0, signatures0);
    FakeImplementation impl10 = new FakeImplementation(1, 0, new FakeResourceDescription(3));
    List<Implementation<?>> impls1 = new LinkedList<>();
    impls1.add(impl10);
    List<String> signatures1 = new LinkedList<>();
    signatures1.add("fakeSignature10");
    CoreManager.registerNewImplementations(1, impls1, signatures1);
    FakeImplementation impl20 = new FakeImplementation(2, 0, new FakeResourceDescription(1));
    List<Implementation<?>> impls2 = new LinkedList<>();
    impls2.add(impl20);
    List<String> signatures2 = new LinkedList<>();
    signatures2.add("fakeSignature20");
    CoreManager.registerNewImplementations(2, impls2, signatures2);
    int maxSlots = 4;
    FakeResourceDescription frd = new FakeResourceDescription(maxSlots);
    FakeWorker fw = new FakeWorker("worker1", frd, maxSlots);
    drs = new FakeResourceScheduler(fw, fao, 0);
    drs.profiledExecution(impl00, new FakeProfile(50));
    drs.profiledExecution(impl10, new FakeProfile(50));
    drs.profiledExecution(impl20, new FakeProfile(30));
    CORE0 = drs.getProfile(impl00).getAverageExecutionTime();
    CORE1 = drs.getProfile(impl10).getAverageExecutionTime();
    CORE2 = drs.getProfile(impl20).getAverageExecutionTime();
// debugConfiguration();
}
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) FakeResourceScheduler(es.bsc.es.bsc.compss.scheduler.types.fake.FakeResourceScheduler) Implementation(es.bsc.compss.types.implementations.Implementation) FakeImplementation(es.bsc.es.bsc.compss.scheduler.types.fake.FakeImplementation) LinkedList(java.util.LinkedList) FakeWorker(es.bsc.es.bsc.compss.scheduler.types.fake.FakeWorker) BeforeClass(org.junit.BeforeClass)

Example 15 with Implementation

use of es.bsc.compss.types.implementations.Implementation 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");
    }
}
Also used : MOResourceScheduler(es.bsc.compss.scheduler.multiobjective.MOResourceScheduler) JSONObject(org.json.JSONObject) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) Implementation(es.bsc.compss.types.implementations.Implementation) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) MOProfile(es.bsc.compss.scheduler.multiobjective.types.MOProfile) Test(org.junit.Test)

Aggregations

Implementation (es.bsc.compss.types.implementations.Implementation)54 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)24 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)20 LinkedList (java.util.LinkedList)19 JSONObject (org.json.JSONObject)13 Test (org.junit.Test)12 ResourceScheduler (es.bsc.compss.components.impl.ResourceScheduler)10 List (java.util.List)9 MOProfile (es.bsc.compss.scheduler.multiobjective.types.MOProfile)8 CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)8 HashMap (java.util.HashMap)7 AllocatableAction (es.bsc.compss.scheduler.types.AllocatableAction)6 Profile (es.bsc.compss.scheduler.types.Profile)6 BeforeClass (org.junit.BeforeClass)6 CloudInstanceTypeDescription (es.bsc.compss.types.resources.description.CloudInstanceTypeDescription)5 WorkerResourceDescription (es.bsc.compss.types.resources.WorkerResourceDescription)4 Score (es.bsc.compss.scheduler.types.Score)3 ServiceImplementation (es.bsc.compss.types.implementations.ServiceImplementation)3 Worker (es.bsc.compss.types.resources.Worker)3 Processor (es.bsc.compss.types.resources.components.Processor)3