Beispiel #1
0
	void create(unsigned int size1)
	{
		if(!is_ready())
		{
			rank1 = size1;
			if(!init_data())
			{
				reset_data_members();
			}
		}
	};
Beispiel #2
0
/* Daemon init sequence */
static void
start_check(void)
{
	/* Initialize sub-system */
	ipvs_start();
	init_checkers_queue();
#ifdef _WITH_VRRP_
	init_interface_queue();
	kernel_netlink_init();
#endif

	/* Parse configuration file */
	data = alloc_global_data();
	check_data = alloc_check_data();
	init_data(conf_file, check_init_keywords);
	if (!check_data) {
		stop_check();
		return;
	}

	/* Post initializations */
	log_message(LOG_INFO, "Configuration is using : %lu Bytes", mem_allocated);

	/* SSL load static data & initialize common ctx context */
	if (!init_ssl_ctx()) {
		stop_check();
		return;
	}

	/* Processing differential configuration parsing */
	if (reload)
		clear_diff_services();

	/* Initialize IPVS topology */
	if (!init_services()) {
		stop_check();
		return;
	}

	/* Dump configuration */
	if (debug & 4) {
		dump_global_data(data);
		dump_check_data(check_data);
	}

#ifdef _WITH_VRRP_
	/* Initialize linkbeat */
	init_interface_linkbeat();
#endif

	/* Register checkers thread */
	register_checkers_thread();
}
void init(void)
{
	count = 0;
	t = 0.0;
	N = 11;
	p = 2;
	amp = 0.5;
	offset = 0.5;
	init_prbs(N, p);
	m = param->n; // test duration
	init_data();
}
Beispiel #4
0
//尾部插入一个节点-
list insert_list(list L)
{
    list newlist = (list)malloc(sizeof(struct node_s_t));
    while(L->next!=NULL)
    {
        L=L->next;
    }
    L->next=newlist;
    newlist->next=NULL;
    init_data(newlist,0);
    return newlist;
}
/**
 * The inboard and outboard links are set to NULL.
 */
