UNITY (programming language)

UNITY (programming language)

The UNITY programming language was constructed by K. Mani Chandy and Jayadev Misra for their book "Parallel Program Design: A Foundation". It is a rather theoretical language, which tries to focus on "what", instead of "where", "when" or "how". The peculiar thing about the language is that it has no flow control. The statements in the program run in a random order, until none of the statements causes change if run. A correct program converges into a "fix-point".

Description

All statements are assignments, and are separated by #. A statement can consist of multiple assignments, on the form a,b,c := x,y,z, or a := x || b := y || c := z. You can also have a "quantified statement list", &lt;# x,y : "expression" :: "statement"&gt;, where x and y are chosen randomly among the values that satisfy "expression". A "quantified assignment" is similar. In <|| x,y : "expression" :: "statement" &gt;, "statement" is executed simultaneously for "all" pairs of x and y that satisfy "expression".

Examples

Bubble sort

Bubble sort the array by comparing adjacent numbers, and swapping them if they are in the wrong order. Using Theta(n) expected time, Theta(n) processors and Theta(n^2) expected work. The reason you only have Theta(n) "expected" time, is that k is always chosen randomly from {0,1}. This can be fixed by flipping k manually.

Program bubblesort declare n: integer, A: array [0..n-1] of integer initially n = 20 # <# i : 0 <= i and i < n :: A [i] = rand() % 100 > assign <# k : 0 <= k < 2 :: <|| i : i % 2 = k and 0 <= i < n - 1 :: A [i] , A [i+1] := A [i+1] , A [i] if A [i] > A [i+1] > > end

Rank-sort

You can sort in Theta(log n) time with rank-sort. You need Theta(n^2) processors, and do Theta(n^2) work.

Program ranksort declare n: integer, A,R: array [0..n-1] of integer initially n = 15 # <|| i : 0 <= i < n :: A [i] , R [i] = rand() % 100, i > assign <|| i : 0 <= i < n :: R [i] := <+ j : 0 <= j < n and (A [j] < A [i] or (A [j] = A [i] and j < i)) :: 1 > > # <|| i : 0 <= i < n :: A [R [i] := A [i] > end

Floyd-Warshall

Using the Floyd-Warshall all pairs shortest path algorithm, we include intermediate nodes iteratively, and get Theta(n) time, using Theta(n^2) processors and Theta(n^3) work.

Program shortestpath declare n,k: integer, D: array [0..n-1, 0..n-1] of integer initially n = 10 # k = 0 # <|| i,j : 0 <= i < n and 0 <= j < n :: D [i,j] = rand() % 100 > assign <|| i,j : 0 <= i < n and 0 <= j < n :: D [i,j] := min(D [i,j] , D [i,k] + D [k,j] ) > |
k := k + 1 if k < n - 1 end

We can do this even faster. The following programs computes all pairs shortest path in Theta(log^2 n) time, using Theta(n^3) processors and Theta(n^3 log n) work.

Program shortestpath2 declare n: integer, D: array [0..n-1, 0..n-1] of integer initially n = 10 # <|| i,j : 0 <= i < n and 0 <= j < n :: D [i,j] = rand() % 10 > assign <|| i,j : 0 <= i < n and 0 <= j < n :: D [i,j] := min(D [i,j] , ) > end

After round r, D [i,j] contains the length of the shortest path from i to j of length 0 dots r. In the next round, of length 0 dots 2r, and so on.

References

* K. Mani Chandy and Jayadev Misra (1988) "Parallel Program Design: A Foundation".


Wikimedia Foundation. 2010.

Look at other dictionaries:

  • Cg (programming language) — Cg (short for C for Graphics) is a high level shading language developed by Nvidia in close collaboration with Microsoft[1][2] for programming vertex and pixel shaders. It is very similar to Microsoft s HLSL. Cg is based on the C programming… …   Wikipedia

  • Dart (programming language) — Dart Appeared in 2011 Developer Google Preview release 0.05[1] (November 16, 2011; 6 days ago& …   Wikipedia

  • Unity — may refer to:;Education: * Unity School District Public School in Balsam Lake, Wisconsin * Unity University College A university in Ethiopia * Unity College (Maine) a college in Maine, USA;In entertainment: * Unity (song), a duet by Afrika… …   Wikipedia

  • language — /lang gwij/, n. 1. a body of words and the systems for their use common to a people who are of the same community or nation, the same geographical area, or the same cultural tradition: the two languages of Belgium; a Bantu language; the French… …   Universalium

  • List of programming languages — Programming language lists Alphabetical Categorical Chronological Generational The aim of this list of programming languages is to include all notable programming languages in existence, both those in current use and historical ones, in… …   Wikipedia

  • Unity (game engine) — Infobox Software name = Unity caption = developer = Unity Technologies latest release version = 2.1 latest release date = July 24, 2008 operating system = Mac OS X (creation and deployment), Microsoft Windows (deployment only), Wii (deployment… …   Wikipedia

  • Structured programming — can be seen as a subset or subdiscipline of procedural programming, one of the major programming paradigms. It is most famous for removing or reducing reliance on the GOTO statement.Historically, several different structuring techniques or… …   Wikipedia

  • Digital Novel Markup Language — Original author(s) Karin (Internet name) Developer(s) J. Miguel Initial release 1998 Stable release 2.24 / 2000 Developm …   Wikipedia

  • Aramaic language — Not to be confused with the Amharic language. For the people, see Aramaeans. Aramaic Arāmît Pronunciation [arɑmiθ], [arɑmit], [ɑrɑmɑjɑ], [ɔrɔmɔjɔ] Spoken in Ir …   Wikipedia

  • Kurdish language — Kurdish كوردی, Kurdî, Kurdí, Кöрди[1] Spoken in  Turkey …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”