Example #1
0
  void
  machine::route(const node* from, sched::base *sched_caller, const node::node_id id, simple_tuple* stpl, const uint_val delay)
  {
    assert(sched_caller != NULL);



    if (api::onLocalVM(id)){
      /* Belongs to the same process, does not require MPI */
      node *node(vm::All->DATABASE->find_node(id));

      sched::base *sched_other(sched_caller->find_scheduler(node));
      const predicate *pred(stpl->get_predicate());

      if(delay > 0) {
        work new_work(node, stpl);
        sched_caller->new_work_delay(sched_caller, from, new_work, delay);
      } else if(pred->is_action_pred()) {
        run_action(sched_other, node, stpl->get_tuple(), sched_caller != sched_other);
        delete stpl;
      } else if(sched_other == sched_caller) {
        work new_work(node, stpl);

        sched_caller->new_work(from, new_work);
      } else {
        work new_work(node, stpl);

        sched_caller->new_work_other(sched_other, new_work);
      }
    } else {

      /* Send to the correct process */
      api::sendMessage(from,id,stpl);
    }
  }
Example #2
0
 void
 machine::route_self(sched::base *sched, node *node, simple_tuple *stpl, const uint_val delay)
 {
   if(delay > 0) {
     work new_work(node, stpl);
     sched->new_work_delay(sched, node, new_work, delay);
   } else {
     assert(!stpl->get_tuple()->is_action());
     sched->new_work_self(node, stpl);
   }
 }
Example #3
0
 // a new work was created for the current executing node
    inline void new_work_self(db::node *node, db::simple_tuple *stpl, const process::work_modifier mod = process::mods::NOTHING)
    {
       process::work work(node, stpl, process::mods::LOCAL_TUPLE | mod);
       new_work(node, work);
    }
Example #4
0
int
newe(void)
{
    struct natstr *natp;
    struct sctstr sect;
    struct nstr_sect nstr;
    double work, lcms, hcms;
    int nsect;
    int civs = 0;
    int uws = 0;
    int bwork;
    int twork;
    int type;
    int eff;
    int maxpop;

    if (!snxtsct(&nstr, player->argp[1]))
	return RET_SYN;
    player->simulation = 1;
    prdate();
    nsect = 0;
    while (nxtsct(&nstr, &sect)) {
	if (!player->owner)
	    continue;
	if (!sect.sct_off) {
	    civs = (1.0 + obrate * etu_per_update) * sect.sct_item[I_CIVIL];
	    uws = (1.0 + uwbrate * etu_per_update) * sect.sct_item[I_UW];
	    natp = getnatp(sect.sct_own);
	    maxpop = max_pop(natp->nat_level[NAT_RLEV], &sect);
	    work = new_work(&sect,
			    total_work(sect.sct_work, etu_per_update,
				       civs, sect.sct_item[I_MILIT], uws,
				       maxpop));
	    bwork = work / 2;

	    type = sect.sct_type;
	    eff = sect.sct_effic;
	    if (sect.sct_newtype != type) {
		twork = (eff + 3) / 4;
		if (twork > bwork) {
		    twork = bwork;
		}
		bwork -= twork;
		eff -= twork * 4;
		if (eff <= 0) {
		    type = sect.sct_newtype;
		    eff = 0;
		}

		twork = 100 - eff;
		if (twork > bwork) {
		    twork = bwork;
		}
		if (dchr[type].d_lcms > 0) {
		    lcms = sect.sct_item[I_LCM];
		    lcms = (int)(lcms / dchr[type].d_lcms);
		    if (twork > lcms)
			twork = lcms;
		}
		if (dchr[type].d_hcms > 0) {
		    hcms = sect.sct_item[I_HCM];
		    hcms = (int)(hcms / dchr[type].d_hcms);
		    if (twork > hcms)
			twork = hcms;
		}
		eff += twork;
	    } else if (eff < 100) {
		twork = 100 - eff;
		if (twork > bwork) {
		    twork = bwork;
		}
		if (dchr[type].d_lcms > 0) {
		    lcms = sect.sct_item[I_LCM];
		    lcms = (int)(lcms / dchr[type].d_lcms);
		    if (twork > lcms)
			twork = lcms;
		}
		if (dchr[type].d_hcms > 0) {
		    hcms = sect.sct_item[I_HCM];
		    hcms = (int)(hcms / dchr[type].d_hcms);
		    if (twork > hcms)
			twork = hcms;
		}
		eff += twork;
	    }
	} else {
	    eff = sect.sct_effic;
	    type = sect.sct_type;
	}
	if (nsect++ == 0) {
	    pr("EFFICIENCY SIMULATION\n");
	    pr("   sect  des    projected eff\n");
	}
	prxy("%4d,%-4d", nstr.x, nstr.y);
	pr(" %c", dchr[type].d_mnem);
	pr("    %3d%%\n", eff);
    }
    player->simulation = 0;
    if (nsect == 0) {
	if (player->argp[1])
	    pr("%s: No sector(s)\n", player->argp[1]);
	else
	    pr("%s: No sector(s)\n", "");
	return RET_FAIL;
    } else
	pr("%d sector%s\n", nsect, splur(nsect));
    return RET_OK;
}