Hi Anuj,
thanks for your work!
I am unable to apply the patch, so I only looked at the testcases.
Generally speaking, runtime tests should verify that they work as
expected. Just printing a result does not. Use a comparison
against an expected result and do e.g. STOP 123 on failure.
Also, never use -std=gnu in the options; -std=gnu is the default,
and its behavior may change any time. If you want to test something
that is enabled at F2023, please use -std=f2023. Also, -std=gnu is
meant to enable a GNU extension, but DO CONCURRENT is not an extension
but defined in the Fortran standard.
For details on my comments see below.
Thanks,
Harald
Am 22.09.24 um 08:19 schrieb Anuj Mohite:
diff --git a/gcc/testsuite/gfortran.dg/do_concurrent_10.f90
b/gcc/testsuite/gfortran.dg/do_concurrent_10.f90
new file mode 100644
index 00000000000..6bbeb3bc990
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/do_concurrent_10.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! { dg-options "-std=f2018" }
+
+program do_concurrent_parsing
+ implicit none
+ integer :: concurrent, do
+ do concurrent = 1, 5
+ end do
+ do concurrent = 1, 5
^^^ should this be 'do' instead of 'concurrent'?
+ end do
+end program do_concurrent_parsing
diff --git a/gcc/testsuite/gfortran.dg/do_concurrent_8_f2023.f90
b/gcc/testsuite/gfortran.dg/do_concurrent_8_f2023.f90
new file mode 100644
index 00000000000..a99d81e4a5c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/do_concurrent_8_f2023.f90
@@ -0,0 +1,23 @@
+! { dg-do compile }
+! { dg-options "-std=gnu" }
^^^ here you want -std=f2023
+program do_concurrent_complex
+ implicit none
+ integer :: i, j, k, sum, product
+ integer, dimension(10,10,10) :: array
+ sum = 0
+ product = 1
+ do concurrent (i = 1:10) local(j) shared(sum) reduce(+:sum)
+ ! { dg-error "Variable .sum. at .1. has already been specified in
a locality-spec" "" { target *-*-* } .-1 }
+ ! { dg-error "Sorry, LOCAL and LOCAL_INIT are not yet supported
for 'do concurrent' constructs" "" { target *-*-* } .-2 }
+ do concurrent (j = 1:10) local(k) shared(product) reduce(*:product)
+ ! { dg-error "Variable .product. at .1. has already been
specified in a locality-spec" "" { target *-*-* } .-1 }
+ ! { dg-error "Sorry, LOCAL and LOCAL_INIT are not yet supported
for 'do concurrent' constructs" "" { target *-*-* } .-2 }
+ do concurrent (k = 1:10)
+ array(i,j,k) = i * j * k
+ sum = sum + array(i,j,k)
+ product = product * array(i,j,k)
+ end do
+ end do
+ end do
+ print *, sum, product
+end program do_concurrent_complex
\ No newline at end of file
diff --git a/gcc/testsuite/gfortran.dg/do_concurrent_basic.f90
b/gcc/testsuite/gfortran.dg/do_concurrent_basic.f90
new file mode 100644
index 00000000000..fe8723d48b4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/do_concurrent_basic.f90
@@ -0,0 +1,11 @@
+! { dg-do run }
+program basic_do_concurrent
+ implicit none
+ integer :: i, arr(10)
+
+ do concurrent (i = 1:10)
+ arr(i) = i
+ end do
+
+ print *, arr
+end program basic_do_concurrent
\ No newline at end of file
^^^ this testcase does neither test the result, nor does it provide
anything beyond existing tests. Consider dropping it.
diff --git a/gcc/testsuite/gfortran.dg/do_concurrent_multiple_reduce.f90
b/gcc/testsuite/gfortran.dg/do_concurrent_multiple_reduce.f90
new file mode 100644
index 00000000000..47c71492107
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/do_concurrent_multiple_reduce.f90
@@ -0,0 +1,17 @@
+! { dg-do compile }
+program do_concurrent_multiple_reduce
+ implicit none
+ integer :: i, arr(10), sum, product
+ sum = 0
+ product = 1
+
+ do concurrent (i = 1:10) reduce(+:sum) reduce(*:product)
+ arr(i) = i
+ sum = sum + i
+ product = product * i
+ end do
+
+ print *, arr
+ print *, "Sum:", sum
+ print *, "Product:", product
^^^ please verify results!
+end program do_concurrent_multiple_reduce
\ No newline at end of file
diff --git a/gcc/testsuite/gfortran.dg/do_concurrent_nested.f90
b/gcc/testsuite/gfortran.dg/do_concurrent_nested.f90
new file mode 100644
index 00000000000..83b9cdbc04f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/do_concurrent_nested.f90
@@ -0,0 +1,26 @@
+! { dg-do compile }
+program nested_do_concurrent
+ implicit none
+ integer :: i, j, x(10, 10)
+ integer :: total_sum
+
+ total_sum = 0
+
+ ! Outer loop remains DO CONCURRENT
+ do concurrent (i = 1:10)
+ ! Inner loop changed to regular DO loop
+ do j = 1, 10
+ x(i, j) = i * j
+ end do
+ end do
+
+ ! Separate loops for summation
+ do i = 1, 10
+ do j = 1, 10
+ total_sum = total_sum + x(i, j)
+ end do
+ end do
+
+ print *, "Total sum:", total_sum
+ print *, "Array:", x
^^^ please verify results!
+end program nested_do_concurrent
\ No newline at end of file
diff --git a/gcc/testsuite/gfortran.dg/do_concurrent_reduce_max.f90
b/gcc/testsuite/gfortran.dg/do_concurrent_reduce_max.f90
new file mode 100644
index 00000000000..ddf9626da7b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/do_concurrent_reduce_max.f90
@@ -0,0 +1,14 @@
+! { dg-do compile }
+program do_concurrent_reduce_max
+ implicit none
+ integer :: i, arr(10), max_val
+ max_val = 0
+
+ do concurrent (i = 1:10) reduce(max:max_val)
+ arr(i) = i * i
+ max_val = max(max_val, arr(i))
+ end do
+
+ print *, arr
+ print *, "Max value:", max_val
^^^ please verify results!
+end program do_concurrent_reduce_max
\ No newline at end of file
diff --git a/gcc/testsuite/gfortran.dg/do_concurrent_reduce_sum.f90
b/gcc/testsuite/gfortran.dg/do_concurrent_reduce_sum.f90
new file mode 100644
index 00000000000..1165e0c5243
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/do_concurrent_reduce_sum.f90
@@ -0,0 +1,14 @@
+! { dg-do compile }
+program do_concurrent_reduce_sum
+ implicit none
+ integer :: i, arr(10), sum
+ sum = 0
+
+ do concurrent (i = 1:10) reduce(+:sum)
+ arr(i) = i
+ sum = sum + i
+ end do
+
+ print *, arr
+ print *, "Sum:", sum
^^^ please verify results!
+end program do_concurrent_reduce_sum
\ No newline at end of file
diff --git a/gcc/testsuite/gfortran.dg/do_concurrent_shared.f90
b/gcc/testsuite/gfortran.dg/do_concurrent_shared.f90
new file mode 100644
index 00000000000..6e3dd1c883d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/do_concurrent_shared.f90
@@ -0,0 +1,14 @@
+! { dg-do compile }
+program do_concurrent_shared
+ implicit none
+ integer :: i, arr(10), sum
+ sum = 0
+
+ do concurrent (i = 1:10) shared(sum)
+ arr(i) = i
+ sum = sum + i
+ end do
+
+ print *, arr
+ print *, "Sum:", sum
^^^ please verify results!
+end program do_concurrent_shared
\ No newline at end of file