A followup to yesterday's question about improving graphics performance
on DEC Personal Workstations, especially as compared to Sun Ultras.
Workstation details:
EV56 433MHz DEC Personal Workstation
2MB L3 cache
128MB RAM, 300MB swap
4D20 24-plane graphics card
The application:
Attached is the benchmark (C source code) with instructions in the comments.
The goal:
I am interested in finding ways of increasing the "frames/second" rate
of this benchmark, or in why this runs so much faster on Sun Ultras.
The benchmark should complete in only a few seconds.
Any information in this area would be greatly appreciated.
I'll summarize the runs (non-DEC gladly accepted).
-Allen Winter, winter_at_clark.net
#define CODE_VERSION "FRAME RATE TEST v1.O"
#define CODE_DATE "12 January 1998"
/***************************************************
The experiment:
Please time (/usr/bin/time will do) two different experiments
for each platform, namely
frame-rate-test 176 144 1000 #height=176, width=144, frames=1000
frame-rate-test 352 288 1000 #height=352, width=288, frames=1000
If you have a library that would improve the performance of this function,
please run it with and without this library, reporting the results in
each case.
Send your times to Allen Winter, winterz_at_clark.net
*/
/***************************************************
A Simple X-Windows based frame rate tester.
Essentially a 24 bit Window is created along with a 24bit ZPixmap
XImage. Then the image is sent, via XPutImage to the screen a
specified number of times. The intent of this is to calculate a frame
rate given the number of frames and wall clock time.
FPS = (#Frames)/(WallClock);
Assumptions are made in this code (ie 24bit) which was intended to
eliminate the entire dither process. In addition, there is some
1-time overhead at the beginning to create the image buffer, but this
shouldn't detract from the test.
BUILD: (with whatever flavor of cc, and the desired Xlib):
cc frame-rate-test.c -o frame-rate-test -lXll
USAGE:
frame-rate-test <height> <width> <nframes>
****************************************************************************/
/* standard include */
#include <stdio.h>
#include <stdlib.h>
/* XWindows Headers */
#include <X11/Xlib.h>
#include <X11/Xutil.h>
void print_version(char *execname)
{
fprintf(stderr,"exec : %s\nver : %s\ndate : %s\n",
execname,CODE_VERSION,CODE_DATE);
}
Display *display; /* X Display */
Window win; /* X Window */
GC gc; /* Graphics Context for the Image */
XVisualInfo vinfo; /* Visual Information */
XEvent event; /* Xevent */
int screen; /* Screen number */
/* prototype */
#ifdef __STDC__
int initialize_Xll(int image_width,int image_height);
#else
int initialize_Xll();
#endif
/*******************************************************************
Main
*******************************************************/
int main (int argc, char *argv[])
{
XImage *ximage; /* Pointer to the XImage structure */
unsigned int *image; /* Actual 24Bit image */
int image_width; /* Width of the Image */
int image_height; /* Height of the image */
int num_runs; /* Number of frames to put out */
int i; /* counter */
int total_pixels; /* Total number of pixels in image */
int middle; /* Middle of the image */
/* check the command line */
if((argc==1)||(argc<4))
{
fprintf(stderr,"usage : %s <height> <width> <nframes>\n",argv[0]);
print_version(argv[0]);
return(-1);
}
/* read in the command line args */
sscanf(argv[1],"%d",&image_height);
sscanf(argv[2],"%d",&image_width);
sscanf(argv[3],"%d",&num_runs);
if((image_height<0)||(image_width<0)||(num_runs<0))
{
fprintf(stderr,"usage : %s <height> <width> <nframes>\n",argv[0]);
return(-1);
}
/* compute the number of pixels */
total_pixels = image_height*image_width;
middle = total_pixels/2;
/* malloc space for the image */
if((image=(unsigned int *)
malloc(sizeof(unsigned int)*(total_pixels)))==NULL)
{
fprintf(stderr,"%s : Malloc error\n",argv[0]);
return(-1);
}
/* Set up the Xll and Windowing Stuff */
if(initialize_Xll(image_width,image_height)<0)
return(-1);
/* zero the image data */
for(i=0;i<total_pixels;i++)
image[i] = 0;
/* create the pointer to the XImage Struture (one time) */
ximage = XCreateImage(display, /* X Display */
vinfo.visual, /* Visual used */
vinfo.depth, /* Depth (24) */
ZPixmap, /* Pixmap type */
0, /* Offset */
(char *)image, /* ptr to data */
image_width, /* scanline */
image_height, /* num scanlines*/
32, /* bits per pixel*/
0); /* padding */
if(!ximage)
{
fprintf(stderr,"%s : Unable to create Ximage\n",argv[0]);
return(-1);
}
/* now just go through all of the frames */
for(i=0;i<num_runs;i++)
{
/* this next line is to paint a dot giving some visual
representation to progress (not necessary tho little ohead */
image[i%total_pixels+middle] = 0xffffff;
/* put the image to the window */
XPutImage(display,win,gc,ximage,0,0,0,0,image_width,image_height);
}
return(0);
}
/* main */
/********************************************
Initialize the X Window
*******************************************/
#ifdef ANSI
int initialize_Xll(int image_width,int image_height)
#else
int initialize_Xll(image_width,image_height)
int image_width,image_height;
#endif
{
XEvent event;
Colormap colormap;
XSetWindowAttributes winattr;
unsigned int attrib_flags=0;
/*************
Windows Setup stuff
**************/
/* setup the display */
display=XOpenDisplay(NULL);
if(display==NULL)
{
fprintf(stderr,"Unable to connect to x-server \n");
return(-1);
}
/* get the Visual and Screen information */
screen = DefaultScreen(display);
vinfo.visual = DefaultVisual(display,DefaultScreen(display));
/* Try to get the 24bit TrueColor display */
if (!XMatchVisualInfo(display,screen, 24, TrueColor, &vinfo))
{
fprintf(stderr, "TrueColor visual not supported on this display\n");
return(-1);
}
/* Set up attributes for the window we're about to create */
/*- border pixel */
winattr.border_pixel = 0;
attrib_flags = CWBorderPixel;
/*- colormap for non-static colormap visuals */
colormap = XCreateColormap(display,
DefaultRootWindow(display),
vinfo.visual,
AllocNone);
XInstallColormap(display, colormap);
winattr.colormap = colormap;
attrib_flags |= CWColormap;
/*- create the window */
win = XCreateWindow(display,
DefaultRootWindow(display),
0,0,
image_width,image_height,
0,
vinfo.depth,
InputOutput,
vinfo.visual,
attrib_flags,
&winattr);
if(win==0)
{
fprintf(stderr,"Unable to create window!\n");
return(-1);
}
/* List window events used */
XSelectInput(display, win,
ExposureMask);
/* create the graphics context */
gc = XCreateGC(display,win,0L,NULL);
if (gc==NULL)
{
fprintf(stderr,"Unable to create GC\n");
return (-1);
}
/* map the window and wait for it to appear */
XMapWindow(display,win);
while (1)
{
XNextEvent(display, &event);
if (event.xany.type == Expose && event.xexpose.window == win)
break;
}
return (1);
}
Received on Wed Feb 18 1998 - 22:02:53 NZDT