An Algorithm Animation System for Parallel ... - Semantic Scholar

68 downloads 0 Views 131KB Size Report
animation, able to e ciently handle truly parallel algorithms. We extended the ... Stored directives are rearranged by a director module in order to re ect the.
An Algorithm Animation System for Parallel Programs Giuseppe Cattaneo, Umberto Ferraro Petrillo, Antonella Guiducci Dip. Informatica ed Applicazioni \ Universita di Salerno 84081 Baronissi (SA) Italy

"

Renato M. Capocelli

Abstract

In this paper we present an extension of CATAI, a distributed object oriented system for algorithm animation, able to eciently handle truly parallel algorithms. We extended the original project principles of CATAI with two new goals in mind: to face inherently concurrent algorithms and to reuse as much as possible the previous platform, to proof its generality and exibility. The animation framework we propose is able to represent the behavior of a pool of processes running a parallel computation based on MPI through the use of a distributed object-oriented architecture. Moreover, the same animation can be attended by several users that will also be able to safely interact with the running program, setting up and modifying shared data structures. A director module has been introduced to provide synchronization and ordering for the output representations describing the shared data structures evolution.

1 Algorithm Animation Algorithm animation is a technique that allows to represent the behavior of an algorithm through the use of a graphical display. The main application elds of algorithm animation are algorithm teaching and software debugging. The traditional approach to the algorithm animation requires the programmer to use low or high level graphic libraries to provide a direct representation for the input algorithm. The programmer must modify the original algorithm implementation to introduce animation code. Complex animation systems provide animation-oriented primitives and graphic components. However this approach su ers of some important limitations, the animation of an algorithm usually requires an in-depth knowledge of its implementation and, often, it is required also a good graphic programming skill. As a consequence, reusability results heavily limited since the e orts spent into animating an algorithm cannot be easily reinvested into another algorithm, even if the two algorithms are very similar. In the past, several systems for the animation of parallel programs have been presented such as ZEUS [1] and POLKA[2]; however all these systems failed to provide a reusable and easy to use animation system. The CATAI[4] project originated considering these two points as crucial goals, in fact it allows to easily code reusable interactive animations and, then, it uses a distributed multi user architecture to represent them. Basically, CATAI animation system moves the focus from algorithms (or the statements used to implement them) to data structures (used by the algorithms) by introducing the concept of animated data structures. Animated data structures are self containing objects that encapsulate data structures and are able to represent their behavior in a way independent from the algorithms that uses them. Given an algorithm we can obtain its animation at a very low cost by simply replacing its relevant data structures with their animated version. To animate a data structure we use the Object Oriented encapsulation property extending its source code with animation directive noti cations. Animation directives are special-purpose events which describe the algorithm behavior and that are sent by the animated data structure to a representation module which maps them to graphical scenes. We successfully implemented this approach obtaining a system able to e ectively animate sequential algorithms with very low e orts. Starting from these results, we have been encouraged to extend the project to support parallel programs too. The extended version of CATAI takes advantage of the distributed object oriented programming model to provide a system where parallel programs coded in C++ and MPI can be easily animated and then provided to a virtual classroom through the use of a lightweight Java application. 1

2 Main Architecture Description Before starting the project, we had to de ne the operating context as far as parallel computation concerns. At the moment the best of brand was the model de ned by MPI [3] speci cations that allow the user to write concurrent programs based on message passing paradigm and following a well de ned and exible communication standard. The animation architecture we propose is distributed into three distinct levels, these are: 

Parallel animated program



Animation server



Animation client

A pool of C++ coded processes that use MPI to perform a parallel computation. The algorithm shared by the parallel processes uses animated data structures, i.e. data structures that are able to describe their behavior to a remote representation module through the noti cation of animation directives.

A Java process in charge of gathering, organizing and spreading the animation directives received from the parallel animated program toward the animation clients. To accomplish this job, the animation server collects all the animation directives coming from each of the parallel process and stores them in a multi-tape bu er. Stored directives are rearranged by a director module in order to re ect the parallel program behavior and, nally, they are forwarded to all existing animation clients where they will be represented. Another task of the animation server is to let animation clients interact with the parallel animated program in a safe way by accepting their interaction requests and sequentially forwarding them to the animated program. A Java process in charge of displaying the animation and providing some high-level interaction primitives to the nal user. The graphical representation is made by animation windows, these are Java classes specialized into representation of family of data structures. Each remote animated data structures refers to a proper instance of animation window and sends it its own animation directives, these ones are parsed and then represented using precoded graphical scenes. The user can interact with the algorithm using his local copy of the animation.

The components we described above can also reside on di erent hosts, the communication framework we use is the one described by CORBA[5] as an implementation of the distributed object oriented programming paradigm.