FIXEDJOINT::FIXEDJOINT() : JOINT()
{
  // init joint data
  init_data();

  // setup the spatial axis time derivative to zero
  _s_dot.clear();

  // initialize frames
  _F1 = shared_ptr<POSE3>(new POSE3);
  _F2 = shared_ptr<POSE3>(new POSE3);
}
int main(int argc, char **argv)
{
	// define the ptr
	int size = WIDTH * HEIGHT;
	float *h_data, *d_send_data, *d_recv_data; 
	bool use_cuda_time = true;

	if(argc != 3) {
		std::cout << "the number of paramter should be equal 2" << std::endl;
		std::cout << "egs: bandwidth_test_between2gpu 0 1" << std::endl;
		return 1;
	}
	//std::cout << "debug 1" << std::endl;
	int id0 = atoi(argv[1]);
	int id1 = atoi(argv[2]);
	std::cout << "id0=" << id0 << ", id1=" << id1 << std::endl;

	//h_data = new float[size];
	cudaMallocHost(&h_data, size*sizeof(float));
	init_data(h_data, size);

	cudaSetDevice(id0);
	cudaMalloc(&d_send_data, size*sizeof(float));
	cudaSetDevice(id1);
	cudaMalloc(&d_recv_data, size*sizeof(float));
	cudaMemcpy(d_send_data, h_data, size*sizeof(float), cudaMemcpyHostToDevice);

	int can_access_peer_0_1, can_access_peer_1_0;
	cudaSetDevice(id0);
	CUDA_CHECK(cudaDeviceCanAccessPeer(&can_access_peer_0_1, id0, id1));
	CUDA_CHECK(cudaDeviceCanAccessPeer(&can_access_peer_1_0, id1, id0));

	if(can_access_peer_0_1 && can_access_peer_1_0) {
		std::cout << "can GPU" << id0 << "access from GPU" << id1 << ": Yes" << std::endl;
		cudaSetDevice(id0);
		CUDA_CHECK(cudaDeviceEnablePeerAccess(id1, 0));
		cudaSetDevice(id1);
		CUDA_CHECK(cudaDeviceEnablePeerAccess(id0, 0));
	} else {
		std::cout << "can GPU" << id0 << "access from GPU" << id1 << ": No" << std::endl;
	}

	cudaSetDevice(id1);
	use_cuda_time = false;
	//use_cuda_time = true;
	test_2gpu(d_send_data, d_recv_data, size, id0, id1, use_cuda_time);

	cudaFreeHost(h_data);
	cudaFree(d_send_data);
	cudaFree(d_recv_data);

	return 0;
}
Beispiel #7
0
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int){
	lo = new Logic();
	gui = new GUI(lo);
	if (gui->hge->System_Initiate())
	{
		init_data();
		gui->hge->System_Start();
	}
	delete lo;
	delete gui;
    return 0;
}
Beispiel #8
0
DESIGN_mrf::DESIGN_mrf(datamatrix & dm,datamatrix & iv,
                       GENERAL_OPTIONS * o,DISTR * dp,FC_linear * fcl,
                       const MAP::map & m,vector<ST::string> & op,
                       vector<ST::string> & vn)
                      : DESIGN(o,dp,fcl)
  {

  if (errors==false)
    {

    read_options(op,vn);

    discrete = true;

    ma = m;
    type = Mrf;

    nrpar = ma.get_nrregions();
    consecutive=true;

    Zout = datamatrix(nrpar,1,1);
    index_Zout = statmatrix<int>(Zout.rows(),1);
    index_Zout.indexinit();
    }

  if (errors==false)
    init_data(dm,iv);

  if (errors==false)
    {
    compute_penalty();

    XWX = envmatdouble(0,nrpar);
    XWres = datamatrix(nrpar,1);
    Wsum = datamatrix(nrpar,1,1);

    compute_precision(1.0);

    compute_basisNull();

    identity=true;
    }

/*
  ofstream out("c:\\bayesx\\trunk\\testh\\results\\dm.raw");
  dm.prettyPrint(out);

  ofstream out2("c:\\bayesx\\trunk\\testh\\results\\iv.raw");
  iv.prettyPrint(out2);
*/

  }
