예제 #1
0
static void test_one_task(msg_host_t hostA)
{
  const double cpu_speed = MSG_host_get_speed(hostA);
  const double computation_amount = cpu_speed * 10;
  const char *hostA_name = MSG_host_get_name(hostA);

  XBT_INFO("### Test: with/without MSG_task_set_bound");

  XBT_INFO("### Test: no bound for Task1@%s", hostA_name);
  launch_worker(hostA, "worker0", computation_amount, 0, 0);

  MSG_process_sleep(1000);

  XBT_INFO("### Test: 50%% for Task1@%s", hostA_name);
  launch_worker(hostA, "worker0", computation_amount, 1, cpu_speed / 2);

  MSG_process_sleep(1000);

  XBT_INFO("### Test: 33%% for Task1@%s", hostA_name);
  launch_worker(hostA, "worker0", computation_amount, 1, cpu_speed / 3);

  MSG_process_sleep(1000);

  XBT_INFO("### Test: zero for Task1@%s (i.e., unlimited)", hostA_name);
  launch_worker(hostA, "worker0", computation_amount, 1, 0);

  MSG_process_sleep(1000);

  XBT_INFO("### Test: 200%% for Task1@%s (i.e., meaningless)", hostA_name);
  launch_worker(hostA, "worker0", computation_amount, 1, cpu_speed * 2);

  MSG_process_sleep(1000);
}
예제 #2
0
파일: snctl.c 프로젝트: Grace-Liu/bess
static struct snobj *handle_add_worker(struct snobj *q)
{
	unsigned int wid;
	unsigned int core;

	struct snobj *t;

	t = snobj_eval(q, "wid");
	if (!t)
		return snobj_err(EINVAL, "Missing 'wid' field");

	wid = snobj_uint_get(t);
	if (wid >= MAX_WORKERS)
		return snobj_err(EINVAL, "'wid' must be between 0 and %d",
				MAX_WORKERS - 1);

	t = snobj_eval(q, "core");
	if (!t)
		return snobj_err(EINVAL, "Missing 'core' field");

	core = snobj_uint_get(t);
	if (!is_cpu_present(core))
		return snobj_err(EINVAL, "Invalid core %d", core);

	if (is_worker_active(wid))
		return snobj_err(EEXIST, "worker:%d is already active", wid);

	launch_worker(wid, core);

	return NULL;
}
예제 #3
0
static
bool start_worker(void) {
	if(numworkers >= MAXWORKERS) return false;
	// returns true if ACCEPTING is ready
	int pair[2];
	ensure0(socketpair(AF_UNIX,SOCK_STREAM,0,pair));
	worker_connected(pair[0]);
	getnowspec(&workers[numworkers-1].expiration);
	workers[numworkers-1].expiration.tv_sec += WORKER_LIFETIME;
	workers[numworkers-1].pid = launch_worker(pair[1]);
	close(pair[1]);
}
예제 #4
0
static int master_main(int argc, char *argv[])
{
  msg_host_t pm0 = MSG_host_by_name("Fafard");
  msg_host_t pm1 = MSG_host_by_name("Fafard");

  XBT_INFO("# 1. Put a single task on a PM. ");
  test_one_task(pm0);
  XBT_INFO(" ");

  XBT_INFO("# 2. Put two tasks on a PM.");
  test_two_tasks(pm0, pm0);
  XBT_INFO(" ");

  msg_host_t vm0 = MSG_vm_create_core(pm0, "VM0");
  MSG_vm_start(vm0);

  XBT_INFO("# 3. Put a single task on a VM. ");
  test_one_task(vm0);
  XBT_INFO(" ");

  XBT_INFO("# 4. Put two tasks on a VM.");
  test_two_tasks(vm0, vm0);
  XBT_INFO(" ");

  MSG_vm_destroy(vm0);

  vm0 = MSG_vm_create_core(pm0, "VM0");
  MSG_vm_start(vm0);

  XBT_INFO("# 6. Put a task on a PM and a task on a VM.");
  test_two_tasks(pm0, vm0);
  XBT_INFO(" ");

  MSG_vm_destroy(vm0);

  vm0 = MSG_vm_create_core(pm0, "VM0");
  double cpu_speed = MSG_host_get_speed(pm0);
  MSG_vm_set_bound(vm0, cpu_speed / 10);
  MSG_vm_start(vm0);

  XBT_INFO("# 7. Put a single task on the VM capped by 10%%.");
  test_one_task(vm0);
  XBT_INFO(" ");

  XBT_INFO("# 8. Put two tasks on the VM capped by 10%%.");
  test_two_tasks(vm0, vm0);
  XBT_INFO(" ");

  XBT_INFO("# 9. Put a task on a PM and a task on the VM capped by 10%%.");
  test_two_tasks(pm0, vm0);
  XBT_INFO(" ");

  MSG_vm_destroy(vm0);

  vm0 = MSG_vm_create_core(pm0, "VM0");

  s_vm_params_t params;
  memset(&params, 0, sizeof(params));
  params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes
  MSG_host_set_params(vm0, &params);
  MSG_vm_start(vm0);

  cpu_speed = MSG_host_get_speed(pm0);
  MSG_vm_start(vm0);

  XBT_INFO("# 10. Test migration");
  const double computation_amount = cpu_speed * 10;

  XBT_INFO("# 10. (a) Put a task on a VM without any bound.");
  launch_worker(vm0, "worker0", computation_amount, 0, 0);
  MSG_process_sleep(1000);
  XBT_INFO(" ");

  XBT_INFO("# 10. (b) set 10%% bound to the VM, and then put a task on the VM.");
  MSG_vm_set_bound(vm0, cpu_speed / 10);
  launch_worker(vm0, "worker0", computation_amount, 0, 0);
  MSG_process_sleep(1000);
  XBT_INFO(" ");

  XBT_INFO("# 10. (c) migrate");
  MSG_vm_migrate(vm0, pm1);
  XBT_INFO(" ");

  XBT_INFO("# 10. (d) Put a task again on the VM.");
  launch_worker(vm0, "worker0", computation_amount, 0, 0);
  MSG_process_sleep(1000);
  XBT_INFO(" ");

  MSG_vm_destroy(vm0);

  XBT_INFO("# 11. Change a bound dynamically.");
  test_dynamic_change();

  return 0;
}
예제 #5
0
static void test_two_tasks(msg_host_t hostA, msg_host_t hostB)
{
  const double cpu_speed = MSG_host_get_speed(hostA);
  xbt_assert(cpu_speed == MSG_host_get_speed(hostB));
  const double computation_amount = cpu_speed * 10;
  const char *hostA_name = MSG_host_get_name(hostA);
  const char *hostB_name = MSG_host_get_name(hostB);

  XBT_INFO("### Test: no bound for Task1@%s, no bound for Task2@%s", hostA_name, hostB_name);
  launch_worker(hostA, "worker0", computation_amount, 0, 0);
  launch_worker(hostB, "worker1", computation_amount, 0, 0);

  MSG_process_sleep(1000);

  XBT_INFO("### Test: 0 for Task1@%s, 0 for Task2@%s (i.e., unlimited)", hostA_name, hostB_name);
  launch_worker(hostA, "worker0", computation_amount, 1, 0);
  launch_worker(hostB, "worker1", computation_amount, 1, 0);

  MSG_process_sleep(1000);

  XBT_INFO("### Test: 50%% for Task1@%s, 50%% for Task2@%s", hostA_name, hostB_name);
  launch_worker(hostA, "worker0", computation_amount, 1, cpu_speed / 2);
  launch_worker(hostB, "worker1", computation_amount, 1, cpu_speed / 2);

  MSG_process_sleep(1000);

  XBT_INFO("### Test: 25%% for Task1@%s, 25%% for Task2@%s", hostA_name, hostB_name);
  launch_worker(hostA, "worker0", computation_amount, 1, cpu_speed / 4);
  launch_worker(hostB, "worker1", computation_amount, 1, cpu_speed / 4);

  MSG_process_sleep(1000);

  XBT_INFO("### Test: 75%% for Task1@%s, 100%% for Task2@%s", hostA_name, hostB_name);
  launch_worker(hostA, "worker0", computation_amount, 1, cpu_speed * 0.75);
  launch_worker(hostB, "worker1", computation_amount, 1, cpu_speed);

  MSG_process_sleep(1000);

  XBT_INFO("### Test: no bound for Task1@%s, 25%% for Task2@%s", hostA_name, hostB_name);
  launch_worker(hostA, "worker0", computation_amount, 0, 0);
  launch_worker(hostB, "worker1", computation_amount, 1, cpu_speed / 4);

  MSG_process_sleep(1000);

  XBT_INFO("### Test: 75%% for Task1@%s, 25%% for Task2@%s", hostA_name, hostB_name);
  launch_worker(hostA, "worker0", computation_amount, 1, cpu_speed * 0.75);
  launch_worker(hostB, "worker1", computation_amount, 1, cpu_speed / 4);

  MSG_process_sleep(1000);
}