passlab / rexompiler

REX OpenMP Compiler
https://passlab.github.io/rexompiler/
Other
1 stars 1 forks source link

[Fortran]: The generated file for outlined function is empty #135

Open yanyh15 opened 1 year ago

yanyh15 commented 1 year ago

To reproduce this bug, using the following input file and command:

Input code: hello_omp_parallel.f90:

PROGRAM Parallel_Hello_World

!$OMP PARALLEL

        PRINT *, "Hello from process "

!$OMP END PARALLEL

END

Command to compile:

./bin/rose-compiler -rose:OpenMP:lowering /home/yyan7/compiler/hello_omp_parallel.f90

The command produces two files: rose_hello_omp_parallel.f90 and rex_lib_hello_omp_parallel.f90:

For rose_hello_omp_parallel.f90 (needs to be fixed as well):

#include "rex_kmp.h" 
PROGRAM Parallel_Hello_World
INTEGER :: status = 0
external :: OUT__1__4128__Parallel_Hello_World__7__
CALL __kmpc_fork_call(0,0,OUT__1__4128__Parallel_Hello_World__7__,0)
END PROGRAM 

rex_lib_hello_omp_parallel.f90 is empty

yanyh15 commented 1 year ago

This is likely the setting of file_info->unsetOutputInCodeGeneration () flag in https://github.com/passlab/rexompiler/blob/main/src/frontend/SageIII/sageInterface/sageBuilder.C#L4296 of function buildNondefiningFunctionDeclaration_T which is called by SageBuilder::buildFunctionRefExp that is used in omp_lowering.

The flag setting impact the return of the call UnparseLanguageIndependentConstructs::statementFromFile that is used by unparsing to decide whether to unparse an statement to a file or not.