Beispiel #9
0
static void do_read(int len)
{
	ssize_t sz;
	uint64_t old_w_cnt, new_w_cnt;
	uint64_t old_r_cnt, new_r_cnt;

#define READ_CTX 0x4e3dda1aULL
	init_data(source, len, 0);
	init_data(target, len, 0xad);

	old_w_cnt = fi_cntr_read(write_cntr);
	cr_assert(old_w_cnt >= 0);

	old_r_cnt = fi_cntr_read(read_cntr);
	cr_assert(old_r_cnt >= 0);

	sz = fi_read(ep[0], source, len,
			loc_mr, gni_addr[1], (uint64_t)target, mr_key,
			(void *)READ_CTX);
	cr_assert_eq(sz, 0);

	do {
		new_r_cnt = fi_cntr_read(read_cntr);
		cr_assert(new_r_cnt >= 0);
		if (new_r_cnt == (old_r_cnt + 1))
			break;
		pthread_yield();
	} while (1);

	cr_assert(check_data(source, target, len), "Data mismatch");

	new_w_cnt = fi_cntr_read(write_cntr);
	cr_assert(new_w_cnt >= 0);

	/*
	 * no fi_read called so old and new read cnts should be equal
	 */
	cr_assert(new_w_cnt == old_w_cnt);
}
Beispiel #10
0
int main (int agrc, char **argv)
{
	//close server and RedPitaya if CTRL+C
	signal(SIGINT, signal_callback_handler);

	double speed=MotorSpeed; //1 for dec8 3 for dec1
	double *point_sector;
	point_sector=&sector;

	//data data_RP;
	//float level0=0.3;
	//float levelf=1.0;
	init_data(&data_RP, 5, PORT, level0, levelf, full);  //full_16
	data_RP.angle=sector/((double)Nline-1.0);
	move(data_RP.stepper, &(data_RP.angle), &speed, sens2);
	move(data_RP.stepper, &(data_RP.angle), &speed, sens1);
	*point_sector=data_RP.angle*(Nline-1.0);
	printf("sector = %f\n",sector);
	printf("buffer length = %i\n", (int)data_RP.buffer_length);
	//enable_stepper(&(data_RP.stepper));

	int i=1;
	int t=00000;
	while(1)
	{
		for (i=0 ; i<Nline ; i++)
		{
			if (i!=0) {move(data_RP.stepper, &(data_RP.angle), &speed, sens1);}
			internal_trigger_acquisition_TCP(&data_RP, i+1);
			//usleep(t);
		}
		usleep(t);
		//usleep(10000);
		for (i=Nline ; i>0 ; i--)
		{
			if (i!=Nline) {move(data_RP.stepper, &(data_RP.angle), &speed, sens2);}
			internal_trigger_acquisition_TCP(&data_RP, i);
			//usleep(t);
		}
                usleep(t);
		//usleep(100000);
		/*if(i>Nline){i=1;}
		internal_trigger_acquisition_TCP(&data_RP, i);
		i++;*/
		//usleep(100000);
	}

	printf("close all\n");
	clear_data(&data_RP);
	return 0;
}
Beispiel #11
0
static void do_write_wait(int len)
{
	uint64_t old_w_cnt, new_w_cnt;
	uint64_t old_r_cnt, new_r_cnt;
	ssize_t sz;
	const int iters = 1;
	int i;

	init_data(source, len, 0xab);
	init_data(target, len, 0);

	old_w_cnt = fi_cntr_read(write_cntr);
	cr_assert(old_w_cnt >= 0);

	old_r_cnt = fi_cntr_read(read_cntr);
	cr_assert(old_r_cnt >= 0);

	for (i = 0; i < iters; i++) {
		sz = fi_write(ep[0], source, len,
			      loc_mr, gni_addr[1], (uint64_t)target, mr_key,
			      target);
		cr_assert_eq(sz, 0);
	}

	fi_cntr_wait(write_cntr, old_w_cnt+iters, -1);
	new_w_cnt = fi_cntr_read(write_cntr);
	cr_assert(old_w_cnt + iters == new_w_cnt);

	cr_assert(check_data(source, target, len), "Data mismatch");

	new_r_cnt = fi_cntr_read(read_cntr);
	cr_assert(new_r_cnt >= 0);

	/*
	 * no fi_read called so old and new read cnts should be equal
	 */
	cr_assert(new_r_cnt == old_r_cnt);
}
Beispiel #12
0
void do_read_error(int len)
{
	int ret;
	ssize_t sz;
	struct fi_cq_tagged_entry cqe;
	struct fi_cq_err_entry err_cqe;

	init_data(source, len, 0);
	init_data(target, len, 0xad);
	sz = fi_read(ep[0], source, len,
			loc_mr, gni_addr[1], (uint64_t)target, mr_key,
			(void *)READ_CTX);
	cr_assert_eq(sz, 0);

	while ((ret = fi_cq_read(send_cq, &cqe, 1)) == -FI_EAGAIN) {
		pthread_yield();
	}

	cr_assert_eq(ret, -FI_EAVAIL);

	ret = fi_cq_readerr(send_cq, &err_cqe, 0);
	cr_assert_eq(ret, 1);

	cr_assert((uint64_t)err_cqe.op_context == (uint64_t)READ_CTX,
		  "Bad error context");
	cr_assert(err_cqe.flags == (FI_RMA | FI_READ));
	cr_assert(err_cqe.len == 0, "Bad error len");
	cr_assert(err_cqe.buf == 0, "Bad error buf");
	cr_assert(err_cqe.data == 0, "Bad error data");
	cr_assert(err_cqe.tag == 0, "Bad error tag");
	cr_assert(err_cqe.olen == 0, "Bad error olen");
	cr_assert(err_cqe.err == FI_ECANCELED, "Bad error errno");
	cr_assert(err_cqe.prov_errno == GNI_RC_TRANSACTION_ERROR,
		  "Bad prov errno");
	cr_assert(err_cqe.err_data == NULL, "Bad error provider data");

	rdm_rma_check_cntrs(0, 0, 0, 1);
}
Beispiel #13
0
int main(int argc, char **argv){
	const char *ip = "127.0.0.1";
	int port = 8888;
	int requests = 10000;
	int clients = 50;

	welcome();
	usage(argc, argv);
	for(int i=1; i<argc; i++){
		if(strcmp("-v", argv[i]) == 0){
			exit(0);
		}
	}
	if(argc > 1){
		ip = argv[1];
	}
	if(argc > 2){
		port = atoi(argv[2]);
	}
	if(argc > 3){
		requests = atoi(argv[3]);
	}
	if(argc > 4){
		clients = atoi(argv[4]);
	}

	//printf("preparing data...\n");
	init_data(requests);
	//printf("preparing links...\n");
	init_links(clients, ip, port);

	bench("set");
	bench("get");
	bench("del");

	bench("hset");
	bench("hget");
	bench("hdel");

	bench("zset");
	bench("zget");
	bench("zdel");

	bench("qpush");
	bench("qpop");
	
	printf("\n");

	return 0;
}
Beispiel #14
0
int main() {
    bool f**k = false;
    while (scanf("%d%d", &n, &m)) {
        if (n == 0 && m == 0) break;
        if (f**k) printf("\n");
        f**k = true;
        init_data();
        init_weight();
        find_all_posible_circumstances();
        count_ratio_for_all_circumstances();
        find_min_ratio_and_output();
    }
    return 0;
}
Beispiel #15
0
int main_reheader(int argc, char *argv[])
{
    int c;
    args_t *args  = (args_t*) calloc(1,sizeof(args_t));
    args->argc    = argc; args->argv = argv;

    static struct option loptions[] =
    {
        {"header",1,0,'h'},
        {"samples",1,0,'s'},
        {0,0,0,0}
    };
    while ((c = getopt_long(argc, argv, "s:h:c",loptions,NULL)) >= 0)
    {
        switch (c)
        {
            case 's': args->samples_fname = optarg; break;
            case 'h': args->header_fname = optarg; break;
            case '?': usage(args);
            default: error("Unknown argument: %s\n", optarg);
        }
    }

    if ( optind>=argc )
    {
        if ( !isatty(fileno((FILE *)stdin)) ) args->fname = "-";  // reading from stdin
        else usage(args);
    }
    else args->fname = argv[optind];

    if ( !args->samples_fname && !args->header_fname ) usage(args);
    if ( !args->fname ) usage(args);

    init_data(args);

    if ( args->file_type & FT_VCF )
    {
        if ( args->file_type & FT_GZ )
            reheader_vcf_gz(args);
        else
            reheader_vcf(args);
    }
    else
        reheader_bcf(args, args->file_type & FT_GZ);

    destroy_data(args);
    free(args);
    return 0;
}
Beispiel #16
0
/****************************************************************************
 * Public function implementations
 ****************************************************************************/
