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

[flang][OpenMP] Add a semantic check to prevent atomic operations on character variables #112918

Open
tblah opened this issue Oct 18, 2024 · 3 comments · May be fixed by #113045
Open

[flang][OpenMP] Add a semantic check to prevent atomic operations on character variables #112918

tblah opened this issue Oct 18, 2024 · 3 comments · May be fixed by #113045
Assignees
Labels
enhancement Improving things as opposed to bug fixing, e.g. new or missing feature flang:frontend flang:openmp

Comments

@tblah
Copy link
Contributor

tblah commented Oct 18, 2024

program o30_301
  character(2) hi
  !$omp atomic write
    hi = 'hi'
  !$omp end atomic
end program

Fails with not yet implemented: Unsupported atomic type. The wording of the standard is that atomic operations should operate on "scalar variables of intrinsic type" (OpenMP 5.2 section 4.3.1.3).

In Fortran 2023, a scalar variable is defined (3.119) as "data entity that can be represented by a single value of the type and that is not an array". I think that means that a the character variable in the above example is scalar and of intrinsic type.

gfortran and classic flang do not allow character variables in atomic types.

@tblah tblah added enhancement Improving things as opposed to bug fixing, e.g. new or missing feature flang:openmp labels Oct 18, 2024
@kkwli
Copy link
Collaborator

kkwli commented Oct 18, 2024

A scalar variable in the OpenMP spec is defined as: "For Fortran, a scalar variable with intrinsic type, as defined by the base language, excluding character type." (OpenMP 5.2 14:7-8)

I think flang should issue an error but not "not yet implement: ...".

@tblah
Copy link
Contributor Author

tblah commented Oct 18, 2024

Thanks. I agree. This should be a semantic error then

@tblah tblah changed the title [flang][OpenMP] support atomic operations on characters [flang][OpenMP] Add a semantic check to prevent atomic operations on character variables Oct 18, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 18, 2024

@llvm/issue-subscribers-flang-frontend

Author: Tom Eccles (tblah)

``` program o30_301 character(2) hi !$omp atomic write hi = 'hi' !$omp end atomic end program ```

Fails with not yet implemented: Unsupported atomic type. The wording of the standard is that atomic operations should operate on "scalar variables of intrinsic type" (OpenMP 5.2 section 4.3.1.3).

In Fortran 2023, a scalar variable is defined (3.119) as "data entity that can be represented by a single value of the type and that is not an array". I think that means that a the character variable in the above example is scalar and of intrinsic type.

gfortran and classic flang do not allow character variables in atomic types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improving things as opposed to bug fixing, e.g. new or missing feature flang:frontend flang:openmp
Projects
None yet
5 participants