Search in sources :

Example 1 with MOScore

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

the class MOResourceOptimizer method getBestImplementation.

private Implementation getBestImplementation(List<Implementation> impls, MOProfile[] profiles) {
    Implementation impl = impls.get(0);
    MOScore bestScore = new MOScore(0, 0, 0, profiles[0].getAverageExecutionTime(), profiles[0].getPower(), profiles[0].getPrice());
    for (int i = 1; i < impls.size(); i++) {
        Implementation candidate = impls.get(i);
        long length = profiles[i].getAverageExecutionTime();
        double power = profiles[i].getPower();
        double price = profiles[i].getPrice();
        MOScore score = new MOScore(0, 0, 0, length, power * length, price);
        if (Score.isBetter(score, bestScore)) {
            bestScore = score;
            impl = candidate;
        }
    }
    return impl;
}
Also used : Implementation(es.bsc.compss.types.implementations.Implementation) MOScore(es.bsc.compss.scheduler.multiobjective.types.MOScore)

Example 2 with MOScore

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

the class MOResourceScheduler method tryToLaunch.

private boolean tryToLaunch(AllocatableAction action) {
    boolean launched = false;
    try {
        action.tryToLaunch();
        launched = true;
    } catch (InvalidSchedulingException ise) {
    }
    if (!launched) {
        long actionScore = MOScore.getActionScore(action);
        Score aScore = new MOScore(actionScore, 0, 0, 0, 0, 0);
        try {
            action.schedule(aScore);
            try {
                action.tryToLaunch();
            } catch (InvalidSchedulingException ise2) {
                // Impossible exception.
                LOGGER.error(ise2);
            }
        } catch (BlockedActionException | UnassignedActionException be) {
            // Can not happen since there was an original source
            LOGGER.error(be);
        }
    }
    return launched;
}
Also used : Score(es.bsc.compss.scheduler.types.Score) MOScore(es.bsc.compss.scheduler.multiobjective.types.MOScore) UnassignedActionException(es.bsc.compss.scheduler.exceptions.UnassignedActionException) BlockedActionException(es.bsc.compss.scheduler.exceptions.BlockedActionException) InvalidSchedulingException(es.bsc.compss.scheduler.exceptions.InvalidSchedulingException) MOScore(es.bsc.compss.scheduler.multiobjective.types.MOScore)

Example 3 with MOScore

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

the class MOResourceScheduler method generateMOScore.

public MOScore generateMOScore(long resourceFreeTime, long expectedDataAvailable, long actionPriority, Implementation impl) {
    long implScore = 0;
    double energy = 0;
    double cost = 0;
    MOProfile p = (MOProfile) this.getProfile(impl);
    if (p != null) {
        implScore = p.getAverageExecutionTime();
        long waitingTime = Math.max(resourceFreeTime, expectedDataAvailable);
        if (waitingTime < Long.MAX_VALUE) {
            energy = ((waitingTime + implScore) * getIdlePower()) + (p.getPower() * implScore);
            cost = ((waitingTime + implScore) * getIdlePrice()) + (p.getPrice() * implScore);
        } else {
            energy = Double.MAX_VALUE;
            cost = Double.MAX_VALUE;
        }
    }
    // The data transfer penalty is already included on the datadependency time of the resourceScore
    return new MOScore(actionPriority, expectedDataAvailable, resourceFreeTime, implScore, energy, cost);
}
Also used : MOProfile(es.bsc.compss.scheduler.multiobjective.types.MOProfile) MOScore(es.bsc.compss.scheduler.multiobjective.types.MOScore)

Example 4 with MOScore

use of es.bsc.compss.scheduler.multiobjective.types.MOScore 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 5 with MOScore

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

the class MOResourceScheduler method generateResourceScore.

/*--------------------------------------------------
     ---------------------------------------------------
     ------------------ Score Methods ------------------
     ---------------------------------------------------
     --------------------------------------------------*/
/**
 * @param action
 * @param params
 * @param actionScore
 * @return
 */
@Override
public Score generateResourceScore(AllocatableAction action, TaskDescription params, Score actionScore) {
    long resScore = Score.calculateDataLocalityScore(params, myWorker);
    for (AllocatableAction pred : action.getDataPredecessors()) {
        if (pred.isPending() && pred.getAssignedResource() == this) {
            resScore++;
        }
    }
    resScore = params.getParameters().length - resScore;
    long lessTimeStamp = Long.MAX_VALUE;
    Gap g = gaps.peekFirst();
    if (g != null) {
        lessTimeStamp = g.getInitialTime();
        if (lessTimeStamp < 0) {
            lessTimeStamp = 0;
        }
    }
    long actionPriority = actionScore.getActionScore();
    long expectedDataAvailable = ((MOScore) actionScore).getExpectedDataAvailable() + resScore * MOConfiguration.DATA_TRANSFER_DELAY;
    return new MOScore(actionPriority, expectedDataAvailable, lessTimeStamp, 0, 0, 0);
}
Also used : Gap(es.bsc.compss.scheduler.multiobjective.types.Gap) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) MOScore(es.bsc.compss.scheduler.multiobjective.types.MOScore)

Aggregations

MOScore (es.bsc.compss.scheduler.multiobjective.types.MOScore)7 Score (es.bsc.compss.scheduler.types.Score)3 BlockedActionException (es.bsc.compss.scheduler.exceptions.BlockedActionException)2 InvalidSchedulingException (es.bsc.compss.scheduler.exceptions.InvalidSchedulingException)2 UnassignedActionException (es.bsc.compss.scheduler.exceptions.UnassignedActionException)2 Gap (es.bsc.compss.scheduler.multiobjective.types.Gap)2 AllocatableAction (es.bsc.compss.scheduler.types.AllocatableAction)2 Implementation (es.bsc.compss.types.implementations.Implementation)2 ActionNotFoundException (es.bsc.compss.scheduler.exceptions.ActionNotFoundException)1 MOProfile (es.bsc.compss.scheduler.multiobjective.types.MOProfile)1 ConcurrentModificationException (java.util.ConcurrentModificationException)1