Assumed shape arrays

I have stumbled upon a very interesting to me topic. I have written a CUDA Fortran program which takes as input very big double precision arrays (with 115540 elements). I have the subroutine defined in a module, however the only possibility to declare the intent(in) arrays is as assumed size arrays with a (*). I include for completeness my subroutine argument list:


attributes ( global ) subroutine sqrt_temp_int_cuda(T_high,T_low,T_int,IBlock1,IBlock2,Iblock_int,size_dblock1)
     
     integer,parameter :: t=selected_real_kind(12,26) 
     real(T),value :: T_high,T_low,T_int
     real(T),intent(in) :: IBlock1(*),IBlock2(*)
     real(T),intent(out) :: Iblock_int(*)
     integer,value :: size_dblock1
     integer :: i

If I try to use assumed shape arrays (

IBlock1(:)

),I have compilation problems.
My question is:
Is it a general rule to use assumed size arrays or I am doing something wrong.
My last comment is that I use pinned arrays.

Thank you in advance
[/code]

Hi wronski11

Is it a general rule to use assumed size arrays or I am doing something wrong.

Using assumed size arrays should be fine, though I’ll need a complete example to determine what’s wrong. Can you either post or send to PGI Customer Service (trs@pgroup.com) an reproducing example?

Thanks,
Mat

Hi,
First of all thank you for your response. I cannot paste the full code because it is quite large, however here are some main features. The CUDA code is used to interpolate two arrays, which are with double precision reals. Below I include one of the CUDA subroutines I use.



     #ifdef CUDAT                                                                                                                      
     
     module cuda_int                                                                                                                   
     contains
     attributes ( global ) subroutine sqrt_temp_int_cuda(T_high,T_low,T_int,IBlock1,IBlock2,Iblock_int,size_dblock1)                   
     
     integer,parameter :: t=selected_real_kind(12,26)                                                                                  
     real(T),value :: T_high,T_low,T_int
     real(T),intent(in) :: IBlock1(*),IBlock2(*)                                                                                       
     real(T),intent(out) :: Iblock_int(*)                                                                                              
     integer,value :: size_dblock1                                                                                                     
     integer :: i                                                                                                                      
     
     i = blockDim%x*( blockIdx%x -1) + threadIdx%x                                                                                     
     
     if (i <=  (size_dblock1-1) ) then                                                                                                 
     
     Iblock_int(i)=(IBlock1(i)-IBlock2(i))*((T_high - T_int)/(T_high - T_low))+IBlock2(i)                                              
     
     end if                                                                                                                            
     
     end subroutine                                                                                                                    
     
     end module                                                                                                                        
    
    #endif

All arrays are pinned


Thank you in advance

A. Ivanov

Hi A. Ivanov,

All arrays are pinned

This might be your issue since the pinned attribute can only be applied to host arrays. If IBlock1, IBlock2, and Iblock_int are pinned, then this would cause an error since you need to pass in device arrays.

Note, in my earlier post I meant to say “Using assumed shape arrays should be fine”.

  • Mat

Hi if I understand the idea behind the pinned arrays, those are arrays defined in order to enhance the memory transfer between the host and the device. I have pinned arrays which I allocate on the host than I initialize them and what I pass to the device subroutine are of course device arrays. IBlock1, IBlock2, and Iblock_int are device arrays, into which the values contained in the host pinned arrays where copied. After this is done come the issue that the intent(in) arguments of the device subroutine should be assumed size arrays.

Can you please send to PGI Customer Service (trs@pgroup.com) an reproducing example?

Yesterday I submitted an example code, illustrating my problem, to the ‘trs@pgroup.com’.

FYI for those following along, the problem was that wronski11 was using a very early release (10.4) of CUDA Fortran which was missing a few features, including assumed shape arrays which was added in 10.5.

  • MAt