Exemplo n.º 1
0
int main(int argc, char *argv[]) {
  int err = 0;
  unsigned int n;
  qsup_server_t *srv0, *srv1;

  qos_log_debug("Initing...");
  qsup_init();

  qsup_add_level_rule(0, d2bw(0.75));

  qsup_add_group_constraints(0, build_constr(0, 1, d2bw(0.75), d2bw(0.3), 0));

  /* Test check on max_min configured through rules */
  qos_chk_exit(qsup_create_server(&srv0, 0, 0, build_params(0, d2bw(0.5), 0)) == QOS_E_UNAUTHORIZED);

  qos_chk_ok_exit(qsup_create_server(&srv0, 0, 0, build_params(0, d2bw(0.2), 0)));
  qos_chk_ok_exit(qsup_create_server(&srv1, 1, 0, build_params(0, d2bw(0.1), 0)));

  qsup_dump();

  for (n = 0; n < sizeof(bw_requests) / sizeof(pair_t); n++) {
    int i;
    struct timeval tv1, tv2;
    qos_log_debug("n=%d", n);
    gettimeofday(&tv1, NULL);
    for (i = 0; i < 1000000; ++i)
      qsup_set_required_bw(srv0, d2bw(bw_requests[n][0]));
    gettimeofday(&tv2, NULL);
    qos_log_debug("# microseconds: %g\n", (tv2.tv_usec - tv1.tv_usec + (tv2.tv_sec - tv1.tv_sec) * 1000000) / 1000000.0);

    qsup_set_required_bw(srv1, d2bw(bw_requests[n][1]));
    if (
	(fabs(bw2d(qsup_get_approved_bw(srv0)) - bw_approved[n][0]) > tolerance)
	|| (fabs(bw2d(qsup_get_approved_bw(srv1)) - bw_approved[n][1]) > tolerance)
	) {
      qos_log_err("Requests were %g, %g. Expecting %g, %g while got %g, %g.",
		  bw_requests[n][0], bw_requests[n][1],
		  bw_approved[n][0], bw_approved[n][1],
		  bw2d(qsup_get_approved_bw(srv0)), bw2d(qsup_get_approved_bw(srv1)));
      err = -1;
    }
  }

  qsup_dump();

  qos_log_debug("Cleaning up supervisor");
  qsup_cleanup();

  return err;
}
Exemplo n.º 2
0
int ibrdma_transfer(struct transfer_info *tfi, int num_tfi) {
  struct addrinfo *addr;
  struct rdma_cm_id *cmid= NULL;
  struct rdma_event_channel *ec = NULL;
  struct rdma_conn_param cm_params;
  TEST_NZ(getaddrinfo(host, port, NULL, &addr));
  TEST_Z(ec = rdma_create_event_channel());
  TEST_NZ(rdma_create_id(ec, &cmid, NULL, RDMA_PS_TCP));
  TEST_NZ(rdma_resolve_addr(cmid, NULL, addr->ai_addr, TIMEOUT_IN_MS));
  TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_ADDR_RESOLVED));
  freeaddrinfo(addr);
  build_connection(cmid);
  TEST_NZ(rdma_resolve_route(cmid, TIMEOUT_IN_MS));
  TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_ROUTE_RESOLVED));
  build_params(&cm_params);
  TEST_NZ(rdma_connect(cmid, &cm_params));
  TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_ESTABLISHED));
  on_connect(cmid->context);
  


  TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_DISCONNECTED));
  rdma_destroy_id(&cmid);
  rdma_destroy_event_channel(&ec);

  return 0;
}
Exemplo n.º 3
0
//static int run(int argc, char **argv)
int ibrdma_send(char* host, char* port, void* data, uint64_t size)
{
  
  struct addrinfo *addr;
  struct rdma_cm_id *cmid= NULL;
  struct rdma_event_channel *ec = NULL;
  struct rdma_conn_param cm_params;
  TEST_NZ(getaddrinfo(host, port, NULL, &addr));
  TEST_Z(ec = rdma_create_event_channel());
  TEST_NZ(rdma_create_id(ec, &cmid, NULL, RDMA_PS_TCP));
  TEST_NZ(rdma_resolve_addr(cmid, NULL, addr->ai_addr, TIMEOUT_IN_MS));
  TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_ADDR_RESOLVED));
  freeaddrinfo(addr);
  build_connection(cmid);
  TEST_NZ(rdma_resolve_route(cmid, TIMEOUT_IN_MS));
  TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_ROUTE_RESOLVED));
  build_params(&cm_params);
  TEST_NZ(rdma_connect(cmid, &cm_params));
  TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_ESTABLISHED));
  on_connect(cmid->context);

  /* Init MSG send to start RDMA*/
  init_tfile(data,  size);
  send_init(cmid->context);
  /*----------------------------*/

  TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_DISCONNECTED));
  rdma_destroy_id(cmid);
  rdma_destroy_event_channel(ec);

  return 0;
}
Exemplo n.º 4
0
//static int run(int argc, char **argv)
//int RDMA_Connect(struct RDMA_communicator *comm, struct RDMA_param *param)
int RDMA_Active_Init(struct RDMA_communicator *comm, struct RDMA_param *param)
{
  struct addrinfo *addr;
  //  struct rdma_cm_id *cm_id= NULL;
  //  struct rdma_event_channel *ec = NULL;
  struct rdma_conn_param cm_params;
  char port[8];
  //  int i,j;

  sprintf(port, "%d", RDMA_PORT);

  TEST_NZ(getaddrinfo(param->host, port, NULL, &addr));

  TEST_Z(comm->ec = rdma_create_event_channel());

  TEST_NZ(rdma_create_id(comm->ec, &(comm->cm_id), NULL, RDMA_PS_TCP));
  TEST_NZ(rdma_resolve_addr(comm->cm_id, NULL, addr->ai_addr, TIMEOUT_IN_MS));
  TEST_NZ(wait_for_event(comm->ec, RDMA_CM_EVENT_ADDR_RESOLVED));
  freeaddrinfo(addr);

  build_connection(comm->cm_id);
  TEST_NZ(rdma_resolve_route(comm->cm_id, TIMEOUT_IN_MS));
  TEST_NZ(wait_for_event(comm->ec, RDMA_CM_EVENT_ROUTE_RESOLVED));
  build_params(&cm_params);
  TEST_NZ(rdma_connect(comm->cm_id, &cm_params));
  TEST_NZ(wait_for_event(comm->ec, RDMA_CM_EVENT_ESTABLISHED));
  //  on_connect(cm_id->context);

  return 0;
}
Exemplo n.º 5
0
int main(int argc, char *argv[]) {
  int err = 0;
  unsigned int n;
  qsup_server_t *srv0, *srv1;

  qos_log_debug("Initing...");
  qsup_init();

  qsup_add_level_rule(0, d2bw(0.75));

  qsup_add_group_constraints(0, build_constr(0, 1, d2bw(0.75), d2bw(0.3), 0));

  /* Test check on max_min configured through rules */
  qos_chk_exit(qsup_create_server(&srv0, 0, 0, build_params(0, d2bw(0.5), 0)) == QOS_E_UNAUTHORIZED);

  qos_chk_ok_exit(qsup_create_server(&srv0, 0, 0, build_params(0, d2bw(0.1), 0)));
  qos_chk_ok_exit(qsup_create_server(&srv1, 1, 0, build_params(0, d2bw(0.1), 0)));

  qsup_dump();

  for (n = 0; n < sizeof(bw_requests) / sizeof(pair_t); n++) {
    qos_log_debug("n=%d", n);
    qsup_set_required_bw(srv0, d2bw(bw_requests[n][0]));
    qsup_set_required_bw(srv1, d2bw(bw_requests[n][1]));
    if (
	(fabs(bw2d(qsup_get_approved_bw(srv0)) - bw_approved[n][0]) > tolerance)
	|| (fabs(bw2d(qsup_get_approved_bw(srv1)) - bw_approved[n][1]) > tolerance)
	) {
      qos_log_err("Requests were %g, %g. Expecting %g, %g while got %g, %g.",
		  bw_requests[n][0], bw_requests[n][1],
		  bw_approved[n][0], bw_approved[n][1],
		  bw2d(qsup_get_approved_bw(srv0)), bw2d(qsup_get_approved_bw(srv1)));
      err = -1;
    }
  }

  qsup_dump();

  qos_log_debug("Destroying servers (earliest to latest)");
  qos_chk_ok_exit(qsup_destroy_server(srv0));
  qos_chk_ok_exit(qsup_destroy_server(srv1));

  qos_log_debug("Cleaning up supervisor");
  qsup_cleanup();

  return err;
}
Exemplo n.º 6
0
int client_on_route_resolved(struct rdma_cm_id *id)
{
    struct rdma_conn_param cm_params;
    build_params(&cm_params);
    TEST_NZ(rdma_connect(id, &cm_params));

    return 0;
}
Exemplo n.º 7
0
Module GeneratorBase::build_module(const std::string &function_name,
                                   const LoweredFunc::LinkageType linkage_type) {
    build_params();
    Pipeline pipeline = build_pipeline();
    // Building the pipeline may mutate the params and imageparams.
    rebuild_params();
    return pipeline.compile_to_module(get_filter_arguments(), function_name, target, linkage_type);
}
Exemplo n.º 8
0
GeneratorParamValues GeneratorBase::get_generator_param_values() {
    build_params();
    GeneratorParamValues results;
    for (auto key_value : generator_params) {
        GeneratorParamBase *param = key_value.second;
        results[param->name] = param->to_string();
    }
    return results;
}
Exemplo n.º 9
0
int on_route_resolved(struct rdma_cm_id *id)
{
  struct rdma_conn_param cm_params;

  printf("route resolved.\n");
  build_params(&cm_params);
  TEST_NZ(rdma_connect(id, &cm_params));

  return 0;
}
Exemplo n.º 10
0
int on_route_resolved(struct rdma_cm_id *id)
{
  struct rdma_conn_param cm_params;

  printf("route resolved.\n");
  build_params(&cm_params);
  TEST_NZ(rdma_connect(id, &cm_params));
  //register_memory((struct connection *)(id->context)); 

  return 0;
}
Exemplo n.º 11
0
void GeneratorBase::set_generator_param_values(const GeneratorParamValues &params) {
    build_params();
    for (auto key_value : params) {
        const std::string &key = key_value.first;
        const std::string &value = key_value.second;
        auto param = generator_params.find(key);
        user_assert(param != generator_params.end())
            << "Generator has no GeneratorParam named: " << key;
        param->second->from_string(value);
    }
}
Exemplo n.º 12
0
int on_connect_request(struct rdma_cm_id *id)
{
    struct rdma_conn_param cm_params;

    printf("received connection request.\n");
    build_connection(id);
    build_params(&cm_params);
    sprintf(get_local_message_region(id->context), "message from passive/server side with pid %d", getpid());
    TEST_NZ(rdma_accept(id, &cm_params));

    return 0;
}
Exemplo n.º 13
0
void vtbuild(struct vtbuild *builder, const struct vt_token *token) {

	switch (token->action) {
	case VT_ACTION_EXECUTE:
	case VT_ACTION_PRINT:
		builder->cb(builder, token->ch);
		break;

	case VT_ACTION_ESC_DISPATCH:
		builder->cb(builder, ESC);
		/* TODO check, may be the following two lines should be swapped. -- Eldar*/
		builder->cb(builder, token->ch);
		build_attrs(builder, token->attrs,
				min(token->attrs_len, VT_TOKEN_ATTRS_MAX));
		break;

	case VT_ACTION_CSI_DISPATCH:
		builder->cb(builder, ESC);
		builder->cb(builder, CSI);
		build_params(builder, token->params, token->params_len);
		build_attrs(builder, token->attrs,
				min(token->attrs_len, VT_TOKEN_ATTRS_MAX));
		builder->cb(builder, token->ch);
		break;

	case VT_ACTION_OSC_START:
	case VT_ACTION_OSC_PUT:
	case VT_ACTION_OSC_END:
		/* Operating System Command */
		/* ignore them as unused in our system
		  -- Eldar*/
	case VT_ACTION_HOOK:
	case VT_ACTION_PUT:
	case VT_ACTION_UNHOOK:
		/* device control strings */
		/* ignore them as unused in our system
		  -- Eldar*/
		break;
	case VT_ACTION_IGNORE:
	case VT_ACTION_COLLECT:
	case VT_ACTION_PARAM:
	case VT_ACTION_CLEAR:
		/* ignore as VTParser internal states*/
		break;
	default:
		/* unknown action
		 do not fail, just ignore it*/
		break;
	}
}
Exemplo n.º 14
0
void GeneratorBase::emit_filter(const std::string &output_dir,
                                const std::string &function_name,
                                const std::string &file_base_name,
                                const EmitOptions &options) {
    build_params();

    Pipeline pipeline = build_pipeline();

    std::vector<Halide::Argument> inputs = get_filter_arguments();
    std::string base_path = output_dir + "/" + (file_base_name.empty() ? function_name : file_base_name);
    if (options.emit_o || options.emit_assembly || options.emit_bitcode) {
        Outputs output_files;
        if (options.emit_o) {
            // If the target arch is pnacl, then the output "object" file is
            // actually a pnacl bitcode file.
            if (Target(target).arch == Target::PNaCl) {
                output_files.object_name = base_path + ".bc";
            } else if (Target(target).os == Target::Windows &&
                       !Target(target).has_feature(Target::MinGW)) {
                // If it's windows, then we're emitting a COFF file
                output_files.object_name = base_path + ".obj";
            } else {
                // Otherwise it is an ELF or Mach-o
                output_files.object_name = base_path + ".o";
            }
        }
        if (options.emit_assembly) {
            output_files.assembly_name = base_path + ".s";
        }
        if (options.emit_bitcode) {
            // In this case, bitcode refers to the LLVM IR generated by Halide
            // and passed to LLVM, for both the pnacl and ordinary archs
            output_files.bitcode_name = base_path + ".bc";
        }
        pipeline.compile_to(output_files, inputs, function_name, target);
    }
    if (options.emit_h) {
        pipeline.compile_to_header(base_path + ".h", inputs, function_name, target);
    }
    if (options.emit_cpp) {
        pipeline.compile_to_c(base_path + ".cpp", inputs, function_name, target);
    }
    if (options.emit_stmt) {
        pipeline.compile_to_lowered_stmt(base_path + ".stmt", inputs, Halide::Text, target);
    }
    if (options.emit_stmt_html) {
        pipeline.compile_to_lowered_stmt(base_path + ".html", inputs, Halide::HTML, target);
    }
}
Exemplo n.º 15
0
static void accept_connection(struct rdma_cm_id *id)
{
  struct rdma_conn_param   conn_param;
  /*
  simple_context_t        *context = malloc(sizeof(*context));
  if (!context)
    {
       perror("failed to malloc context for connection\n");
        rdma_reject(id, NULL, 0);
        return;
      }

  // associate this context with this id. 
  context->id = id;
  id->context = context;

  context->quit_cq_thread = 0;

  if (allocate_server_resources(context))
    {
      fprintf(stderr, "failed to allocate resources\n");
      rdma_reject(id, NULL, 0);
      return;
    }

  post_server_rec_work_req(context);
  */
  printf("Accepting connection on id == %p (total connections %d)\n",
	 id, ++connections);

  build_connection_s(id);

  //  memset(&conn_param, 0, sizeof(conn_param));
  //  conn_param.responder_resources = 1;
  //  conn_param.initiator_depth = 1;
  build_params(&conn_param);

  //  sprintf(get_local_message_region(id->context), "message from passive/server side with pid %d", getpid());
  //  rdma_accept(context->id, &conn_param);
  TEST_NZ(rdma_accept(id, &conn_param));


  //if (query_qp_on_alloc)
  //    {
  //      debug_print_qp(context);
  //    }
}
Exemplo n.º 16
0
/* 
 * Load kernel image into entry point address.  Assumes that the fs buffer has
 * been filled.
 */
