Example #1
0
void BCubeTopology::init_network() {
    QueueLoggerSampling* queueLogger;

    assert(NUM_PORTS>0);
    assert(K>=0);
    assert(NUM_SRV==(int)pow(NUM_PORTS,K+1));

    for (int i=0; i<NUM_SRV; i++) {
        address_from_srv(i,addresses[i]);
        for (int k=0; k<K; k++) {
            for (int j=0; j<NUM_SW; j++) {
                pipes_srv_switch[i][j][k] = NULL;
                queues_srv_switch[i][j][k] = NULL;
                pipes_switch_srv[j][i][k] = NULL;
                queues_switch_srv[j][i][k] = NULL;
            }
        }
    }

    //  addresses[i][k] = ADDRESS(i,k);

    for (int k=0; k<=K; k++) {
        //create links for level K
        for (int i=0; i<NUM_SRV; i++) {
            int j;

            j = SWITCH_ID(i,k);

            //printf("SWITCH ID for server %d level %d is %d\n",i,k,j);

            //index k of the address

            queueLogger = new QueueLoggerSampling(timeFromMs(1000), *eventlist);
            //queueLogger = NULL;
            logfile->addLogger(*queueLogger);

            queues_srv_switch[i][j][k] = new RandomQueue(speedFromPktps(HOST_NIC), memFromPkt(SWITCH_BUFFER + RANDOM_BUFFER), *eventlist, queueLogger, memFromPkt(RANDOM_BUFFER));
            queues_srv_switch[i][j][k]->setName("SRV_" + ntoa(i) + "(level_" + ntoa(k)+"))_SW_" +ntoa(j));
            logfile->writeName(*(queues_srv_switch[i][j][k]));

            pipes_srv_switch[i][j][k] = new Pipe(timeFromUs(RTT), *eventlist);
            pipes_srv_switch[i][j][k]->setName("Pipe-SRV_" + ntoa(i) + "(level_" + ntoa(k)+")-SW_" +ntoa(j));
            logfile->writeName(*(pipes_srv_switch[i][j][k]));

            queueLogger = new QueueLoggerSampling(timeFromMs(1000), *eventlist);
            //queueLogger = NULL;
            logfile->addLogger(*queueLogger);

            queues_switch_srv[j][i][k] = new RandomQueue(speedFromPktps(HOST_NIC), memFromPkt(SWITCH_BUFFER + RANDOM_BUFFER), *eventlist, queueLogger, memFromPkt(RANDOM_BUFFER));
            queues_switch_srv[j][i][k]->setName("SW_" + ntoa(j) + "(level_" + ntoa(k)+")-SRV_" +ntoa(i));
            logfile->writeName(*(queues_switch_srv[j][i][k]));

            pipes_switch_srv[j][i][k] = new Pipe(timeFromUs(RTT), *eventlist);
            pipes_switch_srv[j][i][k]->setName("Pipe-SW_" + ntoa(j) + "(level_" + ntoa(k)+")-SRV_" +ntoa(i));
            logfile->writeName(*(pipes_switch_srv[j][i][k]));
        }
    }
}
Example #2
0
route_t* BCubeTopology::bcube_routing(int src,int dest, int* permutation) {
    static int pqid = 0;
    route_t* routeout = new route_t();
    Queue* pqueue = new Queue(speedFromPktps(HOST_NIC), memFromPkt(FEEDER_BUFFER), *eventlist, NULL);
    pqueue->setName("PQueue_" + ntoa(src) + "_" + ntoa(dest)+"_"+ntoa(pqid++));
    routeout->push_back(pqueue);

    unsigned int crt_addr[K+1],crt, level,nsrv;
    int i;
    crt = src;

    for (i=0; i<=K; i++)
        crt_addr[i] = addresses[src][i];

    int aaa = srv_from_address(crt_addr);
    //  printf("CRT is %d, SRV FROM ADDRESS %d\n",crt,aaa);
    assert(crt==aaa);

    for (i=K; i>=0; i--) {
        level = permutation[i];
        nsrv = (int)pow(NUM_PORTS,level+1);

        if (addresses[src][level]!=addresses[dest][level]) {
            //add hop from crt_addr by progressing on id level
            //go upto switch in level and correct digit
            //switch id

            routeout->push_back(queues_srv_switch[crt][SWITCH_ID(crt,level)][level]);
            routeout->push_back(pipes_srv_switch[crt][SWITCH_ID(crt,level)][level]);

            //now correct digit
            crt_addr[level] = addresses[dest][level];
            crt = srv_from_address(crt_addr);

            assert(srv_from_address(crt_addr)==crt);

            routeout->push_back(queues_switch_srv[SWITCH_ID(crt,level)][crt][level]);
            routeout->push_back(pipes_switch_srv[SWITCH_ID(crt,level)][crt][level]);
        }
    }
    return routeout;
}
Example #3
0
mp_obj_t pyb_switch_value(mp_obj_t self_in) {
    pyb_switch_obj_t *self = self_in;
    return switch_get(SWITCH_ID(self)) ? mp_const_true : mp_const_false;
}
Example #4
0
void pyb_switch_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
    pyb_switch_obj_t *self = self_in;
    mp_printf(print, "Switch(%u)", SWITCH_ID(self));
}