Ejemplo n.º 1
0
void OTFConverter::makeSingletonPartition(CommEvent * evt)
{
    Partition * p = new Partition();
    p->addEvent(evt);
    evt->partition = p;
    p->new_partition = p;
    trace->partitions->append(p);
}
Ejemplo n.º 2
0
void OTFConverter::addToSavedPartition(CommEvent * evt, int partition)
{
    while (trace->partitions->size() <= partition)
    {
        trace->partitions->append(new Partition());
        trace->partitions->last()->new_partition = trace->partitions->last();
    }
    Partition * p = trace->partitions->at(partition);
    p->addEvent(evt);
    evt->partition = p;
}
Ejemplo n.º 3
0
// This is a lighter weight merge since we know at this stage everything stays
// within its own task and the partitions that must be merged are contiguous
// Therefore we only need to merge the groups and remove the previous ones
// from the partition list -- so we create the new ones and point the old
// ones toward it so we can make a single pass to remove those that point to
// a new partition.
void OTFConverter::mergeContiguous(QList<QList<Partition * > *> * groups)
{
    // Create the new partitions and store them in new parts
    QList<Partition *> * newparts = new QList<Partition *>();

    for (QList<QList<Partition *> *>::Iterator group = groups->begin();
         group != groups->end(); ++group)
    {
        Partition * p = new Partition();
        for (QList<Partition *>::Iterator part = (*group)->begin();
             part != (*group)->end(); ++part)
        {
            (*part)->new_partition = p;
            for (QMap<int, QList<CommEvent *> *>::Iterator proc
                 = (*part)->events->begin();
                 proc != (*part)->events->end(); ++proc)
            {
                for (QList<CommEvent *>::Iterator evt
                     = (proc.value())->begin();
                     evt != (proc.value())->end(); ++evt)
                {
                    (*evt)->partition = p;
                    p->addEvent(*evt);
                }
            }
        }
        p->new_partition = p;
        //newparts->append(p);
    }

    // Add in the partitions in order -- those that didn't get changed
    // just added in normally. Add the first instance of the others so
    // that order can be maintained and delete the ones that represent
    // changes.
    QSet<Partition *> sortSet = QSet<Partition *>();
    QList<Partition *> toDelete = QList<Partition *>();
    for (QList<Partition *>::Iterator part = trace->partitions->begin();
         part != trace->partitions->end(); ++part)
    {
        if ((*part)->new_partition == *part)
        {
            newparts->append(*part);
        }
        else
        {
            if (!sortSet.contains((*part)->new_partition))
            {
                newparts->append((*part)->new_partition);
                sortSet.insert((*part)->new_partition);
            }
            toDelete.append(*part);
        }
    }

    // Delete old parts
    for (QList<Partition *>::Iterator oldpart = toDelete.begin();
         oldpart != toDelete.end(); ++oldpart)
    {
        delete *oldpart;
        *oldpart = NULL;
    }

    // Add the new partitions to trace->partitions
    delete trace->partitions;
    trace->partitions = newparts;
}