Page MenuHomePhabricator

[flang][OpenMP] Add Fortran Specific Semantic Checks for Allocate Directive
Needs ReviewPublic

Authored by Rin on Dec 18 2020, 8:54 AM.

Details

Summary

This is a work in progress

Some comments about this patch:

There seem to be a few issues with the parser.
Currently for this fortran code:

!$omp allocate(zarray) allocator(omp_const_mem_alloc)
!$omp allocate(z) allocator(omp_large_cap_mem_alloc)
!$omp allocate(a) allocator(omp_default_mem_alloc)
!$omp allocate
   allocate ( zarray(z,t) )

The parse tree looks like this:

| | ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPDeclarativeAllocate
| | | Verbatim
| | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'zarray'
| | | OmpClauseList -> OmpClause -> Allocator -> Scalar -> Integer -> Expr = '1_4'
| | | | Designator -> DataRef -> Name = 'omp_const_mem_alloc'
| | ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPDeclarativeAllocate
| | | Verbatim
| | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'z'
| | | OmpClauseList -> OmpClause -> Allocator -> Scalar -> Integer -> Expr = '1_4'
| | | | Designator -> DataRef -> Name = 'omp_large_cap_mem_alloc'
| | ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPDeclarativeAllocate
| | | Verbatim
| | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'a'
| | | OmpClauseList -> OmpClause -> Allocator -> Scalar -> Integer -> Expr = '1_4'
| | | | Designator -> DataRef -> Name = 'omp_default_mem_alloc'
| | ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPExecutableAllocate

Whereas it should look something like this.

| | ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPExecutableAllocate
| | | ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPDeclarativeAllocate
| | | | Verbatim
| | | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'zarray'
| | | | OmpClauseList -> OmpClause -> Allocator -> Scalar -> Integer -> Expr = '1_4'
| | | | | Designator -> DataRef -> Name = 'omp_const_mem_alloc'
| | | ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPDeclarativeAllocate
| | | | Verbatim
| | | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'z'
| | | | OmpClauseList -> OmpClause -> Allocator -> Scalar -> Integer -> Expr = '1_4'
| | | | | Designator -> DataRef -> Name = 'omp_large_cap_mem_alloc'
| | | ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPDeclarativeAllocate
| | | | Verbatim
| | | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'a'
| | | | OmpClauseList -> OmpClause -> Allocator -> Scalar -> Integer -> Expr = '1_4'
| | | | | Designator -> DataRef -> Name = 'omp_default_mem_alloc'

This is affecting the Semantic checks as the list of OpenMPDeclarativeAllocate will always be empty, since they come before the OpenMPExecutableAllocate.

Test also need to be added.

Diff Detail

Event Timeline

Rin created this revision.Dec 18 2020, 8:54 AM
Rin requested review of this revision.Dec 18 2020, 8:54 AM
Herald added a project: Restricted Project. · View Herald Transcript
Rin edited the summary of this revision. (Show Details)Dec 18 2020, 8:55 AM
Rin added a reviewer: kiranchandramohan.
Rin retitled this revision from Add Fortran Specific Semantic Checks for Allocate Directive to [flang][OpenMP] Add Fortran Specific Semantic Checks for Allocate Directive.
Rin added projects: Restricted Project, Restricted Project.
Rin updated this revision to Diff 312818.Dec 18 2020, 8:58 AM
Rin edited the summary of this revision. (Show Details)

Remove unnecessary comments

Rin edited the summary of this revision. (Show Details)Dec 18 2020, 9:01 AM
Rin added inline comments.Dec 18 2020, 9:04 AM
flang/lib/Semantics/check-omp-structure.cpp
274

This functioned is removed and a different one is reused In the General Semantic Checks patch. This should be taken care of after a rebase.

flang/lib/Semantics/resolve-directives.cpp
373

This function is never used, but should be. A place where the ExecutableAllocateNames should be cleared needs to be chosen.

1065

The declarativeList is always empty. My assumption is this happens because the declarative allocate appears before the executable one and so the list remains empty.

1072

Unnecessary comment here that will be removed