Search in sources :

Example 21 with Implementation

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

the class CloudTypeManager method newCoreElementsDetected.

public void newCoreElementsDetected(List<Integer> newCores) {
    int coreCount = CoreManager.getCoreCount();
    for (CloudInstanceTypeDescription type : types.values()) {
        int[][] slotsI = new int[coreCount][];
        // Copy actual values
        int[] slotsC = Arrays.copyOf(type.getSlotsCore(), coreCount);
        for (int i = 0; i < type.getSlotsImplLength(); ++i) {
            int[] slotsImpl = type.getSpecificSlotsImpl(i);
            slotsI[i] = slotsImpl.clone();
        }
        // Get new values
        for (int coreId : newCores) {
            List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
            int implsSize = impls.size();
            slotsI[coreId] = new int[implsSize];
            for (int implId = 0; implId < implsSize; ++implId) {
                Implementation impl = impls.get(implId);
                if (impl.getTaskType() == TaskType.METHOD) {
                    MethodResourceDescription rd = (MethodResourceDescription) impl.getRequirements();
                    Integer into = type.getResourceDescription().canHostSimultaneously(rd);
                    slotsC[coreId] = Math.max(slotsC[coreId], into);
                    slotsI[coreId][implId] = into;
                }
            }
        }
        type.setSlotsCore(slotsC);
        type.setSlotsImpl(slotsI);
    }
}
Also used : CloudInstanceTypeDescription(es.bsc.compss.types.resources.description.CloudInstanceTypeDescription) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) Implementation(es.bsc.compss.types.implementations.Implementation)

Example 22 with Implementation

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

the class ResourceScheduler method toJSONObject.

public JSONObject toJSONObject() {
    JSONObject jsonObject = new JSONObject();
    int coreCount = CoreManager.getCoreCount();
    Map<String, JSONObject> implsMap = new HashMap<>();
    for (int coreId = 0; coreId < coreCount; coreId++) {
        List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
        for (Implementation impl : impls) {
            int implId = impl.getImplementationId();
            JSONObject implProfile = profiles[coreId][implId].toJSONObject();
            implsMap.put(CoreManager.getSignature(coreId, implId), implProfile);
        }
    }
    jsonObject.put("implementations", implsMap);
    return jsonObject;
}
Also used : JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) Implementation(es.bsc.compss.types.implementations.Implementation)

Example 23 with Implementation

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

the class ResourceScheduler method tryToLaunchBlockedActions.

/**
 * Tries to launch blocked actions on resource. When an action cannot be launched, its successors are not tried
 */
@SuppressWarnings("unchecked")
public final void tryToLaunchBlockedActions() {
    LOGGER.debug("[ResourceScheduler] Try to launch blocked actions on resource " + getName());
    while (this.hasBlockedActions()) {
        AllocatableAction firstBlocked = this.getFirstBlocked();
        Implementation selectedImplementation = firstBlocked.getAssignedImplementation();
        if (!firstBlocked.isToReserveResources() || myWorker.canRunNow((T) selectedImplementation.getRequirements())) {
            try {
                firstBlocked.resumeExecution();
                this.removeFirstBlocked();
            } catch (ActionNotWaitingException anwe) {
            // Not possible. If the task is in blocked list it is waiting
            }
        } else {
            break;
        }
    }
}
Also used : ActionNotWaitingException(es.bsc.compss.scheduler.exceptions.ActionNotWaitingException) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) Implementation(es.bsc.compss.types.implementations.Implementation)

Example 24 with Implementation

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

the class TaskScheduler method getCoresMonitoringData.

/**
 * Returns the coreElement information with the given @prefix
 *
 * @param prefix
 * @return
 */
