diff --git a/4-add-test-cases-for-openmp-optimization.patch b/4-add-test-cases-for-openmp-optimization.patch index cf19ec0f70ce8e2ef1e6580d8e8750894fe0eae8..61637e06c8dfc14ae4c9900174912d95c56c3dcd 100644 --- a/4-add-test-cases-for-openmp-optimization.patch +++ b/4-add-test-cases-for-openmp-optimization.patch @@ -1,8 +1,21 @@ -From d285972f0bd71a1db981008cbadda8909da8b1ac Mon Sep 17 00:00:00 2001 +From 22be02d7a701ced84b8f8b5b575f7f2d07e0524b Mon Sep 17 00:00:00 2001 From: xieyihui -Date: Thu, 13 Oct 2022 18:25:41 +0800 +Date: Fri, 11 Nov 2022 13:15:51 +0800 Subject: [PATCH] Add test cases for openmp optimization +diff --git a/test/openmp_optimization/fortran_func010.f90 b/test/openmp_optimization/fortran_func010.f90 +new file mode 100644 +index 0000000..2c0b65e +--- /dev/null ++++ b/test/openmp_optimization/fortran_func010.f90 +@@ -0,0 +1,6 @@ ++subroutine f(a, b, c) ++ integer :: a(10000000), b(10000000), c(10000000) ++ do i = 2, 10000000 ++ a(i) = a(i - 1) + b(i) * c(i) ++ end do ++end +\ No newline at end of file diff --git a/test/openmp_optimization/fortran_main001.f90 b/test/openmp_optimization/fortran_main001.f90 new file mode 100644 index 0000000..2ef72a2 @@ -327,6 +340,312 @@ index 0000000..6f219de +! IWOMP 2018. Lecture Notes in Computer Science(), vol 11128. Springer, +! Cham. https://doi.org/10.1007/978-3-319-98521-3_8 \ No newline at end of file +diff --git a/test/openmp_optimization/fortran_main010.f90 b/test/openmp_optimization/fortran_main010.f90 +new file mode 100644 +index 0000000..9542916 +--- /dev/null ++++ b/test/openmp_optimization/fortran_main010.f90 +@@ -0,0 +1,19 @@ ++! Test optimizaton for fortran use openmp about partial simd ++! ++program main ++ use omp_lib ++ real(kind = 8) :: starttime, endtime, time ++ integer :: a(10000000), b(10000000), c(10000000) ++ do i = 1, 10000000 ++ a(i) = i ++ b(i) = i ++ c(i) = i ++ end do ++ starttime = omp_get_wtime() ++ do i = 1, 50 ++ call f(a, b, c) ++ end do ++ endtime = omp_get_wtime() ++ time = endtime - starttime ++print *, time ++end program main +\ No newline at end of file +diff --git a/test/openmp_optimization/fortran_main011.f90 b/test/openmp_optimization/fortran_main011.f90 +new file mode 100644 +index 0000000..0c53aea +--- /dev/null ++++ b/test/openmp_optimization/fortran_main011.f90 +@@ -0,0 +1,25 @@ ++! Test optimizaton for fortran use openmp about avoid false sharing ++! ++program main ++ use omp_lib ++ real(kind = 8) :: starttime, endtime, time ++ integer :: a(10000) ++ integer :: temp ++ do i = 1, 10000 ++ a(i) = i ++ end do ++ starttime = omp_get_wtime() ++ do n = 1, 50000 ++ !$omp parallel do schedule (static, 1) ++ do i = 1, 10000 ++ a(i) = a(i) + 1 ++ end do ++ !$omp end parallel do ++ end do ++ endtime = omp_get_wtime() ++ time = endtime - starttime ++print *, time ++end program main ++ ++! Reference ++! http://akira.ruc.dk/~keld/teaching/IPDC_f10/Slides/pdf4x/4_Performance.4x.pdf +\ No newline at end of file +diff --git a/test/openmp_optimization/fortran_main012.f90 b/test/openmp_optimization/fortran_main012.f90 +new file mode 100644 +index 0000000..2a02961 +--- /dev/null ++++ b/test/openmp_optimization/fortran_main012.f90 +@@ -0,0 +1,29 @@ ++! Test optimizaton for fortran use openmp about variable attributes ++! ++program main ++ use omp_lib ++ real(kind = 8) :: starttime, endtime, time ++ integer :: a(1000), b(1000) ++ integer :: temp ++ starttime = omp_get_wtime() ++ do n = 1, 5000 ++ !$omp parallel ++ !$omp do private(a) ++ do i = 1, 1000 ++ temp = a(i) ++ end do ++ !$omp end do ++ !$omp do private(a) ++ do i = 1, 1000 ++ temp = b(i) ++ end do ++ !$omp end do ++ !$omp end parallel ++ end do ++ endtime = omp_get_wtime() ++ time = endtime - starttime ++ print *, time ++end program main ++ ++! Reference ++! 游佐勇. OpenMP并行编程模型与性能优化方法的研究及应用[D].成都理工大学,2011. +\ No newline at end of file +diff --git a/test/openmp_optimization/fortran_main013.f90 b/test/openmp_optimization/fortran_main013.f90 +new file mode 100644 +index 0000000..f7eb485 +--- /dev/null ++++ b/test/openmp_optimization/fortran_main013.f90 +@@ -0,0 +1,27 @@ ++! Test optimizaton for fortran use openmp about parallel region ++! reconstruction ++! ++subroutine add1(s) ++ use omp_lib ++ real :: s(10000) ++ !$omp parallel do ++ do i = 1, 10000 ++ s(i) = i + 1 ++ end do ++ !$omp end parallel do ++end subroutine add1 ++program main ++ use omp_lib ++ real(kind = 8) :: starttime, endtime, time ++ real :: a(10000) ++ starttime = omp_get_wtime() ++ do n = 1, 50000 ++ call add1(a) ++ end do ++ endtime = omp_get_wtime() ++ time = endtime - starttime ++ print *, time ++end program main ++ ++! Reference ++! 刘京,郑启龙,李彭勇,郭连伟.面向Open64的OpenMP程序优化[J].计算机系统应用,2016,25(01):154-159. +\ No newline at end of file +diff --git a/test/openmp_optimization/fortran_main014.f90 b/test/openmp_optimization/fortran_main014.f90 +new file mode 100644 +index 0000000..5e6f6b7 +--- /dev/null ++++ b/test/openmp_optimization/fortran_main014.f90 +@@ -0,0 +1,24 @@ ++! Test optimizaton for fortran use openmp about parallel removing ++! parallel region with no side-effects ++! ++subroutine foo() ++ integer :: x = 1 ++end subroutine foo ++program main ++ use omp_lib ++ real(kind = 8) :: starttime, endtime, time ++ starttime = omp_get_wtime() ++ do n = 1, 100000 ++ !$omp parallel ++ !$omp end parallel ++ !$omp parallel ++ call foo() ++ !$omp end parallel ++ end do ++ endtime = omp_get_wtime() ++ time = endtime - starttime ++print *, time ++end program main ++ ++! Reference ++! https://openmp.llvm.org/remarks/OptimizationRemarks.html +\ No newline at end of file +diff --git a/test/openmp_optimization/fortran_main015.f90 b/test/openmp_optimization/fortran_main015.f90 +new file mode 100644 +index 0000000..9c9ee4d +--- /dev/null ++++ b/test/openmp_optimization/fortran_main015.f90 +@@ -0,0 +1,28 @@ ++! Test optimizaton for fortran use openmp about remove dependencies ++! ++program main ++ use omp_lib ++ real(kind = 8) :: starttime, endtime, time ++ integer :: a(1000000) ++ integer :: b(1000000) ++ integer :: c(1000000) ++ integer :: x ++ do i = 1, 1000000 ++ a(i) = i ++ b(i) = i + 1 ++ c(i) = i + 2 ++ end do ++ starttime = omp_get_wtime() ++ do w = 1, 100 ++ do i = 1, 1000000 ++ x = (b(i) + c(i)) / 2 ++ a(i) = a(i + 1) + x ++ end do ++ end do ++ endtime = omp_get_wtime() ++ time = endtime - starttime ++print *, time ++end program main ++ ++! Reference ++! http://akira.ruc.dk/~keld/teaching/IPDC_f10/Slides/pdf4x/4_Performance.4x.pdf +\ No newline at end of file +diff --git a/test/openmp_optimization/fortran_main016.f90 b/test/openmp_optimization/fortran_main016.f90 +new file mode 100644 +index 0000000..4aa262e +--- /dev/null ++++ b/test/openmp_optimization/fortran_main016.f90 +@@ -0,0 +1,27 @@ ++! Test optimizaton for fortran use openmp about remove dependencies ++! ++program main ++ use omp_lib ++ real(kind = 8) :: starttime, endtime, time ++ integer :: a(1000000) ++ integer :: b(1000000) ++ integer :: c(1000000) ++ do i = 1, 1000000 ++ a(i) = i ++ b(i) = i + 1 ++ c(i) = i + 2 ++ end do ++ starttime = omp_get_wtime() ++ do w = 1, 1000 ++ do i = 1, 1000000 ++ b(i) = b(i) + a(i - 1) ++ a(i) = a(i) + c(i) ++ end do ++ end do ++ endtime = omp_get_wtime() ++ time = endtime - starttime ++print *, time ++end program main ++ ++! Reference ++! http://akira.ruc.dk/~keld/teaching/IPDC_f10/Slides/pdf4x/4_Performance.4x.pdf +\ No newline at end of file +diff --git a/test/openmp_optimization/fortran_main017.f90 b/test/openmp_optimization/fortran_main017.f90 +new file mode 100644 +index 0000000..014f0b6 +--- /dev/null ++++ b/test/openmp_optimization/fortran_main017.f90 +@@ -0,0 +1,53 @@ ++! Test optimizaton for fortran use openmp about communication ++! ++subroutine f(x, y) ++ integer, pointer :: x(:) ++ integer, pointer :: y ++ integer :: n = 512 ++ integer :: l ++ integer :: k ++ integer :: m ++ l = x(1) ++ a = n + l ++ !$omp parallel do firstprivate(x, y, n, l, a) ++ do i = 1, n ++ k = y ++ m = n * k ++ x(i) = m + a * l * i ++ end do ++ !$omp end parallel do ++end ++ ++program main ++ use omp_lib ++ interface ++ subroutine f(x, y) ++ integer, pointer :: x(:) ++ integer, pointer :: y ++ end subroutine ++ end interface ++ real(kind = 8) :: starttime, endtime, time ++ integer, target :: a(512) ++ integer, target :: b = 1 ++ integer, pointer :: ap(:) ++ integer, pointer :: bp ++ do i = 1, 512 ++ a(i) = i ++ end do ++ ap => a ++ bp => b ++ starttime = omp_get_wtime() ++ do i = 1, 1000 ++ call f(ap, bp) ++ end do ++ endtime = omp_get_wtime() ++ time = endtime - starttime ++ print *, time ++end program main ++ ++! Reference ++! Doerfert, J., Finkel, H. (2018). Compiler Optimizations for OpenMP. ++! In: de Supinski, B., Valero-Lara, P., Martorell, X., Mateo Bellido S. ++! , Labarta, J. (eds) Evolving OpenMP for Evolving Architectures. ++! IWOMP 2018. Lecture Notes in Computer Science(), vol 11128. Springer, ++! Cham. https://doi.org/10.1007/978-3-319-98521-3_8 +\ No newline at end of file +diff --git a/test/openmp_optimization/fortran_optimized_func010.f90 b/test/openmp_optimization/fortran_optimized_func010.f90 +new file mode 100644 +index 0000000..be0920d +--- /dev/null ++++ b/test/openmp_optimization/fortran_optimized_func010.f90 +@@ -0,0 +1,11 @@ ++subroutine f(a, b, c, d) ++ integer :: a(10000000), b(10000000), c(10000000), d(10000000) ++ !$omp parallel do ++ do i = 2, 10000000 ++ d(i) = b(i) * c(i) ++ end do ++ !$parallel end do ++ do i = 2, 10000000 ++ a(i) = a(i - 1) + d(i) ++ end do ++end +\ No newline at end of file diff --git a/test/openmp_optimization/optimized_main001.f90 b/test/openmp_optimization/optimized_main001.f90 new file mode 100644 index 0000000..f3c3cfa @@ -548,11 +867,11 @@ index 0000000..728c8a8 \ No newline at end of file diff --git a/test/openmp_optimization/optimized_main009.f90 b/test/openmp_optimization/optimized_main009.f90 new file mode 100644 -index 0000000..1111c77 +index 0000000..fdfc304 --- /dev/null +++ b/test/openmp_optimization/optimized_main009.f90 @@ -0,0 +1,37 @@ -+! Test optimizaton for fortran use openmp about parallel region expand ++! Test optimizaton for fortran use openmp about partial simd +! +program main + use omp_lib @@ -590,12 +909,311 @@ index 0000000..1111c77 +! IWOMP 2018. Lecture Notes in Computer Science(), vol 11128. Springer, +! Cham. https://doi.org/10.1007/978-3-319-98521-3_8 \ No newline at end of file +diff --git a/test/openmp_optimization/optimized_main010.f90 b/test/openmp_optimization/optimized_main010.f90 +new file mode 100644 +index 0000000..ca0189f +--- /dev/null ++++ b/test/openmp_optimization/optimized_main010.f90 +@@ -0,0 +1,19 @@ ++! Test optimizaton for fortran use openmp about partial simd ++! ++program main ++ use omp_lib ++ real(kind = 8) :: starttime, endtime, time ++ integer :: a(10000000), b(10000000), c(10000000), d(10000000) ++ do i = 1, 10000000 ++ a(i) = i ++ b(i) = i ++ c(i) = i ++ end do ++ starttime = omp_get_wtime() ++ do i = 1, 50 ++ call f(a, b, c, d) ++ end do ++ endtime = omp_get_wtime() ++ time = endtime - starttime ++print *, time ++end program main +\ No newline at end of file +diff --git a/test/openmp_optimization/optimized_main011.f90 b/test/openmp_optimization/optimized_main011.f90 +new file mode 100644 +index 0000000..dd7fd85 +--- /dev/null ++++ b/test/openmp_optimization/optimized_main011.f90 +@@ -0,0 +1,25 @@ ++! Test optimizaton for fortran use openmp about avoid false sharing ++! ++program main ++ use omp_lib ++ real(kind = 8) :: starttime, endtime, time ++ integer :: a(10000 * 16) ++ integer :: temp ++ do i = 1, 10000 ++ a(i * 16) = i ++ end do ++ starttime = omp_get_wtime() ++ do n = 1, 50000 ++ !$omp parallel do schedule (static, 1) ++ do i = 1, 10000 ++ a(i) = a(i * 16) + 1 ++ end do ++ !$omp end parallel do ++ end do ++ endtime = omp_get_wtime() ++ time = endtime - starttime ++print *, time ++end program main ++ ++! Reference ++! http://akira.ruc.dk/~keld/teaching/IPDC_f10/Slides/pdf4x/4_Performance.4x.pdf +\ No newline at end of file +diff --git a/test/openmp_optimization/optimized_main012.f90 b/test/openmp_optimization/optimized_main012.f90 +new file mode 100644 +index 0000000..6a2c1f6 +--- /dev/null ++++ b/test/openmp_optimization/optimized_main012.f90 +@@ -0,0 +1,29 @@ ++! Test optimizaton for fortran use openmp about variable attributes ++! ++program main ++ use omp_lib ++ real(kind = 8) :: starttime, endtime, time ++ integer :: a(1000), b(1000) ++ integer :: temp ++ starttime = omp_get_wtime() ++ do n = 1, 5000 ++ !$omp parallel private(a) ++ !$omp do ++ do i = 1, 1000 ++ temp = a(i) ++ end do ++ !$omp end do ++ !$omp do ++ do i = 1, 1000 ++ temp = b(i) ++ end do ++ !$omp end do ++ !$omp end parallel ++ end do ++ endtime = omp_get_wtime() ++ time = endtime - starttime ++ print *, time ++end program main ++ ++! Reference ++! 游佐勇. OpenMP并行编程模型与性能优化方法的研究及应用[D].成都理工大学,2011. +\ No newline at end of file +diff --git a/test/openmp_optimization/optimized_main013.f90 b/test/openmp_optimization/optimized_main013.f90 +new file mode 100644 +index 0000000..f5b1ae6 +--- /dev/null ++++ b/test/openmp_optimization/optimized_main013.f90 +@@ -0,0 +1,29 @@ ++! Test optimizaton for fortran use openmp about parallel region ++! reconstruction ++! ++subroutine add1(s) ++ use omp_lib ++ real :: s(10000) ++ !$omp do ++ do i = 1, 10000 ++ s(i) = i + 1 ++ end do ++ !$omp end do ++end subroutine add1 ++program main ++ use omp_lib ++ real(kind = 8) :: starttime, endtime, time ++ real :: a(10000) ++ starttime = omp_get_wtime() ++ do n = 1, 50000 ++ !$omp parallel ++ call add1(a) ++ !$omp end parallel ++ end do ++ endtime = omp_get_wtime() ++ time = endtime - starttime ++ print *, time ++end program main ++ ++! Reference ++! 刘京,郑启龙,李彭勇,郭连伟.面向Open64的OpenMP程序优化[J].计算机系统应用,2016,25(01):154-159. +\ No newline at end of file +diff --git a/test/openmp_optimization/optimized_main014.f90 b/test/openmp_optimization/optimized_main014.f90 +new file mode 100644 +index 0000000..96393d0 +--- /dev/null ++++ b/test/openmp_optimization/optimized_main014.f90 +@@ -0,0 +1,20 @@ ++! Test optimizaton for fortran use openmp about parallel removing ++! parallel region with no side-effects ++! ++subroutine foo() ++ integer :: x = 1 ++end subroutine foo ++program main ++ use omp_lib ++ real(kind = 8) :: starttime, endtime, time ++ starttime = omp_get_wtime() ++ do n = 1, 100000 ++ ++ end do ++ endtime = omp_get_wtime() ++ time = endtime - starttime ++print *, time ++end program main ++ ++! Reference ++! https://openmp.llvm.org/remarks/OptimizationRemarks.html +\ No newline at end of file +diff --git a/test/openmp_optimization/optimized_main015.f90 b/test/openmp_optimization/optimized_main015.f90 +new file mode 100644 +index 0000000..727fe74 +--- /dev/null ++++ b/test/openmp_optimization/optimized_main015.f90 +@@ -0,0 +1,37 @@ ++! Test optimizaton for fortran use openmp about remove dependencies ++! ++program main ++ use omp_lib ++ real(kind = 8) :: starttime, endtime, time ++ integer :: a(1000000), a_copy(1000000) ++ integer :: b(1000000) ++ integer :: c(1000000) ++ integer :: x ++ do i = 1, 1000000 ++ a(i) = i ++ b(i) = i + 1 ++ c(i) = i + 2 ++ end do ++ starttime = omp_get_wtime() ++ !$omp parallel shared(a, a_copy) ++ do w = 1, 100 ++ !$omp do ++ do i = 1, 1000000 ++ a_copy(i) = a(i + 1) ++ end do ++ !$omp end do ++ !$omp do ++ do i = 1, 1000000 ++ x = (b(i) + c(i)) / 2 ++ a(i) = a_copy(i) + x ++ end do ++ !$omp end do ++ end do ++ !$omp end parallel ++ endtime = omp_get_wtime() ++ time = endtime - starttime ++print *, time ++end program main ++ ++! Reference ++! http://akira.ruc.dk/~keld/teaching/IPDC_f10/Slides/pdf4x/4_Performance.4x.pdf +\ No newline at end of file +diff --git a/test/openmp_optimization/optimized_main016.f90 b/test/openmp_optimization/optimized_main016.f90 +new file mode 100644 +index 0000000..2b0f650 +--- /dev/null ++++ b/test/openmp_optimization/optimized_main016.f90 +@@ -0,0 +1,31 @@ ++! Test optimizaton for fortran use openmp about remove dependencies ++! ++program main ++ use omp_lib ++ real(kind = 8) :: starttime, endtime, time ++ integer :: a(1000000) ++ integer :: b(1000000) ++ integer :: c(1000000) ++ do i = 1, 1000000 ++ a(i) = i ++ b(i) = i + 1 ++ c(i) = i + 2 ++ end do ++ starttime = omp_get_wtime() ++ do w = 1, 1000 ++ b(1) = b(1) - a(0) ++ !$omp parallel do shared(a, b, c) ++ do i = 2, 1000000 ++ b(i) = b(i) + a(i - 1) ++ a(i) = a(i) + c(i) ++ end do ++ !$omp end parallel do ++ a(1000000 - 1) = a(1000000 - 1) + c(1000000 - 1) ++ end do ++ endtime = omp_get_wtime() ++ time = endtime - starttime ++print *, time ++end program main ++ ++! Reference ++! http://akira.ruc.dk/~keld/teaching/IPDC_f10/Slides/pdf4x/4_Performance.4x.pdf +\ No newline at end of file +diff --git a/test/openmp_optimization/optimized_main017.f90 b/test/openmp_optimization/optimized_main017.f90 +new file mode 100644 +index 0000000..09d6741 +--- /dev/null ++++ b/test/openmp_optimization/optimized_main017.f90 +@@ -0,0 +1,53 @@ ++! Test optimizaton for fortran use openmp about communication ++! ++subroutine f(x, y) ++ integer, pointer :: x(:) ++ integer, pointer :: y ++ integer :: l ++ integer :: k ++ integer :: m ++ integer :: a ++ l = x(1) ++ k = y ++ m = 512 * k ++ a = 512 + l ++ !$omp parallel do firstprivate(x, m, l, a) ++ do i = 1, 512 ++ x(i) = m + a * l * i ++ end do ++ !$omp end parallel do ++end ++ ++program main ++ use omp_lib ++ interface ++ subroutine f(x, y) ++ integer, pointer :: x(:) ++ integer, pointer :: y ++ end subroutine ++ end interface ++ real(kind = 8) :: starttime, endtime, time ++ integer, target :: a(512) ++ integer, target :: b = 1 ++ integer, pointer :: ap(:) ++ integer, pointer :: bp ++ do i = 1, 512 ++ a(i) = i ++ end do ++ ap => a ++ bp => b ++ starttime = omp_get_wtime() ++ do i = 1, 1000 ++ call f(ap, bp) ++ end do ++ endtime = omp_get_wtime() ++ time = endtime - starttime ++print *, time ++end program main ++ ++! Reference ++! Doerfert, J., Finkel, H. (2018). Compiler Optimizations for OpenMP. ++! In: de Supinski, B., Valero-Lara, P., Martorell, X., Mateo Bellido S. ++! , Labarta, J. (eds) Evolving OpenMP for Evolving Architectures. ++! IWOMP 2018. Lecture Notes in Computer Science(), vol 11128. Springer, ++! Cham. https://doi.org/10.1007/978-3-319-98521-3_8 +\ No newline at end of file diff --git a/test/openmp_optimization/readme.md b/test/openmp_optimization/readme.md new file mode 100644 -index 0000000..e12c628 +index 0000000..e8cf656 --- /dev/null +++ b/test/openmp_optimization/readme.md -@@ -0,0 +1,35 @@ +@@ -0,0 +1,71 @@ +These files are designed to test how OpenMP programs can be optimized. +This folder has two types of test file, one is unoptimized, the other +one is optimized. @@ -604,17 +1222,45 @@ index 0000000..e12c628 +3.20GHz, 512GB RAM, X86 +OMP_NUM_THREADS=8 + -+test every case 10 times ++test every case 10 times with flang-new + unoptimized optimized -+test001: 0.771 0.395 -+test002: 0.270 0.153 ++test001: 1.424 0.660 ++test002: 0.636 0.442 +test003: Unable to optimize with hand-written code -+test004: 0.571 0.201 -+test005: 0.524 0.199 ++test004: 1.021 0.568 ++test005: 0.992 0.572 +test006: Unable to optimize with hand-written code -+test007: 1.808 0.614 -+test008: 6.265E-03 1.313E-04 -+test009: 0.798 0.466 ++test007: 3.682 0.960 ++test008: 0.0185 0.000089 ++test009: 1.428 0.820 ++test010: 1.886 0.604 ++test011: 2.468 1.758 ++test012: 0.0986 0.0981 ++test013: 0.626 0.621 ++test014: 0.284 0.00102 ++test015: 0.463 0.907 ++test016: 3.903 0.713 ++test017: 0.0295 0.0221 //run by gfortran ++ ++test every case 10 times with flang ++ unoptimized optimized ++test001: 0.899 0.461 ++test002: 0.592 0.437 ++test003: Unable to optimize with hand-written code ++test004: 0.939 0.562 ++test005: 0.981 0.559 ++test006: Unable to optimize with hand-written code ++test007: 3.644 1.550 ++test008: 0.0146 0.0028 ++test009: 0.938 0.802 ++test010: 1.347 0.585 ++test011: 3.148 2.070 ++test012: 0.120 0.120 ++test013: 0.489 0.520 ++test014: 0.608 0.000495 ++test015: 0.392 1.812 ++test016: 2.822 0.593 ++test017: 0.0362 0.0254 + +Reference +[1] Müller, Matthias S.. "Some Simple OpenMP Optimization Techniques." @@ -631,13 +1277,21 @@ index 0000000..e12c628 +Engineering, Artificial Intelligences, Networking and +Parallel/Distributed Computing, 2009, pp. 495-500, doi: +10.1109/SNPD.2009.16. ++ ++[4] 刘京,郑启龙,李彭勇,郭连伟.面向Open64的OpenMP程序优化[J].计算机系统应用,2016,25(01):154-159. ++ ++[5] 游佐勇. OpenMP并行编程模型与性能优化方法的研究及应用[D].成都理工大学,2011. ++ ++[6] http://akira.ruc.dk/~keld/teaching/IPDC_f10/Slides/pdf4x/4_Performance.4x.pdf ++ ++[7] https://openmp.llvm.org/remarks/OptimizationRemarks.html \ No newline at end of file -diff --git a/test/openmp_optimization/run.sh b/test/openmp_optimization/run.sh +diff --git a/test/openmp_optimization/run_flang-new.sh b/test/openmp_optimization/run_flang-new.sh new file mode 100644 -index 0000000..510f119 +index 0000000..1faa2e3 --- /dev/null -+++ b/test/openmp_optimization/run.sh -@@ -0,0 +1,32 @@ ++++ b/test/openmp_optimization/run_flang-new.sh +@@ -0,0 +1,67 @@ +for i in {001..009} +do +echo "------- test $i ------." @@ -646,6 +1300,24 @@ index 0000000..510f119 +./a.out +rm a.out +done ++echo "------- test 10 ------." ++flang-new fortran_main010.f90 -c -o fortran-test.o -fopenmp ++flang-new fortran_func010.f90 -c -o fortran-test2.o ++flang-new fortran-test2.o fortran-test.o -fopenmp -O3 ++export OMP_NUM_THREADS=8 ++./a.out ++rm *.o ++rm a.out ++ ++for i in {011..017} ++do ++echo "------- test $i ------." ++flang-new fortran_main$i.f90 -fopenmp ++export OMP_NUM_THREADS=8 ++./a.out ++rm a.out ++done ++ +for i in {001..002} +do +echo "------- test $i ------." @@ -670,6 +1342,97 @@ index 0000000..510f119 +./a.out +rm a.out +done ++echo "------- test 10 ------." ++flang-new optimized_main010.f90 -c -o fortran-test.o -fopenmp ++flang-new fortran_optimized_func010.f90 -c -o fortran-test2.o -fopenmp -O3 ++flang-new fortran-test2.o fortran-test.o -fopenmp -O3 ++export OMP_NUM_THREADS=8 ++./a.out ++rm *.o ++rm a.out ++ ++for i in {011..017} ++do ++echo "------- test $i ------." ++flang-new optimized_main$i.f90 -fopenmp ++export OMP_NUM_THREADS=8 ++./a.out ++rm a.out ++done +\ No newline at end of file +diff --git a/test/openmp_optimization/run_flang.sh b/test/openmp_optimization/run_flang.sh +new file mode 100644 +index 0000000..9977b42 +--- /dev/null ++++ b/test/openmp_optimization/run_flang.sh +@@ -0,0 +1,67 @@ ++for i in {001..009} ++do ++echo "------- test $i ------." ++flang fortran_main$i.f90 -fopenmp ++export OMP_NUM_THREADS=8 ++./a.out ++rm a.out ++done ++echo "------- test 10 ------." ++flang fortran_main010.f90 -c -o fortran-test.o -fopenmp ++flang fortran_func010.f90 -c -o fortran-test2.o ++flang fortran-test2.o fortran-test.o -fopenmp -O3 ++export OMP_NUM_THREADS=8 ++./a.out ++rm *.o ++rm a.out ++ ++for i in {011..017} ++do ++echo "------- test $i ------." ++flang fortran_main$i.f90 -fopenmp ++export OMP_NUM_THREADS=8 ++./a.out ++rm a.out ++done ++ ++for i in {001..002} ++do ++echo "------- test $i ------." ++flang optimized_main$i.f90 -fopenmp ++export OMP_NUM_THREADS=8 ++./a.out ++rm a.out ++done ++for i in {004..005} ++do ++echo "------- test $i ------." ++flang optimized_main$i.f90 -fopenmp ++export OMP_NUM_THREADS=8 ++./a.out ++rm a.out ++done ++for i in {007..009} ++do ++echo "------- test $i ------." ++flang optimized_main$i.f90 -fopenmp ++export OMP_NUM_THREADS=8 ++./a.out ++rm a.out ++done ++echo "------- test 10 ------." ++flang optimized_main010.f90 -c -o fortran-test.o -fopenmp ++flang fortran_optimized_func010.f90 -c -o fortran-test2.o -fopenmp -O3 ++flang fortran-test2.o fortran-test.o -fopenmp -O3 ++export OMP_NUM_THREADS=8 ++./a.out ++rm *.o ++rm a.out ++ ++for i in {011..017} ++do ++echo "------- test $i ------." ++flang optimized_main$i.f90 -fopenmp ++export OMP_NUM_THREADS=8 ++./a.out ++rm a.out ++done \ No newline at end of file -- 2.25.1 diff --git a/flang.spec b/flang.spec index 13df3693303b332ec774949ed576d6cb9f055993..330967d40aef778e7501818a8399042aacd300f3 100644 --- a/flang.spec +++ b/flang.spec @@ -2,7 +2,7 @@ Name: flang Version: flang_20210324 -Release: 12 +Release: 13 Summary: Fortran language compiler targeting LLVM License: Apache-2.0 @@ -39,6 +39,9 @@ TODO: support build Flang. %changelog +* Fri Nov 4 2022 xieyihui - flang_20210324-13 +- Fix 4-add-test-cases-for-openmp-optimization.patch for add new test cases for OpenMP optimization + * Thu Oct 27 2022 wangzhewei - flang_20210324-12 - Add patch for add test cases for attribute declarations and specifications