-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrrectly Master-workshare nesting #857
Comments
@dmishura Awesome - thank you, Dmitry! |
- Cleanup USE OMP_LIB directives.
I explored an approach to use CP2K's convention checker and essentially ban nested parallelism or more specifically a parallel region inside of a master section. However, the GFortran AST cannot be combined with a call graph query unless much additional work is invested. Alternative approach is to rely on an assertion. |
- Avoid IF-condition as part of the directive. - Cleanup USE OMP_LIB directives.
- Avoid IF-condition as part of the directive.
This questions the whole MPI-like programming model in OpenMP based on ( That's too much to ask for ;-) |
- Avoid IF-condition as part of the directive.
- Avoid IF-condition as part of the directive.
- Avoid IF-condition as part of the directive.
- Avoid IF-condition as part of the directive.
- Avoid IF-condition as part of the directive.
- Avoid IF-condition as part of the directive.
- Avoid IF-condition as part of the directive.
- Avoid nested parallelism (dbcsr_acc_set_active_device). - Avoid IF-condition as part of the WORKSHARE-directive. - Keep WORKSHARE if not in parallel region.
- Avoid nested parallelism (dbcsr_acc_set_active_device). - Avoid IF-condition as part of the WORKSHARE-directive. - Keep WORKSHARE if not in parallel region.
- Avoid nested parallelism (dbcsr_acc_set_active_device). - Rely on omp_get_level (instead of omp_in_parallel), omp_in_parallel only accounts for active regions. - Avoid IF-condition as part of the WORKSHARE-directive. - Removed WORKSHARE construct from dbcsr_ptr_util, - otherwise keep WORKSHARE if not in parallel region. - There is potentially invalid nesting (parallel+X), e.g., nested in master or sections constructs.
The current thesis is, nested parallelism like PARALLEL WORKSHARE even inside inside of a MASTER section (which in turn is inside of another PARALLEL region) should never hang. GNU Fortran as well as IFORT seems to confirm this at runtime. However, GNU, IFORT, and IFX produce an error message at compile-time if the nest is not "firewalled" by a subroutine but literally nested (second code-path when writing PROGRAM NESTED
IMPLICIT NONE
INTEGER :: dst(24), src(24), i
DO i = 1, SIZE(src)
src(i) = i - 1
END DO
!$OMP PARALLEL
!$OMP MASTER
#if 1
CALL workshare(dst, src)
#else
!$OMP PARALLEL WORKSHARE
dst(:) = src(:)
!$OMP END PARALLEL WORKSHARE
#endif
!$OMP END MASTER
!$OMP END PARALLEL
DO i = 1, SIZE(dst)
WRITE(*,*) dst(i)
END DO
CONTAINS
SUBROUTINE workshare(dst, src)
INTEGER, INTENT(OUT) :: dst(:)
INTEGER, INTENT(IN) :: src(:)
!$OMP PARALLEL WORKSHARE
dst(:) = src(:)
!$OMP END PARALLEL WORKSHARE
END SUBROUTINE
END PROGRAM The confusion in compiler's implementation seems to stem from |
Nice investigation @hfp ! |
- Avoid nested parallelism (dbcsr_acc_set_active_device). - Rely on omp_get_level (instead of omp_in_parallel), omp_in_parallel only accounts for active regions. - Avoid IF-condition as part of the WORKSHARE-directive. - Removed (nested) PARALLEL WORKSHARE constructs.
- Avoid nested parallelism (dbcsr_acc_set_active_device). - Rely on omp_get_level (instead of omp_in_parallel), omp_in_parallel only accounts for active regions. - Avoid IF-condition as part of the WORKSHARE-directive. - Removed (nested) PARALLEL WORKSHARE constructs.
- Avoid nested parallelism (dbcsr_acc_set_active_device). - Rely on omp_get_level (instead of omp_in_parallel), omp_in_parallel only accounts for active regions. - Avoid IF-condition as part of the WORKSHARE-directive. - Removed (nested) PARALLEL WORKSHARE constructs.
Thanks for pointing this out. |
Found in code evaluation with CP2K. Code hung with latest ifx compiler. Caused by nested OpenMP regions that doesn't allow by standard. Code path contain multiple source files, so only short snippets here.
Situation when __DBCSR_DISABLE_WORKSHARE macros is not defined violated OpenMP standard that says:
" DO, SECTIONS, SINGLE, and WORKSHARE directives are not permitted in the
dynamic extent of CRITICAL, ORDERED, and MASTER directives"
Also please note that MASTER construct is deprecated in latest spec.
Fortran pretty old spec:
https://www.openmp.org/wp-content/uploads/fspec20.pdf
The text was updated successfully, but these errors were encountered: