Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

[OMPIRBuilder] Improve type handling for kmpc_for_static_loop #237

Conversation

skatrak
Copy link
Contributor

@skatrak skatrak commented Oct 2, 2023

There are 4 variants to this new RTL function:

  • kmpc_for_static_loop_4: 4-byte, signed
  • kmpc_for_static_loop_4u: 4-byte, unsigned
  • kmpc_for_static_loop_8: 8-byte, signed
  • kmpc_for_static_loop_8u: 8-byte, unsigned

This patch aims at using the type of the trip count variable to select the appropriate variant of this RTL function, rather than always calling the signed 4-byte version and possibly truncating the trip count. It's based on getKmpcForDynamicInitForType() and other similar helper functions, which result always in codegen for the unsigned variants of the function.

A small bug, which produces a compiler crash when a target worksharing loop construct does not capture outside variables, is also addressed. This example would trigger this bug:

subroutine foo()
  !$omp target parallel do
  do i = 1, 10
    call bar(i)
  end do
  !$omp end target parallel do
end subroutine

There are 4 variants to this new RTL function:
  - kmpc_for_static_loop_4: 4-byte, signed
  - kmpc_for_static_loop_4u: 4-byte, unsigned
  - kmpc_for_static_loop_8: 8-byte, signed
  - kmpc_for_static_loop_8u: 8-byte, unsigned

This patch aims at using the type of the trip count variable to select the
appropriate variant of this RTL function, rather than always calling the signed
4-byte version and possibly truncating the trip count. It's based on
`getKmpcForDynamicInitForType()` and other similar helper functions, which
result always in codegen for the unsigned variants of the function.

A small bug, which produces a compiler crash when a target worksharing loop
construct does not capture outside variables, is also addressed. This example
would trigger this bug:

```
subroutine foo()
  !$omp target parallel do
  do i = 1, 10
    call bar(i)
  end do
  !$omp end target parallel do
end subroutine
```
@skatrak skatrak self-assigned this Oct 2, 2023
@skatrak
Copy link
Contributor Author

skatrak commented Oct 11, 2023

Closing due to being replaced by #240.

@skatrak skatrak closed this Oct 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant