the code works with "-fast" compiler flag, but without "-fast" the compilation fails

I have a simple code: https://github.com/AndStorm/openacc.git. It reproduces the error i get.
I use the compile line, which is specified in README.md file of the git repository, because i am not able to write it here - when i click on the “Preview” button, the browser opens a blank page with “403 - Forbidden”. The code is compiled for launch on GPU using OpenAcc and PGI 19.4 compiler.

The code works properly. But if to uncomment the line 233 of nbody.cpp file (it is already uncommented), the compilation fails with an error:

PGCC-S-0155-Procedures called in a compute region must have acc routine information: t3::ParticleTable::ParticleTable(const t3::ParticleTable&) (/home/70-gaa/NFbuild_script_CHECK_GPU/source_HOW_KMV_told/nbody.cpp: 233)
PGCC-S-0155-Accelerator region ignored; see -Minfo messages

And if to add “-fast” compiler flag, the code compiles and seemes to work well.
What should i do to get the code to work without “-fast”?
P. C. I sent another question to the PGI Customer Service yesterday and did not receive a reply yet, i am afraid it was lost. Could You be so kind to have a look at it?

Hi Andrey,

I use the compile line, which is specified in README.md file of the git repository, because i am not able to write it here - when i click on the “Preview” button, the browser opens a blank page with “403 - Forbidden”.

We’re not sure what’s wrong here, but you’re 4th users to encounter this issue. Our webmaster is investigating. I’ll update once I know more. Our current theory is that it’s a browser security issue and that you may want to check if your SSL and TLS security settings are up to date.

The code works properly. But if to uncomment the line 233 of nbody.cpp file (it is already uncommented), the compilation fails with an error:

“-fast” implies inlining, hence the constructor is getting inlined when -fast is used. Without inlining, the compiler is expecting a device routine for the constructor.

Though the real issue is that you’re passing “aParticles” by value to “SetEtot”. This causes a copy of “aParticles” to be created and why the constructor is getting invoked. Instead, pass “aParticles” by reference so it doesn’t get copied and hence no constructor call.

P. C. I sent another question to the PGI Customer Service yesterday and did not receive a reply yet, i am afraid it was lost. Could You be so kind to have a look at it?

Unless Alex already responded, I don’t see a note yesterday from you. Though, I do see the one from this morning. I’ll take a look at that in a few.

-Mat

Thank You for the answer.
Added “-Minline” flag to the compile line and now pass the ParticleTable object by reference. Now the code compiles, but fails at runtime with an error:

Failing in Thread:1
call to cuStreamSynchronize returned error 700: Illegal address during kernel execution

I described the problem thoroughly in the letter which i sent to the PGI Customer Support Service.
Could You be so kind to have a look at it?

Excuse me, please. There was a silly small error in the code, i corrected it.
But this error occurs again, a little bit later at runtime.
I found that it is because std::map is used in T3ParticleTable.h:
https://github.com/AndStorm/openacc.git, the previous commit “2.09.19 Everything works on CPU and GPU properly.” commit f45bfcfa5c5ac9ef20700bd4f4fad783e737a2

If to comment std::map usage in GetMass() in T3ParticleTable.h - #1 code piece at line 56 and below and use instead of it either #2 code piece (line 80) or #3 code piece at line 107, the program works fine. Why?

I also have a question why the code in the last commit at https://github.com/AndStorm/openacc.git fails at the compile time with an error:

PGCC-S-0155-Cannot determine bounds for array this

I sent a letter to the PGI Customer Service, where thoroughly described the question.
Could You be so kind to answer?