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