void
display_test_info()
{
  printfQuda("running the following test:\n");
    
  printfQuda("prec    sloppy_prec    link_recon  sloppy_link_recon test_type  S_dimension T_dimension\n");
  printfQuda("%s   %s             %s            %s            %s         %d          %d \n",
	 get_prec_str(prec),get_prec_str(prec_sloppy),
	 get_recon_str(link_recon), 
	 get_recon_str(link_recon_sloppy), get_test_type(testtype), sdim, tdim);     
  return ;
  
}
  void
display_test_info()
{
  printfQuda("running the following test:\n");

  printfQuda("prec    sloppy_prec    link_recon  sloppy_link_recon test_type  S_dimension T_dimension\n");
  printfQuda("%s   %s             %s            %s            %s         %d/%d/%d          %d \n",
      get_prec_str(prec),get_prec_str(prec_sloppy),
      get_recon_str(link_recon), 
      get_recon_str(link_recon_sloppy), get_test_type(test_type), xdim, ydim, zdim, tdim);     

  printfQuda("Grid partition info:     X  Y  Z  T\n"); 
  printfQuda("                         %d  %d  %d  %d\n", 
      dimPartitioned(0),
      dimPartitioned(1),
      dimPartitioned(2),
      dimPartitioned(3)); 

  return ;

}
int main(int argc, char** argv)
{
   struct network_test_parameters_struct test_parameters;
   
    if (argc < 3)
    {
        printf("Use: convert_to_netcdf <inputfile_path> <outputfile_path>");
    }

    Network_speed test_data;

    char* file_name = argv[1];
    int netcdf_file;
    int netcdf_var;

    
    test_data.fread(file_name);

    if ( test_data.is_no_file( ) || test_data.is_processor_info( ) )
    {
        printf( "Bad file. No test parameters info.\n" );
	    return 1;
    }


    if (! test_data.is_test_info( ) )
    {
        printf("Sorry, information on test parameters is epsent in file '%s'",argv[1]);
        return 1;
    }
        /*
         * Building test parameters
         */
        test_parameters.num_procs = test_data.get_num_processors( );
        test_parameters.begin_message_length = test_data.get_message_begin_length( );
        test_parameters.end_message_length = test_data.get_message_end_length( );
        test_parameters.step_length = test_data.get_step_length( );
#ifndef MODULES_SUPPORT
        test_parameters.noise_message_length = test_data.get_noise_message_length( );
        test_parameters.num_noise_messages = test_data.get_noise_message_num( );
        test_parameters.num_noise_procs = test_data.get_number_of_noise_processors( );
#endif
        test_parameters.num_repeats = test_data.get_number_of_repeates( );
        test_parameters.file_name_prefix=argv[2];

        char str[BUFFSIZE];
        test_data.get_test_type( str );
        int test_type = get_test_type(str);
        int data_type = 0;

        if(create_netcdf_header(test_type,&test_parameters,&netcdf_file,&netcdf_var))
        {
            printf("Can not to create NetCDF file with prefix \"%s\"\n",test_parameters.file_name_prefix);
            return 1;
        }

        if(create_test_hosts_file(&test_parameters,test_data.get_host_names()))
        {
             printf("Can not to create file with name \"%s_hosts.txt\"\n",test_parameters.file_name_prefix);                
             return 1;
        }

        for(int i=0;i<test_data.get_num_messages();i++)
        {
             if(netcdf_write_matrix(
                                        netcdf_file,
                                        netcdf_var,
                                        i,
                                        test_parameters.num_procs,
                                        test_parameters.num_procs,
                                        test_data.get_certain_matix(i).get_body()
                                    )
                ) /* End condition */
             {
                printf("Sorry. write matrix to netCDF filed\n");
                return 1;
             }             
        }
    
        netcdf_close_file(netcdf_file);
        printf("Done\n");

        return 0;
}
int parse_network_test_arguments(int argc,char **argv,struct network_test_parameters_struct *parameters)
{
	int arg_val;

#ifdef MODULES_SUPPORT
	parameters->num_procs            =  0; /* Special for program break on any error */
	parameters->test_type            =  ONE_TO_ONE_TEST_TYPE;
    parameters->begin_message_length =  MESSAGE_BEGIN_LENGTH;
    parameters->end_message_length   =  MESSAGE_END_LENGTH;
    parameters->step_length          =  MESSAGE_STEP;
    parameters->num_repeats          =  NUM_REPEATS;
    parameters->file_name_prefix     =  default_file_name_prefix;
    strcpy(parameters->module_name, "one_to_one2");

#ifdef _GNU_SOURCE
    struct option options[14]=
    {
        {"type",required_argument,NULL,'t'},
        {"file",required_argument,NULL,'f'},
        {"num_iterations",required_argument,NULL,'n'},
        {"begin",required_argument,NULL,'b'},
        {"end",required_argument,NULL,'e'},
        {"step",required_argument,NULL,'s'},
        {"version",no_argument,NULL,'v'},
        {"help",no_argument,NULL,'h'},
        {"resume",no_argument,NULL,'r'},
        {"ignore",no_argument,NULL,'i'},
        {0,0,0,0}
    };
#endif /* _GNU_SOURCE */

    for ( ; ; )
    {
#ifdef _GNU_SOURCE
        arg_val = getopt_long(argc,argv,"t:f:n:b:e:shv:r:i",options,NULL);
#else /* _GNU_SOURCE */
        arg_val = getopt(argc,argv,"t:f:n:b:e:shv:r:i");
#endif /* _GNU_SOURCE */

        if ( arg_val== -1 )
            break;

        switch ( arg_val )
        {
        case 'b':
            parameters->begin_message_length = atoi(optarg);
            break;
        case 'e':
            parameters->end_message_length = atoi(optarg);
            break;
        case 's':
            parameters->step_length = atoi(optarg);
            break;
        case 'n':
            parameters->num_repeats = atoi(optarg);
            break;
        case 'f':
            parameters->file_name_prefix = optarg;
            break;
        case 't':
            strncpy(parameters->module_name, optarg, MAX_MODULE_NAME);
            if ( ( parameters->test_type = get_test_type(optarg) ) == UNKNOWN_TEST_TYPE )
                parameters->test_type = ONE_TO_ONE_TEST_TYPE;
			break;
        case 'v':
			printf("Version: %s\n",PARUS_VERSION);
            return  VERSION_FLAG;
            break;
        case 'h':
            print_network_test_help_message();
            return  HELP_FLAG;
            break;
        case '?':
            print_network_test_help_message();
            return ERROR_FLAG;
           break;
        }
    }
#else /* MODULES_SUPPORT */
	parameters->num_procs            =  0; /* Special for program break on any error */
	parameters->test_type            =  ONE_TO_ONE_TEST_TYPE;
    parameters->begin_message_length =  MESSAGE_BEGIN_LENGTH;
    parameters->end_message_length   =  MESSAGE_END_LENGTH;
    parameters->step_length          =  MESSAGE_STEP;
    parameters->num_repeats          =  NUM_REPEATS;
    parameters->noise_message_length  =  NOISE_MESSAGE_LENGTH;
    parameters->num_noise_messages   =  NOISE_MESSAGE_NUM;
    parameters->num_noise_procs      =  NUM_NOISE_PROCS;
    parameters->file_name_prefix     =  default_file_name_prefix;

#ifdef _GNU_SOURCE
    struct option options[14]=
    {
        {"type",required_argument,NULL,'t'},
        {"file",required_argument,NULL,'f'},
        {"num_iterations",required_argument,NULL,'n'},
        {"begin",required_argument,NULL,'b'},
        {"end",required_argument,NULL,'e'},
        {"step",required_argument,NULL,'s'},
        {"length_noise_message",required_argument,NULL,'l'},
        {"num_noise_message",required_argument,NULL,'m'},
        {"procs_noise",required_argument,NULL,'p'},
        {"version",no_argument,NULL,'v'},
        {"help",no_argument,NULL,'h'},
        {"resume",no_argument,NULL,'r'},
        {"ignore",no_argument,NULL,'i'},
        {0,0,0,0}
    };
#endif /* _GNU_SOURCE */

    for ( ; ; )
    {
#ifdef _GNU_SOURCE
        arg_val = getopt_long(argc,argv,"t:f:n:b:e:s:l:m:phv:r:i",options,NULL);
#else /* _GNU_SOURCE */
        arg_val = getopt(argc,argv,"t:f:n:b:e:s:l:m:phv:r:i");
#endif /* _GNU_SOURCE */

        if ( arg_val== -1 )
            break;

        switch ( arg_val )
        {
        case 'b':
            parameters->begin_message_length = atoi(optarg);
            break;
        case 'e':
            parameters->end_message_length = atoi(optarg);
            break;
        case 's':
            parameters->step_length = atoi(optarg);
            break;
        case 'l':
            parameters->noise_message_length = atoi(optarg);
            break;
        case 'm':
            parameters->num_noise_messages = atoi(optarg);
            break;
        case 'p':
            parameters->num_noise_procs = atoi(optarg);
            break;
        case 'n':
            parameters->num_repeats = atoi(optarg);
            break;
        case 'f':
            parameters->file_name_prefix = optarg;
            break;
        case 't':
            if ( ( parameters->test_type = get_test_type(optarg) ) == UNKNOWN_TEST_TYPE )
                parameters->test_type = ONE_TO_ONE_TEST_TYPE;
			break;
        case 'v':
			printf("Version: %s\n",PARUS_VERSION);
            return  VERSION_FLAG;
            break;
        case 'h':
            print_network_test_help_message();
            return  HELP_FLAG;
            break;
        case '?':
            print_network_test_help_message();
            return ERROR_FLAG;
           break;
        }

    }
#endif /* MODULES_SUPPORT */

    return 0;
}
Exemple #5
0
int
main (int argc, char **argv) {
  
    XEvent event;
    XSizeHints xsh;
    XSetWindowAttributes xswa;
    XVisualInfo *vinfo;

    glitz_drawable_format_t templ;
    glitz_drawable_format_t *dformat;
    unsigned long mask = 0;
    
    unsigned int width, height, window_width, window_height;
    int i;

    program_name = argv[0];
    
    for (i = 1; i < argc; i++) {
	if (!strcasecmp ("-image", argv[i]))
	    output_type = IMAGE_TYPE;

#ifdef CAIRO_HAS_XLIB_SURFACE
	else if (!strcasecmp ("-xrender", argv[i])) {
	    output_type = XRENDER_TYPE;
	} 
#endif

	else if (!strcasecmp ("-glx", argv[i])) {
	    output_type = GLX_TYPE;
	} else if (!strcasecmp ("-noaa", argv[i])) {
	    aa = 0;
	} else if (!strcasecmp ("-swaa", argv[i])) {
	    aa = 1;
	} else if (!strcasecmp ("-hwaa", argv[i])) {
	    aa = 3;
        } else {
            test_type = get_test_type (argv[i]);
        }
    }
  
    if (!test_type) {
	usage();
	exit(1);
    }

    if (output_type != GLX_TYPE && test_type >= OPENGL_TYPE) {
	printf ("Sorry, this test only works with OpenGL!\n");
	usage();
	exit(1);
    }

    window_width = width = WINDOW_WIDTH;
    window_height = height = WINDOW_HEIGHT;
    
    if (aa == 3)
	templ.samples = 4;
    else
	templ.samples = 1;
    
    templ.depth_size = 16;
    if (test_type == CUBE_TYPE)
	mask |= GLITZ_FORMAT_DEPTH_SIZE_MASK;

    mask |= GLITZ_FORMAT_SAMPLES_MASK;
    
    if ((dpy = XOpenDisplay (NULL)) == NULL) {
	fprintf(stderr, "%s: can't open display: %s\n", argv[0],
		XDisplayName (NULL));
	exit(1);
    }

    if (output_type != GLX_TYPE) {
	xsh.flags = PSize;
	xsh.width = width;
	xsh.height = height;
	xsh.x = 0;
	xsh.y = 0;
	
	win = XCreateWindow (dpy, RootWindow (dpy, DefaultScreen (dpy)), 
			     xsh.x, xsh.y, xsh.width, xsh.height,
			     0, CopyFromParent, CopyFromParent,
			     CopyFromParent, 0, &xswa);
  
	XSetStandardProperties (dpy, win, PACKAGE, PACKAGE, None,
				argv, argc, &xsh);
	XSetWMHints (dpy, win, &xwmh);

	XSelectInput (dpy, win, StructureNotifyMask);
	
    } else {

	xsh.flags = PSize;
	xsh.width = width;
	xsh.height = height;
	xsh.x = 0;
	xsh.y = 0;

	mask = 0;
	
	templ.doublebuffer = 1;
	mask |= GLITZ_FORMAT_DOUBLEBUFFER_MASK;
	
	dformat = glitz_glx_find_window_format (dpy, DefaultScreen (dpy),
						mask, &templ, 0);
	
	vinfo = glitz_glx_get_visual_info_from_format (dpy,
						       DefaultScreen (dpy),
						       dformat);
	xswa.colormap =
	    XCreateColormap (dpy,
			     RootWindow (dpy, DefaultScreen (dpy)), 
			     vinfo->visual, AllocNone);
	win = XCreateWindow (dpy, RootWindow (dpy, DefaultScreen (dpy)), 
			     xsh.x, xsh.y, xsh.width, xsh.height,
			     0, vinfo->depth, CopyFromParent,
			     vinfo->visual, CWColormap, &xswa);
  
	XSetStandardProperties (dpy, win, PACKAGE, PACKAGE, None,
				argv, argc, &xsh);
	XSetWMHints (dpy, win, &xwmh);

	XSelectInput (dpy, win, StructureNotifyMask);
    }
	
    switch (output_type) {
      
    case XRENDER_TYPE:
	resize_pixmap (width, height);
	break;
      
    case IMAGE_TYPE:
	resize_image (width, height);
	break;
    case GLX_TYPE:
	drawable =
	    glitz_glx_create_drawable_for_window (dpy, 0, dformat, win,
						  width, height);
	if (!drawable) {
	    printf ("failed to create glitz drawable\n");
	    exit (1);
	}
	break;
    }
  
    if (aa == 3 && dformat->samples < 2) {
	fprintf (stderr, "hardware multi-sampling not available\n");
	exit (1);
    }

    if (drawable) {
	surface = resize_glitz_drawable (drawable, dformat, width, height);
    }

    cr = cairo_create (surface);
    cairo_set_tolerance (cr, 0.5);

    setup (test_type);

    XMapWindow (dpy, win);

    for (;;) {
	if (XPending (dpy)) {
	    XNextEvent (dpy, &event);
	    if (event.type == ConfigureNotify) {
		width = event.xconfigure.width;
		height = event.xconfigure.height;
                
		switch (output_type) {
		    
#ifdef CAIRO_HAS_XLIB_SURFACE
		case XRENDER_TYPE:
		    resize_pixmap (width, height);
		    cairo_destroy (cr);
		    cr = cairo_create (surface);
		    cairo_set_tolerance (cr, 0.5);
		    break;
#endif
		    
		case IMAGE_TYPE:
		    resize_image (width, height);
		    cairo_destroy (cr);
		    cr = cairo_create (surface);
		    cairo_set_tolerance (cr, 0.5);
		    break;
		case GLX_TYPE:
		    cairo_surface_destroy (surface);
		    surface = resize_glitz_drawable (drawable, dformat, 
						     width, height);
		    cairo_destroy (cr);
		    cr = cairo_create (surface);
		    cairo_set_tolerance (cr, 0.5);
		    break;
		}
	    }
	} else {
	    render (test_type, output_type == GLX_TYPE);
       	    switch (output_type) {
		
#ifdef CAIRO_HAS_XLIB_SURFACE
	    case XRENDER_TYPE:
		XSetWindowBackgroundPixmap (dpy, win, pixmap);
		XClearWindow (dpy, win);
		break;
#endif
		
	    case IMAGE_TYPE: {
		GC gc;
		XImage *xim;

		pixmap = XCreatePixmap (dpy, DefaultRootWindow (dpy),
					width, height,
					DefaultDepth (dpy,
						      DefaultScreen (dpy)));
		xim = XCreateImage(dpy, DefaultVisual (dpy,
						       DefaultScreen (dpy)),
				   DefaultDepth(dpy, DefaultScreen (dpy)),
				   ZPixmap, 0, (char *) image,
				   width, height, 32, 0);
		gc = XCreateGC (dpy, pixmap, 0, NULL);
		XPutImage (dpy, pixmap, gc, xim, 0, 0, 0, 0, width, height);
                    
		XFreeGC (dpy, gc);
		xim->data = NULL;
		XDestroyImage (xim);

		XSetWindowBackgroundPixmap (dpy, win, pixmap);
		XClearWindow (dpy, win);
		XFreePixmap (dpy, pixmap);
	    } break;
	    }

	    XSync (dpy, 0);
	}
    }

    exit (1);
}