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);
}
}
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);
}
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);
}
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);
}
Aggregations