use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.
the class CloudTypeManager method newCoreElementsDetected.
public void newCoreElementsDetected(List<Integer> newCores) {
int coreCount = CoreManager.getCoreCount();
for (CloudInstanceTypeDescription type : types.values()) {
int[][] slotsI = new int[coreCount][];
// Copy actual values
int[] slotsC = Arrays.copyOf(type.getSlotsCore(), coreCount);
for (int i = 0; i < type.getSlotsImplLength(); ++i) {
int[] slotsImpl = type.getSpecificSlotsImpl(i);
slotsI[i] = slotsImpl.clone();
}
// Get new values
for (int coreId : newCores) {
List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
int implsSize = impls.size();
slotsI[coreId] = new int[implsSize];
for (int implId = 0; implId < implsSize; ++implId) {
Implementation impl = impls.get(implId);
if (impl.getTaskType() == TaskType.METHOD) {
MethodResourceDescription rd = (MethodResourceDescription) impl.getRequirements();
Integer into = type.getResourceDescription().canHostSimultaneously(rd);
slotsC[coreId] = Math.max(slotsC[coreId], into);
slotsI[coreId][implId] = into;
}
}
}
type.setSlotsCore(slotsC);
type.setSlotsImpl(slotsI);
}
}
use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.
the class ResourceScheduler method toJSONObject.
public JSONObject toJSONObject() {
JSONObject jsonObject = new JSONObject();
int coreCount = CoreManager.getCoreCount();
Map<String, JSONObject> implsMap = new HashMap<>();
for (int coreId = 0; coreId < coreCount; coreId++) {
List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
for (Implementation impl : impls) {
int implId = impl.getImplementationId();
JSONObject implProfile = profiles[coreId][implId].toJSONObject();
implsMap.put(CoreManager.getSignature(coreId, implId), implProfile);
}
}
jsonObject.put("implementations", implsMap);
return jsonObject;
}
use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.
the class ResourceScheduler method tryToLaunchBlockedActions.
/**
* Tries to launch blocked actions on resource. When an action cannot be launched, its successors are not tried
*/
@SuppressWarnings("unchecked")
public final void tryToLaunchBlockedActions() {
LOGGER.debug("[ResourceScheduler] Try to launch blocked actions on resource " + getName());
while (this.hasBlockedActions()) {
AllocatableAction firstBlocked = this.getFirstBlocked();
Implementation selectedImplementation = firstBlocked.getAssignedImplementation();
if (!firstBlocked.isToReserveResources() || myWorker.canRunNow((T) selectedImplementation.getRequirements())) {
try {
firstBlocked.resumeExecution();
this.removeFirstBlocked();
} catch (ActionNotWaitingException anwe) {
// Not possible. If the task is in blocked list it is waiting
}
} else {
break;
}
}
}
use of es.bsc.compss.types.implementations.Implementation 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.types.implementations.Implementation 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());
}
}
Aggregations