3 Implementation Issues During the design phase of the project we had to solve several problems coming from the concurrent nature of the algorithms we want to animate. In the next sections we present the formal problems de nitions and the solutions we adopted for them.

3.1 MPI-CORBA Integration As the MPI parallel environment uses its own communication channels we had to distinguish between internal messages exchanged by the parallel processes and all the messages exchanged between the animation server and the parallel processes. The rst kind of communication uses the MPI protocol while the second one relies on CORBA messages. The integration of these two technologies is not a straightforward task because both of them require some con icting task such as waiting on a message queue and reacting to the received messages. Generally, MPI processes are not able to correctly receive and parse CORBA messages. The solution we propose relies on the use of the MPI master process1 as a gateway for the two environments. In the implementation of the MPI speci cation we have used, mpich [6], we have experimented that the master process is able to receive remote CORBA messages. Our idea is to let each MPI process directly send messages to remote CORBA objects while incoming messages are received only by the master process and then forwarded to the interested slave process using the MPI communication primitives. To be able to do this, we coded a library of functions to be used by parallel processes for marshaling and unmarshaling CORBA messages into the MPI message protocol. 1 We de ne master the rst process being created in an MPI execution while we de ne slave the other ones 2

3.2 A Director for Distributed Data Structures Animation

In parallel algorithms a data structure instance can be scattered through several processes with each process holding a portion of it. Therefore, there could be multiple sources of animation directives, in this situation our system must be able to collect directives from di erent source while preserving ordering in the representation. The solution we propose introduces a new specialized synchronization module located in the animation server. The director module holds a multi-tape bu er for each running MPI animated computation. Each bu er has as many tapes as the number of parallel processes, each time the animation server receives a new animation directive this is appended in the proper tape in the bu er. The director asynchronously examines the tapes contents and forwards animation directives to the clients. There are several policies that the director module can adopt to consume entries into the bu er. These policies allow the director to synchronize the events coming from the di erent processes in order to enhance the representation of parallel processes.

3.3 Distributed Data Structures Representation

An e ective and easy to code representation for an input data structure can be an hard task in the algorithm animation since it requires both a good knowledge of the represented algorithm behavior and a deep skill of graphic programming ( nal rendering of the scenes). Catai provides a set of specialized Java classes to help the user to code new animation windows. This animation framework represents each distributed data structure into an animation window. Animation windows implements high-level speci c animation functions used to represent the abstract behavior of the data structure. Moreover, since in a parallel environment data structures are distributed among several process, we added to the CATAI architecture the ability to handle groups of graphical objects inside a same animation window. In this way, each process of a parallel computation can access the representation of its portion of data structure in a safe way providing its unique id.

4 Conclusions Our animation system o ers a general and ecient framework for the animation of parallel algorithms written using the MPI abstraction layer. The solution we propose allows a user to easily get a rst simple animation starting from an input algorithm using animated data structures, in addition, more complex animations can be obtained using the provided high level animation functions. In this way our system is able to deliver animated parallel algorithms to a group of users without comprising their original implementation. We have experimented our system with the Kelp[7] library, Kelp provides an MPI based implementation for several distributed data structures like n-dimensional array. As a preliminary result we have built the animated version of the simplest but also most used distributed data structure, namely the vector. One of our future goals is to extend this result to include more general data structures like multidimensional array and regions. We are also investigating the extension of the director module to save running animations, make them persistent and then playing them back without using any algorithm server and, nally, we are currently considering the introduction of several others high-level coordination directives to be used to instruct the director module while representing complex animations.

References

[1] Brown, M. H. \Zeus: A System for Algorithm Animation and Multi-View Editing ". In Proceedings of IEEE Workshop on Visual Languages , (pp. 4-9). New York: IEEE Computer Society Press, 1991. [2] John T. Stasko, John B. Domingue, Marc H. Brown, and Blaine A. Price (Eds.).\Software Visualization". MIT Press, GA, 1998. [3] \MPI standard 2.0 ". MPI Forum, 18 July 1997. [4] G. F. Italiano, G.Cattaneo, U. Ferraro P.and V.Scarano.\CATAI: Concurrent Algorithms and Data Types Animation over the Internet ". \15th IFIP World Computer Congress" Wien, August - September 1998. [5] S. Vinoski. \CORBA: Integrating Diverse Applications Within Distributed Heterogeneous Environments". IEEE Communications Magazine. 14 (2), February 1997. [6] W. Gropp, E. Lusk, N. Doss and A. Skjellum. \A high-performance, portable implementation of the MPI message passing interface standard". Parallel Computing. 22 (6), pp. 789-828, September 1996. [7] J. H. Merlin, S.B. Baden, S.J. Fink and B.M. Chapman.\Multiple data parallelism with HPF and KeLP ". HPCN 98 Amsterdam, April 1998.

3