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

ACCKernelsTrans should exclude character assignments #2854

Open
arporter opened this issue Jan 15, 2025 · 4 comments
Open

ACCKernelsTrans should exclude character assignments #2854

arporter opened this issue Jan 15, 2025 · 4 comments

Comments

@arporter
Copy link
Member

Daley has found that if we include character assignments within a KERNELS region, the nvfortran compiler (24.5) errors with:

Character local variable unsupported on device

Unfortunately, a simple example does not replicate this problem which indicates it's probably a compiler bug and depends on the precise context.

NEMO source files that exercise this problem: obs_group_def.f90, sbccpl.f90

@arporter
Copy link
Member Author

I think the sensible thing for us to do is to exclude character assignments. In #2602 I did initially alter ACCKernelsTrans to exclude all character literals but that had a big, negative performance impact. Therefore, I refined it to check for character vars of assumed size. I can try just checking for literals on the RHS of assignments...

@arporter
Copy link
Member Author

We could have an option to permit them so that a developer can always enable them if the compiler is happy.

@arporter
Copy link
Member Author

A similar but related problem...we get an ICE in lib_mpp (the nml reading code therein) for:

          !$acc kernels
          cdnambuff(itot:itot + inl - 1) = chline(1:inl)
          !$acc end kernels

where:

   CHARACTER(LEN = :), ALLOCATABLE, INTENT(INOUT) :: cdnambuff

and the error is:

NVFORTRAN-S-0000-Internal compiler error. size_of: attempt to size deferred size character

@arporter
Copy link
Member Author

Sergi has pointed out that we don't have this problem in the OMP-related transformation script because there, we first use the ArrayAssignment2LoopsTrans transformation and the validate of that class checks for string assignments:

for child in node.walk((Literal, Reference)):
try:
forbidden = ScalarType.Intrinsic.CHARACTER
if (child.is_character(unknown_as=False) or
(child.symbol.datatype.intrinsic == forbidden)):
message = (f"{self.name} does not expand ranges "
f"on character arrays by default (use the"
f"'allow_string' option to expand them)")
if verbose:
node.append_preceding_comment(message)
# pylint: disable=cell-var-from-loop
raise TransformationError(LazyString(
lambda: f"{message}, but found:"
f"\n{node.debug_string()}"))
except (NotImplementedError, AttributeError):
# We cannot always get the datatype, we ignore this for now
pass

It's not a lot of code so I think the simplest solution is to copy that bit into the validate of ACCKernelsTrans. I think any other transformation will be OK because they too will have to first use ArrayAssignment2LoopsTrans.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant