HMCS-G (Grid-enabled Heterogeneous Multi-Computer System for Gravity) 1.1 Trial Kit

Sample Code of HMCS-G Client

Table of Contents

Links to other contents


Sample code-1: gg6test.c

gg6test.c is something like "ping" command for network reachability check. Giving the number of particles and iterations, it sends a request for dummy calculation with the specified number of particles, receives the result, and iterates these actions for specified cycles. You have to try this program first to verify the correctness of your installation of HMCS-G API library and your request is certainly served by our server.

The source code and Makefile are found in:

/Software/HMCS-G_Trial_Kit/sample/gg6test
To compile it, just type
% make
at this directory. The Makefile assumes that your HMCS-G client API library is installed in default system directory. If you changed it, you have to modify HMCSGTOP macro in Makefile.

You are strongly recommended to run this sample code first before running any other codes including the next sample code (gcalc.c) because it will check the network reachability to our HMCS-G server and the authentication with RSA key. Without them, HMCS-G does not work correctly.

The usage of gg6test is as follows:

gg6test [OmniRPC-options] server #particles #iteration
You can specify option-flags for OmniRPC at OmniRPC-options. At least, you have to specify ``--ssh'' option for HMCS-G trial account. server specifies the host name of HMCS-G server. If you have your own account on the server and the user name is same as that on your machine to run the client program, you have to specify only the server host name. Otherwise, using another user name as service account of HMCS-G server, you have to specify the server host name in ``username@servername'' style. #particles and #iteration specify the number of target particles to be tested and the number of iteration of the loop, respectively.

After you recored RSA private key for trial account, run the program with the server name ``hmcsg@hmcs-gw.ccs.tsukuba.ac.jp''. For instance, the following command

% gg6test --ssh hmcsg@hmcs-gw.ccs.tsukuba.ac.jp 1000 10
executes the program with 1000 particles and 10 times of iteration. It is a good start just for checking the system run correctly. Do not try heavy use something like ``#particles=500000'' and ``#iteration=1000'' at first time.

If the program runs successfully, you can see the following output on your display.

ITR 0: service time = 0.110000
ITR 1: service time = 0.110000
ITR 2: service time = 0.120000
ITR 3: service time = 0.120000
ITR 4: service time = 0.110000
ITR 5: service time = 0.120000
ITR 6: service time = 0.110000
ITR 7: service time = 0.120000
ITR 8: service time = 0.110000
ITR 9: service time = 0.120000
It shows 10 times of HMCS-G service call runs correctly. ``service time'' means the internal service time at HMCS-G server including pure computation time for gravity and all other overhead except communication latency.

Sample code-2: gcalc.c

This program is a graphical sample code for actual computation of gravity. First, a specified number of particles are randomly distributed in a 3-D space. Then a request for gravity calculation on all particles is sent and the result is received. After that, a simple time-integration to determine the movement of all particles are calculated with the result (acceleration). This part is performed by the client program itself. Finally, new coordinate of all particles are determined and displayed on X-window. Since the problem space is in 3-D, just a slice of X-Y plane which crosses the central point of Z-axis is shown, and all particles' X-Y coordinates are vertically mapped on to the plane. The program iterates these steps for specified time step, so all particles seem to concentrate to the center of the plane and you can observe it on the display.

The source code and Makefile are found in:

/Software/HMCS-G_Trial_Kit/sample/gcalc
To compile it, just type
% make
at this directory. The Makefile assumes that your HMCS-G client API library is installed in default system directory. If you changed it, you have to modify HMCSGTOP macro in Makefile. Upon the compilation of ``gcalc'', X-window system must be correctly installed as the default of RedHat Linux. Otherwise, you have to modify several macros for X-window application compilation in Makefile.

The usage of gcalc is as follows:

gcalc [OmniRPC-options] [-d] {c|b} server #particles #iteration dt [interval]
OmniRPC-options is the same as that in gg6test above. The meaning of remaining arguments are as follows.

-d This is an optional argument for debugging. With this flag, all coordinate of all particles are displayed at each time step.
b|c You can select one of them for the shape of initial random distribution of particles. b stands for ``ball'' which means all particles have a shape like 3-D ball (actually it seems like a circle on 2-D plane). c stands for ``cube'' which means all particles have a shape like 3-D cube (actually it seems like a square on 2-D plane).
server Specifies HMCS-G server. It is similar to that of gg6test.
#particles Specifies the number of particles. Similar to gg6test.
#iteration Specifies the number of loop iteration. Similar to gg6test.
dt Delta-T, the physical time step length in the simulation. It is simply multipied to the acceleration to get the moving speed of particles, then the speed is multiplied again to determine the coordinates of particles at the next time step. Thus, the time-integration scheme in this program is a simple Euler method. You have to specify dt carefully because too large number makes an explosion on the calculation. For thousands of particles with hundreds of iterations, a figure ranged in 0.001 - 0.01 is suitable..
interval This is an optional argument to adjust the output frequency to display X-window image. The default value is 1, which means movement of particles is shown at every time step. If it is specified, the snap shot with this interval is displayed. For example, if 10 is specified, the output is shown at every 10 time steps.

Running the program, a window to display 2-D projection of particles in 3-D problem space is made on X-window system. It shows the movement of particles in time steps. In the text window where you invoked the program, simple time stepping and service time on HMCS-G server are displayed similar to gg6test. After completion of the calculation, the window displays the final snap shot, then stops. To finish the program, you have to click any place in the display window.


Last Update: November 7th, 2005
HMCS-G Research Team: Taisuke Boku (taisuke@cs.tsukuba.ac.jp)