Parallel programming with OpenMP

We can do parallel programming by calling OmniRpcCall on a multi-thread program with Omni OpenMP, which is one of OpenMP compiler of an implementation using a thread. We show an example as follows.

#include <OmniRpc.h>
#include <stdio.h>
#include <math.h>

int main(int argc,char *argv[]){
   int i;
   double x, res[10];
   OmniRpcRequest req[10];

   OmniRpcInit(&argc,&argv);

   x = 0.0;
#pragma omp parallel for
   for(i = 0; i <; 10; i++){
       req[i] = OmniRpcCall("calc_sin",x,&res[i]);
       x += 1.0;
   }
   for(i = 0; i < 10; i++) 
      printf("sin(%d)=%g\n",i,res[i]);

  OmniRpcFinalize();

}

When you want to run this program, remember to set the OMP_NUM_THREADS environmental value, which specifies the number of OpenMP threads, to a value more than the number of remote hosts.