http://www.mesham.com/api.php?action=feedcontributions&user=Polas&feedformat=atomMesham - User contributions [en-gb]2024-03-29T13:37:47ZUser contributionsMediaWiki 1.32.0http://www.mesham.com/index.php?title=File:Classb.jpg&diff=1414File:Classb.jpg2019-04-15T16:09:22Z<p>Polas: Polas uploaded File:Classb.jpg</p>
<hr />
<div>NASA's Parallel Benchmark IS class B</div>Polashttp://www.mesham.com/index.php?title=File:128.jpg&diff=1413File:128.jpg2019-04-15T16:09:11Z<p>Polas: Polas uploaded File:128.jpg</p>
<hr />
<div>Fast Fourier Transformation example performed with 128MB data</div>Polashttp://www.mesham.com/index.php?title=File:Imagep.jpg&diff=1412File:Imagep.jpg2019-04-15T16:08:45Z<p>Polas: Polas uploaded File:Imagep.jpg</p>
<hr />
<div>Example of high and low pass filters operating on an image</div>Polashttp://www.mesham.com/index.php?title=File:Messagepassing.gif&diff=1411File:Messagepassing.gif2019-04-15T16:08:22Z<p>Polas: Polas uploaded File:Messagepassing.gif</p>
<hr />
<div>Message Passing based communication</div>Polashttp://www.mesham.com/index.php?title=File:Evendist.jpg&diff=1410File:Evendist.jpg2019-04-15T16:08:11Z<p>Polas: Polas uploaded File:Evendist.jpg</p>
<hr />
<div>Even distribution of 10 blocks over 4 processors</div>Polashttp://www.mesham.com/index.php?title=File:Pram.gif&diff=1409File:Pram.gif2019-04-15T16:07:59Z<p>Polas: Polas uploaded File:Pram.gif</p>
<hr />
<div>Parallel Random Access Machine</div>Polashttp://www.mesham.com/index.php?title=File:Process.jpg&diff=1408File:Process.jpg2019-04-15T16:07:49Z<p>Polas: Polas uploaded File:Process.jpg</p>
<hr />
<div>NASA's Parallel Benchmark IS Million Operations per Second per Process</div>Polashttp://www.mesham.com/index.php?title=File:Mandle.gif&diff=1407File:Mandle.gif2019-04-15T16:07:40Z<p>Polas: Polas uploaded File:Mandle.gif</p>
<hr />
<div>Mandelbrot example written in Mesham</div>Polashttp://www.mesham.com/index.php?title=File:Mandlezoom.jpg&diff=1406File:Mandlezoom.jpg2019-04-15T16:07:29Z<p>Polas: Polas uploaded File:Mandlezoom.jpg</p>
<hr />
<div>Mandelbrot Performance Tests</div>Polashttp://www.mesham.com/index.php?title=File:2gb.jpg&diff=1405File:2gb.jpg2019-04-15T16:06:19Z<p>Polas: Polas uploaded File:2gb.jpg</p>
<hr />
<div>Fast Fourier Transformation with 2GB of data</div>Polashttp://www.mesham.com/index.php?title=File:Dartboard.jpg&diff=1404File:Dartboard.jpg2019-04-15T16:06:02Z<p>Polas: Polas uploaded File:Dartboard.jpg</p>
<hr />
<div>Dartboard</div>Polashttp://www.mesham.com/index.php?title=File:Mesham.gif&diff=1403File:Mesham.gif2019-04-15T16:05:52Z<p>Polas: Polas uploaded File:Mesham.gif</p>
<hr />
<div>Mesham arjuna logo</div>Polashttp://www.mesham.com/index.php?title=File:Runtimelibrary.png&diff=1402File:Runtimelibrary.png2019-04-15T16:05:40Z<p>Polas: Polas uploaded File:Runtimelibrary.png</p>
<hr />
<div>Runtime library icon</div>Polashttp://www.mesham.com/index.php?title=File:Bell.jpg&diff=1401File:Bell.jpg2019-04-15T16:05:29Z<p>Polas: Polas uploaded File:Bell.jpg</p>
<hr />
<div>Decreasing performance as the number of processors becomes too great</div>Polashttp://www.mesham.com/index.php?title=File:Spec.png&diff=1400File:Spec.png2019-04-15T16:05:19Z<p>Polas: Polas uploaded File:Spec.png</p>
<hr />
<div>Language specification</div>Polashttp://www.mesham.com/index.php?title=File:Bell.gif&diff=1399File:Bell.gif2019-04-15T16:05:06Z<p>Polas: Polas uploaded File:Bell.gif</p>
<hr />
<div>Decreasing performance as the number of processors becomes too great</div>Polashttp://www.mesham.com/index.php?title=File:Vert.jpg&diff=1398File:Vert.jpg2019-04-15T16:04:55Z<p>Polas: Polas uploaded File:Vert.jpg</p>
<hr />
<div>Vertical partitioning of an array via the vertical type</div>Polashttp://www.mesham.com/index.php?title=File:Flexdetail.jpg&diff=1397File:Flexdetail.jpg2019-04-15T16:04:42Z<p>Polas: Polas uploaded File:Flexdetail.jpg</p>
<hr />
<div>Flexibo translation in detail</div>Polashttp://www.mesham.com/index.php?title=File:Classc.jpg&diff=1396File:Classc.jpg2019-04-15T16:04:22Z<p>Polas: Polas uploaded File:Classc.jpg</p>
<hr />
<div>NASA's Parallel Benchmark IS class C</div>Polashttp://www.mesham.com/index.php?title=File:Horiz.jpg&diff=1395File:Horiz.jpg2019-04-15T16:04:11Z<p>Polas: Polas uploaded File:Horiz.jpg</p>
<hr />
<div>Horizontal partitioning of an array via the horizontal type</div>Polashttp://www.mesham.com/index.php?title=File:Overview.jpg&diff=1394File:Overview.jpg2019-04-15T16:04:01Z<p>Polas: Polas uploaded File:Overview.jpg</p>
<hr />
<div>Overview of Translation Process</div>Polashttp://www.mesham.com/index.php?title=File:Oubliette.png&diff=1393File:Oubliette.png2019-04-15T16:03:48Z<p>Polas: Polas uploaded File:Oubliette.png</p>
<hr />
<div>Oubliette Mesham logo</div>Polashttp://www.mesham.com/index.php?title=File:Total.jpg&diff=1392File:Total.jpg2019-04-15T16:03:32Z<p>Polas: Polas uploaded File:Total.jpg</p>
<hr />
<div>NASA's Parallel Benchmark IS Total Million Operations per Second</div>Polashttp://www.mesham.com/index.php?title=File:Types.jpg&diff=1391File:Types.jpg2019-04-15T16:03:21Z<p>Polas: Polas uploaded File:Types.jpg</p>
<hr />
<div>Type Chain formed when combining types A::B::C::D::E</div>Polashttp://www.mesham.com/index.php?title=File:Robot-cleaner.jpg&diff=1390File:Robot-cleaner.jpg2019-04-15T16:03:09Z<p>Polas: Polas uploaded File:Robot-cleaner.jpg</p>
<hr />
<div></div>Polashttp://www.mesham.com/index.php?title=File:Oubliettelandscape.png&diff=1389File:Oubliettelandscape.png2019-04-15T15:59:58Z<p>Polas: Polas uploaded File:Oubliettelandscape.png</p>
<hr />
<div>Oubliette landscape</div>Polashttp://www.mesham.com/index.php?title=File:Meshamworkflow.png&diff=1388File:Meshamworkflow.png2019-04-15T15:54:50Z<p>Polas: Polas uploaded File:Meshamworkflow.png</p>
<hr />
<div>Workflow of the oubliette Mesham compiler</div>Polashttp://www.mesham.com/index.php?title=Wait&diff=1378Wait2019-04-15T15:45:06Z<p>Polas: 4 revisions imported</p>
<hr />
<div>== Overview ==<br />
<br />
This wait(n) function will block and wait for a notification from process ''n''<br />
<br />
* '''Pass:''' an [[Int]] representing the process ID to wait for a notification from<br />
* '''Returns:''' Nothing<br />
<br />
== Example ==<br />
<br />
#include <parallel><br />
<br />
function void main() {<br />
proc 1 {<br />
notify(0);<br />
};<br />
<br />
proc 0 {<br />
wait(1);<br />
};<br />
};<br />
<br />
''Since: Version 1.00''<br />
<br />
[[Category:Function Library]]<br />
[[Category:Parallel Functions]]</div>Polashttp://www.mesham.com/index.php?title=Notifyall&diff=1380Notifyall2019-04-15T15:45:06Z<p>Polas: 1 revision imported</p>
<hr />
<div>== Overview ==<br />
<br />
This notifyall() function will notify all other process, all these target process can wait on or test for a notification. This is non-blocking and will continue as soon as the function is called.<br />
<br />
* '''Pass:''' Nothing<br />
* '''Returns:''' Nothing<br />
<br />
== Example ==<br />
<br />
#include <parallel><br />
<br />
function void main() {<br />
proc 1 {<br />
notifyall();<br />
};<br />
};<br />
<br />
''Since: Version 1.00''<br />
<br />
[[Category:Function Library]]<br />
[[Category:Parallel Functions]]</div>Polashttp://www.mesham.com/index.php?title=Waitany&diff=1383Waitany2019-04-15T15:45:06Z<p>Polas: 2 revisions imported</p>
<hr />
<div>== Overview ==<br />
<br />
This waitany() function will block and wait for a notification from any process. The id of that process is returned.<br />
<br />
* '''Pass:''' Nothing<br />
* '''Returns:''' The id of the process that notified this process.<br />
<br />
== Example ==<br />
<br />
#include <parallel><br />
<br />
function void main() {<br />
proc 1 {<br />
notify(0);<br />
};<br />
<br />
proc 0 {<br />
var p:=waitany();<br />
};<br />
};<br />
<br />
''Since: Version 1.00''<br />
<br />
[[Category:Function Library]]<br />
[[Category:Parallel Functions]]</div>Polashttp://www.mesham.com/index.php?title=Test_notification&diff=1387Test notification2019-04-15T15:45:06Z<p>Polas: 3 revisions imported</p>
<hr />
<div>== Overview ==<br />
<br />
This test_notification(n) function will test for a notification from process ''n'', if such a notification is available then this is received (i.e. one need not then call [[Wait|wait]] or [[Waitany|waitany]].)<br />
<br />
* '''Pass:''' an [[Int]] representing the process ID to test for a notification from<br />
* '''Returns:''' a [[Bool]] representing whether a notification was received or not<br />
<br />
== Example ==<br />
<br />
#include <parallel><br />
<br />
function void main() {<br />
proc 1 {<br />
notify(0);<br />
};<br />
<br />
proc 0 {<br />
while (!test_notification(1)) { };<br />
};<br />
};<br />
<br />
''Since: Version 1.00''<br />
<br />
[[Category:Function Library]]<br />
[[Category:Parallel Functions]]</div>Polashttp://www.mesham.com/index.php?title=Trim&diff=1344Trim2019-04-15T15:45:05Z<p>Polas: 1 revision imported</p>
<hr />
<div>== Overview ==<br />
<br />
This trim(s) function will return a new string where the leading and trailing whitespace of string ''s'' has been removed.<br />
<br />
* '''Pass:''' A [[String]]<br />
* '''Returns:''' A [[String]]<br />
<br />
== Example ==<br />
<br />
#include <string><br />
#include <io><br />
<br />
function void main() {<br />
var m:=" hello world ";<br />
print(m+"-\n"+trim(m)+"-\n");<br />
};<br />
<br />
''Since: Version 1.0''<br />
<br />
[[Category:Function Library]]<br />
[[Category:String Functions]]</div>Polashttp://www.mesham.com/index.php?title=Arraydist&diff=1346Arraydist2019-04-15T15:45:05Z<p>Polas: 1 revision imported</p>
<hr />
<div>== Syntax ==<br />
<br />
arraydist[integer array]<br />
<br />
== Semantics ==<br />
<br />
Will distribute data blocks amongst the processes dependant on the integer array supplied. The number of elements in this array must equal the number of blocks. The index of each element corresponds to the block Id and the value at this location the process that it resides upon. For example, the value 5 at location 2 will place block number 2 onto process 5.<br />
<br />
== Example ==<br />
<br />
function void main() {<br />
var d:array[Int,4];<br />
d[0]:=3;<br />
d[1]:=0;<br />
d[2]:=2;<br />
d[3]:=1;<br />
<br />
var a:array[Int,16,16] :: allocated[horizontal[4] :: single[arraydist[d]]];<br />
var b:array[Int,16,16] :: allocated[single[on[1]]];<br />
a:=b;<br />
};<br />
<br />
In this example the array is split using horizontal partitioning into 4 blocks, the first block held on process 3, the second on process 0, third on process 2 and lastly the fourth on process 1. In the assignment on line 10 the data in array ''b'' is distributed to the correct blocks which are held on the appropriate processes depending on the array distribution. To change what data goes where one can simply modify the values in array ''d''.<br />
<br />
''Since: Version 1.0''<br />
<br />
[[Category:Type Library]]<br />
[[Category:Compound Types]]<br />
[[Category:Distribution Types]]</div>Polashttp://www.mesham.com/index.php?title=Template:OneDimPartitionDotOperators&diff=1348Template:OneDimPartitionDotOperators2019-04-15T15:45:05Z<p>Polas: 1 revision imported</p>
<hr />
<div>{| border="1" cellspacing="0" cellpadding="5" align="center"<br />
! Dot operation<br />
! Semantics<br />
|- <br />
| high<br />
| Largest global coordinate wrt a block in specific block dimension<br />
|-<br />
| low<br />
| Smallest global coordinate wrt a block in specific block dimension<br />
|-<br />
| top<br />
| Largest global coordinate in specific block dimension<br />
|-<br />
| localblocks<br />
| Number of blocks held on local process<br />
|-<br />
| localblockid[i]<br />
| Id number of ith local block<br />
|}</div>Polashttp://www.mesham.com/index.php?title=Template:OneDimPartitionCommunication&diff=1351Template:OneDimPartitionCommunication2019-04-15T15:45:05Z<p>Polas: 2 revisions imported</p>
<hr />
<div>There are a number of different default communication rules associated with the one dimensional partitions, based on the assignment ''assigned variable:=assigning variable'' which are detailed below.<br />
<br />
{| border="1" cellspacing="0" cellpadding="5" align="center"<br />
! Assigned Variable<br />
! Assigning Variable<br />
! Semantics<br />
|- <br />
| single<br />
| partition<br />
| Gather<br />
|-<br />
| partition<br />
| single<br />
| Scatter<br />
|-<br />
| partition<br />
| partition<br />
| Local copy<br />
|}<br />
As in the last row of the table , if the two partitions are the same type then a simple copy is performed. However, if they are different then an error will be generated as Mesham disallows differently typed partitions to be assigned to each other.<br />
<br />
The programmer can also read and write to each element in the partitioned data directly. Either the global coordinates or the block ID its local coordinates can be supplied. This will deduce whether or not the block is on another process, issue any communication as required and complete in that single assignment or access. Because this completes in that expression rather than waiting for a synchronisation, non local data movement is potentially an expensive operation.</div>Polashttp://www.mesham.com/index.php?title=Eageronesided&diff=1353Eageronesided2019-04-15T15:45:05Z<p>Polas: 1 revision imported</p>
<hr />
<div>== Syntax ==<br />
<br />
eageronesided[a,b]<br />
<br />
== Syntax ==<br />
<br />
eageronesided[]<br />
<br />
== Semantics ==<br />
<br />
Identical to the [[Onesided]] type, but will perform onesided communication rather than p2p. This form of one sided communication is similar to normal [[Onesided|one sided]] communication but remote memory access happens immediately and is not linked to the synchronisation keyword. By virtue of the fact that RMA access happens immediately means this form of communication is potentially less performant than normal one sided.<br />
<br />
== Example ==<br />
<br />
function void main() {<br />
var i:Int::eageronesided::allocated[single[on[2]]];<br />
proc 0 {i:=34;};<br />
};<br />
<br />
In the above code example variable ''i'' is declared to be an Integer using eager onesided communication on process two only. In line two an assignment occurs on process zero which will write the value, from process zero into the memory held by process two immediately and that value is now available after that line to every other process.<br />
<br />
''Since: Version 1.0''<br />
<br />
[[Category:Type Library]]<br />
[[Category:Compound Types]]<br />
[[Category:Primitive Communication Types]]</div>Polashttp://www.mesham.com/index.php?title=Sleep&diff=1355Sleep2019-04-15T15:45:05Z<p>Polas: 1 revision imported</p>
<hr />
<div>== Overview ==<br />
<br />
This sleep(l) function will pause execution for ''l'' milliseconds.<br />
<br />
* '''Pass:''' A [[Long]] number of milliseconds to sleep for<br />
<br />
* '''Returns:''' Nothing<br />
<br />
== Example ==<br />
<br />
#include <system><br />
<br />
function void main() {<br />
sleep(1000);<br />
};<br />
<br />
''Since: Version 1.0''<br />
<br />
[[Category:Function Library]]<br />
[[Category:System Functions]]</div>Polashttp://www.mesham.com/index.php?title=LineNumber&diff=1359LineNumber2019-04-15T15:45:05Z<p>Polas: 3 revisions imported</p>
<hr />
<div>== Syntax ==<br />
<br />
_LINE_NUMBER<br />
<br />
== Semantics ==<br />
<br />
Will be substituted in source code by the current line number of that specific file, this is useful for debugging and error messages<br />
<br />
''Since: Version 1.0''<br />
<br />
[[Category:preprocessor]]</div>Polashttp://www.mesham.com/index.php?title=SourceFile&diff=1361SourceFile2019-04-15T15:45:05Z<p>Polas: 1 revision imported</p>
<hr />
<div>== Syntax ==<br />
<br />
_SOURCE_FILE<br />
<br />
== Semantics ==<br />
<br />
Will be substituted in source code by the name of the current source code file, this is useful for debugging and error messages<br />
<br />
''Since: Version 1.0''<br />
<br />
[[Category:preprocessor]]</div>Polashttp://www.mesham.com/index.php?title=Tutorial_-_RMA&diff=1368Tutorial - RMA2019-04-15T15:45:05Z<p>Polas: 6 revisions imported</p>
<hr />
<div><metadesc>Tutorial describing RMA of data in Mesham</metadesc><br />
'''Tutorial number eight''' - [[Tutorial_-_Arrays|prev]] :: [[Tutorial_-_Dynamic Parallelism|next]]<br />
<br />
== Introduction ==<br />
<br />
The default behaviour in Mesham is for communication involving variables to be performed via Remote Memory Access (RMA.) This is one sided, where data is remotely retrieved or written to a target process by the source. We briefly looked at this in the [[Tutorial_-_Shared_Memory|shared memory tutorial]] and here we build on that to consider the concepts in more depth.<br />
<br />
== Data visibility ==<br />
<br />
function void main() {<br />
var a:Int::allocated[single[on[1]]];<br />
var b:Int::allocated[multiple[]];<br />
var c:Int::allocated[multiple[commgroup[0,1]]];<br />
var d:Int::allocated[single[on[0]];<br />
<br />
b:=a;<br />
proc 1 {<br />
c:=a;<br />
};<br />
d:=a;<br />
proc 1 {<br />
d:=a;<br />
};<br />
};<br />
<br />
In the code snippet above exactly what communications are occurring (i.e. are processes reading remote data or writing to remote data?) The best way to think about this is via a simple visibility rule; all variables marked multiple (including those with extra commgroup type) are private to the processes that contain them and all variables marked single are publicly visible to all processes. Therefore in the assignment at line 6 each processes will remotely read from ''a'' held on process one and write this into their own local (private) copy of ''b''. At line 8, only process one will write the value of ''a'' (a local copy as ''a'' is held on the same process) into its own local (private) version of ''c'', the value of ''c'' on process zero will remain unchanged. For variables marked single, assignment favours reading the value remotely if possible rather than writing remotely, for instance at line 10 the assignment ''d:=a'' will result in process zero reading the value of ''a'' from process one, but at line 12 the only process that can execute this is process one so this results in a remote write of ''a'' to variable ''d'' held on process zero.<br />
<br />
== Synchronisation ==<br />
<br />
By default RMA is non-blocking, so that remote reads or writes might complete at any point and need to be synchronised before values are available. This approach is adopted for performance and scalability, such that many reads and/or writes can occur between synchronisation points. The [[Sync|sync]] keyword provides synchronisation in Mesham, there are actually two ways to use this, firstly ''sync'' on its own will result in a barrier synchronisation, where each process will complete all of its outstanding RMA and then wait (barrier) for all other processes to reach that same point. The other use of synchronisation is with a variable for instance ''sync v'' (assuming variable ''v'' already exists) which will ensure all outstanding RMA involving only variable ''v'' will complete - this second use of synchronisation does not involve any form of barrier so is far more efficient. It is fine to synchronise on a variable which has no outstanding RMA communications and in this case the processes will continue immediately.<br />
<br />
Completion of outstanding RMA means that all communications have fully completed, i.e. remote writes have completed and the data is visibile on the target process.<br />
<br />
function void main() {<br />
var a:Int::allocated[single[on[1]]];<br />
var b:Int::allocated[multiple[]];<br />
<br />
b:=a;<br />
sync b;<br />
};<br />
<br />
The code snippet above illustrates a potential question here, based on the assignment ''b:=a'' (which involves RMA) if the programmer wished to synchronise the RMA for this assignment, should they issue ''sync b'' or ''sync a''? The simple answer is that it doesn't matter as for synchronisation an assignment will tie the variables together so that, for instance ''sync b'' will synchronise RMA for variable ''b'', RMA for variable ''a'' and any other tied RMA for both these variables and their own tied variables.<br />
<br />
== Eager RMA ==<br />
<br />
var a:array[Int,10]::allocated[single[on[1]]];<br />
proc 0 {<br />
var i;<br />
for i from 0 to 7 { <br />
a[i]:=i;<br />
};<br />
sync a;<br />
}; <br />
<br />
We saw this example previously, where process zero will most likely write out the value of 10 (variable ''i'' after the loop) to all elements of the array, this is because the remote write is issued based on the variable rather than the variable's value. You could instead place the ''sync a'' call directly after the assignment, or alternatively remove this call all together and append the [[Eageronesided|eageronesided]] type to the type chain of variable ''a'' which will ensure the RMA communication and completion is atomic.<br />
<br />
== Bulk Synchronous RMA ==<br />
<br />
Many of the RMA examples we have seen in these tutorials follow a bulk synchronous approach (similar to fences), where all processes will synchronise, then communicate and then synchronise again before continuing with computation.<br />
<br />
function void main() {<br />
var a:Int::allocated[single[on[1]]];<br />
var b:Int::allocated[multiple[]];<br />
<br />
proc 1 {<br />
a:=55;<br />
};<br />
sync;<br />
b:=a;<br />
sync;<br />
proc 1 {<br />
a:=15<br />
};<br />
};<br />
<br />
Because RMA communication is non-blocking and may complete at any point from issuing the communication up until the synchronisation, in the example here we need two [[Sync|sync]] calls. The first one ensures that process zero doesn't race ahead and issue the remote read before process one has written the value of ''55'' into variable ''a''. The second synchronisation call ensures that process one doesn't then rush ahead and overwrite the value of ''a'' with ''15'' until process zero has finished remotely reading it. If this last assignment (''a:=15'') did not exist then the last synchronisation could be weakened into ''sync b'' (or ''sync a'') which will complete RMA on process zero at that point and process one would be free to rush ahead.<br />
<br />
== Notify and wait ==<br />
<br />
The bulk synchronous approach is simple but not very scalable, certainly it is possible to play with different synchronisation options (for instance putting them inside the [[Proc|process selection]] blocks) but care must be taken for data consistency. Another approach is to use the [[Notify|notify]] and [[Wait|wait]] support of the parallel function library. The [[Notify|notify]] function will send a notification to a specific process and the [[Wait|wait]] function will block and wait for a notification from a specific process.<br />
<br />
#include <io><br />
#include <string><br />
#include <parallel><br />
<br />
function void main() {<br />
var j:array[Int,10]::allocated[single[on[1]]]; <br />
<br />
proc 0 {<br />
var d:array[Int,10];<br />
var i;<br />
for i from 0 to 9 {<br />
d[i]:=i;<br />
};<br />
j:=d;<br />
sync j;<br />
notify(1);<br />
};<br />
<br />
proc 1 {<br />
wait(0);<br />
var i;<br />
for i from 0 to 9 {<br />
print(itostring(j[i])+"\n");<br />
};<br />
};<br />
};<br />
<br />
In the example here process zero will issue a remote write to variable ''j'' (held on process one), then synchronise (complete) this RMA before sending a notification to process one. Process one will block waiting for a notification from process zero, and once it has received a notification will display its local values of ''j''. Due to the notification and waiting these values will be those written by process zero, if you comment out the [[Wait|wait]] call then process one will just display zeros.<br />
<br />
There are some variation of these calls [[Notifyall|notifyall]] to notify all processes, [[Waitany|waitany]] to wait for a notification from any process and [[Test_notification|test_notification]] to test whether there is a notification from a specific process or not.<br />
<br />
#include <io><br />
#include <string><br />
#include <parallel><br />
<br />
function void main() {<br />
var j:array[Int,10]::allocated[single[on[2]]]; <br />
<br />
proc 0 {<br />
var d:array[Int,10];<br />
var i;<br />
for i from 0 to 9 {<br />
d[i]:=i;<br />
};<br />
j:=d;<br />
sync j;<br />
notifyall();<br />
};<br />
proc 1 {<br />
var m:array[Int,10];<br />
var p:=waitany();<br />
m:=j;<br />
sync m;<br />
var i;<br />
for i from 0 to 9 {<br />
print(itostring(m[i])+" written by process "+itostring(p)+"\n");<br />
}; <br />
};<br />
proc 2 {<br />
while (!test_notification(0)) { };<br />
var i;<br />
for i from 0 to 9 {<br />
print("Local value is "+itostring(j[i])+"\n");<br />
};<br />
};<br />
};<br />
<br />
This example extends the previous one, here ''j'' is held on process two and process zero remotely writes to it and then issues [[Notifyall|notifyall]] to send a notification to every other process. These other two processes could have used the [[Wait|wait]] call as per the previous example, but instead process one will wait on a notification from any process (which returns the ID of the process that issued that notification which is displayed) and process two tests for a notification and loops whilst this returns false.<br />
<br />
[[Category: Tutorials]]</div>Polashttp://www.mesham.com/index.php?title=Notify&diff=1373Notify2019-04-15T15:45:05Z<p>Polas: 4 revisions imported</p>
<hr />
<div>== Overview ==<br />
<br />
This notify(n) function will notify process ''n'', this target process can wait on or test for a notification. This is non-blocking and will continue as soon as the function is called.<br />
<br />
* '''Pass:''' an [[Int]] representing the process ID to notify<br />
* '''Returns:''' Nothing<br />
<br />
== Example ==<br />
<br />
#include <parallel><br />
<br />
function void main() {<br />
proc 1 {<br />
notify(0);<br />
};<br />
};<br />
<br />
''Since: Version 1.00''<br />
<br />
[[Category:Function Library]]<br />
[[Category:Parallel Functions]]</div>Polashttp://www.mesham.com/index.php?title=Tutorial_-_Advanced_Types&diff=1328Tutorial - Advanced Types2019-04-15T15:45:04Z<p>Polas: 4 revisions imported</p>
<hr />
<div><metadesc>Tutorial describing advanced type features of Mesham</metadesc><br />
'''Tutorial number ten''' - [[Tutorial_-_Dynamic Parallelism|prev]]<br />
<br />
== Introduction ==<br />
Mesham has a number of advanced typing features over and above type chains and type coercion. In this tutorial we will look at some of this, how they might be used and how they can simplify your program code.<br />
<br />
== Type Variables ==<br />
<br />
The language has a concept of a type variable, which is a, compilation time, programmer defined type representing a more complex type chain. Let's have a look at this in more detail via an example<br />
<br />
function void main() {<br />
typevar typeA::=Int::allocated[multiple];<br />
typevar typeB::=String::allocated[single[on[3]]];<br />
<br />
var a:typeA;<br />
var b:typeB;<br />
};<br />
<br />
In this example we create type type variables called ''typeA'' and ''typeB'' which represent different type chains. Then the actual program variables ''a'' and ''b'' are declared using these type variables. Notice how type assignment is using the ''::='' operator rather than normal program variable assignment which folows '':=''.<br />
<br />
function void main() {<br />
typevar typeA::=Int::allocated[multiple];<br />
var a:typeA;<br />
<br />
typeA::=String;<br />
var b:typeA;<br />
<br />
typeA::=typeA::const;<br />
var c:typeA;<br />
};<br />
<br />
This example demonstrates assigning types and chains to existing type variables. At lines two and three we declare the type variable ''typeA'' and use it in the declaration of program variable ''a''. However, then on line five we modify the value of the type variable, ''typeA'' using the ''::='' operator to be a [[String]] instead. Then on line six we declare variable ''b'' using this type variable, which effectively sets the type to be a String. Line eight demonstrates how we can use the type variable in type chain modification and variable ''c'' is a constant [[String]].<br />
<br />
'''Note:''' It is important to appreciate that type variables exist only during compilation, they do not exist at runtime and as such can not be used in conditional statements.<br />
<br />
== Types of program variables ==<br />
<br />
Mesham provides some additional keywords to help manage and reference the type of program variables, however it is imperative to remember that these are static only i.e. only exist during compilation.<br />
<br />
=== Currenttype ===<br />
<br />
Mesham has an inbuilt [[Currenttype|currenttype]] keyword which will result in the current type chain of a program variable. <br />
<br />
a:currenttype a :: const;<br />
a:a::const<br />
<br />
In this code snippet both lines of code are identical, they will set the type of program variable ''a'' to be the current type chain combined with the [[Const|const]] type. Note that using a program variable in a type chain such as in the snippet above is a syntactic short cut for the current type (using the [[Currenttype|currenttype]] keyword) and either can be used.<br />
<br />
=== Declaredtype ===<br />
<br />
It can sometimes be useful to reference or even revert back to the declared type of a program variable later on in execution. To do this we supply the [[Declaredtype|declaredtype]] keyword.<br />
<br />
function void main() {<br />
var a:Int;<br />
a:a::const;<br />
a:declaredtype a;<br />
a:=23;<br />
};<br />
<br />
This code will compile and work fine because, although we are coercing the type of ''a'' to be that of the [[Const|const]] type at line three, on line four we are reverting the type to be the declared type of the program variable. If you are unsure about why this is the case, then move the assignment around to see when the code will not compile with it.<br />
<br />
== An example ==<br />
<br />
Type variables are commonly used with [[Record|records]] and [[Referencerecord|referencerecords]]. In fact, the [[Complex|complex]] type obtained from the [[:Category:Maths_Functions|maths library]] is in fact a type variable. <br />
<br />
#include <string><br />
#include <io><br />
<br />
typevar node;<br />
node::=referencerecord[Int, "data", node, "next"];<br />
function void main() {<br />
var i;<br />
var root:node;<br />
root:=null;<br />
for i from 0 to 9 {<br />
var newnode:node;<br />
newnode.data:=i;<br />
newnode.next:=root;<br />
root:=newnode;<br />
};<br />
while (root != null) {<br />
print(itostring(root.data)+"\n");<br />
root:=root.next;<br />
};<br />
};<br />
<br />
This code will build up a linked list of numbers and then walk it, displaying each number as it goes. Whilst it is a relatively simple code, it illustrates how one might use type variables to improve the readability of their code. One important point to note is a current limitation in the Mesham parser and that is the fact that we are forced to declare the type variable ''node'' on line four and then separately assign to it at line five. The reason for this is that in this assignment we are referencing back to the ''node'' type variable in the [[Referencerecord|referencerecord]] type and as such it must exist.<br />
<br />
== Limitations ==<br />
<br />
There are some important limitations to note about the current use of types. Types currently only exist explicitly during compilation - what this means is that you can not do things such as passing them into functions or communicating them. Additionally, once allocation information (the [[Allocated|allocated]] type) and its subtypes have been set then you can not modify this, nor can you change the [[:Category:Element_Types|element type]].<br />
<br />
[[Category: Tutorials|Advanced Types]]</div>Polashttp://www.mesham.com/index.php?title=Exp&diff=1331Exp2019-04-15T15:45:04Z<p>Polas: 2 revisions imported</p>
<hr />
<div>== Overview ==<br />
<br />
This exp(x) function will return the exponent of ''x'' (e to the power of ''x'').<br />
<br />
* '''Pass:''' A [[Double]]<br />
* '''Returns:''' A [[Double]] representing the exponent<br />
<br />
== Example ==<br />
<br />
#include <maths><br />
<br />
function void main() {<br />
var a:=exp(23.4);<br />
};<br />
<br />
''Since: Version 1.0''<br />
<br />
[[Category:Function Library]]<br />
[[Category:Maths Functions]]</div>Polashttp://www.mesham.com/index.php?title=MediaWiki:Aboutsite&diff=1333MediaWiki:Aboutsite2019-04-15T15:45:04Z<p>Polas: 1 revision imported</p>
<hr />
<div>About Mesham</div>Polashttp://www.mesham.com/index.php?title=Findchar&diff=1336Findchar2019-04-15T15:45:04Z<p>Polas: 2 revisions imported</p>
<hr />
<div>== Overview ==<br />
<br />
This findchar(s, c) function will return the index of the first occurrence of character ''c'' in string ''s''.<br />
<br />
* '''Pass:''' A [[String]] and [[Char]]<br />
* '''Returns:''' An [[Int]]<br />
* '''Throws:''' The error string ''notfound'' if the character does not exist within the string<br />
<br />
== Example ==<br />
<br />
#include <string><br />
<br />
function void main() {<br />
var a:="hello";<br />
var c:=findchar(a,'l');<br />
};<br />
<br />
''Since: Version 1.0''<br />
<br />
[[Category:Function Library]]<br />
[[Category:String Functions]]</div>Polashttp://www.mesham.com/index.php?title=Findrchar&diff=1339Findrchar2019-04-15T15:45:04Z<p>Polas: 2 revisions imported</p>
<hr />
<div>== Overview ==<br />
<br />
This findrchar(s, c) function will return the index of the last occurrence of character ''c'' in string ''s''.<br />
<br />
* '''Pass:''' A [[String]] and [[Char]]<br />
* '''Returns:''' An [[Int]]<br />
* '''Throws:''' The error string ''notfound'' if the character does not exist within the string<br />
<br />
== Example ==<br />
<br />
#include <string><br />
<br />
function void main() {<br />
var a:="hello";<br />
var c:=findrchar(a,'l');<br />
};<br />
<br />
''Since: Version 1.0''<br />
<br />
[[Category:Function Library]]<br />
[[Category:String Functions]]</div>Polashttp://www.mesham.com/index.php?title=Findstr&diff=1342Findstr2019-04-15T15:45:04Z<p>Polas: 2 revisions imported</p>
<hr />
<div>== Overview ==<br />
<br />
This findstr(s, s2) function will return the index of the first occurrence of search string ''s2'' in text string ''s''.<br />
<br />
* '''Pass:''' Two [[String|Strings]]<br />
* '''Returns:''' An [[Int]]<br />
* '''Throws:''' The error string ''notfound'' if the character does not exist within the string<br />
<br />
== Example ==<br />
<br />
#include <string><br />
<br />
function void main() {<br />
var a:="hello";<br />
var c:=findstr(a,'el');<br />
};<br />
<br />
''Since: Version 1.0''<br />
<br />
[[Category:Function Library]]<br />
[[Category:String Functions]]</div>Polashttp://www.mesham.com/index.php?title=Mesham_parallel_programming_language:About&diff=1311Mesham parallel programming language:About2019-04-15T15:45:03Z<p>Polas: 1 revision imported</p>
<hr />
<div>#REDIRECT [[What_is_Mesham]]</div>Polashttp://www.mesham.com/index.php?title=Mesham_parallel_programming_language:General_disclaimer&diff=1314Mesham parallel programming language:General disclaimer2019-04-15T15:45:03Z<p>Polas: 2 revisions imported</p>
<hr />
<div>= No warranty of any kind =<br />
<br />
Mesham makes no guarantee of validity or safety of the information contained or copied from this site. This site contains source code, binary executables and documentation which can be used to in the creation of source code. The information contained here is for research purposes and should be verified by yourself as accurate before use. Any software (source or binary) created by the information contained here or software located at this site has the following disclaimer:<br />
<br />
<pre><br />
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br />
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br />
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br />
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br />
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br />
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br />
THE SOFTWARE.<br />
</pre><br />
<br />
We strongly advise that you virus check all downloaded software, regardless of origin, before use.</div>Polashttp://www.mesham.com/index.php?title=Mesham_parallel_programming_language:Privacy_policy&diff=1316Mesham parallel programming language:Privacy policy2019-04-15T15:45:03Z<p>Polas: 1 revision imported</p>
<hr />
<div>=Privacy Policy=<br />
<br />
Where possible Mesham will attempt to respect your privacy. No information collected will be shared with third parties. This includes such data as server logs and the information not publicly shared by authors and editors. Mesham is located in the United Kingdom, and may be required to compile with legal requests to identify people if they commit illegal activities on this site. Please, no wazes, virus writing, OS exploiting, or links to those types of activities. Please do not add you private information unless you are sure you want it shared as deleting content in the wiki does not permanently remove it. Do not post other peoples private information.</div>Polas