3.2. Running Sample Code

Ninf-G contains some sample applications which you can use to both test your installation and get started learning how to write Ninf-G code. In order to run these examples you must first copy the source code into your home directory. Please follow the steps in the below example to create a ng-samples directory at the top of your home directory. In addition to copying the sample code to your home directory all of the Ninf-G client.conf files are re-written to specify local host as the RPC server machine.

$ cd /opt/ng/test/samples/
$ make
if [ ! -d /home/mjk/ng-samples ]; then                          \
        mkdir -p /home/mjk/ng-samples;                          \
fi
cp -pR pi pi_mpi add /home/mjk/ng-samples
for d in pi pi_mpi add; do                                      \
        cd /home/mjk/ng-samples/$d;                             \
        sed -e s%example.org%`/bin/hostname`% client.conf > x;  \
        mv x client.conf;                                       \
        cd ..;                                                  \
done

$ cd ~/ng-samples
$ ls
add  pi  pi_mpi

A good example to begin with is the pi application (similar to the MPICH pi sample code). Running make will create a pi_client application which can then be used to test Grid RPC on the local machine through the loopback interface. Please refer to the Ninf-G documentation for how to run this across multiple machines.

$ cd ~/ng-samples/pi

$ ls
client.conf  Makefile  pi_client.c  pi.idl  pi_trial.c

$ make
[mjk@rocks-39 pi]$ make
/opt/ng/bin/ng_cc -g -o pi_client pi_client.c

cc -Wall -O2 -I/opt/ng/include -DNG_CPU_I386 -DNG_OS_LINUX -DPLAT_LINUX 
-DNGI_ARCHITECTURE_ID=12 -D_FILE_OFFSET_BITS=64 -D__USE_FIXED_PROTOTYPE
S__ -I/opt/ng/include -I/opt/nmi/include -I/opt/nmi/include/gcc32 -g -o
 pi_client pi_client.c -L/opt/ng/lib -lnggrpc -lngclient -lngcommon -ln
gnet -lngutility -lexpat -L/opt/nmi/lib -L/opt/nmi/lib -lglobus_gram_cl
ient_gcc32 -lglobus_gass_server_ez_gcc32 -lglobus_gram_protocol_gcc32 -
lglobus_gass_transfer_gcc32 -lglobus_io_gcc32 -lglobus_gss_assist_gcc32
 -lglobus_gssapi_gsi_gcc32 -lglobus_gsi_proxy_core_gcc32 -lglobus_gsi_c
redential_gcc32 -lglobus_gsi_callback_gcc32 -lglobus_oldgaa_gcc32 -lglo
bus_gsi_sysconfig_gcc32 -lglobus_gsi_cert_utils_gcc32 -lglobus_openssl_
gcc32 -lldap_gcc32 -llber_gcc32 -llutil_gcc32 -lglobus_proxy_ssl_gcc32 
-lglobus_openssl_error_gcc32 -lsasl_gcc32 -lssl_gcc32 -lcrypto_gcc32 -l
ltdl_gcc32 -lglobus_common_gcc32 -lm -lz -lm
/opt/ng/bin/ng_gen pi.idl
make -f pi.mak
make[1]: Entering directory `/home/mjk/ng-samples/pi'
cc -DNG_CPU_I386 -DNG_OS_LINUX -DPLAT_LINUX -DNGI_ARCHITECTURE_ID=12 -D
_FILE_OFFSET_BITS=64      -D__USE_FIXED_PROTOTYPES__  -I/opt/ng/include
  -I/opt/nmi/include -I/opt/nmi/include/gcc32  -c _stub_pi_trial.c
cc -DNG_CPU_I386 -DNG_OS_LINUX -DPLAT_LINUX -DNGI_ARCHITECTURE_ID=12 -D
_FILE_OFFSET_BITS=64      -D__USE_FIXED_PROTOTYPES__  -I/opt/ng/include
  -I/opt/nmi/include -I/opt/nmi/include/gcc32  -c pi_trial.c
cc  -o _stub_pi_trial _stub_pi_trial.o  -L/opt/ng/lib -lngexecutable -l
ngcommon -lngnet -lngutility -Wl,-R/opt/nmi/lib -L/opt/ng/lib -lexpat  
-L/opt/nmi/lib  -L/opt/nmi/lib -lglobus_gass_copy_gcc32 -lglobus_ftp_cl
ient_gcc32 -lglobus_gass_transfer_gcc32 -lglobus_ftp_control_gcc32 -lgl
obus_io_gcc32 -lglobus_gss_assist_gcc32 -lglobus_gssapi_gsi_gcc32 -lglo
bus_gsi_proxy_core_gcc32 -lglobus_gsi_credential_gcc32 -lglobus_gsi_cal
lback_gcc32 -lglobus_oldgaa_gcc32 -lglobus_gsi_sysconfig_gcc32 -lglobus
_gsi_cert_utils_gcc32 -lglobus_openssl_gcc32 -lglobus_proxy_ssl_gcc32 -
lglobus_openssl_error_gcc32 -lssl_gcc32 -lcrypto_gcc32 -lglobus_common_
gcc32 -lm -lz pi_trial.o 
./_stub_pi_trial -i _stub_pi_trial.inf
/opt/ng/bin/ng_gen_dif _stub_pi_trial

$ ./pi_client  10000000 `/bin/hostname`
counter = 7852825, times = 10000000
PI = 3.141130