An interesting CUDA Fortran ICE involving XOR

This is an ICE, and so should probably be fixed or warned against, but I thought I’d report it. Namely, while testing/shaking out some new GPU code, it turns out that you don’t want to name any array “XOR”–which sort of makes sense in this code, name-wise–as it seems to interfere with -Mcuda (as of PGI 12.4).

To test this, I copied the mmul_mod code from the end of the CUDA Fortran manual and put it in mmulmod.F90. I then copied that to a new file, mmulmod.xor.F90 and did a simple sed renaming Asub to XOR:

(339) > diff mmulmod.F90 mmulmod.xor.F90
19c19
-   real, shared :: Asub(16,16), Bsub(16,16)
---
+   real, shared :: XOR(16,16), Bsub(16,16)
39c39
-     ! loads one element of Asub and Bsub
---
+     ! loads one element of XOR and Bsub
41c41
-     Asub(tx,ty) = A(i,kb+ty-1)
---
+     XOR(tx,ty) = A(i,kb+ty-1)
53c53
-       Cij = Cij + Asub(tx,k) * Bsub(k,ty)
---
+       Cij = Cij + XOR(tx,k) * Bsub(k,ty)

Now when you compile:

(337) > pgfortran -Mcuda=keepgpu,keepptx,keepbin mmulmod.F90
/opt/pgi/linux86-64/12.4/lib/f90main.o: In function `main':
f90main.c:(.text+0x40): undefined reference to `MAIN_'
(338) > pgfortran -Mcuda=keepgpu,keepptx,keepbin mmulmod.xor.F90
mmulmod.xor.001.gpu(9): error: expected an identifier

mmulmod.xor.001.gpu(59): error: expected an expression

mmulmod.xor.001.gpu(69): error: expected an expression

3 errors detected in the compilation of "/tmp/pgnvdmhUK-FoMe3r.nv0".
PGF90-F-0000-Internal compiler error. Device compiler exited with error status code       0 (mmulmod.xor.F90: 109)
PGF90/x86-64 Linux 12.4-0: compilation aborted

where line 9 is:

       9 __shared__ __align__(8) long long xor[128];

My guess is that naming an array the same name as an operation/intrinsic can lead to interesting clashes. The right thing to do is not use XOR as an variable name, but it is technically allowed in Fortran, right?

Matt

Hi Matt,

The right thing to do is not use XOR as an variable name, but it is technically allowed in Fortran, right?

I believe you are correct, so I’ve add a problem report (TPR#18656) and sent it on to our engineers for investigation.

Thanks,
Mat

18656 - CUDA Fortran: naming a shared array the same as intrinsic cause CUDA errors is corrected in the current 13.7 release. Thnaks again for the report.

dave