Convey vector example

From Cpre584
Jump to navigation Jump to search

The following is a short example on loop unrolling; for more information, see section 5 of the Convey Programmers Guide (.pdf).

Note that Team Slytherin (author) 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];
    }
}