예제 #1
0
파일: mem.c 프로젝트: jyoung3131/oncilla
///Sends a request message to rank 0 to find a node for an allocation,
///then sends a subsquent message to rank N to request an allocation
  static int
msg_send_req_alloc(struct message *msg)
{
  int ret = 0;
  BUG(!msg);
  BUG(msg->type != MSG_REQ_ALLOC);

  printd("requesting alloc from rank0\n");
  if (myrank == 0)
    __msg_req_alloc(msg);
  else
    ret = send_recv_msg(msg, 0);
  if (ret)
    goto out;

  printd("got alloc type %d\n", msg->u.alloc.type);
  if ((msg->u.alloc.type != ALLOC_MEM_HOST) && (msg->u.alloc.type != ALLOC_MEM_GPU)) {
    msg->type   = MSG_DO_ALLOC;
    msg->status = MSG_REQUEST;
    /* TODO support multiple allocs across nodes here */
    ret = send_recv_msg(msg, msg->u.alloc.remote_rank);
    if (ret)
      goto out;
  }
  ret = 0;
out:
  return ret;
}
예제 #2
0
int timer_add(long sec, long usec, void (*hndlr) (void *), void *hndlr_arg)
{
	int ret = 0;
	tl_timer_t req_info;
	int need_recv = 1;

	if (hndlr == NULL)
		return -1;

	/* ensure timeout is in the future */
	if ((sec < 0) || (usec < 0) || ((sec == 0) && (usec == 0))) {
		return -1;
	}

	memset(&req_info, 0, sizeof(tl_timer_t));

	req_info.action = e_ACTION_TYPY_ADD;
	req_info.handler = hndlr;
	req_info.handler_arg = hndlr_arg;
	req_info.timeout.tv_sec = sec;
	req_info.timeout.tv_usec = usec;

	ret = send_recv_msg(&req_info, need_recv);
	if (ret != 0 ) {
		fprintf(std_err, "send_recv_msg() failed.\n");
		return -1;
	}
	
	return req_info.id;
}
예제 #3
0
파일: mem.c 프로젝트: jyoung3131/oncilla
///Sends a notification message to rank 0 to free info on an allocation,
///then sends a subsquent message to rank N to free an allocation
  static int
msg_send_req_free(struct message *msg)
{
  int ret = 0;
  BUG(!msg);
  BUG(msg->type != MSG_REQ_FREE);

  /*printd("Notifying rank0 to release resources\n");
    if (myrank == 0)
    __msg_req_free(msg);
    else
    ret = send_recv_msg(msg, 0);
    if (ret)
    goto out;
   */
  msg->type   = MSG_DO_FREE;
  msg->status = MSG_REQUEST;

  printd("Sending free for allocation type %d to remote rank %d\n", msg->u.alloc.type, msg->u.alloc.remote_rank);
  if ((msg->u.alloc.type == ALLOC_MEM_RDMA) || (msg->u.alloc.type == ALLOC_MEM_RMA))
  {
    ret = send_recv_msg(msg, msg->u.alloc.remote_rank);
    if (ret)
      goto out;
  }
  else
    BUG(1);

  ret = 0;
out:
  return ret;
}
예제 #4
0
void timer_clear()
{
	int ret = 0;
	tl_timer_t req_info;
	int need_recv = 1;
	
	memset(&req_info, 0, sizeof(tl_timer_t));

	req_info.action = e_ACTION_TYPY_DEL_ALL;

	ret = send_recv_msg(&req_info, need_recv);
	if (ret != 0 ) {
		fprintf(std_err, "send_recv_msg() failed.\n");
		return ;
	}
	
	return ;
}
예제 #5
0
파일: mem.c 프로젝트: jyoung3131/oncilla
//Message is sent from local node to remote node
//that handles remote allocation
  static int
msg_send_do_free(struct message *msg) 
{ 
  int ret = 0;
  BUG(!msg);
  BUG(msg->type != MSG_DO_FREE);
  BUG(msg->u.alloc.remote_rank > node_file_entries - 1);
  BUG(msg->u.alloc.remote_rank == myrank);

  ret = send_recv_msg(msg, msg->u.alloc.remote_rank);
  if (ret)
    goto out;
  send_pid(msg, msg->pid);

  ret = 0;
out:
  return ret;
}
예제 #6
0
void uri_tst(char *uri)
{
	int a = 1, b = 22, c = 333;
	int *A, *B, *C;
	brpc_id_t cid = 1234;
	BRPC_STR_STATIC_INIT(mname, "method name");
	brpc_t *snd_msg, *rcv_msg;
	snd_msg = brpc_req(mname, cid);
	assert(brpc_asm(snd_msg, "d<dd>", a, b, c));
	assert((rcv_msg = send_recv_msg(uri, snd_msg)));
	brpc_finish(snd_msg);
	brpc_dsm(rcv_msg, "d<dd>", &A, &B, &C);
	assert(a == *A);
	assert(b == *B);
	assert(c == *C);
	assert(brpc_id(rcv_msg) == cid);
	brpc_finish(rcv_msg);
}
예제 #7
0
void timer_rem(int id, void (*free_arg) (void *))
{
	int ret = 0;
	tl_timer_t req_info;
	int need_recv = 1;

	if (id < 0) {
		return;
	}

	memset(&req_info, 0, sizeof(tl_timer_t));

	req_info.action = e_ACTION_TYPY_DEL;
	req_info.id = id;
	req_info.handler = free_arg;

	ret = send_recv_msg(&req_info, need_recv);
	if (ret != 0 ) {
		fprintf(std_err, "send_recv_msg() failed.\n");
		return ;
	}
	
	return ;
}