Convey vector example: Difference between revisions

From Cpre584
Jump to navigation Jump to search
Ktown (talk | contribs)
New page: Note we are having difficulty running this example <br /> Convey allows you to write c/c++ or fortran code that is compiled to run on the co-processor. This is done by changing loops into...
 
Ktown (talk | contribs)
No edit summary
Line 6: Line 6:
  #pragma cny begin_coproc
  #pragma cny begin_coproc
     for(i = 0; i < n; i++){
     for(i = 0; i < n; i++){
         x[i] = x[i] * y[i];
         x[i] = x[i] + y[i];
     }
     }
  #pragma cny end_coproc
  #pragma cny end_coproc
Line 17: Line 17:
     int i;
     int i;
     for(i = 0; i < n; i++){
     for(i = 0; i < n; i++){
         x[i] = x[i] * y[i];
         x[i] = x[i] + y[i];
     }
     }
  }
  }

Revision as of 22:14, 1 February 2012

Note we are having difficulty running this example

Convey allows you to write c/c++ or fortran code that is compiled to run on the co-processor. This is done by changing loops into vector opererations. Below is an example of a function that can be compiled to run with the co-processor

void SimpleVectorAdder(int x[], int y[], int n){
    int i;
#pragma cny begin_coproc
    for(i = 0; i < n; i++){
        x[i] = x[i] + y[i];
    }
#pragma cny end_coproc
}

or

void SimpleVectorAdder(int x[], int y[], int n){
#pragma cny dual_target
    int i;
    for(i = 0; i < n; i++){
        x[i] = x[i] + y[i];
    }
}