<< Chapter < Page Chapter >> Page >
The creation of this content was supported in some part by NSF grant 0538934.

In 1985, by design, G was developed to address and simplify parallel programming. If you have gone through the examples in this book, you have already developed various parallel programs.

In the following example, we will develop a simple program where interactivity and parallelism are part of the program.

A diagram of Parallel Programming. The diagram consists of two rows of icons. The upper row from left to right consist of an orange box contina '0.02' over a blue box containg 'i'. lines connect these icons to a triangular icon with apex pointing right and it contains 'x'. A line connects this to a graph icon and then that is connected to another triangle icon and that triangle that points to a final graph icon labeled 'sine wave'. The bottom row of icons consist of an orange icon labeled 'amplitude' which connects via a line to the second triangle in the upper row. To the right of the 'Amplitude' icon is  'stop' button icon.
Select Diagram for Parallel Programming

From the menu select Edit>>Copy .

A typical edit menu in Windows with the item 'copy' highlighted.
Copy Selected Diagram

Create a copy of the while loop and its contents by selecting Edit>>Paste . Organize the diagram as shown in the figure below.

A diagram of two Parallel Programming diagrams. The diagrams consist of two rows of icons and are idenitical except for a names of icons. The upper row from left to right they consist of an orange box contina '0.02' over a blue box containg 'i'. lines connect these icons to a triangular icon with apex pointing right and it contains 'x'. A line connects this to a graph icon and then that is connected to another triangle icon and that triangle that points to a final graph icon labeled 'sine wave'. In the second diagram the final icon is labeled 'sine wave 2'. The bottom row of icons consist of an orange icon labeled 'amplitude' or 'amplitude 2' for the second diagram which connects via a line to the second triangle in the upper row. To the right of the 'Amplitude' icon is  'stop' button icon.
Paste Diagram

Go the Front Panel window and organize the input and output controls as shown in the figure below.

Two parallel empty graphs.
Parallel G Program

You have just completed your first parallel interactive program using G. Save the program, run it and interact with it.

Two parallel graphs containing sine waves. The graph on the left contains a sine wave with a large amplitude than the one on the rightt.
Parallel Interactive G Program

To end this program click on the stop and stop 2 terminals.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Introduction to g programming. OpenStax CNX. Mar 15, 2010 Download for free at http://cnx.org/content/col11192/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Introduction to g programming' conversation and receive update notifications?

Ask