Many computational science applications generate huge amounts of data which must be transferred between main memory and I/O devices such as disk and tape. We will not attempt to characterize file I/O in this chapter since the devices and their connections to the rest of the system tend to be idiosyncratic. If your application needs to read or write large data files you will need to learn how your system organizes and transfers files and tune your application to fit that system. It is worth reiterating, though, that performance is measured in terms of bandwidth: what counts is the volume of data per unit of time that can be moved into and out of main memory.
The rest of this section contains a brief discussion of video displays. These output devices and their capabilities also vary from system to system, but since scientific visualization is such a prominent part of this book we should introduce some concepts and terminology for readers who are not familiar with video displays.
Most users who generate high quality images will do so on workstations configured with extra hardware for creating and manipulating images. Almost every workstation manufacturer includes in its product line versions of their basic systems that are augmented with extra processors that are dedicated to drawing images. These extra processors work in parallel with the main processor in the workstation. In most cases data generated on a supercomputer is saved in a file and later viewed on a video console attached to a graphics workstation. However there are situations that make use of high bandwidth connections from supercomputers directly to video displays; these are useful when the computer is generating complex data that should be viewed in ``real time.'' For example, a demonstration program from Thinking Machines, Inc. allows a user to move a mouse over the image of a fluid moving through a pipe. When the user pushes the mouse button, the position of the mouse is sent to a parallel processor which simulates the path of particles in a turbulent flow at this position. The results of the calculations are sent directly to the video display, which shows the new positions of the particles in real time. The net effect is as if the user is holding a container of fluid that is being poured into the pipe.
There are many different techniques for drawing images with a computer, but the dominant technology is based on a raster scan. A beam of electrons is directed at a screen that contains a quick-fading phosphor. The beam can be turned on and off very quickly, and it can be bent in two dimensions via magnetic fields. The beam is swept from left to right (from the user's point of view) across the screen. When the beam is on, a small white dot will appear on the screen where the beam is aimed, but when it is off the screen will remain dark. To paint an image on the entire screen, the beam is swept across the top row; when it reaches the right edge, it is turned off, moved back to the left and down one row, and then swept across to the right again. When it reaches the lower right corner, the process repeats again in the upper left corner.
The number of times per second the full screen is painted determines the refresh rate. If the rate is too low, the image will flicker, since the bright spots on the phosphor will fade before the gun comes back to that spot on the next pass. Refresh rates vary from 30 times per second up to 60 times per second.
The individual locations on a screen that can be either painted or not are known as pixels (from ``picture cell''). The resolution of the image is the number of pixels per inch. A high resolution display will have enough pixels in a given area that from a reasonable distance (an arm's length away) the gaps between pixels are not visible and a sequence of pixels that are all on will appear to be a continuous line. A common screen size is 1280 pixels across and 1024 pixels high on a 16'' or 19'' monitor.
The controller for the electron gun decides whether a pixel will be black or white by reading information from a memory that has one bit per pixel. If the bit is a 1, the pixel will be painted, otherwise it will remain dark. From the PMS diagram in Figure 1 you can see that the display memory on the Macintosh was part of the main memory. The operating system set aside a portion of the main memory for displays, and all an application had to do to paint something on the screen was to write a bit pattern into this portion of memory. This was an economical choice for the time (early 1980s), but it came at the cost of performance: the processor and video console had to alternate accesses to memory. During periods when the electron gun was being moved back to the upper left hand corner, the display did not access memory, and the processor was able to run at full speed. Once the gun was positioned and ready for the next scan line, however, the processor and display went back to alternating memory cycles.
With the fall in memory prices and the rising demand for higher performance, modern systems use a dedicated memory known as a frame buffer for holding bit patterns that control the displays. On inexpensive systems the main processor will compute the patterns and transfer them to the frame buffer. On high performance systems, though, the main processor sends information to the ``graphics engine'', a dedicated processor that performs the computations. For example, if the user wants to draw a rectangle, the CPU can send the coordinates to the graphics processor, and the latter will figure out which pixels lie within the rectangle and turn on the corresponding bits in the frame buffer. Sophisticated graphics processors do all the work required in complex shading, texturing, overlapping of objects (deciding what is visible and what is not), and other operations required in 3D images.
The discussion so far has
dealt only with black and white images. Color displays are based
on the same principles: a raster scan illuminates regions on a
phosphor, with the information that controls the display coming
from a frame buffer. However, instead of one gun there are three,
one for each primary color. When combining light, the primary
colors are red, green, and blue, which is why these displays are
known as RGB monitor.
Since we need to specify whether or not
each gun should be on for each pixel, the frame buffer will have
at least three bits per pixel. To have a wide variety of colors,
though, it is not enough just to turn a gun on or off; we need to
control its intensity. For example, a violet color can be formed
by painting a pixel with the red gun at 61% of full intensity,
green at 24%, and blue at 80%.
Typically a system will divide the range of intensities into 256 discrete values, which means the intensity can be represented by an 8-bit number. 8 bits times 3 guns means 24 bits are required for each pixel. Recall that high resolution displays have 1024 rows of 1280 pixels each, for a total of 1.3 million pixels. Dedicating 24 bits to each pixel would require almost 32MB of RAM for the frame buffer alone. What is done instead is to create a color map with a fixed number of entries, typically 256. Each entry in the color map is a full 24 bits wide. Each pixel only needs to identify a location in the map that contains its color, and since a color map of 256 entries requires only 8 bits per pixel to specify one of the entries there is a savings of 16 bits per pixel. The drawback is that only 256 different colors can be displayed in any one image, but this is enough for all applications except those that need to create highly realistic images.