HOME

TheInfoList



OR:

Parallel Specification and Implementation Language (ParaSail) is an
object-oriented Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of ...
parallel programming language Parallel computing is a type of computation in which many calculations or processes are carried out simultaneously. Large problems can often be divided into smaller ones, which can then be solved at the same time. There are several different fo ...
. Its design and ongoing implementation is described in a blogParaSail blog
/ref> and on its official website.ParaSail website
/ref> ParaSail uses a pointer-free programming model, where
objects Object may refer to: General meanings * Object (philosophy), a thing, being, or concept ** Object (abstract), an object which does not exist at any particular time or place ** Physical object, an identifiable collection of matter * Goal, an ai ...
can grow and shrink, and value semantics are used for assignment. It has no global
garbage collected Garbage, trash, rubbish, or refuse is waste material that is discarded by humans, usually due to a perceived lack of utility. The term generally does not encompass bodily waste products, purely liquid or gaseous wastes, or toxic waste T ...
heap. Instead,
region-based memory management In computer science, region-based memory management is a type of memory management in which each allocated object is assigned to a region. A region, also called a zone, arena, area, or memory context, is a collection of allocated objects that ca ...
is used throughout. Types can be recursive, so long as the recursive components are declared ''optional''. There are no global variables, no parameter aliasing, and all subexpressions of an expression can be evaluated in parallel. Assertions,
precondition In computer programming, a precondition is a condition or predicate that must always be true just prior to the execution of some section of code or before an operation in a formal specification. If a precondition is violated, the effect of the s ...
s,
postcondition In computer programming, a postcondition is a condition or predicate that must always be true just after the execution of some section of code or after an operation in a formal specification. Postconditions are sometimes tested using assertions wit ...
s, class invariants, etc., are part of the standard syntax, using a Hoare-like notation. Any possible
race condition A race condition or race hazard is the condition of an electronics, software, or other system where the system's substantive behavior is Sequential logic, dependent on the sequence or timing of other uncontrollable events. It becomes a software ...
s are detected at
compile time In computer science, compile time (or compile-time) describes the time window during which a computer program is compiled. The term is used as an adjective to describe concepts related to the context of program compilation, as opposed to concep ...
. Initial design of ParaSail began in September 2009, by S. Tucker Taft. Both an interpreter using the ParaSail
virtual machine In computing, a virtual machine (VM) is the virtualization/ emulation of a computer system. Virtual machines are based on computer architectures and provide functionality of a physical computer. Their implementations may involve specialized h ...
, and an
LLVM LLVM is a set of compiler and toolchain technologies that can be used to develop a front end for any programming language and a back end for any instruction set architecture. LLVM is designed around a language-independent intermediate repre ...
-based ParaSail
compiler In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs tha ...
are available.
Work stealing In parallel computing Parallel computing is a type of computation in which many calculations or processes are carried out simultaneously. Large problems can often be divided into smaller ones, which can then be solved at the same time. There ...
is used for scheduling ParaSail's light-weight threads. The latest version can be downloaded from the ParaSail website.


Description

