Search in sources :

Example 51 with Implementation

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

the class TestCompatible method resourceManagerTest.

/*
     * **********************************************************************************************************
     * RESOURCE MANAGER TEST IMPLEMENTATION
     * **********************************************************************************************************
     */
private static void resourceManagerTest() {
    coreCount = CoreManager.getCoreCount();
    ActionOrchestrator orchestrator = COMPSsRuntimeImpl.getOrchestrator();
    // Check for each implementation the correctness of its resources
    System.out.println("[LOG] Number of cores = " + coreCount);
    for (int coreId = 0; coreId < coreCount; coreId++) {
        System.out.println("[LOG] Checking Core" + coreId);
        Action a = new Action(orchestrator, coreId);
        Map<Worker<?>, List<Implementation>> m = a.findAvailableWorkers();
        // For the test construction, all implementations can be run. Check it
        if (m.size() == 0) {
            System.err.println("[ERROR] CoreId " + coreId + " cannot be run");
            List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
            for (Implementation impl : impls) {
                System.out.println("-- Impl: " + impl.getRequirements().toString());
            }
            System.exit(-1);
        }
        // Check that all assigned resources are really valid
        checkCoreResources(coreId, m);
    }
}
Also used : ActionOrchestrator(es.bsc.compss.scheduler.types.ActionOrchestrator) Action(commons.Action) ServiceWorker(es.bsc.compss.types.resources.ServiceWorker) Worker(es.bsc.compss.types.resources.Worker) MethodWorker(es.bsc.compss.types.resources.MethodWorker) List(java.util.List) LinkedList(java.util.LinkedList) Implementation(es.bsc.compss.types.implementations.Implementation) ServiceImplementation(es.bsc.compss.types.implementations.ServiceImplementation) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation)

Example 52 with Implementation

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

the class ExecutionAction method schedule.

private final <T extends WorkerResourceDescription> void schedule(Score actionScore, List<ResourceScheduler<? extends WorkerResourceDescription>> candidates) throws BlockedActionException, UnassignedActionException {
    // COMPUTE BEST WORKER AND IMPLEMENTATION
    StringBuilder debugString = new StringBuilder("Scheduling " + this + " execution:\n");
    ResourceScheduler<? extends WorkerResourceDescription> bestWorker = null;
    Implementation bestImpl = null;
    Score bestScore = null;
    int usefulResources = 0;
    for (ResourceScheduler<? extends WorkerResourceDescription> worker : candidates) {
        if (this.getExecutingResources().contains(worker)) {
            if (DEBUG) {
                LOGGER.debug("Task already ran on worker " + worker.getName());
            }
            continue;
        }
        Score resourceScore = worker.generateResourceScore(this, task.getTaskDescription(), actionScore);
        ++usefulResources;
        for (Implementation impl : getCompatibleImplementations(worker)) {
            Score implScore = worker.generateImplementationScore(this, task.getTaskDescription(), impl, resourceScore);
            if (DEBUG) {
                debugString.append(" Resource ").append(worker.getName()).append(" ").append(" Implementation ").append(impl.getImplementationId()).append(" ").append(" Score ").append(implScore).append("\n");
            }
            if (Score.isBetter(implScore, bestScore)) {
                bestWorker = worker;
                bestImpl = impl;
                bestScore = implScore;
            }
        }
    }
    // CHECK SCHEDULING RESULT
    if (DEBUG) {
        LOGGER.debug(debugString.toString());
    }
    if (bestWorker == null && usefulResources == 0) {
        LOGGER.warn("No worker can run " + this);
        throw new BlockedActionException();
    }
    schedule(bestWorker, bestImpl);
}
Also used : Score(es.bsc.compss.scheduler.types.Score) BlockedActionException(es.bsc.compss.scheduler.exceptions.BlockedActionException) Implementation(es.bsc.compss.types.implementations.Implementation)

Example 53 with Implementation

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

the class ExecutionAction method schedule.

@Override
public final <T extends WorkerResourceDescription> void schedule(ResourceScheduler<T> targetWorker, Score actionScore) throws BlockedActionException, UnassignedActionException {
    if (targetWorker == null || // Resource is not compatible with the Core
    !targetWorker.getResource().canRun(task.getTaskDescription().getId()) || // already ran on the resource
    this.getExecutingResources().contains(targetWorker)) {
        String message = "Worker " + (targetWorker == null ? "null" : targetWorker.getName()) + " has not available resources to run " + this;
        LOGGER.warn(message);
        throw new UnassignedActionException();
    }
    Implementation bestImpl = null;
    Score bestScore = null;
    Score resourceScore = targetWorker.generateResourceScore(this, task.getTaskDescription(), actionScore);
    for (Implementation impl : getCompatibleImplementations(targetWorker)) {
        Score implScore = targetWorker.generateImplementationScore(this, task.getTaskDescription(), impl, resourceScore);
        if (Score.isBetter(implScore, bestScore)) {
            bestImpl = impl;
            bestScore = implScore;
        }
    }
    schedule(targetWorker, bestImpl);
}
Also used : Score(es.bsc.compss.scheduler.types.Score) UnassignedActionException(es.bsc.compss.scheduler.exceptions.UnassignedActionException) Implementation(es.bsc.compss.types.implementations.Implementation)

Example 54 with Implementation

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

the class MOResourceSchedulerTest method setUpClass.

@BeforeClass
public static void setUpClass() {
    LOGGER.info("Setup Class");
    // Method resource description and its slots
    Processor p = new Processor();
    p.setComputingUnits(4);
    MethodResourceDescription description = new MethodResourceDescription();
    description.addProcessor(p);
    worker = new FakeWorker(description, 4);
    int coreId = CoreManager.registerNewCoreElement("methodA");
    LinkedList<Implementation> impls = new LinkedList<>();
    LinkedList<String> signs = new LinkedList<>();
    Implementation impl = new MethodImplementation("ClassA", "methodA", coreId, 0, new MethodResourceDescription());
    impls.add(impl);
    signs.add("ClassA.methodA");
    impl = new MethodImplementation("ClassB", "methodA", coreId, 1, new MethodResourceDescription());
    impls.add(impl);
    signs.add("ClassB.methodA");
    CoreManager.registerNewImplementations(coreId, impls, signs);
    coreId = CoreManager.registerNewCoreElement("methodB");
    impls = new LinkedList<>();
    signs = new LinkedList<>();
    impl = new MethodImplementation("ClassA", "methodB", coreId, 0, new MethodResourceDescription());
    impls.add(impl);
    signs.add("ClassA.methodB");
    CoreManager.registerNewImplementations(coreId, impls, signs);
}
Also used : MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) Processor(es.bsc.compss.types.resources.components.Processor) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) FakeWorker(es.bsc.compss.scheduler.types.fake.FakeWorker) Implementation(es.bsc.compss.types.implementations.Implementation) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) LinkedList(java.util.LinkedList) BeforeClass(org.junit.BeforeClass)

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