Skip to content

Conversation

skatrak
Copy link
Member

@skatrak skatrak commented Aug 16, 2024

This PR enables Flang lowering and some preliminary MLIR to LLVM IR translation support for teams reductions.

Translation to LLVM IR is limited at the moment: it has only been tested to work for a simple host-only program.

! test.f90
program main
  integer :: sum
  sum = 0
  !$omp teams reduction(+:sum) num_teams(10)
  !$omp parallel reduction(+:sum) num_threads(2)
  sum = sum + 1
  !$omp end parallel
  !$omp end teams
  print *, sum
end program main

! flang-new -fopenmp test.f90 && ./a.out
! 20

Need to investigate incorrect loop reductions (and most likely target SPMD reductions are broken too).

! test.f90
program main
  integer :: sum
  sum = 0
  !$omp teams distribute parallel do reduction(+:sum) num_teams(2)
  do i = 1, 10
    sum = sum + 1
  end do
  !$omp end teams distribute parallel do
  print *, sum
end program main

! flang-new -fopenmp test.f90 && ./a.out
! 20 (should be 10)

@skatrak skatrak requested a review from jsjodin August 16, 2024 12:06
@skatrak skatrak force-pushed the users/skatrak/teams-reduction branch from da27467 to 3643fc4 Compare August 16, 2024 12:14
@skatrak skatrak force-pushed the users/skatrak/teams-reduction branch from 3643fc4 to b996d13 Compare August 22, 2024 15:57
@skatrak
Copy link
Member Author

skatrak commented Oct 1, 2024

Closing as it's already merged as part of #159.

@skatrak skatrak closed this Oct 1, 2024
@skatrak skatrak deleted the users/skatrak/teams-reduction branch October 2, 2024 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant