The $NETSOLVE_ROOT/Tutorial directory contains several tutorials which should demonstrate the use of NetSolve. It should be a starting point for new users to write their own programs and also shows how to enhance the capabilities of NetSolve by adding new functions to the repository. The tutorials do not depend on each other and can be performed in any order. However, if you are completly new to NetSolve it is recommended to perform the tutorials in the order described below, since some explanations are given in more detail in the first sections.
The first three examples include code sections for blocking and non-blocking calls as well as the task-farming feature. The last example (sparse) demonstrates how to include an existing application into NetSolve and uses only blocking codes, although it should be easy with the information from the previous tutorials to build non-blocking and farming calls too.
If some additional software is required to build the example a link to the sources is provided. The examples are designed that they can be performed in userspace (this includes the additional software that may be necessary).
Before you start a tutorial make sure that NetSolve is properply installed by running C_test and farm_test. If these functions do not work consult the NetSolve User Guide and fix the issue.
The following tutorials are included:
basic - demonstrates the use of the following basic data types: int, double, char; includes server library, PDF and client program
file - demonstrates the way of sending files with NetSolve to remotely execute programs; includes server library, PDF and client program
matrix - demonstrates the handling of matrices and vectors when performing a matrix - vector multiplication; includes client program
sparse - demonstrates how to include your own software library on the basis of an example which uses a solver for sparse linear systems, ie it uses the sparse matrix format; includes server library, PDF and client program
This tutorial develops a little library which performs a basic operation on two numbers. It shows how to compile and include the problem into the NetSolve repository and how to invoke the function. This include the following steps:
Building the library
Installing the problem to the NetSolve repository
Invoking the function via NetSolve
Requirements: The following files are needed (they should be in the current directory).
libcalc.c - Contains the function which should perform the calculation
calc.idl - A file which describes how the problem should be included into the NetSolve repository (Interface Definition Language)
myprog.c - An example program which invokes the newly created NetSolve function
Instructions
1. Building the Library
NetSolve provides all functions through statically linked libraries. Execute the following steps on the server to build libcalc.a
UNIX> gcc -c libcalc.c UNIX> ar rc libcalc.a libcalc.o |
2. Installing the Problem to the NetSolve Repository
Use idltopdf to convert povray.idl to povray.pdf. Then copy povray.pdf to your problems subdirectory and add an entry in the file NETSOLVE_ROOT/server_config. Set NSPOVRAY_LIB to the path where libpovray.a is located and recompile the server with the command:
UNIX> make server |
![]() | Note: |
---|---|
Since the library makes an external call to a program it can not take advantage of the Hardware/Software server feature of NetSolve (i.e., it cannot be transfered from one server to another). To mark a problem as non-moveable use the keyword NONMOVEABLE in the IDL. |
3. Invoking the Function Via NetSolve The file myprog.c demonstrates how to invoke the function calc via NetSolve. When you compile it you have to provide the include and library directory of NetSolve. Set the NETSOLVE_ROOT environment variable to your NetSolve directory and NETSOLVE_AGENT to your architecture (you can use the following or similar shell script to set it).
UNIX> export NETSOLVE_ARCH=`$NETSOLVE_ROOT/conf/config.guess | sed 's/[-|.]/_/g'` |
UNIX> gcc myprog.c -o myprog -I$NETSOLVE_ROOT/include -lnetsolve \ -L$NETSOLVE_ROOT/lib/$NETSOLVE_ARCH |
UNIX> myprog 1 2.1 + |
UNIX>myprog 0 <number of requests> |
UNIX>myprog 1 <number of requests> |
![]() | Note: |
---|---|
Be sure to have an agent and your newly compiled server running. Also check that the NETSOLVE_AGENT enironment variable is set (it should be the same value as the "@AGENT:" line in server_config in the NetSolve directory). |