Array slices in CUDA Fortran?

I have a module-scope device array:

real(real_kind), device, allocatable, dimension(:,:) :: coeffs

I have a device subroutine that takes a device array as one of its arguments:

attributes(device) subroutine ConvertToInterpolationCoefficients(length, arr)

		integer :: length
		real(real_kind), device, dimension(length) :: arr

		real(real_kind) :: previous_c
		integer :: n	

		! causal initialization
		arr(1) = lambda * InitialCausalCoefficient(length, arr)
		previous_c = arr(1)

		! causal recursion
		do n=2,length
			arr(n) = lambda*arr(n) + pole*previous_c
			previous_c = arr(n)

		! anticausal initialization
		arr(length) = InitialAnticausalCoefficient(length, arr)
		previous_c = arr(length)

		! anticausal recursion
		do n=length-1,1,-1
			arr(n) = pole * (previous_c - arr(n))
			previous_c = arr(n)

end subroutine ConvertToInterpolationCoefficients

Finally, I have a kernel from which I call the above subroutine. I would like to pass slices of the module-scope array as the 2nd argument as below.

attributes(global) subroutine SamplesToCoefficients2DX(height,width)

		integer, value :: height,width
		integer :: row

		row = (blockidx%x-1) * blockdim%x + threadidx%x
		if(row<=height) then
			call ConvertToInterpolationCoefficients(width, coeffs(row,1:width))
end subroutine SamplesToCoefficients2DX ! line 152

Is this possible? I’m guessing not, since when I do this, I get the following error when I try to compile:

PGF90-F-0000-Internal compiler error. unsupported procedure     370 (../src/cubic_bspline_interp_2D_mod_v2.cuf: 152)

For reference, line 152 is marked in the above kernel code with a comment. I am using version 10.5 on 64-bit Ubuntu Linux. Thanks in advance.

I’m not sure Fortran 90 strong typing will allow you do what you are doing. ConvertToInterpolationCoefficients is expecting a 1-D array:

real(real_kind), device, dimension(length) :: arr

while you are passing a 2-D array:

call ConvertToInterpolationCoefficients(width, coeffs(row,1:width))

In memory, that might be equivalent to a 1-D array of length width, but I’m not sure Fortran 90 allows that when passing to subroutines. If a subroutine is expecting a 1-D array, you have to pass it something typed as a 1-D array. (Or do interface blocks and all that so you can pass 1-D and 2-D arrays to a generic procedure call.)


You’re welcome…if it’s true. These are just my thoughts; Mat or someone else from PGI might ring in here and speak The Truth.

I’ve been hit with lots of strong typing errors recently (all my fault…and how), so it was the first thing that ran through my mind.

Hi Matt, Joe,

We’re most likely trying to convert the 2-D array into a temporary 1-D array when passing to the device routine. I think this should be ok but if not, we should be giving you an error, not an ICE.

Joe, can you please send a reproducing example to PGI Customer Service (


Hi Mat
When 2D array is transformed to 1D, is it row-based or column-based?
1 2
3 4
is the 1D with column-based like this
1 3 2 4


Sorry I haven’t responded, I’ve just finished getting my code working using a different (albeit less elegant) approach. I will send you guys the full code right now.

Fixed in the 12.10 release.