Last change
on this file since 743 was
432,
checked in by alain, 10 years ago
|
1) Introduce the "applications" directory.
2) Introduce the fixed format (X_WIDTH / Y_WIDTH / P_WIDTH) for processor index in all applications.
|
File size:
1.1 KB
|
Rev | Line | |
---|
[191] | 1 | #include "stdio.h" |
---|
[295] | 2 | #include "hard_config.h" |
---|
[191] | 3 | |
---|
| 4 | ///////////////////////////////////////// |
---|
| 5 | __attribute__ ((constructor)) void main() |
---|
| 6 | { |
---|
| 7 | unsigned int opx; |
---|
| 8 | unsigned int opy; |
---|
| 9 | |
---|
[432] | 10 | // get processor identifiers |
---|
| 11 | unsigned int x; |
---|
| 12 | unsigned int y; |
---|
| 13 | unsigned int lpid; |
---|
| 14 | giet_proc_xyp( &x, &y, &lpid ); |
---|
[191] | 15 | |
---|
[295] | 16 | giet_tty_printf( "*** Starting task pgcd on processor[%d,%d,%d] at cycle %d\n\n", |
---|
| 17 | x, y, lpid, giet_proctime() ); |
---|
| 18 | |
---|
[191] | 19 | while (1) |
---|
| 20 | { |
---|
| 21 | giet_tty_printf("\n*******************\n"); |
---|
| 22 | giet_tty_printf("operand X = "); |
---|
| 23 | giet_tty_getw( &opx ); |
---|
| 24 | giet_tty_printf("\n"); |
---|
| 25 | giet_tty_printf("operand Y = "); |
---|
| 26 | giet_tty_getw( &opy ); |
---|
| 27 | giet_tty_printf("\n"); |
---|
| 28 | if( (opx == 0) || (opy == 0) ) |
---|
| 29 | { |
---|
[254] | 30 | giet_tty_printf("operands must be larger than 0\n"); |
---|
[191] | 31 | } |
---|
| 32 | else |
---|
| 33 | { |
---|
| 34 | while (opx != opy) |
---|
| 35 | { |
---|
| 36 | if(opx > opy) opx = opx - opy; |
---|
| 37 | else opy = opy - opx; |
---|
| 38 | } |
---|
| 39 | giet_tty_printf("pgcd = %d\n", opx); |
---|
| 40 | } |
---|
| 41 | } |
---|
| 42 | } // end pgcd |
---|
| 43 | |
---|
Note: See
TracBrowser
for help on using the repository browser.