본문 바로가기
csapp

5.3 Program Example

by 정구지개발자 2023. 5. 16.
728x90

 

  • The declaration uses data_t to designate the data type of the underlying elements.
  • We allocate the data array block to store the vector elements as an array of len objects of type data_t.

 

 

 

  • An important feature to note is that get_vec_element, the vector access routine, performs bounds checking for every vector reference

 

 

 

 

5.4 Eliminating Loop Inefficiencies

 

 

  • This optimization is an instance of a general class of optimizations known as code motion
  • Figure 5.5 와 Figure 5.6 의 차이는 loop속에 vec_length함수가 들어가서 loop가 돌떄마다 함수를 계속 호출하냐 안하냐 차이
  • To improve the code, the programmer must often help the compiler by explicitly performing code motion.

 

 

 

  • Function lower2 shown in Figure 5.7 is identical to that of lower1, except that we have moved the call to strlen out of the loop.
  • In an ideal world, a compiler would recognize that each call to strlen in the loop test will return the same result, and thus the call could be moved out of the loop.
728x90

'csapp' 카테고리의 다른 글

5.7.2 Functional Unit Performance  (0) 2023.05.18
5.7 Understanding Modern Processors  (0) 2023.05.17
5. Optimizing ProgramPerformance  (0) 2023.05.15
Diminishing Returns of Deep Pipelining  (0) 2023.05.08
4.4 General Principles of Pipelining  (0) 2023.05.05

댓글