Beispiel #1
0
void
driver()
{

    StubXAppl appl(myAppl->getOH());
    int vp;

    startworkerbar=new BlockBarrier(NUMPROC);
    GlobalUpdate((void **)&startworkerbar);

    testAndDecSharedCounter *globalcounter=new testAndDecSharedCounter(CAPACITY);
    GlobalUpdate((void **)&globalcounter);
    
    // start a workers up one per processor
    for (vp=0;vp<NUMPROC;vp++) {
	appl.setVP(vp);
	appl.createProcess1( (tstatusfunc) startworker, (reg_t)globalcounter);
    }
}
Beispiel #2
0
void 
test()
{
 
//    tr_printf("Scenario 0a: Starting Test ...\n");
    tstbar=new BlockBarrier(NUMPROC+1);
    GlobalUpdate((void **)&tstbar);
    driver();
    tstbar->enter();
//    tr_printf("Scenario 0a: Main process done.\n");
}
        void UpdateAI(uint32 diff)
        {
            ReduceCD(diff);
            if (!GlobalUpdate(diff))
                return;
            CheckAttackState();
            CheckAuras();
            if (wait == 0)
                wait = GetWait();
            else
                return;
            BreakCC(diff);
            if (CCed(me)) return;

            ////if pet is dead or unreachable
            //Creature* m_botsPet = me->GetBotsPet();
            //if (!m_botsPet || m_botsPet->FindMap() != master->GetMap() || (me->GetDistance2d(m_botsPet) > sWorld->GetMaxVisibleDistanceOnContinents() - 20.f))
            //    if (master->getLevel() >= 10 && !me->IsInCombat() && !IsCasting() && !me->IsMounted())
            //        SummonBotsPet(PET_VOIDWALKER);

            //TODO: implement healthstone
            if (Potion_cd <= diff && GetHealthPCT(me) < 67)
            {
                temptimer = GC_Timer;
                if (doCast(me, HEALINGPOTION))
                {
                    Potion_cd = POTION_CD;
                    GC_Timer = temptimer;
                }
            }
            if (Potion_cd <= diff && GetManaPCT(me) < 50)
            {
                temptimer = GC_Timer;
                if (doCast(me, MANAPOTION))
                {
                    Potion_cd = POTION_CD;
                    GC_Timer = temptimer;
                }
            }
            if (!me->IsInCombat())
                DoNonCombatActions();

            if (!CheckAttackTarget(BOT_CLASS_WARLOCK))
                return;

            DoNormalAttack(diff);
        }
Beispiel #4
0
void
driver()
{

    StubXAppl appl(myAppl->getOH());
    int vp;

    startworkerbar=new BlockBarrier(NUMPROC);
    GlobalUpdate((void **)&startworkerbar);
//    tr_printf("Scenario 0a: Starting driver ...\n");
    Data *data=new Data;
    data->newreference();

    // start a workers up one per processor
    for (vp=0; vp<NUMPROC; vp++) {
        appl.setVP(vp);
        data->newreference();
        appl.createProcess1( (tstatusfunc) startworker, (reg_t) data);
    }
    data->destroy();
//    tr_printf("Scenario 0a: End driver ...\n");
}
Beispiel #5
0
		        TFLOW FifoGap<TFLOW,TCAP>::FindMaxFlow()
		        {
                    if (m_stage != 1)
                    {
                        throw System::InvalidOperationException(__FUNCTION__, __LINE__,
                            "Call Init method before computing maximum flow.");
                    }              

                    Size rl_count = 0, rl_threshold = (Size) (m_glob_rel_freq * m_nodes);
                    Size next_layer_rank, min_rank;
                    Node *node, *head;
                    Arc *arc, *min_arc = NULL;
                    Layer *lay;
                    TCAP bottleneck;

                    GlobalUpdate();

                    while (m_fifo_first != NULL)
                    {
                        // Pop node from the queue
                        node = m_fifo_first;
                        m_fifo_first = node->m_next_active;

                        if (node->m_rank == m_nodes)
                        {
                            // The node was removed during gap relabeling
                            continue;
                        }

                        RemoveFromLayer(&m_layer_list[node->m_rank], node);

                        // DISCHARGE node
                        while (node->m_rank < m_nodes)
                        {
                            lay = &m_layer_list[node->m_rank];
                            next_layer_rank = node->m_rank - 1;

                            // PUSH excess
                            for (arc = node->m_current; arc != NULL; arc = arc->m_next)
                            {
                                if (arc->m_res_cap > 0)
                                {
                                    head = arc->m_head;

                                    if (head->m_rank == next_layer_rank)
                                    {
                                        bottleneck = Math::Min(node->m_excess, arc->m_res_cap);

                                        arc->m_res_cap -= bottleneck;
                                        arc->m_sister->m_res_cap += bottleneck;

                                        if (head->m_excess <= 0)
                                        {
                                            if (head->m_excess + bottleneck > 0)
                                            {
                                                // Add node to active queue
                                                if (m_fifo_first == NULL)
                                                {
                                                    m_fifo_first = head;
                                                }
                                                else
                                                {
                                                    m_fifo_last->m_next_active = head;
                                                }

                                                m_fifo_last = head;
                                                head->m_next_active = NULL;
                                                m_flow -= head->m_excess;
                                            }
                                            else
                                            {
                                                m_flow += bottleneck;
                                            }
                                        }

                                        head->m_excess += bottleneck;
                                        node->m_excess -= bottleneck;

                                        if (node->m_excess == 0)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }

                            if (arc != NULL)
                            {
                                // All excess pushed away, the node becomes inactive
                                AddToLayer(lay, node);
                                node->m_current = arc;
                                break;
                            }

                            // RELABEL node
                            node->m_rank = min_rank = m_nodes;
                            
                            if (lay->m_first == NULL)
                            {
                                // Gap relabeling
                                GapRelabeling(lay, next_layer_rank);
                            }
                            else
                            {
                                // Node relabeling
                                for (arc = node->m_first; arc != NULL; arc = arc->m_next)
                                {
                                    if (arc->m_res_cap > 0 && arc->m_head->m_rank < min_rank)
                                    {
                                        min_rank = arc->m_head->m_rank;
                                        min_arc = arc;
                                    }
                                }

                                rl_count++;

                                if (++min_rank < m_nodes)
                                {
                                    node->m_rank = min_rank;
                                    node->m_current = min_arc;

                                    if (min_rank > m_max_rank)
                                    {
                                        m_max_rank = min_rank;
                                    }
                                }
                            }
                        }

                        // Check if global relabeling should be done
                        if (rl_count > rl_threshold && m_fifo_first != NULL)
                        {
                            GlobalUpdate();
                            rl_count = 0;
                        }
                    }

                    // Find nodes that are connected to the sink after the last step.
                    // This is IMPORTANT, because it allows us to find which nodes are
                    // connected to the source and which to the sink.
                    GlobalUpdate();

                    m_stage = 2;

                    return m_flow;
		        }