An optimization called “dead code elimination” is removing C since it’s never used. Hence, there is nothing to accelerate. To fix, print a value of C after the loop.
I added a write statement after the loop, but got the following errors…
Error 1 unresolved external symbol _MAIN referenced in function MAIN tp.obj
Error 2 unresolved external symbol _cudaThreadSynchronize referenced in function ___pgi_cuda_launchk libacc1cu.lib
Error 3 unresolved external symbol _cudaEventCreate referenced in function ___pgi_cuda_launchk libacc1cu.lib
Error 4 unresolved external symbol _cudaEventRecord referenced in function ___pgi_cuda_launchk libacc1cu.lib
Error 5 unresolved external symbol _cudaEventSynchronize referenced in function ___pgi_cuda_launchk libacc1cu.lib
Error 6 unresolved external symbol _cudaEventElapsedTime referenced in function ___pgi_cuda_launchk libacc1cu.lib
When you installed the compilers, did you also install the CUDA Tookkit that is included in the PGI installation package? If you are not sure, look in the directory where your PGI compilers are installed (.i.e. $PGI). The CUDA libraries should be in “$PGI/linux86-64/2011/cuda/” If you do not have this directory, please reinstall the compilers, and select ‘yes’ when asked if you wish to install the CUDA Toolkit.
If you do have the CUDA Toolkit installed, please post your complete compilation, link, and output with the addition of the “-v” (verbose) flags.
Thanks for the reply. I had put the write statement before the !$acc end region directive instead of after it. Now I am getting the output. I observed that the compiler generates a ‘copyout(c(1:n))’ even if it is not mentioned explicitly as a clause in the !$acc region directive. Also, I face problems if I use a format specifier in the write statement i.e.
I observed that the compiler generates a ‘copyout(c(1:n))’ even if it is not mentioned explicitly
Correct. You only need to use the copy clauses when you want to override the compiler default or when the compiler can not determine the bounds of an array.
Also, I face problems if I use a format specifier in the write statement
It works for me. Though, posting example would help since I can never be sure I’m doing the exact same thing as you as was the case with your previous error.