Optimization Topics/Exercise 01: Difference between revisions
From Wiki**3
No edit summary |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 3: | Line 3: | ||
# Traduza-a para Postfix optimizado. | # 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 11: | 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;
}