Search in sources :

Example 46 with Implementation

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

the class MOResourceScheduler method manageRunningAction.

private void manageRunningAction(AllocatableAction action, LocalOptimizationState state) {
    Implementation impl = action.getAssignedImplementation();
    MOSchedulingInformation actionDSI = (MOSchedulingInformation) action.getSchedulingInfo();
    // Set start Time
    Long startTime = action.getStartTime();
    long start;
    if (startTime != null) {
        start = startTime - state.getId();
    } else {
        start = 0;
    }
    actionDSI.setExpectedStart(start);
    // Set End Time
    MOProfile p = (MOProfile) getProfile(impl);
    long endTime = start;
    if (p != null) {
        endTime += p.getAverageExecutionTime();
    }
    if (endTime < 0) {
        endTime = 0;
    }
    actionDSI.setExpectedEnd(endTime);
    actionDSI.clearPredecessors();
    actionDSI.clearSuccessors();
    actionDSI.setToReschedule(false);
    state.runningAction(impl, p, endTime);
}
Also used : Implementation(es.bsc.compss.types.implementations.Implementation) MOProfile(es.bsc.compss.scheduler.multiobjective.types.MOProfile)

Example 47 with Implementation

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

the class LocalOptimizationState method updateConsumptions.

// CONSUMPTIONS
public void updateConsumptions(AllocatableAction action) {
    Implementation impl = action.getAssignedImplementation();
    MOProfile p = (MOProfile) worker.getProfile(impl);
    if (p != null) {
        MOSchedulingInformation dsi = (MOSchedulingInformation) action.getSchedulingInfo();
        long length = dsi.getExpectedEnd() - (dsi.getExpectedStart() < 0 ? 0 : dsi.getExpectedStart());
        implementationCount[impl.getCoreId()][impl.getImplementationId()]++;
        totalEnergy += p.getPower() * length;
        totalCost += p.getPrice() * length;
    }
}
Also used : MOSchedulingInformation(es.bsc.compss.scheduler.multiobjective.MOSchedulingInformation) Implementation(es.bsc.compss.types.implementations.Implementation)

Example 48 with Implementation

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

the class CERegistration method process.

@Override
public void process(TaskScheduler ts) {
    // Register the coreElement
    Integer coreId = CoreManager.registerNewCoreElement(coreElementSignature);
    if (coreId == null) {
        // CoreElement already exists, retrieve its id
        coreId = CoreManager.getCoreId(coreElementSignature);
    }
    // Retrieve the new implementation number
    int implId = CoreManager.getNumberCoreImplementations(coreId);
    // Create the implementation
    Implementation m = null;
    switch(implType) {
        case METHOD:
            if (this.implTypeArgs.length != 2) {
                ErrorManager.error("Incorrect parameters for type METHOD on " + this.coreElementSignature);
            }
            String declaringClass = EnvironmentLoader.loadFromEnvironment(implTypeArgs[0]);
            String methodName = EnvironmentLoader.loadFromEnvironment(implTypeArgs[1]);
            if (declaringClass == null || declaringClass.isEmpty()) {
                ErrorManager.error("Empty declaringClass annotation for method " + this.coreElementSignature);
            }
            if (methodName == null || methodName.isEmpty()) {
                ErrorManager.error("Empty methodName annotation for method " + this.coreElementSignature);
            }
            m = new MethodImplementation(declaringClass, methodName, coreId, implId, implConstraints);
            break;
        case MPI:
            if (this.implTypeArgs.length != 3) {
                ErrorManager.error("Incorrect parameters for type MPI on " + this.coreElementSignature);
            }
            String mpiBinary = EnvironmentLoader.loadFromEnvironment(implTypeArgs[0]);
            String mpiWorkingDir = EnvironmentLoader.loadFromEnvironment(implTypeArgs[1]);
            String mpiRunner = EnvironmentLoader.loadFromEnvironment(implTypeArgs[2]);
            if (mpiRunner == null || mpiRunner.isEmpty()) {
                ErrorManager.error("Empty mpiRunner annotation for MPI method " + this.coreElementSignature);
            }
            if (mpiBinary == null || mpiBinary.isEmpty()) {
                ErrorManager.error("Empty binary annotation for MPI method " + this.coreElementSignature);
            }
            m = new MPIImplementation(mpiBinary, mpiWorkingDir, mpiRunner, coreId, implId, this.implConstraints);
            break;
        case DECAF:
            if (this.implTypeArgs.length != 5) {
                ErrorManager.error("Incorrect parameters for type DECAF on " + this.coreElementSignature);
            }
            String dfScript = EnvironmentLoader.loadFromEnvironment(implTypeArgs[0]);
            String dfExecutor = EnvironmentLoader.loadFromEnvironment(implTypeArgs[1]);
            String dfLib = EnvironmentLoader.loadFromEnvironment(implTypeArgs[2]);
            String decafWorkingDir = EnvironmentLoader.loadFromEnvironment(implTypeArgs[3]);
            String decafRunner = EnvironmentLoader.loadFromEnvironment(implTypeArgs[4]);
            if (decafRunner == null || decafRunner.isEmpty()) {
                ErrorManager.error("Empty mpiRunner annotation for DECAF method " + this.coreElementSignature);
            }
            if (dfScript == null || dfScript.isEmpty()) {
                ErrorManager.error("Empty dfScript annotation for DECAF method " + this.coreElementSignature);
            }
            m = new DecafImplementation(dfScript, dfExecutor, dfLib, decafWorkingDir, decafRunner, coreId, implId, this.implConstraints);
            break;
        case BINARY:
            if (this.implTypeArgs.length != 2) {
                ErrorManager.error("Incorrect parameters for type BINARY on " + this.coreElementSignature);
            }
            String binary = EnvironmentLoader.loadFromEnvironment(implTypeArgs[0]);
            String binaryWorkingDir = EnvironmentLoader.loadFromEnvironment(implTypeArgs[1]);
            if (binary == null || binary.isEmpty()) {
                ErrorManager.error("Empty binary annotation for BINARY method " + this.coreElementSignature);
            }
            m = new BinaryImplementation(binary, binaryWorkingDir, coreId, implId, implConstraints);
            break;
        case OMPSS:
            if (this.implTypeArgs.length != 2) {
                ErrorManager.error("Incorrect parameters for type OMPSS on " + this.coreElementSignature);
            }
            String ompssBinary = EnvironmentLoader.loadFromEnvironment(implTypeArgs[0]);
            String ompssWorkingDir = EnvironmentLoader.loadFromEnvironment(implTypeArgs[1]);
            if (ompssBinary == null || ompssBinary.isEmpty()) {
                ErrorManager.error("Empty binary annotation for OmpSs method " + this.coreElementSignature);
            }
            m = new OmpSsImplementation(ompssBinary, ompssWorkingDir, coreId, implId, implConstraints);
            break;
        case OPENCL:
            if (this.implTypeArgs.length != 2) {
                ErrorManager.error("Incorrect parameters for type OPENCL on " + this.coreElementSignature);
            }
            String openclKernel = EnvironmentLoader.loadFromEnvironment(implTypeArgs[0]);
            String openclWorkingDir = EnvironmentLoader.loadFromEnvironment(implTypeArgs[1]);
            if (openclKernel == null || openclKernel.isEmpty()) {
                ErrorManager.error("Empty kernel annotation for OpenCL method " + this.coreElementSignature);
            }
            m = new OpenCLImplementation(openclKernel, openclWorkingDir, coreId, implId, implConstraints);
            break;
        default:
            ErrorManager.error("Unrecognised implementation type");
            break;
    }
    // Register the new implementation
    List<Implementation> newImpls = new LinkedList<>();
    newImpls.add(m);
    List<String> newSignatures = new LinkedList<>();
    newSignatures.add(implSignature);
    CoreManager.registerNewImplementations(coreId, newImpls, newSignatures);
    // Update the Resources structures
    LinkedList<Integer> newCores = new LinkedList<>();
    newCores.add(coreId);
    ResourceManager.coreElementUpdates(newCores);
    // Update the Scheduler structures
    ts.coreElementsUpdated();
    LOGGER.debug("Data structures resized and CE-resources links updated");
    sem.release();
}
Also used : MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) MPIImplementation(es.bsc.compss.types.implementations.MPIImplementation) BinaryImplementation(es.bsc.compss.types.implementations.BinaryImplementation) MPIImplementation(es.bsc.compss.types.implementations.MPIImplementation) OpenCLImplementation(es.bsc.compss.types.implementations.OpenCLImplementation) Implementation(es.bsc.compss.types.implementations.Implementation) OmpSsImplementation(es.bsc.compss.types.implementations.OmpSsImplementation) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) DecafImplementation(es.bsc.compss.types.implementations.DecafImplementation) LinkedList(java.util.LinkedList) OpenCLImplementation(es.bsc.compss.types.implementations.OpenCLImplementation) DecafImplementation(es.bsc.compss.types.implementations.DecafImplementation) BinaryImplementation(es.bsc.compss.types.implementations.BinaryImplementation) OmpSsImplementation(es.bsc.compss.types.implementations.OmpSsImplementation)

Example 49 with Implementation

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

the class IDLParser method parseCFunction.

private static void parseCFunction(String line, MethodResourceDescription currConstraints, CImplementation implementation) {
    StringBuilder implementedTaskSignatureBuffer = new StringBuilder();
    StringBuilder implementationSignatureBuffer = new StringBuilder();
    // boolean isStatic = false;
    boolean hasReturn = false;
    if (line.startsWith("static ")) {
        // isStatic = true;
        line = line.replace("static ", "");
    }
    if (!line.startsWith("void ")) {
        hasReturn = true;
    }
    line = line.replaceAll("[(|)|,|;|\n|\t]", " ");
    String[] splits = line.split("\\s+");
    CImplementation task = loadCImplementation(splits[1]);
    String methodName = task.getMethodName();
    String declaringClass = task.getClassName();
    if (implementation != null) {
        implementedTaskSignatureBuffer.append(implementation.getMethodName()).append("(");
    } else {
        implementedTaskSignatureBuffer.append(methodName).append("(");
    }
    implementationSignatureBuffer.append(methodName).append("(");
    /*
         * if (declaringClass!="NULL" && !isStatic){ implementedTaskSignatureBuffer.append("FILE_T").append(",");
         * implementationSignatureBuffer.append("FILE_T").append(","); }
         */
    if (hasReturn) {
        implementedTaskSignatureBuffer.append("FILE_T").append(",");
        implementationSignatureBuffer.append("FILE_T").append(",");
    }
    // Computes the method's signature
    for (int i = 2; i < splits.length; i++) {
        String paramDirection = splits[i++];
        String paramType = splits[i++];
        String type = "FILE_T";
        /*
             * OLD version C-binding String type = "OBJECT_T";
             */
        if (paramDirection.toUpperCase().compareTo("INOUT") == 0) {
            type = "FILE_T";
        } else if (paramDirection.toUpperCase().compareTo("OUT") == 0) {
            type = "FILE_T";
        } else if (paramType.toUpperCase().compareTo("FILE") == 0) {
            type = "FILE_T";
        } else if (paramType.compareTo("boolean") == 0) {
            type = "BOOLEAN_T";
        } else if (paramType.compareTo("char") == 0) {
            type = "CHAR_T";
        } else if (paramType.compareTo("int") == 0) {
            type = "INT_T";
        } else if (paramType.compareTo("float") == 0) {
            type = "FLOAT_T";
        } else if (paramType.compareTo("double") == 0) {
            type = "DOUBLE_T";
        } else if (paramType.compareTo("byte") == 0) {
            type = "BYTE_T";
        } else if (paramType.compareTo("short") == 0) {
            type = "SHORT_T";
        } else if (paramType.compareTo("long") == 0) {
            type = "LONG_T";
        } else if (paramType.compareTo("string") == 0) {
            type = "STRING_T";
        }
        implementedTaskSignatureBuffer.append(type).append(",");
        implementationSignatureBuffer.append(type).append(",");
    // String paramName = splits[i];
    }
    implementedTaskSignatureBuffer.deleteCharAt(implementedTaskSignatureBuffer.lastIndexOf(","));
    implementationSignatureBuffer.deleteCharAt(implementationSignatureBuffer.lastIndexOf(","));
    implementedTaskSignatureBuffer.append(")");
    implementationSignatureBuffer.append(")");
    if (implementation != null) {
        implementedTaskSignatureBuffer.append(implementation.getClassName());
    } else {
        implementedTaskSignatureBuffer.append(declaringClass);
    }
    implementationSignatureBuffer.append(declaringClass);
    String taskSignature = implementedTaskSignatureBuffer.toString();
    String implementationSignature = implementationSignatureBuffer.toString();
    // Create the core Element if it does not exist
    Integer coreId = CoreManager.registerNewCoreElement(taskSignature);
    if (coreId == null) {
        // The coreId already exists
        coreId = CoreManager.getCoreId(taskSignature);
    }
    LOGGER.debug("CoreId for task " + taskSignature + " is " + coreId);
    // Add the implementation to the core element
    int implId = CoreManager.getNumberCoreImplementations(coreId);
    List<Implementation> newImpls = new LinkedList<>();
    MethodImplementation m = new MethodImplementation(declaringClass, methodName, coreId, implId, currConstraints);
    newImpls.add(m);
    List<String> newSigns = new LinkedList<>();
    newSigns.add(implementationSignature);
    CoreManager.registerNewImplementations(coreId, newImpls, newSigns);
    LOGGER.debug("[IDL Parser] Adding implementation: " + declaringClass + "." + methodName + " for CE id " + coreId);
}
Also used : MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) Implementation(es.bsc.compss.types.implementations.Implementation) LinkedList(java.util.LinkedList)

