Manifolda Language Elements
1. Progressives
Manifolda supports a language construct called progressive for describing the algebraic behavior of dimensioned elements. An example is shown below.
progressive soft Adder(in int x, in int y, out int z)
{
east()
{
using = + play(x, y, z);
}
}
progressive Multiplier(in int x, in int y, out int z)
{
east()
{
using = * play(x, y, z);
}
}
In the above listing, a dimensional element named Adder is described using a progressive declaration. The soft keyword in the declaration specifies that the progressive should be realized as a software component. The hard keyword can be used to specify that a progressive can be realized as a hardware entity. This element has two inputs named x and y and one output named z. It supports a dimension named east. The algebraic behavior for this dimension is specified through the using-play statement. The statement specifies that the + operator should be applied to the inputs x and y and the result of the operation should be stored in z. Similarly, a Multiplier progressive is also defined to multiply its inputs and store the result in the output.
2. Manifold System
Manifolda also supports the creation of manifold spaces comprising of dimensioned elements. These are specified as part of a system description. The following example shows different manifold spaces comprising of planes of one or more dimensioned elements. Here Adder and Multiplier are assumed to be progressives declared earlier.
system AdderSystem1
{
// A manifold space with a single Adder element
Adder adder0;
}
system AdderSystem2
{
// A manifold space consisting of a one-dimensional plane of
// N Adder elements
Adder adder1[N];
}
system AdderSystem3
{
// A manifold space consisting of a two-dimensional plane of
// MxN Adder elements
Adder adder2[M][N];
}
system MulAddSystem
{
// A manifold space consisting of a two planes of Adder and
// Multiplier elements
Adder adder3[N]; Multiplier mul1[N];
}
3. Transitive Elements
A transitive element describes the dependencies between the dimensional elements of a synthetic manifold. The relationship is specified as a mapping between the inputs and outputs of the manifold elements.
transitive MulAddData
{
int x, y, z;
};
progressive MulAdd(inout MulAddData d)
{
east()
{
Adder adder; Multiplier mul; int tmp;
using mul.east project(d.x, d.y, tmp) [];
using adder.east project(d.z, tmp, d.z)[];
}
}
As shown in the above listing, a transitive element MulAddData has three integer values named x, y, z as its members. A progressive MulAdd is defined to accept a MulAddData object. The MulAdd progressive defines a manifold space containing an Adder element and a Multiplier element. The project statements map the elements of the transitive d to the input/output of mul and add dimensional elements. Note the use of a temporary integer tmp to map the output from the mul element as an input to the adder element .
4. Transducer Elements
A transducer declaration can be used to model an element that transforms its input from one form to another. This can be used to describe different types of sensors, actuators and software entities that perform transformation on input data. An example is shown below.
transducer TemperatureSensor(out Temperature temp)
{
east()
{
using ReadTemperature play(temp);
}
}
Here, TemparatureSensor is defined as a transducer which outputs temperature values in temp. The behavior is specified using ReadTemperature which can be an external function or a progressive.
5. Cognitive Elements
Manifolda supports a cognitive element declaration to represent an element that can learn from its inputs. This can be used to model the components of machine learning systems. A cognitive element can learn the mapping between its inputs and outputs based on training inputs and then apply it to new inputs that it obtains. An example is given below.
cognitive SpamFilter(in Message message, inout MessageType type)
{
east()
{
using MessageClassifier play(message, type);
}
}
The above example shows the declaration of a cognitive element named SpamFilter. It accepts an input message of type Message and a MessageType type which acts as both input and output. This element uses a MessageClassifier entity to determine whether the input message is spam or not and sets type the result and also to learn from sample input messages whose types are specified through type.
6. Ports
A manifold system can interact with its environment through its edges or ports. Manifolda supports port declarations to describe such interactions. Ports are declared within system declarations. A port without any inputs is called a master port and is implicitly activated when the system is started. Here is a fragment taken from Listing 2 that shows port declarations for a matrix multiplier system.
system MM_manifold { MatrixMul mm1;
port SingleFrame (char *m1s, char *m2s, char *m3s) { Mat2D m1 = { m = form(m1s); };
Mat2D m2 = { m = form(m1s); }; Mat2D m3 = { m = form(m3s) ; };
using mm1.east project( m1, m2, m3 )[];
}
system MM_manifold { MatrixMul mm1;
port SingleFrame (char *m1s, char *m2s, char *m3s) { Mat2D m1 = { m = form(m1s); };
Mat2D m2 = { m = form(m1s); }; Mat2D m3 = { m = form(m3s) ; };
using mm1.east project( m1, m2, m3 )[];
}
port MultiFrame () {
Mat2D m1 = { m = form("m1.plane") [100]; }; Mat2D m2 = { m = form("m2.plane") [100]; }; Mat2D m3 = { m = form("m3.plane") [100]; }; using mm1.east project( m1, m2, m3 )[];
}
};
The port SingleFrame accepts three strings containing file names for the two input matrices and the output matrix. Then three transitive elements of type Mat2D are created and their elements are set to the contents of the input data files. Using the form operation Next, the transitive elements are mapped to the inputs and outputs of the dimensional element mm1 using the project statement.
The port MultiFrame is a master port that obtains its inputs from pre-defined files named, 'm1.plane' and 'm2.plane' and writes outputs to the file named 'm3.plane'. The input and output matrices are mapped to the element mm1 as before. The form operation in this port specifies that the matrix creation should be performed 100 times.
7. Temporal and Spatial Inputs
The inputs to a dimensional element can be temporal or spatial in nature as mentioned in section II. Manifolda provides keywords temporal and spatial to indicate this. By default, signals are assumed to be spatial in nature. An example usage is shown below.
progressive SpeedoMeter(in temporal Speed x)
{
east()
{
using DisplaySpeed play(x);
}
}
Manifold System Modeling Examples
1. Connected Car
Listing 1 shows a sample Manifolda description of a connected car system. In this description, two progressives are declared - viz. CarControl and CarSteering. The progressive CarControl accepts one spatial input signal named ctp which is of type CarSteeringPosition. In the CarControl progressive, the using statement passes the value of the steering_direction member of the ctp parameter to an entity named steering_logic, which can be an external function or another progressive.
        A transitive element named CarSteeringPosition is defined with a double value steering_direction. An object of this type is obtained as an output signal from the CarSteering progressive and passed as an input signal to the progressive CarControl, thereby establishing a relationship between these elements.
        A connected_car manifold system is defined. It defines a driver element which is of type CarSteering and a car element which is of type CarControl. It then defines a transitive element csp of type CarSteeringPosition. The steering_direction member of the transitive is set to the values in the file named 'input.txt'. The transitive element automatically takes care of obtaining values from the file and making them available to the elements.
        In Listing 1, a master port named MultiFrame port defined. It contains two using statements to invoke the driver and car elements. The project keyword maps the transitive element csp to the driver and car elements. The [] syntax indicates that the projection proceeds until there are no more values in csp. If a numerical value is specified inside the [] then the projection will be performed for that many times.
2. Big Data Processing (Matrix Multiplication)
Listing 2 shows a Manifolda description of a system for performing matrix multiplications. This can be synthesized to a computational grid which can be processed in parallel on a number of server nodes for Big Data processing.