X10 (programming language)

from Wikipedia, the free encyclopedia
X10
Paradigms : Object-oriented programming language
Publishing year: 2004
Developer: Kemal Ebcioğlu, Vijay Saraswat and Vivek Sarkar ( IBM )
Current  version : 2.6.2   (January 8, 2019)
Typing : strong , static
Influenced by: Java , C ++ , Scala
Operating system : AIX , Linux , macOS , Windows / Cygwin
License : Eclipse Public License 1.0
http://x10-lang.org/

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 Thomas J. Watson Research Center as part of the PERCS project. The target platforms of the programming language are cluster systems with different calculation units (non-uniform cluster computing). The programmer productivity of such systems is to be increased by a factor of ten with X10, which has led to the name X10. The development of X10 was funded by DARPA's High Productivity Computing Systems (HPCS) program .

X10 was specially designed for parallel programming according to the Partitioned Global Address Space (PGAS) model. X10 even extends this with asynchrony , which leads to an APGAS model. A calculation is divided into different 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 properties such as user-defined primitive struct types, globally distributed arrays, and structured and unstructured parallelism.

Basic concepts

Activities

An activity is a lightweight thread with no name of its own. Asynchronous activities are enabled by the command

at (p) async s

created. Here p is the place where the activity is to be carried out and s the command (statement). An activity is created in a specific place and stays there for its entire life. An activity can access its place with the keyword here .

Places

A place contains data and activities that work on this data. You can think of a place as a separate node of a distributed Java Virtual Machine (JVM) with its own heap and its own threads . It can be assumed that all places are ordered. If p is a place, the next place can be accessed with p.next .

There is no explicit command to create a new place, rather 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 for the entire 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 () . The place of the current activity can be accessed with the keyword here .

Access depending on the place is regulated by the static location field , which contains every object. Only the objects of a place get access to non-final fields of the other objects of this place. Attempts to access non-final fields of objects on another place fail with a BadPlaceException (BPE) . However, you can use the expression at to move individual activities synchronously to other places. As with any distributed operation, this is a very expensive operation. However, it forms the basis for multicore programming in X10.

Objects are created on the place on which the constructor call runs. Subsequently, in contrast to activities, an object can no longer change its place. It can only be copied to another place or referenced from other places via GlobalRef .

Distribution and distributed arrays

Distributions are used to distribute distributed arrays to places. The distribution is an object that assigns a place to each element of the array. The place on which an element of a distributed array is to be located must already be known when the array is created. It should be noted that only those elements of the distributed array can be accessed on a place that are also located on this place.

Atomicity

As in many other programming languages, simple instructions such as the increment conceal several machine instructions , which makes them a critical section . This means that such a command can potentially be interrupted by another command executed in parallel. To prevent this, individual commands can be entered in X10 with a

when(c) S

be surrounded. Here c is the Boolean guard condition and S is the atomic statement to be executed . As long as c is not true, execution blocks. If c becomes true, then S is executed atomically.

To execute whole methods atomically, you can put the keyword atomic in front of it. For example, the increment method is executed atomically:

atomic boolean increment() {
   value++;
   return true;
}

Clocks

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

In the following example, two activities A and B are synchronized by a clock object, so that the outputs of the first phase of both activities are output first and then the outputs of the second phase of both activities:

//erzeuge ein Clock Objekt
val clock = Clock.make();

//erzeuge Aktivität A und binde sie an clock
async clocked(clock) {
   //gebe parallel zu B Text aus
   print("A: 1st phase. ");
   //warte auf B
   Clock.advanceAll();
   print("A: 2nd phase. ");
}

//erzeuge Aktivität B und binde sie an clock
async clocked(clock) {
   //gebe parallel zu A Text aus
   print("B: 1st phase. ");
   //warte auf A
   Clock.advanceAll();
   print("B: 2nd phase. ");
}

A possible result of the example would be:

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

no but

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

Classes

A class , like Java, contains data and code. A class can contain various fields, properties, methods , and constructors . In addition, a class specifies at most one or no parent class. A class can implement several interfaces .

A class can be marked as final . You can no longer inherit from such a class .

Fields

Fields specify data belonging to a class. A distinction is made as to whether the fields are changeable (marked with the keyword var ) or unchangeable (marked with the keyword val ). The type of a changeable field must always be specified. This follows the name of the variable after a colon. Immutable fields can already be initialized with a value, but do not have to be.

//veränderbares Feld mit dem Namen "population", vom Typ Integer und mit dem initialen Wert 42
var population:Int = 42;
//veränderbares Feld mit dem Namen "growthRate", vom Typ Integer und ohne initialen Wert
var growthRate:Int;

The type of an unchangeable field does not have to be specified explicitly. It can also be derived implicitly from the initialization value. An immutable field does not have to be initialized as long as it is initialized in the class constructor.

//unveränderbares Feld mit dem Namen "pi", vom expliziten Typ Double und ohne initialen Wert
val pi:Double;
//unveränderbares Feld mit dem Namen "truth", vom impliziten Typ Integer und mit initialem Wert 42
val truth = 42;

Fields can be either object-specific or static (identified with the static keyword ). By default, fields are object-specific, i.e. each object has its own instance of the field. If a field is static, there is only one instance of this field for all objects. Static variables must always be unchangeable in X10.

//statisches, unveränderbares Feld mit dem Namen "pi", vom impliziten Typ Double und mit initialem Wert
static val pi = 3,141;
//objektspezifisches, unveränderbares Feld mit dem Namen "truth", vom impliziten Typ Integer und mit initialem Wert
val truth = 42;

Implementations

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

Individual evidence

  1. a b c d e f g Vijay Saraswat, Bard Bloom, Igor Peshansky, Olivier Tardieu, David Grove ,: X10 Language Specification Version 2.6.2 . 2019, p. 1–303 ( [1] (PDF; 1.5 MB) [accessed January 4, 2019]).
  2. ^ Philippe Charles, Christian Grothoff, Vijay A. Saraswat, et al .: X10: An Object-Oriented Approach to Non-Uniform Cluster Computing . In: OOPSLA . 2005, p. 519-538 , doi : 10.1145 / 1094811.1094852 .
  3. a b c d e f Vijay Saraswat, Radha Jagadeesan: Concurrent Clustered Programming . In: Lecture Notes in Computer Science . tape 3653 . Springer, Berlin Heidelberg 2005, p. 353-367 , doi : 10.1007 / 11539452_28 .
  4. ^ David Grove, Vijay Saraswat, Olivier Tardieu: Developing Scalable Parallel Applications in X10 . 2012, p. 1–85 ( online (PDF; 1.3 MB) [accessed on August 26, 2013]).

Remarks

  1. Activities have no names in X10, in the example the activities are only named for didactic reasons.

Web links