Skip to content
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

Fix omp lowering and enable basic automated tests #104

Open
ouankou opened this issue Jul 25, 2021 · 1 comment
Open

Fix omp lowering and enable basic automated tests #104

ouankou opened this issue Jul 25, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@ouankou
Copy link
Contributor

ouankou commented Jul 25, 2021

It's been a while since we tested the omp lowering thoroughly last time. Due to unknown reasons, it stops working.
For example, given AXPY OpenMP GPU offloading code, it will throw the following errors and no source code is generated.
https://github.com/passlab/rexomptest/blob/main/REXCompiler/REXReferenceManual/axpy/axpy.c

Start parsing...
Start parsing...
ompparser directive is ready.
Got expression: x
Got expression: y
Got expression: n
Got expression: a
Shared Clause added!
Got expression: i
Private Clause added!
ompparser directive is ready.
ompparser map clause is ready.
ompparser map clause is added.
ompparser map clause is ready.
ompparser map clause is added.
A default schedule clause is added.
func                            = 0x7feb3865b520 
func->get_definingDeclaration() = 0x7feb3865b520 
func                            = 0x7feb3865b520 
Start parsing...
Start parsing...
ompparser directive is ready.
Got expression: x
Got expression: y
Got expression: n
Got expression: a
Shared Clause added!
Got expression: i
Private Clause added!
ompparser directive is ready.
ompparser map clause is ready.
ompparser map clause is added.
ompparser map clause is ready.
ompparser map clause is added.
ompparser directive is ready.
fatal error: ROSE::getNextStatement(): current statement is not found within its scope's statement list
current statement is SgPragmaDeclaration
Inside of Sg_File_Info::displayString() 
isTransformation    = false  isCompilerGenerated = false  line number = 68 column number = 1 filename = /home/ouankou/Projects/rexomptest/REXCompiler/REXReferenceManual/axpy/axpy.c 
Its scope is SgBasicBlock
Inside of Sg_File_Info::displayString() 
isTransformation    = false  isCompilerGenerated = false  line number = 60 column number = 51 filename = /home/ouankou/Projects/rexomptest/REXCompiler/REXReferenceManual/axpy/axpy.c 
rose-compiler: ../../../rex_src/src/roseSupport/utility_functions.C:1654: SgStatement* Rose::getNextStatement(SgStatement*): Assertion `false' failed.
Aborted (core dumped)

The last version before our recent synchronization with ROSE works (working commit: 61a5157). For the same input, the output is:

Start parsing...
Start parsing...
ompparser directive is ready.
ompparser clause is ready.
Got expression: x
Got expression: y
Got expression: n
Got expression: a
Shared Clause added!
ompparser clause is ready.
Got expression: i
Private Clause added!
ompparser directive is ready.
ompparser map clause is ready.
ompparser map clause is added.
ompparser map clause is ready.
ompparser map clause is added.
A default schedule clause is added.

It seems that the current version of REX run the second time and encountered the errors (the lines after "func ..."). We need to check the relevant changes within these three months.
To avoid similar issues in the future, even though the omp lowering is still being developed and not stable, we should enable some basic tests at least. For now, we can generate lowered code to make sure something can be produced successfully, regardless of whether it's correct or not. In the GitHub CI system, there is no GPU, so the GPU programs can't be executed.

@ouankou ouankou added the bug Something isn't working label Jul 25, 2021
@ouankou ouankou self-assigned this Jul 25, 2021
ouankou added a commit that referenced this issue Jul 26, 2021
Last synchronization with ROSE brought a change in the file "src/frontend/SageIII/sageInterface/sageBuilder.C".

When creating a new source file for the outlined function, it was attaching some necessary preprocessing info to the new file.
In the latest commits from ROSE, during outlining, it calls a secondary pass to duplicate the original source file, which contains all the OpenMP source code, and then repeat the whole processing from scratch again. This secondary pass will parse the source code, create the AST and lower the AST.
The lowering will trigger the secondary pass again. Therefore, it falls to an infinite loop here.

As a temporary fix to issue #104, we reverted this particular change for now. More details should be investigated later.
@ouankou
Copy link
Contributor Author

ouankou commented Jul 26, 2021

Last synchronization with ROSE brought a change in the file src/frontend/SageIII/sageInterface/sageBuilder.C.

When creating a new source file for the outlined function, it was attaching some necessary preprocessing info to the new file.
In the latest commits from ROSE, during outlining, it calls a secondary pass to duplicate the original source file, which contains all the OpenMP source code, and then repeats the whole processing from scratch again. This secondary pass will parse the source code, create the AST and lower the AST. The lowering will trigger the secondary pass again. Therefore, it falls to an infinite loop here.

As a temporary fix (commit f13670d), we reverted this particular change for now.
The change to src/frontend/SageIII/ompAstConstruction.cpp come from the ROSE commit rose-compiler/rose@2ecad6f. It solved the fatal error listed above that happened in the infinite loop, but not the infinite loop itself.

It could be some compatibility issue of our code or a bug from ROSE's commits. More details should be investigated to find a better solution to follow ROSE's workflow.

To test this fix, please check the sample code: https://github.com/passlab/rexomptest/tree/main/REXCompiler/REXReferenceManual/multi_src
Build the latest REX compiler, regenerate the lowered code of target.c and foo.c, and then run make.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant