code example
HMPP CAPS Hybrid Multi-core Parallel Programming Environment



#pragma hmpp code1 codelet, &
#pragma hmpp code1 target=CUDA:BROOK:PTHREADSSE:PTHREAD:SSE, &
#pragma hmpp code1 args[x,e].io=inout
static void sub1(int n, float x[n], float y[n+2], float e[1]) {
  int i;
  float e_local = e[0];
  // do computation
  for (i=0; i<n; ++i) {
   x[i] += ( y[i+2] + y[i] )*.5;
   e_local += y[i+1] * y[i+1];
  }
  e[0] = e_local;
}

int main(int argc, char *argv[]) {
  int n = ...;
  float *x, *y;
  x = new float[n+1];
  y = new float[n+1];

  ... // fill x, y

  float e = 0;
  #pragma hmpp code1 callsite
  sub1(n-1, &x[1], &y[1-1], &e);

  ... // output x, e

  delete[] x, y;
  return 0;
}

[start] [references] [download] [install]