Compiling the snippet:
!$omp target write(*,*)1234 !$omp end target
generates the error:
ifx -qopenmp -fopenmp-targets=spir64 -g -traceback -c tbp.F90 tbp.F90(53): error #8945: Generalized I/O not supported in an offload region. write(*,*)1234 ------^ compilation aborted for tbp.F90 (code 1)
Note: Simple write statements to standard output from an OpenACC offload region are supported by the Nvidia (PGI) compiler.
- Is it possible to have debugging output in a target region of a Fortran program using OpenMP offload and compiling with ifx?
- If this is not currently supported, are there plans for ifx to support simple output from target regions in the future?
- Any other suggestions for inspecting the values of variables in running device code?
This snippet compiles for me .
$ cat snippet.f90 program snippet !$omp target x = 1234. print *, x print *, 1234 !$omp end target stop end $ ifx -qopenmp -fopenmp-targets=spir64 snippet.f90 $ ifx -what --version ifx (IFORT) 2022.0.0 20211123 Copyright (C) 1985-2021 Intel Corporation. All rights reserved.
Thanks for looking into this. It must be because I was using a write(*,*) instead of print*
If I change one of the prints in your snippet I get:
$ cat snip.F90 program snippet !$omp target x = 1234. write(*,*) x print *, 1234 !$omp end target stop end $ ifx -qopenmp -fopenmp-targets=spir64 snip.F90 snip.F90(4): error #8945: Generalized I/O not supported in an offload region. write(*,*) x ^ compilation aborted for snip.F90 (code 1) $
Mystery solved, thank you.
According to the Fortran developers, "At this time, the only I/O we’re allowing in an offload region is 'print *' and even that is limited to numeric and character strings."
I'll add that tidbit to the Porting Guide for ifort Users to ifx.
Thanks all for following up. For what it's worth, write(*,*) and print* are analogous. But I'm in good shape, now that I know the rule.
Also FWIW, I think output of numeric and character strings to stdout from print and write(*,*) is all that the Nvidia compiler supports from an offload region.
Doesn't look like it inside an OpenMP TARGET region.
+ ifx -qopenmp -fopenmp-targets=spir64 snippet.f90 snippet.f90(7): error #8945: Generalized I/O not supported in an offload region. PRINT '("Value=",F6.2)', 123.456 ^ snippet.f90(8): error #8945: Generalized I/O not supported in an offload region. WRITE(CharacterVariable, '("Value=",F6.2)') 123.456 ^ compilation aborted for snippet.f90 (code 1)