This is the daily pratice No.202001 of the team for supercomputer in Southwest Petroleum University(西南石油大学超算与并行计算团队).
The MathJax cannot be displayed rightly on github, you can download it and display it under other MarkDown viwevers.
├── XiaZhuozhao --my answer
│ ├── main.cpp --main cpp file
│ └── trapezoid.h --the cpp header file
└── original question
├── 性能优化过程记录表.xlsx --examinees are required to record their process of optimization
├── 优化要求.pdf --the main requirement PDF file of this problem
├── main.cpp --main cpp file
└── trapezoid.h --the cpp header file
As we all known, the trapezoidal method can approximately solve the definite integral of a function. OpenMP is a basic tool of the parallel programming of the C language. Now, you are required to use OpenMP to realize the trapezoidal method of given definite integral for approximate solution optimization, the step length should not be more than
- i7 10750H with 12 logical processors
- 32GB memory
- Linux64, GCC 8.3
The conputing task was divided into 10000 parts, every parts are the minimum parallel conputing units. For every unit, the program will operation $110^7$ times, to satisfy the requirement of the minimun step length. Such operation is used to avoid the maximum limit of the integer (the integer is only permitted in the for loop in some versions of OpenMP as the incremental expression).
What's more, i optimized the algorithm. The original algorithm:
$$\sum_{i=0}^{110^{11}}(f(i10^{-18})+f((i+1)10^{-18}))0.510^{-7}$$
After algorithm optimizatiom, we could just calculate:
$$10^{-7}\sum_{i=0}^{110^{11}}f(i*10^{-18})$$
It significantly reduced the time comsume of each computing unit.
- Original serial running time consuption: 323128ms
- My time consuption: 34121.3ms
- 10.06 times faster than before