public final String getCoresMonitoringData(String prefix) {
    LOGGER.info("[TaskScheduler] Get cores monitoring data");
    // Create size structure for profiles
    int coreCount = CoreManager.getCoreCount();
    Profile[][] implementationsProfile = new Profile[coreCount][];
    for (int i = 0; i < coreCount; ++i) {
        int implsCount = CoreManager.getNumberCoreImplementations(i);
        implementationsProfile[i] = new Profile[implsCount];
        for (int j = 0; j < implsCount; ++j) {
            implementationsProfile[i][j] = new Profile();
        }
    }
    // Collect information from turned off VMs
    for (int i = 0; i < coreCount; ++i) {
        int implsCount = CoreManager.getNumberCoreImplementations(i);
        for (int j = 0; j < implsCount; ++j) {
            implementationsProfile[i][j].accumulate(offVMsProfiles[i][j]);
        }
    }
    // Retrieve information from workers
    for (ResourceScheduler<? extends WorkerResourceDescription> ui : workers.values()) {
        if (ui == null) {
            continue;
        }
        List<Implementation>[] runningCoreImpls = ui.getExecutableImpls();
        for (int coreId = 0; coreId < coreCount; coreId++) {
            for (Implementation impl : runningCoreImpls[coreId]) {
                int implId = impl.getImplementationId();
                implementationsProfile[coreId][implId].accumulate(ui.getProfile(impl));
            }
        }
    }
    // Construct information string
    StringBuilder coresInfo = new StringBuilder();
    coresInfo.append(prefix).append("<CoresInfo>").append("\n");
    for (int coreId = 0; coreId < implementationsProfile.length; ++coreId) {
        coresInfo.append(prefix).append("\t").append("<Core id=\"").append(coreId).append("\"").append(">").append("\n");
        for (int implId = 0; implId < implementationsProfile[coreId].length; ++implId) {
            // Get method's signature
            String signature = CoreManager.getSignature(coreId, implId);
            coresInfo.append(prefix).append("\t\t").append("<Impl id=\"").append(implId).append("\"").append(">").append("\n");
            coresInfo.append(prefix).append("\t\t\t").append("<Signature>").append(signature).append("</Signature>").append("\n");
            coresInfo.append(prefix).append("\t\t\t").append("<MeanExecutionTime>").append(implementationsProfile[coreId][implId].getAverageExecutionTime()).append("</MeanExecutionTime>").append("\n");
            coresInfo.append(prefix).append("\t\t\t").append("<MinExecutionTime>").append(implementationsProfile[coreId][implId].getMinExecutionTime()).append("</MinExecutionTime>").append("\n");
            coresInfo.append(prefix).append("\t\t\t").append("<MaxExecutionTime>").append(implementationsProfile[coreId][implId].getMaxExecutionTime()).append("</MaxExecutionTime>").append("\n");
            coresInfo.append(prefix).append("\t\t\t").append("<ExecutedCount>").append(implementationsProfile[coreId][implId].getExecutionCount()).append("</ExecutedCount>").append("\n");
            coresInfo.append(prefix).append("\t\t").append("</Impl>").append("\n");
        }
        coresInfo.append(prefix).append("\t").append("</Core>").append("\n");
    }
    coresInfo.append(prefix).append("</CoresInfo>").append("\n");
    return coresInfo.toString();
}
Also used : LinkedList(java.util.LinkedList) List(java.util.List) Profile(es.bsc.compss.scheduler.types.Profile) Implementation(es.bsc.compss.types.implementations.Implementation)

Example 25 with Implementation

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

the class TaskScheduler method updateWorkloadState.

protected void updateWorkloadState(WorkloadState state) {
    LOGGER.info("[TaskScheduler] Get workload state");
    int coreCount = CoreManager.getCoreCount();
    Profile[] coreProfile = new Profile[coreCount];
    for (int coreId = 0; coreId < coreCount; coreId++) {
        coreProfile[coreId] = new Profile();
    }
    for (ResourceScheduler<? extends WorkerResourceDescription> ui : workers.values()) {
        if (ui == null) {
            continue;
        }
        List<Implementation>[] impls = ui.getExecutableImpls();
        for (int coreId = 0; coreId < coreCount; coreId++) {
            for (Implementation impl : impls[coreId]) {
                coreProfile[coreId].accumulate(ui.getProfile(impl));
            }
        }
        AllocatableAction[] runningActions = ui.getHostedActions();
        long now = System.currentTimeMillis();
        for (AllocatableAction running : runningActions) {
            if (running.getImplementations().length > 0) {
                Integer coreId = running.getImplementations()[0].getCoreId();
                // CoreId can be null for Actions that are not tasks
                if (coreId != null) {
                    state.registerRunning(coreId, now - running.getStartTime());
                }
            }
        }
    }
    for (int coreId = 0; coreId < coreCount; coreId++) {
        state.registerNoResources(coreId, blockedActions.getActionCounts()[coreId]);
        state.registerReady(coreId, readyCounts[coreId]);
        state.registerTimes(coreId, coreProfile[coreId].getMinExecutionTime(), coreProfile[coreId].getAverageExecutionTime(), coreProfile[coreId].getMaxExecutionTime());
    }
}
Also used : AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) LinkedList(java.util.LinkedList) List(java.util.List) Profile(es.bsc.compss.scheduler.types.Profile) Implementation(es.bsc.compss.types.implementations.Implementation)

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