Abstract This article is mainly aimed at the Intel C + + 9.0 compiler in the Visual C + + 6.0 environment for some common functions of the optimization of the function of the test verification. Mainly from the use of the compiler before and after the running time comparison to judge. The test scope focuses on the switching time of the thread, the exception and the exception recovery time, the high priority thread preemptive time and the semaphore response time. In addition, the running time of some common mathematical functions is tested and compared. The test data and conclusion can be used for reference to the users of this compiler.
Keywords Intel c++,visual C + +, compiler, optimization
Introduction
Nowadays, many computer applications, such as weather forecast, signal processing and military trajectory tracking, are very high in the processing speed of the program. Otherwise, the result will be biased or lose its meaning. To improve the speed of the program, generally through the following aspects of the improvement measures to do: (1) The adoption of new processing faster hardware devices, such as faster CPU, more memory, and faster I/O devices. But this obviously leads to a substantial increase in costs and is not a practical improvement measure suitable for any unit. (2) More optimized program design methods, such as the introduction of multithreading in the program, parallel processing methods. This is a more effective method, of course, the level of the programmer and programmers have higher requirements. (3) Adopting some optimization software, this is also a simple and effective method. In addition, if it is used in conjunction with the other two methods, it will be very helpful for some situations that require a large increase in processing speed.
Using an optimized compiler is the third method described above. Due to the data correlation, conditional transfer and resource conflict, the instruction level parallelism is greatly restricted by the processor. By optimizing the compiler to reorganize the instruction sequence and using the software and hardware method to deal with data correlation, conditional transfer and resource conflict, the instruction level parallelism of the processor can be greatly improved, so that the instruction number can be fired as much as possible in a certain time. In addition, the optimization compiler can also be based on the size of the Advance Command window in the processor, there is no data-related, control-related and functional components conflict, or conflict and less relevant instructions are dispatched to the same Front command window, so that these instructions beyond its previous instructions to launch into the operating components, thereby increasing the utilization of functional components, This will further improve the performance of the processor.
Generally speaking, the optimal scheduling of the program requires the combination of software (mainly compiler) and hardware to achieve better scheduling effect. The Intel C + + compiler as a compiler specifically for the Intel-type processor, the combination of the two can theoretically achieve optimal scheduling, the implementation of the program can be some aspects of performance and a certain degree of improvement. The processor in the test should select the Intel family of products, the actual processor is Intel Pentium 4 processor (1.8GHZ), the memory is 256MB, the operating system considers versatility and universality, and the programming environment for Windows XP systems is Visual C + + 6.0.
Thread Extra cost test
For more and more multi-threaded programming applications, the overhead of threading, such as handoff time between threads, preemptive time of high priority thread, and response time of thread to semaphore, is an important aspect of restraining program execution speed. Reducing the extra overhead time of a thread makes sense to improve the speed of the program.
1, test indicators
This mainly includes four test metrics, (1) thread switching time. (2) Preemptive time for high priority threads. (3) Response time of semaphore. (4) Thread-turn exceptions and the exception recovery time.
2. Test method
In the test, the started thread begins an unconditional loop operation. Take the test of indicator (1) as an example, the loop only carries out the operation of the cumulative and thread switching operations, no additional operations until the end of the event, terminate the thread and give the number of runs and time. The test results are based on ignoring the cost of the thread itself, where the time spent by the thread itself is very small compared to the total amount of time spent by the test, and does not have much effect on the results of the calculation. In addition, if the thread itself added to the cost of the statistics, will introduce other operations, there will also be a certain amount of time overhead, there will still be errors. Each test project was tested five times, averaging the resulting five values.
3. Testing process
The test process here illustrates the test for indicator (1) as a flowchart, and the following three tests are similar.
4. Test steps
4.1 The basic steps of the thread switching time test
(1) Create two threads of the same priority 1 and 2.
(2) The running thread 1 gets the current run number of thread 1, and immediately switches to thread 2.
(3) The running thread 2 gets the current run number of thread 2, and immediately switches to thread 1.
(4) Repeat steps 2nd and 3rd until the end event is given.
(5) The total time spent by 2 to 4 steps and the number of times the two threads were run separately.
(6) Calculate the switching time between threads.
The time spent here is emplasedtime, the number of runs is runcount1 and Runcount2, then the switch time is emplasedtime/(runcount1+runcount2-1). The following items are similar.
Figure 1 Thread switch time test process