* Model *
*********/
-void CpuModel::updateActionsStateLazy(double now, double delta)
+void CpuModel::updateActionsStateLazy(double now, double /*delta*/)
{
void *_action;
CpuActionLmmPtr action;
return m_core;
}
+CpuLmm::CpuLmm(CpuModelPtr model, const char* name, xbt_dict_t properties, int core, double powerPeak, double powerScale)
+: ResourceLmm(), Cpu(model, name, properties, core, powerPeak, powerScale) {
+ /* At now, we assume that a VM does not have a multicore CPU. */
+ if (core > 1)
+ xbt_assert(model == surf_cpu_model_pm);
+
+ p_constraintCore = xbt_new(lmm_constraint_t, core);
+ p_constraintCoreId = xbt_new(void*, core);
+
+ int i;
+ for (i = 0; i < core; i++) {
+ /* just for a unique id, never used as a string. */
+ p_constraintCoreId[i] = bprintf("%s:%i", name, i);
+ p_constraintCore[i] = lmm_constraint_new(p_model->p_maxminSystem, p_constraintCoreId[i], m_powerScale * m_powerPeak);
+ }
+}
+
+CpuLmm::~CpuLmm(){
+ if (p_constraintCore){
+ for (int i = 0; i < m_core; i++) {
+ xbt_free(p_constraintCoreId[i]);
+ }
+ xbt_free(p_constraintCore);
+ xbt_free(p_constraintCoreId);
+ }
+}
+
/**********
* Action *
**********/
* action object does not have the information about the location where the
* action is being executed.
*/
-void CpuActionLmm::setAffinity(CpuLmmPtr cpu, unsigned long mask)
+void CpuActionLmm::setAffinity(CpuPtr _cpu, unsigned long mask)
{
lmm_variable_t var_obj = p_variable;
-
+ CpuLmmPtr cpu = reinterpret_cast<CpuLmmPtr>(_cpu);
XBT_IN("(%p,%lx)", this, mask);
{
unsigned long nbits = 0;
/* FIXME: There is much faster algorithms doing this. */
- unsigned long i;
- for (i = 0; i < cpu->m_core; i++) {
+ for (int i = 0; i < cpu->m_core; i++) {
unsigned long has_affinity = (1UL << i) & mask;
if (has_affinity)
nbits += 1;
}
}
-
-
- unsigned long i;
- for (i = 0; i < cpu->m_core; i++) {
- XBT_DEBUG("clear affinity %p to cpu-%lu@%s", this, i, cpu->m_name);
+ for (int i = 0; i < cpu->m_core; i++) {
+ XBT_DEBUG("clear affinity %p to cpu-%d@%s", this, i, cpu->m_name);
lmm_shrink(cpu->p_model->p_maxminSystem, cpu->p_constraintCore[i], var_obj);
unsigned long has_affinity = (1UL << i) & mask;
* accept affinity settings on a future host. We might be able to assign
* zero to elem->value to maintain such inactive affinity settings in the
* system. But, this will make the system complex. */
- XBT_DEBUG("set affinity %p to cpu-%lu@%s", this, i, cpu->m_name);
+ XBT_DEBUG("set affinity %p to cpu-%d@%s", this, i, cpu->m_name);
lmm_expand(cpu->p_model->p_maxminSystem, cpu->p_constraintCore[i], var_obj, 1.0);
}
}