Fortran PGI Compiler Copy to Constant Variable failure

Hello all. Wondering if anyone has come across this error before? I think I’m missing some Fortran stuff but I’m not sure. I’m copying a variable to constant memory. What is interesting is that a few things have changed in the meantime. The first version I had was pretty good and worked well. However Ive changed the hardware and the driver.

I’m currently using nvidia docker with Ubuntu 14.04LTS. nvidia-smi reports

+------------------------------------------------------+                       
| NVIDIA-SMI 361.42     Driver Version: 361.42         |                       
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 960     Off  | 0000:01:00.0      On |                  N/A |
| 30%   26C    P8    10W / 120W |    217MiB /  2039MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
+-----------------------------------------------------------------------------+

This card is also in use as my display card.

The constant term is defined here:

13   use cudafor
14   integer, constant :: n_flow_vars_OP2

It is set here:

istat = cudaMemcpyToSymbol(c_loc(n_flow_vars_OP2), N_FLOW_VARS, 1, 0, cudaMemcpyHostToDevice)
write(*,*) "ISTAT", cudaGetErrorString(istat)

The output is

ISTAT
invalid device symbol

Interestingly, copying like this gives a different message

istat = cudaMemcpy(N_FLOW_VARS,n_flow_vars_OP2, 1, cudaMemcpyHostToDevice)

gives

0: Get Symbol Address (cmblk=0xa81e60) FAILED: 13(invalid device symbol)

I’ve seen some things about using a string representation vs the actual symbol but I’ve had issues with both. Has anyone seen this sort of thing before?

Cheers

Ben

Hi Ben:

You are using c_loc() on a device variabe which won’t work. c_devloc(), which is defined in the cudafor module, should be used instead. There is an example of using c_devloc() in the article on batched cublas at:

Also, constant memory must be declared at module scope, not sure if that is the case from the code you listed above.

Finally, I think you can accomplish what you are trying to do simply with an assignment statement:

n_flow_vars_OP2 = N_FLOW_VARS

Hope this helps,

Greg