static u32 load_kernel(char *cmdline)
{
	u32 entry_point;
	struct image_header *hdr;

	if(tfs_load_file("uImage", (u32 *)(0x8000-sizeof(image_header_t))) != 0)
		return 0;

	build_params(cmdline, (struct tag *)params_buffer);

	hdr = (struct image_header *)(0x8000-sizeof(image_header_t));
	if(ntohl(hdr->ih_magic) != IH_MAGIC) {
		db_puts("ERROR: bad magic number\n");
		return 0;
	}

#ifdef CHECK_KERNEL_CRC
	do {
		u32 checksum;

		checksum = ntohl(hdr->ih_hcrc);
		hdr->ih_hcrc = 0;

		/* check uImage header CRC */
		if(crc32(0, (u8 *)hdr, sizeof(image_header_t)) != checksum) {
			db_puts("ERROR: header CRC mismatch\n");
		}

		/* check uImage data CRC */
		checksum = crc32(0, (u8 *)hdr+sizeof(image_header_t), 
				ntohl(hdr->ih_size));
		if(checksum != ntohl(hdr->ih_dcrc)) {
			db_puts("ERROR: bad data CRC\n");
			return 0;
		}
	} while(0);
#endif

	entry_point = ntohl(hdr->ih_ep);

	/* Retrieve the kernel image's contents in such a way that the image
	 * header is skipped and the actual start of the kernel sits at the
	 * entry point. */

	return entry_point;
}
Exemplo n.º 17
0
int on_route_resolved(struct rdma_cm_id *id)
{
  struct rdma_conn_param cm_params;
  struct timeval start, end, dt;

  printf("route resolved.\n");
  build_params(&cm_params);
  TEST_NZ(rdma_connect(id, &cm_params));

  gettimeofday(&start, NULL);
  register_memory((struct connection *)(id->context)); 
  gettimeofday(&end, NULL);
  timersub(&end, &start, &dt);
  long usec = dt.tv_usec + 1000000 * dt.tv_sec;
  printf("[Register] takes %ld micro_secs.\n", usec);

  post_receive_for_msg(id->context);

  return 0;
}
Exemplo n.º 18
0
int ibrdma_transfer(struct transfer_info tfi, int num_tfi) {
  struct addrinfo *addr;
  struct rdma_cm_id *cmid= NULL;
  struct rdma_event_channel *ec = NULL;
  struct rdma_conn_param cm_params;
  int i,j;

  /*Allocation buffer space for reading from local fs to memory*/
  struct transfer_file *ffile = tfi.tfiles;
  int nf = tfi.tfiles;
  char* host = tfi.ib_host;
  char* port; sprintf(port,"%d",tfi.ib_port);
  for (i = 0; i < NUM_FILE_BUF_C; i++) {
    tfi.fbufs[i].fbuf = (char *)malloc(FILE_BUF_SIZE_C);
    tfi.fbufs[i].size = 0;
  }

    TEST_NZ(getaddrinfo(host, port, NULL, &addr));
    TEST_Z(ec = rdma_create_event_channel());
    TEST_NZ(rdma_create_id(ec, &cmid, NULL, RDMA_PS_TCP));
    TEST_NZ(rdma_resolve_addr(cmid, NULL, addr->ai_addr, TIMEOUT_IN_MS));
    TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_ADDR_RESOLVED));
    freeaddrinfo(addr);
    build_connection(cmid);
    TEST_NZ(rdma_resolve_route(cmid, TIMEOUT_IN_MS));
    TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_ROUTE_RESOLVED));
    build_params(&cm_params);
    TEST_NZ(rdma_connect(cmid, &cm_params));
    TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_ESTABLISHED));
    on_connect(cmid->context);
    
    TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_DISCONNECTED));
    rdma_destroy_id(&cmid);
    rdma_destroy_event_channel(&ec);


  return 0;
}
Exemplo n.º 19
0
void build_hr0( int flag, int precflag )/*  0, fresh start, 1--restart with stored vectors,*/
{

    register int i,j;
    register site *s;
    int total_R_iters ;
    Real re,im;
    complex cc;
    int nn0;
    Real eigenval_tol_save;

    /* code for good h(-r0) eigenmodes */
    int failed,ifailed,nextra;
    double *MyeigVal0;
    wilson_vector **MyeigVec0;
    wilson_vector *tmpvec;
    Real ftmp;

    Real invp,invp5;



    tmpvec=(wilson_vector*)malloc(sites_on_node*sizeof(wilson_vector));
    nn0=-ndelta0;

    if (precflag==HIGHP) 
    {
	eigenval_tol=eigenval_tol_high;
	error_decr=error_decr_high;
    } else {
	eigenval_tol=eigenval_tol_low;
	error_decr=error_decr_low;
    }


    node0_printf("\n");
    eigenval_tol_save=eigenval_tol;


    build_params(-R0);
    make_clov1();
    kind_of_h0=HZERO;
    if(Maxr0Iter != 0){

      /*
     FORALLSITES(i,s){
       clear_wvec(&(eigVec0[0][i]));
       if(s->x==0 && s->y==0 && s->z==0 && s->t==0) eigVec0[0][i].d[0].c[0].real=1.0;
     }
    delta0_field(eigVec0[0],eigVec0[1],PLUS);
     FORALLSITES(i,s){
       if(s->x ==0 && s ->y==0 && s->z==0){
         node0_printf("DT %d %d %d %d\n",s->x,s->y,s->z,s->t);
         dump_wvec(&(eigVec0[1][i]));
       }
     }
      */


	/* initialize the CG vectors */
	if(flag==0)
	{
	    if(this_node==0) printf("random initial vectors for h(m0)\n");
	    /* Initiallize all the eigenvectors to a random vector */
	    for(j=0;j<Nvecs_h0r0;j++){
		grsource_dirac(EVENANDODD);
		FORSOMEPARITY(i,s,EVENANDODD){
		    copy_wvec(&(s->g_rand),&(eigVec0[j][i]));
		}
		eigVal0[j]=1.0e+16;
	    }
	}
	else 
	{

	    /* eigenvectors and eigenvalues of h(-r0) already exist, but we need eigenvalues of h^2 */
	    for(j=0;j<Nvecs_h0r0;j++){
Exemplo n.º 20
0
//static int run(int argc, char **argv)
//int RDMA_Connect(struct RDMA_communicator *comm, struct RDMA_param *param)
int RDMA_Active_Init(struct RDMA_communicator *comm, struct RDMA_param *param)
{
  struct addrinfo *addr;
  //  struct rdma_cm_id *cm_id= NULL;
  //  struct rdma_event_channel *ec = NULL;
  struct rdma_conn_param cm_params;
  char port[8];
  //  int i,j;

  sprintf(port, "%d", RDMA_PORT);

  if(getaddrinfo(param->host, port, NULL, &addr)){
    fprintf(stderr, "RDMA lib: SEND: ERROR: getaddrinfo failed @ %s:%d", __FILE__, __LINE__);
    exit(1);
  }

  if(!(comm->ec = rdma_create_event_channel())){
    fprintf(stderr, "RDMA lib: SEND: ERROR: rdma event channel create failed @ %s:%d", __FILE__, __LINE__);
    exit(1);
  }

  if (rdma_create_id(comm->ec, &(comm->cm_id), NULL, RDMA_PS_TCP)){
    fprintf(stderr, "RDMA lib: SEND: ERROR: rdma id create failed @ %s:%d", __FILE__, __LINE__);
    exit(1);
  }
  if (rdma_resolve_addr(comm->cm_id, NULL, addr->ai_addr, TIMEOUT_IN_MS)) {
    fprintf(stderr, "RDMA lib: SEND: ERROR: rdma address resolve failed @ %s:%d", __FILE__, __LINE__);
    exit(1);
  }

  if (wait_for_event(comm->ec, RDMA_CM_EVENT_ADDR_RESOLVED)) {
    fprintf(stderr, "RDMA lib: SEND: ERROR: event wait failed @ %s:%d", __FILE__, __LINE__);
    exit(1);
  }
  freeaddrinfo(addr);

  build_connection(comm->cm_id);

  if (rdma_resolve_route(comm->cm_id, TIMEOUT_IN_MS)) {
    fprintf(stderr, "RDMA lib: SEND: ERROR: rdma route resolve failed @ %s:%d", __FILE__, __LINE__);
    exit(1);
  }
  if (wait_for_event(comm->ec, RDMA_CM_EVENT_ROUTE_RESOLVED)) {
    fprintf(stderr, "RDMA lib: SEND: ERROR: event wait failed @ %s:%d", __FILE__, __LINE__);
    exit(1);
  }

  build_params(&cm_params);

  if (rdma_connect(comm->cm_id, &cm_params)) {
    fprintf(stderr, "RDMA lib: SEND: ERROR: rdma connection failed @ %s:%d", __FILE__, __LINE__);
    exit(1);
  }

  if (wait_for_event(comm->ec, RDMA_CM_EVENT_ESTABLISHED)) {
    fprintf(stderr, "RDMA lib: SEND: ERROR: event wait failed @ %s:%d\n", __FILE__, __LINE__);
    exit(1);
  }
  //  on_connect(cm_id->context);
  int i ;
  for (i = 0; i < RDMA_BUF_NUM_C; i++){ rdma_msg_mr[i] = NULL;}

  char *value;
  value = getenv("RDMA_CLIENT_NUM_S");
  if (value == NULL) {
    rdma_buf_size = RDMA_BUF_SIZE_C;
  } else {
    rdma_buf_size  =  MAX_RDMA_BUF_SIZE_C / atoi(value);
  }
  fprintf(stderr, "rdma_buf_size: %d\n", rdma_buf_size);

  return 0;
}
Exemplo n.º 21
0
static int init_db(struct dbops_action* p)
{
	db_fld_t* matches = NULL, *result = NULL, *values = NULL;
	int type, i;

	DEBUG(MODULE_NAME": init_db: query: %s(%d)\n", p->query_name, p->query_no);
	if (p->db_url == NULL) {
		ERR(MODULE_NAME": No database URL specified\n");
		return -1;
	}
	p->ctx = db_ctx(MODULE_NAME);
	if (p->ctx == NULL) {
		ERR(MODULE_NAME": Error while initializing database layer\n");
		return -1;
	}
	
	if (db_add_db(p->ctx, p->db_url) < 0) return -1;
	if (db_connect(p->ctx) < 0) return -1;

	if (p->is_raw_query) {
		type = DB_SQL;
		if (build_params(&matches, p) < 0) return -1;
	}
	else {
		switch(p->operation) {
		case INSERT_OPS:
		case REPLACE_OPS:
			type = DB_PUT;
			if (build_params(&values, p) < 0) return -1;
			break;

		case UPDATE_OPS:
			type = DB_UPD;
			if (build_match(&matches, p) < 0) return -1;
			if (build_params(&values, p) < 0) {
				if (matches) pkg_free(matches);
				return -1;
			}
			break;

		case DELETE_OPS:
			type = DB_DEL;

			if (build_match(&matches, p) < 0) return -1;
			break;

		case OPEN_QUERY_OPS:
			type = DB_GET;
			if (build_match(&matches, p) < 0) return -1;
			if (build_result(&result, p) < 0) {
				if (matches) pkg_free(matches);
				return -1;
			}
			break;
		default:
			BUG("Unknown operation %d\n", p->operation);
			return -1;
		}
	}

	p->cmd = db_cmd(type, p->ctx, p->table.s, result, matches, values);
	if (p->cmd == NULL) {
		ERR(MODULE_NAME": init_db: query: %s(%d), error while compiling database query\n", p->query_name, p->query_no);
		if (values) pkg_free(values);
		if (matches) pkg_free(matches);
		if (result) pkg_free(result);
		db_disconnect(p->ctx);
		db_ctx_free(p->ctx);
		return -1;
	}
	if (values) pkg_free(values);
	if (matches) pkg_free(matches);
	if (result) pkg_free(result);

	for (i=0; i<p->extra_ops_count; i++) {
		char *end;
		DEBUG(MODULE_NAME": init_db: query_no: %s(%d), setopt('%s', %i, '%s'\n", p->query_name, p->query_no, p->extra_ops[i].name, p->extra_ops[i].type, p->extra_ops[i].value);
		switch (p->extra_ops[i].type) {
			case DB_NONE: 
				/* set null ?? */
				break;			
			case DB_DATETIME: {
				time_t v;
				v = strtol(p->extra_ops[i].value, &end, 10);
				if (db_setopt(p->cmd, p->extra_ops[i].name, v) < 0) return -1;
				break;
			}
			case DB_INT: {
				int v;
				v = strtol(p->extra_ops[i].value, &end, 10);
				if (db_setopt(p->cmd, p->extra_ops[i].name, v) < 0) return -1;
				break;
			}
			case DB_FLOAT: {
				float v;
				#ifdef  __USE_ISOC99
				v = strtof(p->extra_ops[i].value, &end);
				#else
				v = strtod(p->extra_ops[i].value, &end);
				#endif
				if (db_setopt(p->cmd, p->extra_ops[i].name, v) < 0) return -1;
				break;
			}
			case DB_DOUBLE: {
				double v;
				v = strtod(p->extra_ops[i].value, &end);
				if (db_setopt(p->cmd, p->extra_ops[i].name, v) < 0) return -1;
				break;
			}
			case DB_CSTR:
				if (db_setopt(p->cmd, p->extra_ops[i].name, p->extra_ops[i].value) < 0) return -1;
				break;
		default:
				BUG("Unknown extra_op type: %d\n", p->extra_ops[i].type);
				return -1;
		}
	}
	return 0;
}
Exemplo n.º 22
0
static int run(int argc, char **argv)
{
  struct addrinfo *addr;
  //struct rdma_cm_event *event = NULL;
  struct rdma_cm_id *cmid= NULL;
  struct rdma_event_channel *ec = NULL;
  struct rdma_conn_param cm_params;

  if (argc != 4)
    usage(argv[0]);

  if (strcmp(argv[1], "write") == 0)
    set_mode(M_WRITE);
  else if (strcmp(argv[1], "read") == 0)
    set_mode(M_READ);
  else
    usage(argv[0]);

  TEST_NZ(getaddrinfo(argv[2], argv[3], NULL, &addr));

  TEST_Z(ec = rdma_create_event_channel());
  /*create rdma socket*/
  TEST_NZ(rdma_create_id(ec, &cmid, NULL, RDMA_PS_TCP));

  /* int rdma_resolve_addr (struct rdma_cm_id *id, struct sockaddr *src_addr, 
                            struct sockaddr dst_addr, int timeout_ms)
       id          RDMA identifier
       src_addr    Source address information. This parameter may be NULL.
       dst_addr    Destination address information
       timeout_ms  Time to wait for resolution to complete
     Description:
       Resolve destination and optional source addresses from IP addresses 
       to an RDMA address. If suc- cessful, 
       the specified rdma_cm_id will be bound to a local device.
  */
  TEST_NZ(rdma_resolve_addr(cmid, NULL, addr->ai_addr, TIMEOUT_IN_MS));
  TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_ADDR_RESOLVED));
  freeaddrinfo(addr);
  build_connection(cmid);
  
  sprintf(get_local_message_region(cmid->context), "message from active/client side with pid %d", getpid());
  /*--------------------*/

  /* int rdma_resolve_route (struct rdma_cm_id *id, int timeout_ms); 
       id            RDMA identifier
       timeout_ms    Time to wait for resolution to complete
     Description:
       Resolves an RDMA route to the destination address in order 
       to establish a connection. The destination address must have 
       already been resolved by calling rdma_resolve_addr. 
   */
  TEST_NZ(rdma_resolve_route(cmid, TIMEOUT_IN_MS));
  TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_ROUTE_RESOLVED));
  /* -------------------- */
  
  print_path_rec(cmid);

  /* int rdma_connect (struct rdma_cm_id *id, struct rdma_conn_param *conn_param); 
       id            RDMA identifier
       conn_param    connection parameters

       Description:
       For an rdma_cm_id of type RDMA_PS_TCP, this call initiates a connection 
       request to a remote destination. For an rdma_cm_id of type RDMA_PS_UDP, 
       it initiates a lookup of the remote QP providing the datagram service
  */
  build_params(&cm_params);
  printf("Connecting ...\n");
  TEST_NZ(rdma_connect(cmid, &cm_params));
  TEST_NZ(wait_for_event(ec, RDMA_CM_EVENT_ESTABLISHED));
  printf("Connected !\n");
  /* --------------------- */
  
  /*TODO: do something */
  on_connect(cmid->context);
  send_mr(cmid->context);
  /*--------------------*/

  rdma_disconnect(cmid);
  rdma_destroy_id(cmid);
  rdma_destroy_event_channel(ec);

  return 0;
  /*=================*/
  /*=================*/

  /*
  while (rdma_get_cm_event(ec, &event) == 0) {


    memcpy(&event_copy, event, sizeof(*event));
    rdma_ack_cm_event(event);

    if (on_event(&event_copy))
      break;
  }
  */
}
Exemplo n.º 23
0
int main(int argc, char *argv[])
{
int meascount;
int prompt;
Real avm_iters,avs_iters;

double ssplaq,stplaq;


double starttime,endtime;
double dtime;

int MinCG,MaxCG;
Real size_r,RsdCG;

register int i,j,l;
register site *s;

int spinindex,spin,color,k,kk,t;
int flag;
int ci,si,sf,cf;
int num_prop;
Real space_vol;

int status;

int source_chirality;

    wilson_vector **eigVec ;
    double *eigVal ;
    int total_R_iters ;
    double norm;
    Real re,im,re5,im5;
    complex cc;
    char label[20] ;

    double *grad, *err, max_error;
  Matrix Array,V ;

int key[4];
#define restrict rstrict /* C-90 T3D cludge */
int restrict[4];

Real norm_fac[10];

static char *mes_kind[10] = {"PION","PS505","PS055","PS0505",
		"RHO33","RHO0303","SCALAR","SCALA0","PV35","B12"};
static char *bar_kind[4] = {"PROTON","PROTON0","DELTA","DELTA0"};

complex *pmes_prop[MAX_MASSES][10];
complex *smes_prop[MAX_MASSES][10];
complex *bar_prop[MAX_MASSES][4];

w_prop_file *fp_in_w[MAX_MASSES];        /* For propagator files */
w_prop_file *fp_out_w[MAX_MASSES];       /* For propagator files */

    initialize_machine(&argc,&argv);

  /* Remap standard I/O */
  if(remap_stdio_from_args(argc, argv) == 1)terminate(1);

    g_sync();
    /* set up */
    prompt = setup_p();
    /* loop over input sets */


    while( readin(prompt) == 0)
    {



	starttime=dclock();
	MaxCG=niter;

	avm_iters=0.0;
	meascount=0;



	if(this_node==0)printf("END OF HEADER\n");
	setup_offset();

/*
if(this_node==0)printf("warning--no fat link\n");
*/
	monte_block_ape_b(1);
                /* call plaquette measuring process */
                d_plaquette(&ssplaq,&stplaq);
                if(this_node==0)printf("FATPLAQ  %e %e\n",
                    (double)ssplaq,(double)stplaq);




/* flip the time oriented fat links 
if(this_node==0) printf("Periodic time BC\n");
*/
if(this_node==0) printf("AP time BC\n");
boundary_flip(MINUS);





	setup_links(SIMPLE);

/*	if(this_node==0) printf("num_masses = %d\n", num_masses); */
	/* Loop over mass */
	for(k=0;k<num_masses;k++){

	  m0=mass[k];
	if(m0 <= -10.0) exit(1);
	  RsdCG=resid[k];
	  if(this_node==0)printf("mass= %g r0= %g residue= %g\n",
		(double)m0,(double)wqs[k].r0,(double)RsdCG);
	  build_params(m0);
	  make_clov1();


                eigVal = (double *)malloc(Nvecs*sizeof(double));
                eigVec = (wilson_vector **)malloc(Nvecs*sizeof(wilson_vector*));
                for(i=0;i<Nvecs;i++)
                  eigVec[i]=
                    (wilson_vector*)malloc(sites_on_node*sizeof(wilson_vector));


          /* open files for wilson propagators */
          fp_in_w[k]  = r_open_wprop(startflag_w[k], startfile_w[k]);
          fp_out_w[k] = w_open_wprop(saveflag_w[k],  savefile_w[k],
				     wqs[k].type);


                    if(startflag_w[k] == FRESH)flag = 0;
                    else
                      flag = 1;
spin=color=0; /* needed by wilson writing routines */




		/* initialize the CG vectors */
		    if(flag==0){
if(this_node==0) printf("random (but chiral) initial vectors\n");
  /* Initiallize all the eigenvectors to a random vector */
  for(j=0;j<Nvecs;j++)
    {
      if(j< Nvecs/2){ source_chirality=1;}
      else{source_chirality= -1;}
      printf("source chirality %d\n",source_chirality);
      grsource_w();
      FORALLSITES(i,s){
        copy_wvec(&(s->g_rand),&(eigVec[j][i]));
	if(source_chirality==1){
	  for(kk=2;kk<4;kk++)for(l=0;l<3;l++)
	    eigVec[j][i].d[kk].c[l]=cmplx(0.0,0.0);
	}

	if(source_chirality== -1){
	  for(kk=0;kk<2;kk++)for(l=0;l<3;l++)
	    eigVec[j][i].d[kk].c[l]=cmplx(0.0,0.0);
	}
      }
      eigVal[j]=1.0e+16;
    }
		    }
		    else{
if(this_node==0) printf("reading in %d wilson_vectors--must be <= 12\n",Nvecs);
                    /* load psi if requested */
for(j=0;j<Nvecs;j++){
printf("reading %d %d %d\n",j,spin,color);
#ifdef IOTIME
                    status = reload_wprop_sc_to_site( startflag_w[k], fp_in_w[k], 
                                      spin, color, F_OFFSET(psi),1);
#else
                    status = reload_wprop_sc_to_site( startflag_w[k], fp_in_w[k], 
                                      spin, color, F_OFFSET(psi),0);
#endif

		    /* compute eigenvalue */
		    herm_delt(F_OFFSET(psi),F_OFFSET(chi));

		  re=im=0.0;
		  FORALLSITES(i,s){
		    cc = wvec_dot( &(s->chi), &(s->psi) );
		    re += cc.real ;
		  }
		  g_floatsum(&re);
		  eigVal[j]=re;
printf("trial eigenvalue of state %d %e\n",j,eigVal[j]);
		  FORALLSITES(i,s){eigVec[j][i]=s->psi;}
spin++;
if((spin %4) == 0){spin=0;color++;}
}

		    }
Exemplo n.º 24
0
void GeneratorBase::rebuild_params() {
    params_built = false;
    filter_arguments.clear();
    generator_params.clear();
    build_params();
}
Exemplo n.º 25
0
// Handle a set of case methods, starting at the given method.
// Generate wrapper and worker methods and append them to the given list.
// Returns: true on success, false on failure.
static bool sugar_case_method(ast_t* first_case_method, ast_t* members,
  const char* name, typecheck_t* t)
{
  assert(first_case_method != NULL);
  assert(members != NULL);
  assert(name != NULL);
  assert(t != NULL);

  ast_t* wrapper = make_match_wrapper(first_case_method);

  if(wrapper == NULL)
    return false;

  ast_t* match_cases = ast_from(first_case_method, TK_CASES);
  ast_scope(match_cases);

  // Process all methods with the same name.
  // We need to remove processed methods. However, removing nodes from a list
  // we're iterating over gets rather complex. Instead we mark nodes and remove
  // them all in one sweep later.
  for(ast_t* p = first_case_method; p != NULL; p = ast_sibling(p))
  {
    const char* p_name = ast_name(ast_childidx(p, 1));

    if(p_name == name)
    {
      // This method is in the case set.
      ast_t* case_ast = add_case_method(wrapper, p);

      if(case_ast == NULL)
      {
        ast_free(wrapper);
        ast_free(match_cases);
        return false;
      }

      ast_append(match_cases, case_ast);
      ast_setid(p, TK_NONE);  // Mark for removal.
    }
  }

  // Check params and build match operand, worker parameters and worker call
  // arguments.
  ast_t* match_params = ast_childidx(wrapper, 3);
  ast_t* worker_params = ast_from(match_params, TK_PARAMS);
  ast_t* call_args = ast_from(match_params, TK_POSITIONALARGS);
  ast_t* match_operand = build_params(match_params, worker_params, call_args,
    name, t);

  if(match_operand == NULL)
  {
    ast_free(wrapper);
    ast_free(match_cases);
    ast_free(worker_params);
    ast_free(call_args);
    return false;
  }

  // Complete wrapper function and add to containing entity.
  const char* worker_name = package_hygienic_id(t);
  ast_t* wrapper_body = ast_childidx(wrapper, 6);
  ast_t* wrapper_call;
  ast_t* call_t_args = ast_from(wrapper, TK_NONE);
  assert(ast_id(wrapper_body) == TK_SEQ);
  assert(ast_childcount(wrapper_body) == 0);

  build_t_params(ast_childidx(wrapper, 2), call_t_args);

  if(ast_id(call_t_args) == TK_NONE)
  {
    // No type args needed.
    ast_free(call_t_args);
    BUILD(tmp, wrapper_body,
      NODE(TK_CALL,
        TREE(call_args)
        NONE
        NODE(TK_REFERENCE, ID(worker_name))));

    wrapper_call = tmp;
  }
  else
  {
    // Type args needed on call.
    BUILD(tmp, wrapper_body,
      NODE(TK_CALL,
        TREE(call_args)
        NONE
        NODE(TK_QUALIFY,
          NODE(TK_REFERENCE, ID(worker_name))
          TREE(call_t_args))));

    wrapper_call = tmp;
  }

  ast_append(wrapper_body, wrapper_call);
  ast_append(members, wrapper);

  // Make worker function and add to containing entity.
  AST_GET_CHILDREN(wrapper, cap, wrapper_id, t_params, wrapper_params,
    ret_type, error);

  if(ast_id(wrapper) == TK_BE)
    cap = ast_from(cap, TK_REF);

  BUILD(worker, wrapper,
    NODE(TK_FUN, AST_SCOPE
      TREE(cap)
      ID(worker_name)
      TREE(t_params)
      TREE(worker_params)
      TREE(ret_type)
      TREE(error)
      NODE(TK_SEQ,
        NODE(TK_MATCH, AST_SCOPE
          NODE(TK_SEQ, TREE(match_operand))
          TREE(match_cases)
          NONE)) // Else clause.
      NONE    // Doc string.
      NONE)); // Guard.

  ast_append(members, worker);
  return true;
}