Search in sources :

Example 31 with Implementation

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

the class ResourceScheduler method updatedCoreElements.

/**
 * Updates the coreElement structures
 *
 * @param newCoreCount
 * @param resourceJSON
 */
public void updatedCoreElements(int newCoreCount, JSONObject resourceJSON) {
    int oldCoreCount = this.profiles.length;
    Profile[][] profiles = new Profile[newCoreCount][];
    JSONObject implMap;
    if (resourceJSON != null) {
        try {
            implMap = resourceJSON.getJSONObject("implementations");
        } catch (JSONException je) {
            implMap = null;
        }
    } else {
        implMap = null;
    }
    for (int coreId = 0; coreId < newCoreCount; coreId++) {
        int oldImplCount = 0;
        if (coreId < oldCoreCount) {
            oldImplCount = this.profiles[coreId].length;
        }
        List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
        int newImplCount = impls.size();
        // Create new array
        profiles[coreId] = new Profile[newImplCount];
        // Copy the previous profile implementations
        for (Implementation impl : impls) {
            int implId = impl.getImplementationId();
            if (implId < oldImplCount) {
                profiles[coreId][implId] = this.profiles[coreId][implId];
            } else {
                JSONObject jsonImpl;
                if (implMap != null) {
                    try {
                        jsonImpl = implMap.getJSONObject(CoreManager.getSignature(coreId, implId));
                    } catch (JSONException je) {
                        jsonImpl = null;
                    }
                } else {
                    jsonImpl = null;
                }
                profiles[coreId][implId] = generateProfileForImplementation(impl, jsonImpl);
            }
        }
    }
    this.profiles = profiles;
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) Profile(es.bsc.compss.scheduler.types.Profile) Implementation(es.bsc.compss.types.implementations.Implementation)

Example 32 with Implementation

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

the class ResourceScheduler method loadProfiles.

/*
     * ***************************************************************************************************************
     * ACTION PROFILE MANAGEMENT
     * ***************************************************************************************************************
     */
/**
 * Prepares the default profiles for each implementation cores
 *
 * @param resMap
 *            default profile values for the resource
 * @param implMap
 *            default profile values for the implementation
 *
 * @return default profile structure
 */
protected final Profile[][] loadProfiles(JSONObject resMap, JSONObject implMap) {
    Profile[][] profiles;
    int coreCount = CoreManager.getCoreCount();
    profiles = new Profile[coreCount][];
    for (int coreId = 0; coreId < coreCount; ++coreId) {
        List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
        int implCount = impls.size();
        profiles[coreId] = new Profile[implCount];
        for (Implementation impl : impls) {
            String signature = CoreManager.getSignature(coreId, impl.getImplementationId());
            JSONObject jsonImpl = null;
            if (resMap != null) {
                try {
                    jsonImpl = resMap.getJSONObject(signature);
                    profiles[coreId][impl.getImplementationId()] = generateProfileForImplementation(impl, jsonImpl);
                } catch (JSONException je) {
                // Do nothing
                }
            }
            if (profiles[coreId][impl.getImplementationId()] == null) {
                if (implMap != null) {
                    try {
                        jsonImpl = implMap.getJSONObject(signature);
                    } catch (JSONException je) {
                    // Do nothing
                    }
                }
                profiles[coreId][impl.getImplementationId()] = generateProfileForImplementation(impl, jsonImpl);
                profiles[coreId][impl.getImplementationId()].clearExecutionCount();
            }
        }
    }
    return profiles;
}
Also used : JSONObject(org.json.JSONObject) JSONException(org.json.JSONException) Implementation(es.bsc.compss.types.implementations.Implementation)

Example 33 with Implementation

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

the class TaskScheduler method getTaskSummary.

/*
     * *********************************************************************************************************
     * *********************************************************************************************************
     * ********************************* MONITORING OPERATIONS *************************************************
     * *********************************************************************************************************
     * *********************************************************************************************************
     */
/**
 * Prints the task summary on a given logger @logger
 *
 * @param logger
 */
