Optimization Topics/Exercise 01: Difference between revisions
From Wiki**3
Created page with "Considere a seguinte função em C: (i) Que optimizações independentes da máquina são possíveis? (ii) Traduza-a para Postfix optimizado. <c> int *fun(int *a, int *b) { in..." |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
Considere a seguinte função em C: | Considere a seguinte função em C: | ||
# Que optimizações independentes da máquina são possíveis? | |||
# Traduza-a para Postfix optimizado. | |||
<c> | <source lang="c"> | ||
int *fun(int *a, int *b) { | int *fun(int *a, int *b) { | ||
int *c = (int *)malloc(160 * 4), i, j; | int *c = (int *)malloc(160 * 4), i, j; | ||
| Line 9: | Line 11: | ||
return c; | return c; | ||
} | } | ||
</ | </source> | ||
Latest revision as of 18:05, 14 May 2019
Considere a seguinte função em C:
- Que optimizações independentes da máquina são possíveis?
- Traduza-a para Postfix optimizado.
int *fun(int *a, int *b) {
int *c = (int *)malloc(160 * 4), i, j;
for (j = 0; j < 40; ++j)
for (i = 0; i < 4; ++i)
c[i+j*4] = a[i+j*4] + b[i*40+j] + 100*j;
return c;
}