use of es.bsc.compss.scheduler.types.Profile in project compss by bsc-wdc.
the class LocalOptimizationState method pollActionForGap.
public AllocatableAction pollActionForGap(Gap gap) {
AllocatableAction gapAction = null;
PriorityQueue<AllocatableAction> peeks = selectableActions.peekAll();
// Get Main action to fill the gap
while (!peeks.isEmpty() && gapAction == null) {
AllocatableAction candidate = peeks.poll();
// Check times
MOSchedulingInformation candidateDSI = (MOSchedulingInformation) candidate.getSchedulingInfo();
long start = candidateDSI.getExpectedStart();
if (start > gap.getEndTime()) {
continue;
}
Implementation impl = candidate.getAssignedImplementation();
Profile p = worker.getProfile(impl);
long expectedLength = p.getAverageExecutionTime();
if ((gap.getEndTime() - gap.getInitialTime()) < expectedLength) {
continue;
}
if ((start + expectedLength) > gap.getEndTime()) {
continue;
}
// Check description
if (gap.getResources().canHostDynamic(impl)) {
selectableActions.removeFirst(candidate.getCoreId());
gapAction = candidate;
}
}
return gapAction;
}
use of es.bsc.compss.scheduler.types.Profile 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();
}
use of es.bsc.compss.scheduler.types.Profile 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());
}
}
use of es.bsc.compss.scheduler.types.Profile in project compss by bsc-wdc.
the class TaskScheduler method reducedWorkerResources.
@SuppressWarnings("unchecked")
private <T extends WorkerResourceDescription> void reducedWorkerResources(ResourceScheduler<T> worker, ResourceUpdate<T> modification) {
CloudMethodWorker cloudWorker = (CloudMethodWorker) worker.getResource();
if (!cloudWorker.getDescription().getTypeComposition().isEmpty()) {
synchronized (workers) {
workers.remove(((ResourceScheduler<WorkerResourceDescription>) worker).getResource());
int coreCount = CoreManager.getCoreCount();
List<Implementation>[] runningCoreImpls = worker.getExecutableImpls();
for (int coreId = 0; coreId < coreCount; coreId++) {
for (Implementation impl : runningCoreImpls[coreId]) {
Profile p = worker.getProfile(impl);
if (p != null) {
offVMsProfiles[coreId][impl.getImplementationId()].accumulate(p);
}
}
}
}
this.workerRemoved((ResourceScheduler<WorkerResourceDescription>) worker);
StopWorkerAction action = new StopWorkerAction(generateSchedulingInformation(worker), worker, this, modification);
try {
action.schedule((ResourceScheduler<WorkerResourceDescription>) worker, (Score) null);
action.tryToLaunch();
} catch (BlockedActionException | UnassignedActionException | InvalidSchedulingException e) {
// Can not be blocked nor unassigned
}
} else {
ResourceManager.terminateCloudResource(cloudWorker, (CloudMethodResourceDescription) modification.getModification());
}
}
use of es.bsc.compss.scheduler.types.Profile 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;
}
Aggregations