public final void getTaskSummary(Logger logger) {
    LOGGER.info("[TaskScheduler] Get task summary");
    // Structures for global and per worker stats
    int coreCount = CoreManager.getCoreCount();
    Profile[] coreGlobalProfiles = new Profile[coreCount];
    for (int i = 0; i < coreCount; ++i) {
        coreGlobalProfiles[i] = new Profile();
    }
    HashMap<String, Profile[]> coreProfilesPerWorker = new HashMap<>();
    // Retrieve information
    for (ResourceScheduler<? extends WorkerResourceDescription> ui : workers.values()) {
        if (ui == null) {
            continue;
        }
        Profile[] coreProfiles = new Profile[coreCount];
        for (int i = 0; i < coreCount; ++i) {
            coreProfiles[i] = new Profile();
        }
        List<Implementation>[] impls = ui.getExecutableImpls();
        for (int coreId = 0; coreId < coreCount; coreId++) {
            for (Implementation impl : impls[coreId]) {
                String signature = CoreManager.getSignature(coreId, impl.getImplementationId());
                boolean isPhantomSignature = signature.endsWith(")");
                if (!isPhantomSignature) {
                    // Phantom signatures are used for external execution wrappers (MPI, OMPSs, etc.)
                    coreGlobalProfiles[coreId].accumulate(ui.getProfile(impl));
                    coreProfiles[coreId].accumulate(ui.getProfile(impl));
                }
            }
        }
        coreProfilesPerWorker.put(ui.getName(), coreProfiles);
    }
    // Process information in output format
    logger.warn("------- COMPSs Task Execution Summary per Worker ------");
    for (Entry<String, Profile[]> workerInfo : coreProfilesPerWorker.entrySet()) {
        String workerName = workerInfo.getKey();
        Profile[] workerCoreProfiles = workerInfo.getValue();
        logger.warn("--- Summary for COMPSs Worker " + workerName);
        long totalExecutedTasksInWorker = 0;
        for (Entry<String, Integer> entry : CoreManager.getSignaturesToId().entrySet()) {
            String signature = entry.getKey();
            boolean isPhantomSignature = signature.endsWith(")");
            if (!isPhantomSignature) {
                int coreId = entry.getValue();
                long executionCount = workerCoreProfiles[coreId].getExecutionCount();
                totalExecutedTasksInWorker += executionCount;
                String info = executionCount + " " + signature + " tasks have been executed";
                logger.warn(info);
            }
        }
        logger.warn("--- Total executed tasks in COMPSs Worker " + workerName + ": " + totalExecutedTasksInWorker);
    }
    logger.warn("-------------------------------------------------------");
    logger.warn("");
    logger.warn("------------ COMPSs Task Execution Summary ------------");
    long totalExecutedTasks = 0;
    for (Entry<String, Integer> entry : CoreManager.getSignaturesToId().entrySet()) {
        String signature = entry.getKey();
        boolean isPhantomSignature = signature.endsWith(")");
        if (!isPhantomSignature) {
            int coreId = entry.getValue();
            long executionCount = coreGlobalProfiles[coreId].getExecutionCount();
            totalExecutedTasks += executionCount;
            String info = executionCount + " " + signature + " tasks have been executed";
            logger.warn(info);
        }
    }
    logger.warn("Total executed tasks: " + totalExecutedTasks);
    logger.warn("-------------------------------------------------------");
}
Also used : HashMap(java.util.HashMap) Profile(es.bsc.compss.scheduler.types.Profile) Implementation(es.bsc.compss.types.implementations.Implementation) LinkedList(java.util.LinkedList) List(java.util.List)

Example 34 with Implementation

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

the class ResourceOptimizer method getUnfulfilledConstraints.

// Removes from the list all the Constraints fulfilled by existing
// resources
@SuppressWarnings("unchecked")
private static List<ConstraintsCore>[] getUnfulfilledConstraints() {
    int coreCount = CoreManager.getCoreCount();
    List<ConstraintsCore>[] unfulfilledConstraints = new LinkedList[coreCount];
    int[] maxSimTasks = ResourceManager.getTotalSlots();
    for (int coreId = 0; coreId < coreCount; coreId++) {
        unfulfilledConstraints[coreId] = new LinkedList<>();
        if (maxSimTasks[coreId] == 0) {
            List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
            for (Implementation impl : impls) {
                if (impl.getTaskType() == TaskType.METHOD) {
                    MethodResourceDescription requirements = (MethodResourceDescription) impl.getRequirements();
                    CloudMethodResourceDescription cd = new CloudMethodResourceDescription(requirements);
                    ConstraintsCore cc = new ConstraintsCore(cd, coreId, unfulfilledConstraints[coreId]);
                    unfulfilledConstraints[coreId].add(cc);
                }
            }
        }
    }
    return unfulfilledConstraints;
}
Also used : CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) LinkedList(java.util.LinkedList) List(java.util.List) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) LinkedList(java.util.LinkedList) Implementation(es.bsc.compss.types.implementations.Implementation) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation)

Example 35 with Implementation

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

the class ResourceSchedulerTest method testAllSetCopy.

@Test
public void testAllSetCopy() {
    ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodA\":" + SET_PROFILE + "," + "\"ClassB.methodA\":" + SET_PROFILE + "," + "\"ClassA.methodB\":" + SET_PROFILE + "}}"), null);
    JSONObject jo = rs.toJSONObject();
    rs = new ResourceScheduler<>(worker, jo, null);
    for (int coreId = 0; coreId < CoreManager.getCoreCount(); coreId++) {
        List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
        for (Implementation impl : impls) {
            Profile p = rs.getProfile(impl);
            try {
                checkSetProfile(p);
            } catch (CheckerException ce) {
                fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on copy 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)

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