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

Manuals of HMCS-G client API

Table of Contents

Links to other contents


General concept

Client API (Application Programming Interface) HMCS-G is a set of functions to provide easy and efficient access to HMCS-G server. You can describe your own client program which calls some of these functions appropriately to access HMCS-G server remotely. In version 1.0, we provide a minimum set of functions which is enough to describe basic programs with gravity calculation. We will enhance them for more flexible usage of GRAPE-6 system in near future. There are 6 functions in HMCS-G 1.0: In ordinary program, gg6init, gg6start and gg6end are called once in a program. Usually, a program consists of a big main loop in which the computation with gravity and other calculation is performed once at a time step then it is iterated with time-integration. To perform an iteration, gg6unit, gg6calc1 and gg6wait1 should be called in this order. The latter two functions have names ending ``1'' since they are for ``mode-1'' functions. Currently, only ``mode-1'' functions are supported in HMCS-G 1.0. Thus, a typical construction of a program is as follows:

(If the above picture is difficult to read, check this PDF version.)

Some programs may skip the step "calculation without gravity" if there is nothing behind the gravity calculation service. With this step, you can overlap your internal calculation with gravity service by GRAPE-6. Here, both client and server run asynchronously and you can hide the communication latency.

After gravity calculation result (acceleration of all particles) is returned, the client program performs calculation with it. Finally, new coordinate of all particles are determined, and the next loop iteration begins.


gg6init()

SYNOPSIS:int gg6init(int *argc, char **argv)
/* argc : IN/OUT */
/* argv : IN/OUT */

gg6init passes the number and contents of main routine arguments to the initializer of grid-RPC. Before processing any command-line arguments of your program, you must call this function at first. gg6init read out the arguments for OmniRPC system, then returns remaining arguments. The first argument, which is usually the program name itself, still remains as the first one and others are packed again so that you can process variables argc and argv as usual.

About the command-line option arguments for OmniRPC, see OmniRPC on-line user's guide.


gg6start()

SYNOPSIS:gg6start(char *server, int *mode, int *error)
/* server: IN */
/* mode: IN */
/* error: OUT */

gg6start specifies the server host which serves all OmniRPC remote procedure call for HMCS-G as well as operation mode. The operation mode specified the service type. Currently, only one service type is supported in HMCS-G 1.0, so mode must be always ``1''.

An integer value to present error code is returned by error instead of the return value of the function itself. If there is no error, 0 is returned in argument error. Otherwise, some negative value is returned.


gg6unit()

SYNOPSIS:gg6unit(int *np, int *newunit_t, int *newunit_x, double *eps2, int *error)
/* np: IN */
/* newunit_t: IN */
/* newunit_x: IN */
/* error: OUT */

gg6unit specifies several important parameters for actual gravity calculation. np specifies the number of particles to be calculated. Since it can be specified every time before sending particle information, you can change the number of particles in a program according to the algorithm.

GRAPE-6 handles the time for predictor in 64-bit fixed point format. newunit_t specifies the binary point for it. For example, if newunit_t is set to be 40, GRAPE-6 can handle the time within the range -223 < t < 223, and the resolution is 2-40. Here, t is the time in simulation scale. newunit_x is same as newunit_t except that this is for the spacial coordinate of particles. It represents all scales for X, Y and Z dimensions.

GRAPE-6 introduces softening length to avoid the divergence of gravitational force for close pairs. For example, if the coordinate of a pair of particles to be calculated is so close, a divergence of gravitational force may happen over the computation range. Since GRAPE-6 targets collision-less system, this feature works well. eps2 specifies the square of usual plummer softening length.

About newunit_t, newunit_x and eps2, see "GRAPE-6 User's Guide".

An integer argument error is returned to indicate status of the function. If there is no error, 0 is returned. Otherwise, some negative number is returned.


gg6calc1()

SYNOPSIS:gg6calc1(double rmass[ ], double x[3][ ], double f_old[ ], double phi_old[ ], int *error)
/* rmass: IN */
/* x: IN */
/* f_old: IN */
/* phi_old: IN */
/* error: OUT */

gg6calc1 passes particle data to HMCS-G server, then returns without waiting for the result. Thus, it is asynchronous function with the server. All arguments except error are array variables to contain a set of particles. There must be particles of at least np specified in gg6start function.

rmass is an array to contain masses of all particles. x is a two-dimensional array to keep coordinates of particles in X-, Y- and Z-dimension. For the first dimension of the array, 0, 1 and 2 represent X-, Y- and Z-dimension, respectively.

f_old contains the maximum of three components of acceleration on previous time step for each particle. For the calculation of the first time step, it must be cleared with 0. phi_old contains the gravitational potential at the position of each particle on previous time step.

An integer argument error is returned to indicate status of the function. If there is no error, 0 is returned. Otherwise, some negative number is returned.

About f_old and phi_old, see "GRAPE-6 User's Guide".


gg6wait1()

SYNOPSIS:gg6wait1(double acc[3][ ], double pot[ ], double *servtime, int *error)
/* acc: OUT */
/* pot: OUT */
/* servtime: OUT */
/* error: OUT */

gg6wait1 waits for the returning of gravity calculation result after gg6calc1. acc and pot are array variables to carry results on all particles. acc contains three components of acceleration for each particle. pot contains the gravitational potential at the position of each particle.

servtime returns the actual service time in GRAPE-6 cluster for requested particles in second. It includes not only the pure computation time on GRAPE-6 board but also the overhead in parallel processes in GRAPE-6 cluster to coordinate the calculation distributed to those nodes.

An integer argument error is returned to indicate status of the function. If there is no error, 0 is returned. Otherwise, some negative number is returned.

About acc and pot, see "GRAPE-6 User's Guide".


gg6end()

SYNOPSIS:gg6end(int *error)
/* error: OUT */

gg6end finishes a sequence of gravity calculation and closes the channel to communicate with HMCS-G server.

An integer argument error is returned to indicate status of the function. If there is no error, 0 is returned. Otherwise, some negative number is returned.



Last Update: November 10th, 2003
HMCS-G Research Team: Taisuke Boku (taisuke@is.tsukuba.ac.jp)