X10 (programming language)

X10 is a parallel, object-oriented programming language for high-end hardware with up to 10 000 hardware threads. It was developed in 2004 at IBM at the Research Thomas J. Watson as part of the PERC project. Target platforms, the programming language are cluster systems with different computing units ( Non-Uniform Cluster Computing ). The programmer productivity of such systems is to be increased by a factor of ten with X10, leading to the name X10. The development of X10 was funded by the High Productivity Computing Systems ( HPCS ) program of DARPA.

X10 specifically for parallel programming on the Partitioned Global Address Space ( PGAS ) model has been designed. X10 this extended even by asynchrony, which leads to a APGAS model. A calculation is divided in several Places. These contain data and one or more Activities that work with this data. X10 has a limited type system for object-oriented programming. It also has other features such as user-defined primitive struct types, globally distributed arrays and structured and unstructured parallelism.

  • 2.1 fields

Basic Concepts

Activities

An Activity is a lightweight thread without own name. Asynchronous Activities are determined by the command

At ( p) async s created. Where p is the Place where the activity is to be executed and the s command (English Statement). An activity is created in a certain place and stays there for its entire lifetime. The keyword here an activity can access their Place.

Places

Place a contains data and Activities, which operate on these data. One can imagine with its own heap and own threads a Place as its own node in a distributed Java Virtual Machine ( JVM). It can be assumed that all Places are ordered. If it is at p to a Place, it can be accessed with p.next to the next place.

There is no explicit command to create a new Place to produce, but each activity is started with an explicit number of Places. This results in a fixed number of Places for the entire program, which remains constant throughout the duration of the program. The Places of the program are numbered from 0 to Place.MAX_PLACES -1 and are stored in a sorted sequence of Place.places (). On the Place of the current activity can be accessed with the keyword here.

Access is dependent on the Place location by the static field that contains any object controlled. Only the objects of Places obtain access to non-final fields of the other objects of this Places. Access attempts to non-final fields of objects to another place may fail with a BadPlaceException ( BPE). However, you can move with the expression at individual Activitys synchronously on other Places. It is, as with any distributed operation to a very expensive operation. However, it forms the basis for multicore programming in X10.

Objects are created on the Place, where the constructor call in progress. Then, an object, as opposed to Activities, not change the Place. It can only be copied to a different place or referenced on globalref of other Places.

Distribution and distributed arrays

With distribution distributed arrays are distributed to Places. The distribution is an object, which assigns to each element of the array a Place. Which Place an element of a distributed array is to be, must already be known to the array creation. It should be noted that in a place to only those elements of the distributed array can be accessed, which are also in this place.

Atomicity

As in many other programming languages ​​are hidden behind simple commands, such as the increment number of machine instructions, which makes this a critical section. This means that such an instruction may potentially be interrupted by a parallel execution another instruction. Can in order to prevent the individual X10 instructions with a

When ( c ) S are surrounded. Where c is the boolean guard condition and S is the command to be executed atomically ( engl. statement). As long as c is not true, blocks execution. If c is true, then S is executed atomically.

To run all the atomic methods, can be the keyword atomic before write. The increment method is executed atomically example:

Atomic boolean increment () {     value ;     return true; } Clocks

Many parallel algorithms are divided into different phases, a phase All activities must be processed before the next stage begins. In X10, these phases are separated by so-called clocks. To bind an activity to such a clock, one defines these as clocked () with the corresponding clock object.

In the following example, two activities A and B are synchronized by a clock object, so that first the outputs of the first phase of the two activities are issued and then the outputs of the second phase of the two activities [Note 1]:

/ / Create a clock object val clock = Clock.make ();   / / Create A activity and bind them to clock async clocked (clock) {     / / Return from parallel to B Text     print (" A: 1st phase. ");     / / wait for B     Clock.advanceAll ();     print (" A: 2nd phase. "); }   / / Create Activity B and tie them to clock async clocked (clock) {     / / Return from parallel to A Text     print (" B: 1st phase. ");     / / wait for A     Clock.advanceAll ();     print (" B: 2nd phase. "); } One possible result of the example would be:

A: 1st phase. B: 1st phase. B: 2nd phase. A: 2nd phase. ,

But not

A: 1st phase. A: 2nd phase. B: 1st phase. B: 2nd phase. .

Classes

Contains a class similar to Java, data and code. A class can contain different fields, properties, methods, constructors. In addition, a class specifies a maximum of one or no parent class. A class can implement multiple interfaces.

A class can be marked as final. From such a class can not be inherited.

Fields

Fields specify data that belong to a class. A distinction is whether the fields are variable ( identified by the keyword var ) or immutable ( identified by the keyword val ). The type of a variable field must always be specified. This follows the variable name preceded by a colon. Immutable fields can be initialized to a value, but do not need it.

/ / variable field named "population " of type integer and the initial value 42 var population: Int = 42; / / variable field named "growth rate", of type integer and without initial value var growth rate: Int; The type of an unchangeable field must not be specified explicitly. It can also be derived implicitly from the initialization value. An immutable field must not be initialized, as long as it is initialized in the class constructor.

/ / un-editable field with the name "pi", from the explicit type Double and without initial value val pi: Double; / / un-editable field with the name of " truth", the implicit integer type with initial value 42 val truth = 42; Fields can either project-specific or static ( identified by the keyword static ) be. By default, fields are object-specific, that is, each object has its own instance of the field. If a field is static, so there is for all objects, only one instance of this field. In X10 static variables must always be immutable.

/ / static, unchangeable field named "pi", from the implicit type Double, and with initial value static val pi = 3.141; / / object-specific, un-editable field with the name of " truth", the implicit integer type with initial value val truth = 42; implementations

There are two implementations of X10: X10 Native and Managed X10. Native X10 is based on C and forms a Place on a process from. It is available for the following operating systems: Linux, AIX, Mac OS, Cygwin and Blue Gene. Managed X10 is based JVM. It forms a Place onto a JVM process. Since it is based on Java, it runs independently of the operating system with any version from Java 6

830438
de