Convey vector example: Difference between revisions
Jump to navigation
Jump to search
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... |
m Added link to relavent section of programmer's guide |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
Note | The following is a short example on loop unrolling; for more information, see section 5 of the [[Media:ConveyProgrammersGuide.pdf | 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 | 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 | ||
Line 6: | Line 8: | ||
#pragma cny begin_coproc | #pragma cny begin_coproc | ||
for(i = 0; i < n; i++){ | for(i = 0; i < n; i++){ | ||
x[i] = x[i] | x[i] = x[i] + y[i]; | ||
} | } | ||
#pragma cny end_coproc | #pragma cny end_coproc | ||
Line 17: | Line 19: | ||
int i; | int i; | ||
for(i = 0; i < n; i++){ | for(i = 0; i < n; i++){ | ||
x[i] = x[i] | x[i] = x[i] + y[i]; | ||
} | } | ||
} | } |
Latest revision as of 17:19, 14 February 2012
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]; } }