int
arrow_cbst_solve(arrow_problem *problem, arrow_problem_info *info,
                 double max_length, arrow_bound_result *result)
{
    int ret = ARROW_SUCCESS;
    int *tree, *cur_tree, *in_heap, *d;
    int max_cost;
    double length;
    arrow_heap heap;
    
    double start_time, end_time;
    start_time = arrow_util_zeit();
    
    /* Allocate data */
    if(!arrow_util_create_int_array(problem->size, &tree))
    {
        arrow_print_error("Could not initialize tree array.");
        ret = ARROW_FAILURE;
        goto CLEANUP;
    }
    if(!init_data(problem->size, &heap, &cur_tree, &in_heap, &d))
    {
        arrow_print_error("Could not initialize MST data structures.");
        ret = ARROW_FAILURE;
        goto CLEANUP;
    }
    
    /* Initial MST call to determine feasibility and bottleneck value */
    min_span_tree(problem, info->max_cost, INT_MIN, cur_tree, tree,
                  &max_cost, &length, &heap, in_heap, d);
    /* See if given max_length is feasible */
    if(length > max_length)
    {
        arrow_print_error("max_length infeasible; must be >= %.0f", length);
        ret = ARROW_FAILURE;
        goto CLEANUP;
    }

    arrow_debug("\nSpanning tree length: %.0f\n", length);

    end_time = arrow_util_zeit();
    
    result->obj_value = max_cost;
    result->total_time = end_time - start_time;    
    
CLEANUP:
    if(tree != NULL) free(tree);
    return ret;
}
Beispiel #17
0
void init(void) {

    init_data();
	
	// Register AppMessage handlers
	app_message_register_inbox_received(in_received_handler); 
	app_message_register_inbox_dropped(in_dropped_handler); 
	app_message_register_outbox_failed(out_failed_handler);
		
	app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
	
    create_window();
    window_set_click_config_provider(window, click_config_provider);
    send_message();
}
Beispiel #18
0
static void do_read_wait(int len)
{
	int i, iters = 10;
	ssize_t sz;
	uint64_t old_w_cnt, new_w_cnt;
	uint64_t old_r_cnt;

#define READ_CTX 0x4e3dda1aULL
	init_data(source, len, 0);
	init_data(target, len, 0xad);

	old_w_cnt = fi_cntr_read(write_cntr);
	cr_assert(old_w_cnt >= 0);

	old_r_cnt = fi_cntr_read(read_cntr);
	cr_assert(old_r_cnt >= 0);

	for (i = 0; i < iters; i++) {
		sz = fi_read(ep[0], source, len,
				loc_mr, gni_addr[1], (uint64_t)target,
				mr_key, (void *)READ_CTX);
		cr_assert_eq(sz, 0);
	}

	fi_cntr_wait(read_cntr, old_r_cnt + iters, -1);

	cr_assert(check_data(source, target, len), "Data mismatch");

	new_w_cnt = fi_cntr_read(write_cntr);
	cr_assert(new_w_cnt >= 0);

	/*
	 * no fi_read called so old and new read cnts should be equal
	 */
	cr_assert(new_w_cnt == old_w_cnt);
}
Beispiel #19
0
void do_inject_write(int len)
{
	ssize_t sz;
	int ret, i, loops = 0;
	struct fi_cq_tagged_entry cqe;

	init_data(source, len, 0x23);
	init_data(target, len, 0);
	sz = fi_inject_write(ep[0], source, len,
			     gni_addr[1], (uint64_t)target, mr_key);
	cr_assert_eq(sz, 0);

	for (i = 0; i < len; i++) {
		loops = 0;
		while (source[i] != target[i]) {
			ret = fi_cq_read(send_cq, &cqe, 1); /* for progress */
			cr_assert(ret == -EAGAIN,
				  "Received unexpected event\n");

			pthread_yield();
			cr_assert(++loops < 10000, "Data mismatch");
		}
	}
}
Beispiel #20
0
t_datalist *creat_datalist(char *login)
{
	t_datalist *data;
	
	data = (t_datalist *)malloc(sizeof(t_datalist));
	data->data = (char **)malloc(100 * sizeof(char *));
	data->login = login;
	data->data[0] = NULL;
	data->cpt_read = 0;
	data->cpt_max = 0;
	add_chain(data);
	recup_datalist(data);
	init_data(-1);
	return (data);
}
Beispiel #21
0
void* power_measurement(void* arg) {
    struct mstimer timer;
    // according to the Intel docs, the counter wraps a most once per second
    // 100 ms should be short enough to always get good information
    init_msTimer(&timer, 100);
    init_data();
    read_rapl_init();
    start = now_ms();

    timer_sleep(&timer);
    while(running) {
        take_measurement();
        timer_sleep(&timer);
    }
}
Beispiel #22
0
void do_write_buf(void *s, void *t, int len)
{
	int ret;
	ssize_t sz;
	struct fi_cq_tagged_entry cqe;

	init_data(s, len, 0xab);
	init_data(t, len, 0);
	sz = fi_write(ep[0], s, len, NULL, gni_addr[1], (uint64_t)t, mr_key,
			 t);
	cr_assert_eq(sz, 0);

	while ((ret = fi_cq_read(send_cq, &cqe, 1)) == -FI_EAGAIN) {
		pthread_yield();
	}

	cr_assert_eq(ret, 1);
	rdm_rma_check_tcqe(&cqe, t, FI_RMA | FI_WRITE, 0);
	rdm_rma_check_cntrs(1, 0, 0, 0);

	dbg_printf("got write context event!\n");

	cr_assert(check_data(s, t, len), "Data mismatch");
}
Beispiel #23
0
struct data *user_input() {
    long long phone_num;
    char name[NAME_MAXLEN];
    char address[ADDRESS_MAXLEN];
    printf("Please input phone number, input 0 for break boring loop:");
    scanf("%lld", &phone_num);
    if (phone_num == 0) {
        return NULL;
    }
    printf("Please input name:");
    scanf("%s", name);
    printf("Please input address:");
    scanf("%s", address);
    return init_data(phone_num, name, address);
}
Beispiel #24
0
void perft(char dep) {
	int start_time, end_time;
	char num[65];
	float time;
	/*char p0[]="r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1";
	char p0[]="8/PPP4k/8/8/8/8/4Kppp/8 w - - ";*/
	/*8/2p5/3p4/KP5r/1R3p1k/6P1/4P3/8 b - - 0 1*/
	/*char p0[]="8/2p5/3p4/KP5r/1R3p1k/6P1/4P3/8 b - - 0 1";*/
	/*8/5kpp/2K5/p5q1/6P1/5P2/8/2q5 w - - 0 53*/
	/*char p0[]="8/5kpp/2K5/p5q1/6P1/5P2/8/2q5 w - - 0 53";

	char p0[]="8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - -";
	

		
	char p0[]="8/2p5/K2p4/1P5r/1R3p1k/8/4P1P1/8 b - - 0 1";//15
	char p0[]="8/2p5/3p4/1P5r/KR3p1k/8/4P1P1/8 b - - 0 1";//15----30


	char p0[]="8/2p5/3p4/KP5r/R4p1k/8/4P1P1/8 b - - 0 1";//15
	char p0[]="8/2p5/3p4/KP5r/5p1k/1R6/4P1P1/8 b - - 0 1";//15
	char p0[]="8/2p5/3p4/KP5r/5p1k/8/1R2P1P1/8 b - - 0 1";//16
	char p0[]="8/2p5/3p4/KP5r/5p1k/8/4P1P1/1R6 b - - 0 1";//16
	char p0[]="8/2p5/3p4/KP5r/2R2p1k/8/4P1P1/8 b - - 0 1";//15
	char p0[]="8/2p5/3p4/KP5r/3R1p1k/8/4P1P1/8 b - - 0 1";//15
	char p0[]="8/2p5/3p4/KP5r/4Rp1k/8/4P1P1/8 b - - 0 1";//15
	char p0[]="8/2p5/3p4/KP5r/5R1k/8/4P1P1/8 b - - 0 1";//2-----109

	char p0[]="8/2p5/3p4/KP5r/1R3p1k/4P3/6P1/8 b - - 0 1";//15 
	char p0[]="8/2p5/3p4/KP5r/1R2Pp1k/8/6P1/8 b - e3 0 1";//17----32 ERROR???

	char p0[]="8/2p5/3p4/KP5r/1R3p1k/6P1/4P3/8 b - - 0 1";//4
	char p0[]="8/2p5/3p4/KP5r/1R3pPk/8/4P3/8 b - g3 0 1";//18-----22
	*/
	init_board();
	/*set_position(p0);*/

	init_data();
	print_board();

	print_bitboard();
	start_time = time_elapsed();
	perf_t(dep);
	end_time = time_elapsed();
	_ui64toa(Nodes,num,10);
	time = ((end_time - start_time) / (float)1000);
	printf("\nmoves %s in %.3f sec.\n", num, time);
	}
