Line | |
---|
1 | |
---|
2 | #include "stdio.h" |
---|
3 | |
---|
4 | #define NPIXELS 128 |
---|
5 | #define NLINES 128 |
---|
6 | #define NORM 46 |
---|
7 | #define RANGE 9 |
---|
8 | |
---|
9 | extern struct plouf NB_PROCS; |
---|
10 | |
---|
11 | int input[NLINES][NPIXELS]; |
---|
12 | int output[NLINES][NPIXELS]; |
---|
13 | |
---|
14 | int kernel[9] = { 1, 2, 4, 8, 16, 8, 4, 2, 1 }; |
---|
15 | |
---|
16 | ///////////////////// |
---|
17 | void filter(int line) |
---|
18 | { |
---|
19 | int p; |
---|
20 | int k; |
---|
21 | int x; |
---|
22 | int accu; |
---|
23 | |
---|
24 | for ( p = 0 ; p < NPIXELS ; p++ ) |
---|
25 | { |
---|
26 | accu = 0; |
---|
27 | for ( k = 0 ; k < RANGE ; k++ ) |
---|
28 | { |
---|
29 | if ( (p - k) < 0 ) x = 0; |
---|
30 | else if ( (p - k) >= (NPIXELS - 1) ) x = NPIXELS - 1; |
---|
31 | else x = p - k; |
---|
32 | accu += (input[line][x] * kernel[k]); |
---|
33 | } |
---|
34 | output[line][p] = accu/NORM; |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | ////////// |
---|
39 | int main() |
---|
40 | { |
---|
41 | int nb_procs = (int)&NB_PROCS; |
---|
42 | int my_index = procid(); |
---|
43 | int time; |
---|
44 | int line; |
---|
45 | |
---|
46 | tty_printf("processor %d is alive!\n\n", my_index); |
---|
47 | |
---|
48 | for ( line = 0 ; line < NLINES ; ++line ) |
---|
49 | { |
---|
50 | if ( (line % nb_procs) == my_index ) |
---|
51 | { |
---|
52 | time = proctime(); |
---|
53 | tty_printf("processor %d processing line %d at time %d\n", my_index, line, time); |
---|
54 | filter(line); |
---|
55 | } |
---|
56 | } |
---|
57 | |
---|
58 | tty_printf("\nprocessor %d completed at time %d\n", my_index, time); |
---|
59 | |
---|
60 | exit(); |
---|
61 | |
---|
62 | return 0; |
---|
63 | } |
---|
64 | |
---|
65 | |
---|
Note: See
TracBrowser
for help on using the repository browser.