slide 21 of 40


Compute Pi Using AFAPI RSM

#include 
#include 
#include "afapi.h"

p_64f pi = 0.0;       /* Approximation to pi (shared) */
s_lock pilock = S_INITLOCK; /* Lock for updates on pi */

main(int argc,
char **argv)
{
  register double width, localsum;
  register int intervals, i;

  /* check-in with AFAPI and enable signals */
  if (p_init()) exit(1);
  if (s_init()) exit(1);

  /* get the number of intervals */
  intervals = atoi(argv[1]);
  width = 1.0 / intervals;

  /* do the local computations */
  localsum = 0;
  for (i=IPROC; i