Beispiel #25
0
/***********************************************************************//**
 * @brief Load table column from FITS file
 *
 * @exception GException::fits_hdu_not_found
 *            Specified HDU not found in FITS file.
 * @exception GException::fits_error
 *            An error occured while loading column data from FITS file.
 *
 * Load Bit (vector) column into memory by reading 8 Bits at once.
 ***************************************************************************/
void GFitsTableBitCol::load_column(void)
{
    // Compute total number of Bits in column
    m_bits = m_number * m_length;

    // Compute number of Bytes and Bits per row
    m_bytes_per_row = (m_number > 0) ? ((m_number-1) / 8) + 1 : 0;
    m_bits_per_row  = m_bytes_per_row * 8;

    // Compute length of memory array
    m_size = m_bytes_per_row * m_length;

    // Load only if the column has a positive size
    if (m_size > 0) {

        // Allocate and initialise fresh memory
        alloc_data();
        init_data();

        // If a FITS file is attached then load column data from the FITS
        // file
        if (FPTR(m_fitsfile)->Fptr != NULL) {

            // Move to the HDU
            int status = 0;
            status     = __ffmahd(FPTR(m_fitsfile),
                                  (FPTR(m_fitsfile)->HDUposition)+1,
                                  NULL, &status);
            if (status != 0) {
                throw GException::fits_hdu_not_found(G_LOAD_COLUMN,
                                  (FPTR(m_fitsfile)->HDUposition)+1,
                                  status);
            }

            // Load data 8 Bits at once
            status = __ffgcv(FPTR(m_fitsfile), __TBYTE, m_colnum, 1, 1, m_size,
                             m_nulval, m_data, &m_anynul, &status);
            if (status != 0) {
                throw GException::fits_error(G_LOAD_COLUMN, status,
                                  "for column \""+m_name+"\".");
            }
        }

    } // endif: column has a positive size

    // Return
    return;
}
Beispiel #26
0
Datei: main.c Projekt: kelu27/42
int		main (void)
{
	t_env		e;
	t_shared	shared;

	if ((e.mlx = mlx_init()) == NULL)
		return (error("mlx init error\n"));
	e.win = mlx_new_window(e.mlx, 420, 420, "Philosophe");
	mlx_key_hook(e.win, key_hook, &e);
	mlx_expose_hook(e.win, expose_hook, &e);
	shared.mlx = e.mlx;
	shared.win = e.win;
	init_chopstick(&shared);
	init_data(shared);
	return (0);
}
Beispiel #27
0
int main(void)
{
	int	size;	/* Working set size (in bytes) */
	int	stride;	/* Stride (in array elements) */
	double	Mhz;	/* Clock frequence */

	init_data(data,MAXELEMS);
	Mhz = mhz(0);	/* Estimate the clock frequency */
	for (size = MAXBYTES;size >= MINBYTES;size >> 1){
		for (stride = 1;stride <= MAXSTRIDE;stride ++){
			printf("%.1f\t",run(size,stride,Mhz));
		}
		printf("\n");
	}
	exit(EXIT_SUCCESS);
}
Beispiel #28
0
int main_consensus(int argc, char *argv[])
{
    args_t *args = (args_t*) calloc(1,sizeof(args_t));
    args->argc   = argc; args->argv = argv;

    static struct option loptions[] = 
    {
        {"sample",1,0,'s'},
        {"iupac-codes",0,0,'i'},
        {"haplotype",1,0,'H'},
        {"output",1,0,'o'},
        {"fasta-ref",1,0,'f'},
        {"mask",1,0,'m'},
        {"chain",1,0,'c'},
        {0,0,0,0}
    };
    char c;
    while ((c = getopt_long(argc, argv, "h?s:1iH:f:o:m:c:",loptions,NULL)) >= 0) 
    {
        switch (c) 
        {
            case 's': args->sample = optarg; break;
            case 'o': args->output_fname = optarg; break;
            case 'i': args->output_iupac = 1; break;
            case 'f': args->ref_fname = optarg; break;
            case 'm': args->mask_fname = optarg; break;
            case 'c': args->chain_fname = optarg; break;
            case 'H': 
                args->haplotype = optarg[0] - '0'; 
                if ( args->haplotype <=0 ) error("Expected positive integer with --haplotype\n");
                break;
            default: usage(args); break;
        }
    }
    if ( optind>=argc ) usage(args);
    args->fname = argv[optind];

    if ( !args->ref_fname && !isatty(fileno((FILE *)stdin)) ) args->ref_fname = "-";
    if ( !args->ref_fname ) usage(args);

    init_data(args);
    consensus(args);
    destroy_data(args);
    free(args);

    return 0;
}
Beispiel #29
0
int
main( int argc, char *argv[] )
{
	int		fd;
	int		i;
	int		count;

	if( argc != 2 ) {
		fprintf( stderr, "Usage %s [seconds willing to wait for ckpt signal]\n",
			argv[0] );
		exit( 1 );
	}

	count = atoi( argv[1] );
	if( count <= 0 ) {
		fprintf( stderr, "Seconds must be positive\n" );
		exit( 1 );
	}

	const char* tmp_dir = create_unique_name("tmp");
	if( (fd=open(tmp_dir,O_CREAT|O_TRUNC|O_RDWR,0664)) < 0 ) {
		perror( "tmp directory creation failed" );
		exit( 1 );
	}

	init_data( Data, sizeof(Data) );

	/* ok, running for X seconds is a bit disingenuous because the program
		could run for 5 seconds, checkpoint and be idle for > count seconds,
		and when it restarts, immediately terminate. Since this test really
		needs us to wait around for a checkpoint signal, the seconds count
		is really the time we're willing to wait for a checkpoint signal
		before stopping the io loop and exiting.
	*/

	{
	time_t b4 = time(0);
	i = 0;
	while ((time(0) - b4) < count) {
		do_it( Data, fd, sizeof(Data) );
		printf( "%d ", i++ );
		fflush( stdout );
	}
	}
	printf( "\nNormal End Of Job\n" );
	exit( 0 );
}
Beispiel #30
0
/*
 * Create a newface on the given address and port, bind the prefix to the face
 */
