Cirrus Logic CS485 Manuale Utente Pagina 2

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 67
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 1
CS485G Spring 2015 2
3 Abstraction and reality
1. Most CS and CE courses emphasize abstraction; it matches how we
think, and it lets us hide implementation details and complexity.
2. But hardware has limits that our abstractions lack (maximum size of
an integer, for instance). If we hide implementation details, we are at
risk of inefficiency and inability to cooperate with other components.
3. Examples
(a) C int is not an integer: 50000*50000 = 2500000000, but the int
is -1794967296.
(b) C float is not real: 1e20 + 3.14 - 1e20 = 3.14, but the float result
is 0.0.
(c) Programming languages hide the instructions that are executed
(d) Layout in memory affects performance (caches, pages). Exam-
ple:
1 #define BIG 10000
2 void copyij(int src[BIG][BIG], int dst[BIG][BIG])
3 {
4 int row, col;
5 for (row = 0; row < BIG; row += 1) // reorder?
6 for (col = 0; col < BIG; col += 1) // reorder?
7 dst[row][col] = src[row][col];
8 }
9 int from[BIG
*
BIG], to[BIG
*
BIG];
10 copyij(from, to);
One experiment shows that in the order given, user time is 0.22
seconds; with interchanged order, user time is 1.13 seconds.
4. We no longer teach assembler-language programming, because com-
pilers are much better and more patient than assembler-language
programmers.
5. But you need to understand computation at the assembler level.
(a) When your program has a bug, high-level models can fail.
(b) To improve performance, you need to understand what opti-
mizations the compiler can and cannot do.
(c) When you write system software, what actually runs is machine
code.
Vedere la pagina 1
1 2 3 4 5 6 7 ... 66 67

Commenti su questo manuale

Nessun commento