Next: Generation of Prefetch Thread
Up: System Architecture
Previous: Synchronization
Although the prefetch thread and the computation thread can share data
through global variables in the application program, sometimes we may
need to share information in other ways.
AASFP provides the abstraction of
a communication channel between the two threads.
This communication channel is provided by the prefetch
library and is implemented using a shared buffer
between the two threads. Typically the only
variables that need to be shared are the common file pointers
and the user/file input variables. The following functions
support sharing data between the two threads:
- send_fileptr(file_pointer),
receive_fileptr(&file_pointer):
These functions send and receive file pointers between
the threads. The functions provide implicit synchronization and
thus eliminate the need to call synchronization functions explicitly.
Lines C3 and P1 in Figure 3 are examples.
- send_XXX(), receive_XXX():
These are a set of functions that a thread uses to
send/receive data to/from the other thread. They replace the
I/O calls of the same name and use almost the same syntax.
For example, for the I/O call
fscanf(fp, "%d", &value), AASFP provides the
send call send_fscanf(fp, "%d", &value), and
the receive call receive_fscanf("%d", &value).
The send function reads in the value as well as sends it to the
communication channel for the other thread to pick up.
The variable fp is not needed in the receive call
since the receive function receives it from the communication
channel. As discussed in Section 3,
the prefetch thread performs all the I/O operations on the
configuration file; these operations are removed
from the computation thread. In Figure 3, lines
marked by XX are removed from the computation thread, and lines
in the prefetch thread that are not marked by $$ are extracted
from the original main function.
Instead of fscanf, the prefetch thread
performs a send_fscanf, and the computation thread performs
a receive_fscanf. These functions also provide
implicit synchronization.
Next: Generation of Prefetch Thread
Up: System Architecture
Previous: Synchronization
chuan-kai yang
2002-04-15