diff --git a/4-add-test-cases-for-openmp-optimization.patch b/4-add-test-cases-for-openmp-optimization.patch index 0ad48aa401d38dca7d95835ce84c371155b283eb..cf19ec0f70ce8e2ef1e6580d8e8750894fe0eae8 100644 --- a/4-add-test-cases-for-openmp-optimization.patch +++ b/4-add-test-cases-for-openmp-optimization.patch @@ -1,14 +1,14 @@ -From 3349f79b289c2e5cbe35bf1fd0b9533a5f54f19b Mon Sep 17 00:00:00 2001 +From d285972f0bd71a1db981008cbadda8909da8b1ac Mon Sep 17 00:00:00 2001 From: xieyihui -Date: Mon, 26 Sep 2022 16:14:11 +0800 -Subject: [PATCH] add test cases for OpenMP optimazation +Date: Thu, 13 Oct 2022 18:25:41 +0800 +Subject: [PATCH] Add test cases for openmp optimization diff --git a/test/openmp_optimization/fortran_main001.f90 b/test/openmp_optimization/fortran_main001.f90 new file mode 100644 -index 0000000..395f415 +index 0000000..2ef72a2 --- /dev/null +++ b/test/openmp_optimization/fortran_main001.f90 -@@ -0,0 +1,24 @@ +@@ -0,0 +1,28 @@ +! Test optimizaton for fortran use openmp about parallel region merge +! +program main @@ -33,13 +33,17 @@ index 0000000..395f415 + time = endtime - starttime +print *, time +end program main ++ ++! Reference ++! Müller, Matthias S.. "Some Simple OpenMP Optimization Techniques." ++! WOMPAT (2001). \ No newline at end of file diff --git a/test/openmp_optimization/fortran_main002.f90 b/test/openmp_optimization/fortran_main002.f90 new file mode 100644 -index 0000000..27ed00e +index 0000000..84302b4 --- /dev/null +++ b/test/openmp_optimization/fortran_main002.f90 -@@ -0,0 +1,21 @@ +@@ -0,0 +1,25 @@ +! Test optimizaton for fortran use openmp about implicit nowait at end +! of parallel region +! @@ -61,12 +65,17 @@ index 0000000..27ed00e + time = endtime - starttime + print *, time +end program main ++ ++! Reference ++! Müller, Matthias S.. "Some Simple OpenMP Optimization Techniques." ++! WOMPAT (2001). +\ No newline at end of file diff --git a/test/openmp_optimization/fortran_main003.f90 b/test/openmp_optimization/fortran_main003.f90 new file mode 100644 -index 0000000..9f70283 +index 0000000..687127f --- /dev/null +++ b/test/openmp_optimization/fortran_main003.f90 -@@ -0,0 +1,27 @@ +@@ -0,0 +1,31 @@ +! Test help optimize code with the OpenMP directive. OpenMP directives +! may help the compiler to generate better code because he knows that +! certain preconditions are fulfilled. Compiler cannot assume that the @@ -94,13 +103,17 @@ index 0000000..9f70283 + time = endtime - starttime + print *, time +end program main ++ ++! Reference ++! Müller, Matthias S.. "Some Simple OpenMP Optimization Techniques." ++! WOMPAT (2001). \ No newline at end of file diff --git a/test/openmp_optimization/fortran_main004.f90 b/test/openmp_optimization/fortran_main004.f90 new file mode 100644 -index 0000000..d3a5f0e +index 0000000..1ce7826 --- /dev/null +++ b/test/openmp_optimization/fortran_main004.f90 -@@ -0,0 +1,26 @@ +@@ -0,0 +1,33 @@ +! Test optimizaton for fortran use openmp about remove the redundant +! barrier +! @@ -127,13 +140,20 @@ index 0000000..d3a5f0e + time = endtime - starttime + print *, time +end program main ++ ++! Reference ++! H. Ma, R. Zhao, X. Gao and Y. Zhang, "Barrier Optimization for ++! OpenMP Program," 2009 10th ACIS International Conference on Software ++! Engineering, Artificial Intelligences, Networking and ++! Parallel/Distributed Computing, 2009, pp. 495-500, doi: ++! 10.1109/SNPD.2009.16. \ No newline at end of file diff --git a/test/openmp_optimization/fortran_main005.f90 b/test/openmp_optimization/fortran_main005.f90 new file mode 100644 -index 0000000..e6cff9b +index 0000000..f79d9d7 --- /dev/null +++ b/test/openmp_optimization/fortran_main005.f90 -@@ -0,0 +1,26 @@ +@@ -0,0 +1,33 @@ +! Test optimizaton for fortran use openmp about remove the redundant +! barrier +! @@ -160,13 +180,20 @@ index 0000000..e6cff9b + time = endtime - starttime + print *, time +end program main ++ ++! Reference ++! H. Ma, R. Zhao, X. Gao and Y. Zhang, "Barrier Optimization for ++! OpenMP Program," 2009 10th ACIS International Conference on Software ++! Engineering, Artificial Intelligences, Networking and ++! Parallel/Distributed Computing, 2009, pp. 495-500, doi: ++! 10.1109/SNPD.2009.16. \ No newline at end of file diff --git a/test/openmp_optimization/fortran_main006.f90 b/test/openmp_optimization/fortran_main006.f90 new file mode 100644 -index 0000000..fc06654 +index 0000000..653a0c9 --- /dev/null +++ b/test/openmp_optimization/fortran_main006.f90 -@@ -0,0 +1,19 @@ +@@ -0,0 +1,26 @@ +! Test optimizaton for fortran use openmp about implement of DOACROSS +! parallelism +! @@ -186,13 +213,20 @@ index 0000000..fc06654 + time = endtime - starttime + print *, time +end program main ++ ++! Reference ++! H. Ma, R. Zhao, X. Gao and Y. Zhang, "Barrier Optimization for ++! OpenMP Program," 2009 10th ACIS International Conference on Software ++! Engineering, Artificial Intelligences, Networking and ++! Parallel/Distributed Computing, 2009, pp. 495-500, doi: ++! 10.1109/SNPD.2009.16. \ No newline at end of file diff --git a/test/openmp_optimization/fortran_main007.f90 b/test/openmp_optimization/fortran_main007.f90 new file mode 100644 -index 0000000..8da7ec6 +index 0000000..b8feee7 --- /dev/null +++ b/test/openmp_optimization/fortran_main007.f90 -@@ -0,0 +1,21 @@ +@@ -0,0 +1,25 @@ +! Test optimizaton for fortran use openmp about orphaned directives +! +subroutine add1(s) @@ -214,13 +248,17 @@ index 0000000..8da7ec6 + time = endtime - starttime + print *, time +end program main ++ ++! Reference ++! Müller, Matthias S.. "Some Simple OpenMP Optimization Techniques." ++! WOMPAT (2001). \ No newline at end of file diff --git a/test/openmp_optimization/fortran_main008.f90 b/test/openmp_optimization/fortran_main008.f90 new file mode 100644 -index 0000000..aa70d3e +index 0000000..fac91c0 --- /dev/null +++ b/test/openmp_optimization/fortran_main008.f90 -@@ -0,0 +1,24 @@ +@@ -0,0 +1,28 @@ +! Test optimizaton for fortran use openmp about alternative code. The +! goal is to have the performance of the serial code if it is faster +! than the parallel @@ -245,14 +283,18 @@ index 0000000..aa70d3e + time = endtime - starttime + print *, time +end program main ++ ++! Reference ++! Müller, Matthias S.. "Some Simple OpenMP Optimization Techniques." ++! WOMPAT (2001). \ No newline at end of file diff --git a/test/openmp_optimization/fortran_main009.f90 b/test/openmp_optimization/fortran_main009.f90 new file mode 100644 -index 0000000..fffb89b +index 0000000..6f219de --- /dev/null +++ b/test/openmp_optimization/fortran_main009.f90 -@@ -0,0 +1,25 @@ -+! Test optimizaton for fortran use openmp about parallel region merge +@@ -0,0 +1,32 @@ ++! Test optimizaton for fortran use openmp about parallel region expand +! +program main + use omp_lib @@ -277,13 +319,20 @@ index 0000000..fffb89b + 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/optimized_main001.f90 b/test/openmp_optimization/optimized_main001.f90 new file mode 100644 -index 0000000..b131f57 +index 0000000..f3c3cfa --- /dev/null +++ b/test/openmp_optimization/optimized_main001.f90 -@@ -0,0 +1,20 @@ +@@ -0,0 +1,24 @@ +! Test optimizaton for fortran use openmp about parallel region merge +! +program main @@ -304,13 +353,17 @@ index 0000000..b131f57 + time = endtime - starttime + print *, time +end program main ++ ++! Reference ++! Müller, Matthias S.. "Some Simple OpenMP Optimization Techniques." ++! WOMPAT (2001). \ No newline at end of file diff --git a/test/openmp_optimization/optimized_main002.f90 b/test/openmp_optimization/optimized_main002.f90 new file mode 100644 -index 0000000..edfba4a +index 0000000..8a9a641 --- /dev/null +++ b/test/openmp_optimization/optimized_main002.f90 -@@ -0,0 +1,21 @@ +@@ -0,0 +1,25 @@ +! Test optimizaton for fortran use openmp about implicit nowait at end +! of parallel region +! @@ -332,12 +385,16 @@ index 0000000..edfba4a + time = endtime - starttime + print *, time +end program main ++ ++! Reference ++! Müller, Matthias S.. "Some Simple OpenMP Optimization Techniques." ++! WOMPAT (2001). diff --git a/test/openmp_optimization/optimized_main004.f90 b/test/openmp_optimization/optimized_main004.f90 new file mode 100644 -index 0000000..3274556 +index 0000000..234aa76 --- /dev/null +++ b/test/openmp_optimization/optimized_main004.f90 -@@ -0,0 +1,26 @@ +@@ -0,0 +1,33 @@ +! Test optimizaton for fortran use openmp about remove the redundant +! barrier +! @@ -364,13 +421,20 @@ index 0000000..3274556 + time = endtime - starttime + print *, time +end program main ++ ++! Reference ++! H. Ma, R. Zhao, X. Gao and Y. Zhang, "Barrier Optimization for ++! OpenMP Program," 2009 10th ACIS International Conference on Software ++! Engineering, Artificial Intelligences, Networking and ++! Parallel/Distributed Computing, 2009, pp. 495-500, doi: ++! 10.1109/SNPD.2009.16. \ No newline at end of file diff --git a/test/openmp_optimization/optimized_main005.f90 b/test/openmp_optimization/optimized_main005.f90 new file mode 100644 -index 0000000..79910a9 +index 0000000..102e387 --- /dev/null +++ b/test/openmp_optimization/optimized_main005.f90 -@@ -0,0 +1,26 @@ +@@ -0,0 +1,33 @@ +! Test optimizaton for fortran use openmp about remove the redundant +! barrier +! @@ -397,13 +461,20 @@ index 0000000..79910a9 + time = endtime - starttime + print *, time +end program main ++ ++! Reference ++! H. Ma, R. Zhao, X. Gao and Y. Zhang, "Barrier Optimization for ++! OpenMP Program," 2009 10th ACIS International Conference on Software ++! Engineering, Artificial Intelligences, Networking and ++! Parallel/Distributed Computing, 2009, pp. 495-500, doi: ++! 10.1109/SNPD.2009.16. \ No newline at end of file diff --git a/test/openmp_optimization/optimized_main007.f90 b/test/openmp_optimization/optimized_main007.f90 new file mode 100644 -index 0000000..557f705 +index 0000000..5b35421 --- /dev/null +++ b/test/openmp_optimization/optimized_main007.f90 -@@ -0,0 +1,25 @@ +@@ -0,0 +1,29 @@ +! Test optimizaton for fortran use openmp about orphaned directives +! +subroutine add1(s) @@ -429,13 +500,17 @@ index 0000000..557f705 + time = endtime - starttime + print *, time +end program main ++ ++! Reference ++! Müller, Matthias S.. "Some Simple OpenMP Optimization Techniques." ++! WOMPAT (2001). \ No newline at end of file diff --git a/test/openmp_optimization/optimized_main008.f90 b/test/openmp_optimization/optimized_main008.f90 new file mode 100644 -index 0000000..d0149b6 +index 0000000..728c8a8 --- /dev/null +++ b/test/openmp_optimization/optimized_main008.f90 -@@ -0,0 +1,30 @@ +@@ -0,0 +1,34 @@ +! Test optimizaton for fortran use openmp about alternative code. The +! goal is to have the performance of the serial code if it is faster +! than the parallel @@ -466,40 +541,61 @@ index 0000000..d0149b6 + time = endtime - starttime + print *, time +end program main ++ ++! Reference ++! Müller, Matthias S.. "Some Simple OpenMP Optimization Techniques." ++! WOMPAT (2001). \ 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..b131f57 +index 0000000..1111c77 --- /dev/null +++ b/test/openmp_optimization/optimized_main009.f90 -@@ -0,0 +1,20 @@ -+! Test optimizaton for fortran use openmp about parallel region merge +@@ -0,0 +1,37 @@ ++! Test optimizaton for fortran use openmp about parallel region expand +! +program main + use omp_lib + real(kind = 8) :: starttime, endtime, time + integer :: a(100) -+ integer :: b(100) ++ integer :: n = 0 + starttime = omp_get_wtime() -+ do n = 1, 100000 -+ !$omp parallel do ++ !$omp parallel shared(n, a) ++ do while (n <= 100000) ++ !$omp do + do i = 1, 100 -+ a(i) = i -+ b(i) = i ++ a(i) = i + 1 + end do -+ !$omp end parallel do ++ !$omp end do ++ !$omp do ++ do i = 1, 100 ++ a(i) = i + a(i) ++ end do ++ !$omp end do ++ !$omp master ++ n = n + 1 ++ !$omp end master ++ !$omp barrier + end do ++ !$omp end parallel + 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.txt b/test/openmp_optimization/readme.txt +diff --git a/test/openmp_optimization/readme.md b/test/openmp_optimization/readme.md new file mode 100644 -index 0000000..010300e +index 0000000..e12c628 --- /dev/null -+++ b/test/openmp_optimization/readme.txt -@@ -0,0 +1,19 @@ ++++ b/test/openmp_optimization/readme.md +@@ -0,0 +1,35 @@ +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. @@ -518,7 +614,23 @@ index 0000000..010300e +test006: Unable to optimize with hand-written code +test007: 1.808 0.614 +test008: 6.265E-03 1.313E-04 -+test009: 0.790 0.376 ++test009: 0.798 0.466 ++ ++Reference ++[1] Müller, Matthias S.. "Some Simple OpenMP Optimization Techniques." ++WOMPAT (2001). ++ ++[2] 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 ++ ++[3] H. Ma, R. Zhao, X. Gao and Y. Zhang, "Barrier Optimization for ++OpenMP Program," 2009 10th ACIS International Conference on Software ++Engineering, Artificial Intelligences, Networking and ++Parallel/Distributed Computing, 2009, pp. 495-500, doi: ++10.1109/SNPD.2009.16. \ No newline at end of file diff --git a/test/openmp_optimization/run.sh b/test/openmp_optimization/run.sh new file mode 100644