TECNICHE DI PARALLELIZZAZIONE DI PROGRAMMI SEQUENZIALI BASATE SU ANNOTAZIONI

[Total: 0    Average: 0/5]

Dynamic loading and reflection have become required features of programming systems, as witnessed by the success of execution environments like Sun’s JVM and Microsoft’s CLR. System adaptation is often achieved by means of dynamic loading, and runtime access to the program definition through the reflection capabilities of such runtimes. Microsoft .NET introduced an extensible model for reflection, allowing programmers to store custom meta-data along with the information kept by the runtime and required for type checking and program verification; more recently also Java introduced such facility starting from JVM 1.5. Custom annotations are ignored by the runtime and used by specific programs to perform tasks depending from the annotated program. Web Services, for instance, can be generated by automatic generation of an interface to a method. Annotations can be used to indicate methods to be exposed as Web Service and the additional information required (as for instance it is the URI of the XML namespace used in SOAP messages). A significant limit of this annotation model is that its scope is restricted to declarations: annotations can be used in front of classes, methods, fields, but not inside method bodies. Therefore there is no way to annotate a scope inside a method with additional (and passive) information. Besides, this ability would be very useful in annotations that states facts about programs and algorithms (for instance to express pre and post conditions inside algorithms). Annotated C# (aC#, see 1) is a small extension to the C# language that fills this need and allows annotations of code blocks inside methods. In this thesis we introduce a set of annotations to provide hints on how to make parallel a sequential method. An external meta-program is responsible for taking as input a program annotated with such hints and generating the parallel version. Our approach is based on program transformation in the binary format (assembly) instead of relying on source-to-source transformations. As a consequence of this, we achieve two main goals: write and debug a sequential algorithm instead of a parallel one; ability to defer the decision of what, when and how to make parallel to runtime. In the thesis we have built a meta-program capable of generating a multi-threaded (thus with shared memory) or a multi-process version of its annotated input. The program performs byte-code analysis in order to determine the portion of the state that should be considered shared among the concurrent activities; and generates IL, using the Reflection.Emit capabilities of .NET, a new assembly with an equivalent functional semantics of the one provided as input but with the parallel execution aspect added to it.