I am experimenting a bit with OpenACC to accelerate my program, but unfortunately I get a crash at the first directive. The attached program is a minimal reproducer for this problem.
Details:
Windows 11, gfortran version 15.2.0 (I obtained this from equation.com, that may be an important detail).
Compile options: -fopenmp or -fopenmp -foffload disable - the behaviour was the same, a crash.
I also tried this on a Linux system, with version 13.2.0 and that ran fine.
Any clues? I would immediately believe that I am making a trivial mistake somewhere … chk_acc.f90 (614 Bytes)
gfortran -fopenacc -O3 -fopt-info-optimized xx.f90 -o xx &&
# Print debug information during memory transfers and kernel execution
export ACC_NOTIFY=1
./xx
Yes, and I would suggest -fopt-info-optimized and -O3 as well if you are
just starting. Actually, you probably always want to use -O3 with -openacc
unless you are debugging. If you want to watch something small run and notify you about actions taken run with the ACC_NOTIFY variable set as well, at least
till you are comfortable you are set up properly.
I was going to say use the “use openacc” directive and it will cause an error
unless you use the -fopenacc option but just tried it and it compiles anyway.
“use openacc” is optional for most programs but I thought sticking it in made
sure I was loading properly, but apparently that is wrong; but with -fopt-info-optimized is used you should see “openACC” in the output when compiling.
Adding -g0 -fbacktrace -fcheck=all and checking that you are not putting a large array on the stack and that your stack size is unlimited if on Linux, or changing to allocate a large array instead of declaring it with a large size would get rid of or identify the simpler issues. Does the code run without -fopenacc?
Well, the program allocates an array of 10 thousand elements, not excessive I hope. It runs if I leave out the -fopenacc option and there are no runtime messages at all:
In program
Starting …
do while …
1
2
3
4
5
6
7
8
9
10
10.0000000
I have received information that it may actually be a bug/limitation in gfortran. The alternative is to use an explicit loop to copy the values from the host to the device (and vice versa). I will have to try that myself, but that will come later.
I am reproducing your reported problem with Gfortran on Win 10
Tested on Gfortran 15.1 and 16.1 / 16.2
Tested ok with -fopenmp but fails with -fopenacc
All Gfortran versions I tested appear to have the same result.
I don’t have experience using -fopenacc.
(16.2 fixed my problems with OpenMP )
ECHO is on.
"++++++++++++++++++++++++++++++++++++++++"
PROCESSOR_DESCRIPTION=AMD Ryzen 9 5900X 12-Core Processor 64GB 3200MHz memory
options=-fimplicit-none -O3 -fopenmp -march=native -fstack-arrays
gcc_path=C:\Users\John\gcc-16.1.0\bin;C:\Users\John\gcc-16.1.0\libexec\gcc\x86_64-w64-mingw32\16.1.0
In program
Starting ...
do while ...
1
2
3
4
5
6
7
8
9
10
10.0000000
ECHO is on.
"++++++++++++++++++++++++++++++++++++++++"
PROCESSOR_DESCRIPTION=AMD Ryzen 9 5900X 12-Core Processor 64GB 3200MHz memory
options=-fimplicit-none -O3 -fopenmp -march=native -fstack-arrays
gcc_path=C:\Program Files (x86)\gcc_eq\gcc_15.1.0\bin;C:\Program Files (x86)\gcc_eq\gcc_15.1.0\libexec\gcc\x86_64-w64-mingw32\15.1.0
In program
Starting ...
do while ...
1
2
3
4
5
6
7
8
9
10
10.0000000
ECHO is on.
"++++++++++++++++++++++++++++++++++++++++"
PROCESSOR_DESCRIPTION=AMD Ryzen 9 5900X 12-Core Processor 64GB 3200MHz memory
options=-fimplicit-none -O3 -fopenacc -march=native -fstack-arrays
gcc_path=C:\Program Files (x86)\gcc_eq\gcc_15.1.0\bin;C:\Program Files (x86)\gcc_eq\gcc_15.1.0\libexec\gcc\x86_64-w64-mingw32\15.1.0
{{ failed with Segmentation fault }}
ECHO is on.
"++++++++++++++++++++++++++++++++++++++++"
PROCESSOR_DESCRIPTION=AMD Ryzen 9 5900X 12-Core Processor 64GB 3200MHz memory
options=-fimplicit-none -O3 -fopenacc -march=native -fstack-arrays
gcc_path=C:\Users\John\gcc-16.2.0\bin;C:\Users\John\gcc-16.2.0\libexec\gcc\x86_64-w64-mingw32\16.2.0
{{ failed with Segmentation fault }}