14.1 llvm problem with constant arrays in modules

The following will not compile with 14.1 and -Mcuda=llvm

module weights
  real*8, parameter :: w(0:1) = (/ 1d0, 1d0 /)
end module weights
implicit none
real*8, device, dimension(64) :: fdev
integer loop
fdev = 1d0
!$cuf kernel do(1) <<<  (*), (*) >>> 
do loop=1,64
   fdev(loop)=fdev(loop)+1d0
enddo
end

The error messages are

nvvmCompileProgram error: 9.
Error: /tmp/pgcudaforABmgowjCRc83.gpu (12, 61): parse error: constant expression type mismatch
PGF90-F-0155-Compiler failed to translate accelerator region (see -Minfo messages): Device compiler exited with error status code (PGI-14.1-module-constant-bug.f90: 1)
PGF90/x86-64 Linux 14.1-0: compilation aborted

The relevant part of the LLVM code (with line 12 in the middle) is

; Begin module variables

@_weights_10_0 = internal addrspace(4) global [64 x double]  [ double  1.00000000000000000E+0, double  1.00000000000000000E+0 ] , align 16

; End module variables

The compiler tries to include the array of constants in the LLVM code it generates, even though the main program doesn’t use the module. In my full program I want to include a similar module in subroutines that don’t contain GPU kernels.

Hi Paul,

Thanks for the example. Looks like our engineers found and fixed this one in 14.2 which while be out in the next day or so.

% pgf90 -Mcuda=llvm llvm.cuf -V14.1
nvvmCompileProgram error: 9.
Error: /tmp/pgcudaforZluczj3OkC1q.gpu (12, 61): parse error: constant expression type mismatch
PGF90-F-0155-Compiler failed to translate accelerator region (see -Minfo messages): Device compiler exited with error status code (llvm.cuf: 1)
PGF90/x86-64 Linux 14.1-0: compilation aborted
% pgf90 -Mcuda=llvm llvm.cuf -V14.2
%
  • Mat