Doppl development iteration #7


Published on

Doppl is a new programming language that aims providing a natural syntax for implementing parallel algorithms, designing data structures for shared memory applications and automated message passing among multiple tasks. The name is an abbreviation of `data oriented parallel programming language`.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Doppl development iteration #7

  1. 1. DOPPL Data Oriented Parallel Programming Language Development Diary Iteration #7 Covered Concepts: Standard Input and Output, once Access Modifier Diego PERINI Department of Computer Engineering Istanbul Technical University, Turkey 2013-08-20 1
  2. 2. Abstract This paper stands for Doppl language development iteration #7. In this paper, standard input and output bindings and will be introduced. Formatting rules for primitive types will be also be set in this iteration. 1. Rationale Doppl ecosystem handles standard input and output by creating predefined bindings as shared members which respectively represent console input and output. Any defined task is allowed to reach console via assignment operations on bindings. Since Doppl tasks are parallel by definition, these shared bindings are also mutually exclusive like any other shared members in nature. Avoiding multiple inputs and outputs of the same value can easily be implemented via shared bool members used with mutex markers (introduced in the future) as well as access modifiers. This iteration will only introduce a method which uses access modifiers to prevent multiple executions. 2. Standard Input in a Single Task Standard input binding is named as input. Its type is string and it can only be used on the right hand side of assignment operator. Assignment operation which uses input on the right hand side are blocking and waits for the user to enter a string to system console. Below is a single task which uses input to initialize a string member. #Standard input task(1) Stdin { data a_string = string #Examples init: { a_string = input #This task is blocked here until #user enters a text to console } } 3. Standard Output in a Single Task Standard output binding is named as output. Its type is string and it can only be used on the left hand side of assignment operator. Assignment operations which use output on the left hand side acts as printing function. Values are on the right hand side are directly printed on the console output. Below is a single task which redirects given input directly to output. #Standard output task(1) Stdout { 2
  3. 3. #Examples init: { output = input } } 4. Standard Input and Output in Multiple Tasks of the Same Task Group Multiple tasks of the same task group wait each other when concurrent access on input and output initiated. This occurs because these members are defined as shared. Using input and output simultaneously may rise various problems listed below. 1. Assigning a value retrieved from input to a shared member can cause a data race if multiple tasks reads standard input at the same time. 2. Assigning a shared member to output can cause repeated printing of the same value. 3. Accessing input and output in a crowded task group may cause too many blocks. Next section introduces a new access modifier for members to solve these problems efficiently. 4. Instruction Bypassing via once Access Modifier Doppl introduces a new concept inherited from `Monads` in functional languages to work around previously mentioned issue in a native way. It is called Instruction Bypassing, a way to automatically skip execution of race expressions via automatic Null checks. Members marked as once behave differently and have the privilege to drop the whole expression they belong to whenever necessary. There are two types of usages which are able to cover all possible scenarios. 1. Using a once member on the Left Hand Side (LHS) of assignment operator. (Write case) 2. Using a once member on the Right Hand Side (RHS) of assignment operator. (Read case) LHS once members execute NOP (no operation) if their values are not Null. In other words, it is not possible to overwrite value of a once member unless its value is Null. RHS once members execute NOP if their values are Null. Moreover, any read operation on a RHS once member nullifies its value at the end of expression. In other words, it is not possible to read a once member twice. Combining RHS and LHS once members on a single expression behaves like an OR statement. At least one valid NOP condition guarantees the bypass and behaves like a short circuit. 3
  4. 4. #once Members task(10) Examples { once foo = string once shared bar = string #Examples init: { foo = "Hello" #foo is now 'Hello' foo = "Hola" #foo is 'Hello', this expression is skipped output = foo #'Hello' is printed, foo is now Null #10 of 10 tasks will execute whole previous #lines bar = input output = bar bar = "Hi" bar = Null #bar is initialized #9 of 10 tasks will #bar is printed and #9 of 10 tasks will from stdin skip this line is now Null skip this line #bar is now 'Hi' #bar is now Null foo = "Ciao" #foo is now 'Ciao' bar = "Hallo" #bar is now 'Hallo' foo = bar #Short circuit, each keep their values } } The example above demonstrates usage of once members in conjunction with shared members to avoid previously mentioned race conditions as well as repeated executions of the same expressions. 5. Conclusion Iteration #7 defines standard input and output bindings as members to work with device consoles in a convenient fashion. In order to avoid possible race conditions that may arise due to parallel nature of Doppl, a new kind of member access modifier is introduced. These newly introduced once members behave like special temporaries which are able to bypass their instructions to avoid repeated executions. 6. Future Concepts Below are the concepts that are likely to be introduced in next iterations. ● ● ● State members (local variables) Target language of Doppl compilation State transition operators 4
  5. 5. ● ● ● ● ● ● ● ● ● ● ● ● if conditional, trueness and anonymous states Booths (mutex markers) Primitive Collections and basic collection operators Provision operators Predefined task members Tasks as members Task and data traits Custom data types and defining traits Built-in traits for primitive data types Formatted input and output Message passing Exception states 7. License CC BY-SA 3.0 5