The
syntax In linguistics, syntax () is the study of how words and morphemes combine to form larger units such as phrases and sentences. Central concerns of syntax include word order, grammatical relations, hierarchical sentence structure ( constituenc ...
of ParaSail is similar to
Modula The Modula programming language is a descendant of the Pascal language. It was developed in Switzerland, at ETH Zurich, in the mid-1970s by Niklaus Wirth, the same person who designed Pascal. The main innovation of Modula over Pascal is a modul ...
, but with a class-and-interface-based object-oriented programming model more similar to
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
or C#. More recently, the parallel constructs of ParaSail have been adapted to other syntaxes, to produce
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
-like, Python-like, and
Ada Ada may refer to: Places Africa * Ada Foah, a town in Ghana * Ada (Ghana parliament constituency) * Ada, Osun, a town in Nigeria Asia * Ada, Urmia, a village in West Azerbaijan Province, Iran * Ada, Karaman, a village in Karaman Province, T ...
-like parallel languages, dubbed, respectively, Javallel, Parython, and Sparkel (named after the Ada subset
SPARK Spark commonly refers to: * Spark (fire), a small glowing particle or ember * Electric spark, a form of electrical discharge Spark may also refer to: Places * Spark Point, a rocky point in the South Shetland Islands People * Spark (surname) * ...
on which it is based). Compilers and interpreters for these languages are included with the ParaSail implementation.


Examples

The following is a
Hello world program ''Hello'' is a salutation or greeting in the English language. It is first attested in writing from 1826. Early uses ''Hello'', with that spelling, was used in publications in the U.S. as early as the 18 October 1826 edition of the '' Norwich ...
in ParaSail: func Hello_World(var IO) is IO.Println("Hello, World"); end func Hello_World; The following is an interface to a basic map module: interface BMap; Element_Type is Assignable<>> is op "[]"() -> BMap; // Create an empty map func Insert(var BMap; Key : Key_Type; Value : Element_Type); func Find(BMap; Key : Key_Type) -> optional Element_Type; func Delete(var BMap; Key : Key_Type); func Count(BMap) -> Univ_Integer; end interface BMap; Here is a possible implementation of this map module, using a binary tree: class BMap is interface Binary_Node<> is // A simple "concrete" binary node module var Left : optional Binary_Node; var Right : optional Binary_Node; const Key : Key_Type; var Value : optional Element_Type; // null means deleted end interface Binary_Node; var Tree : optional Binary_Node; var Count := 0; exports op "[]"() -> BMap is // Create an empty map return (Tree => null, Count => 0); end op "[]"; func Insert(var BMap; Key : Key_Type; Value : Element_Type) is // Search for Key, overwrite if found, insert new node if not for M => BMap.Tree loop if M is null then // Not already in the map; add it M := (Key => Key, Value => Value, Left => null, Right => null); BMap.Count += 1; else case Key =? M.Key of less=> continue loop with M.Left; greater=> continue loop with M.Right; equal=> // Key is already in the map; // bump count if Value was null; if M.Value is null then BMap.Count += 1; end if; // in any case overwrite the Value field M.Value := Value; return; end case; end if; end loop; end func Insert; func Find(BMap; Key : Key_Type) -> optional Element_Type is // Search for Key, return associated Value if present, or null otherwise for M => BMap.Tree while M not null loop case Key =? M.Key of less=> continue loop with M.Left; greater=> continue loop with M.Right; equal=> // Found it; return the value return M.Value; end case; end loop; // Not found in BMap return null; end func Find; func Delete(var BMap; Key : Key_Type) is // Search for Key; delete associated node if found for M => BMap.Tree while M not null loop case Key =? M.Key of less=> continue loop with M.Left; greater=> continue loop with M.Right; equal=> // Found it; if at most one subtree is non-null, overwrite // it; otherwise, set its value field to null // (to avoid a more complex re-balancing). if M.Left is null then // Move right subtree into M M <

M.Right; elsif M.Right is null then // Move left subtree into M M <

M.Left; else // Cannot immediately reclaim node; // set value field to null instead. M.Value := null; end if; // Decrement count BMap.Count -= 1; end case; end loop; // Not found in the map end func Delete; func Count(BMap) -> Univ_Integer is // Return count of number of items in map return BMap.Count; end func Count; end class BMap;
Here is a simple test program for the BMap module: import PSL::Core::Random; import BMap; func Test_BMap(Num : Univ_Integer; Seed : Univ_Integer) is // Test the Binary-Tree-based Map var Ran : Random := Start(Seed); // Start a random-number sequence // Declare a map from integers to strings var M : BMap Univ_Integer, Element_Type => Univ_String>; M := []; // Initialize the map to the empty map for I in 1..Num*2 forward loop // Add elements to the map const Key := Next(Ran) mod Num + 1; const Val := "Val" , To_String(I); Println("About to insert " , Key , " => " , Val); Insert(M, Key, Val); end loop; Println("Count = " , Count(M)); for I in 1..Num loop // Search for elements in the map const Key := Next(Ran) mod Num + 1; Println("Looking for " , Key , ", found " , Find(M, Key)); end loop; for I in 1..Num/3 loop // Delete some elements from the map const Key := Next(Ran) mod Num + 1; Println("About to delete " , Key); Delete(M, Key); end loop; Println("Count = " , Count(M)); for I in 1..Num forward loop // Search again for elements in the map Println("Looking for " , I , ", found " , Find(M, I)); end loop; end func Test_BMap;


References


General references

* * * *


External links

*
Blog of design and implementation process

ParaSail language newsgroup
{{DEFAULTSORT:ParaSail (Programming Language) Pascal programming language family Concurrent programming languages Procedural programming languages Systems programming languages Cross-platform software Programming languages created in 2009 2009 software Free software projects