Example 50 with Implementation

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

the class Worker method updatedCoreElements.

/*-------------------------------------------------------------------------
     * ************************************************************************
     * ************************************************************************
     * ********* EXECUTABLE CORES AND IMPLEMENTATIONS MANAGEMENT **************
     * ************************************************************************
     * ************************************************************************
     * -----------------------------------------------------------------------*/
@SuppressWarnings("unchecked")
public void updatedCoreElements(List<Integer> updatedCoreIds) {
    if (DEBUG) {
        LOGGER.debug("Update coreElements on Worker " + this.getName());
    }
    int coreCount = CoreManager.getCoreCount();
    boolean[] coresToUpdate = new boolean[coreCount];
    for (int coreId : updatedCoreIds) {
        coresToUpdate[coreId] = true;
    }
    boolean[] wasExecutable = new boolean[coreCount];
    for (int coreId : this.executableCores) {
        wasExecutable[coreId] = true;
    }
    this.executableCores.clear();
    List<Implementation>[] executableImpls = new LinkedList[coreCount];
    int[][] implSimultaneousTasks = new int[coreCount][];
    int[] coreSimultaneousTasks = new int[coreCount];
    int[] idealSimultaneousTasks = new int[coreCount];
    for (int coreId = 0; coreId < coreCount; coreId++) {
        if (!coresToUpdate[coreId]) {
            executableImpls[coreId] = this.executableImpls[coreId];
            implSimultaneousTasks[coreId] = this.implSimultaneousTasks[coreId];
            coreSimultaneousTasks[coreId] = this.coreSimultaneousTasks[coreId];
            idealSimultaneousTasks[coreId] = this.idealSimultaneousTasks[coreId];
            if (wasExecutable[coreId]) {
                executableCores.add(coreId);
            }
        } else {
            boolean executableCore = false;
            List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
            implSimultaneousTasks[coreId] = new int[impls.size()];
            executableImpls[coreId] = new LinkedList<>();
            for (Implementation impl : impls) {
                if (canRun(impl)) {
                    int simultaneousCapacity = simultaneousCapacity(impl);
                    idealSimultaneousTasks[coreId] = Math.max(idealSimultaneousTasks[coreId], simultaneousCapacity);
                    implSimultaneousTasks[coreId][impl.getImplementationId()] = simultaneousCapacity;
                    if (implSimultaneousTasks[coreId][impl.getImplementationId()] > 0) {
                        executableImpls[coreId].add(impl);
                        executableCore = true;
                    }
                }
            }
            if (executableCore) {
                executableCores.add(coreId);
            }
        }
    }
    this.executableImpls = executableImpls;
    this.implSimultaneousTasks = implSimultaneousTasks;
    this.coreSimultaneousTasks = coreSimultaneousTasks;
    this.idealSimultaneousTasks = idealSimultaneousTasks;
}
Also used : List(java.util.List) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList) 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