int add_new_face(struct ccn *h, struct ccn_charbuf *prefix, const char *address, const char *port)
{
    struct ccn_charbuf *local_scope_template = ccn_charbuf_create();
    struct ccn_charbuf *no_name = ccn_charbuf_create();
    unsigned char ccndid_storage[32] = {0};
    const unsigned char *ccndid = ccndid_storage;
    size_t ccndid_size = 0;
    struct ccn_face_instance *fi;
    struct ccn_face_instance *nfi;
    int res;

    init_data(local_scope_template, no_name);

    ccndid_size = get_ccndid(h, local_scope_template, ccndid);
    if (ccndid_size != sizeof(ccndid_storage))
    {
        fprintf(stderr, "Incorrect size for ccnd id in response\n");
        ON_ERROR_CLEANUP(-1);
    }

    /* construct a face instance for new face request */
    fi = construct_face(ccndid, ccndid_size, address, port);
    ON_NULL_CLEANUP(fi);

    /* send new face request to actually create a new face */
    nfi = create_face(h, local_scope_template, no_name, fi);
    ON_NULL_CLEANUP(nfi);

    /* bind prefix to the new face */
    res = register_prefix(h, local_scope_template, no_name, prefix, nfi);
    ON_ERROR_CLEANUP(res);

    ccn_charbuf_destroy(&local_scope_template);
    ccn_charbuf_destroy(&no_name);
    ccn_face_instance_destroy(&fi);
    ccn_face_instance_destroy(&nfi);

    return 0;

cleanup:
    ccn_charbuf_destroy(&local_scope_template);
    ccn_charbuf_destroy(&no_name);
    ccn_face_instance_destroy(&fi);
    ccn_face_instance_destroy(&nfi);

    return -1;
}