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

[Fortran] Incorrect unparsing for omp parallel #134

Closed
ouankou opened this issue Dec 14, 2022 · 2 comments
Closed

[Fortran] Incorrect unparsing for omp parallel #134

ouankou opened this issue Dec 14, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ouankou
Copy link
Contributor

ouankou commented Dec 14, 2022

This bug was found while debugging for issue #130.

Given input:

      program main
      include 'omp_lib.h'
      integer i
      integer item(10)
      external process
      do i = 1, 10
        item(i) = 11-i
      enddo  

!$omp parallel
!$omp single
      print *, 'using ', omp_get_num_threads(), ' threads' 
      do i = 1, 10
!$omp task 
      call process(i,item)
!$omp end task
      enddo  
!$omp end single
!$omp end parallel
      end 

******************************************
      subroutine process(input,item)
      include 'omp_lib.h'
      integer input
      integer item(10)
      print *, 'idx ', input,'-> ', item(input)
      print *, 'by thread ', omp_get_thread_num()
      end

!pragma omp end parallel or !$omp omp end parallel will be inserted right above !$omp end single. Neither should happen.

The output from code above:

      PROGRAM main
      include "omp_lib.h"
      INTEGER :: i
      INTEGER, DIMENSION(10) :: item
      external :: process
      DO i = 1, 10
      item(i) = 11 - i
      END DO
      
!$omp parallel 
      
!$omp single 
      PRINT *, 'using ',omp_get_num_threads(),' threads'
      DO i = 1, 10
      
!$omp task 
      CALL process(i,item)
!$omp end task 
      END DO
      !pragma omp end parallel 
!$omp end single 
******************************************
!$omp end parallel
      END PROGRAM 

      SUBROUTINE process(input,item)
      include "omp_lib.h"
      INTEGER :: input
      INTEGER, DIMENSION(10) :: item
      PRINT *, 'idx ',input,'-> ',item(input)
      PRINT *, 'by thread ',omp_get_thread_num()
      END SUBROUTINE

The extra Fortran comment comes from:

AstAttribute* att = stmt->getAttribute("OmpAttributeList"); //TODO: we removed OmpAttribute and this need to be changed

This piece of code above is fine, but it should not be called in this case. I think the bug exists somewhere else.

@yanyh15
Copy link
Member

yanyh15 commented Dec 19, 2022

@ouankou I also found some bugs related to Fortran, but I am not sure whether it is related to this bug or not. After lowing and unparsing, the new file generated for the outlined function is empty. I am submitting another issue with details for that.

ouankou added a commit that referenced this issue Dec 20, 2022
@ouankou ouankou self-assigned this Dec 20, 2022
@ouankou ouankou added the bug Something isn't working label Dec 20, 2022
@ouankou
Copy link
Contributor Author

ouankou commented Dec 20, 2022

It's fixed by the commit cf02a62. We missed or accidentally removed an upstream commit addressing the situation of multiple Fortran comments following the same statement.

@yanyh15 This bug is not related to issue #135. I tested the code in that issue and still got an empty outlined function.

@ouankou ouankou closed this as completed Dec 20, 2022
@ouankou ouankou changed the title Incorrect omp parallel unparsing in Fortran [Fortran] Incorrect unparsing for omp parallel Dec 20, 2022
ouankou added a commit that referenced this issue Dec 20, 2022
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

2 participants