8 inline void print_image(
int width,
int height,
int max,
unsigned char img[width][height])
11 printf(
"P2\n%d %d\n%d\n", width, height, max);
12 for (j = 0; j < height; j++)
14 for (i = 0; i < width; i++)
17 printf(
"%d ",
img[i][j]);
25 #define DECIMAL_PLACES 28 26 #define int2fixed(num) ((num) << DECIMAL_PLACES) 27 #define fixedmul(a, b) ((((long long)a) * ((long long)b)) >> DECIMAL_PLACES) 28 #define fixed2int(num) ((num) >> DECIMAL_PLACES) 36 #define OPS_PER_ACCEL HEIGHT/NUM_ACCEL 57 for (j = startidx; j <
maxidx; j++)
59 for (i = 0; i <
WIDTH; i++)
62 int x_0 =
int2fixed(-2) + ((((3 << 20) * i / WIDTH) ) << 8);
69 unsigned char fiter = 0;
71 for (iter = 0; iter <
MAX_ITER; iter++)
83 unsigned char colour = (fiter >=
MAX_ITER) ? 0 : 1;
91 pthread_exit((
void*)count);
98 legup_start_counter(0);
100 int final_result = 0;
110 if (i == NUM_ACCEL - 1)
116 data[i].
maxidx = (i + 1) * OPS_PER_ACCEL;
131 pthread_join(threads[i], (
void**)&count[i]);
137 final_result += count[i];
150 for (j = 0; j <
HEIGHT; j++)
152 for (i = 0; i <
WIDTH; i++)
154 final[i][j] =
img[i][j];
166 int perf_counter = legup_stop_counter(0);
167 printf(
"perf_counter = %d\n", perf_counter);
169 printf(
"Count: %d\n", final_result);
170 if (final_result == 12013)
void print_image(int width, int height, int max, unsigned char img[width][height])
volatile unsigned char img[WIDTH][HEIGHT]
x
Return the smallest n such that 2^n >= _x.