PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

Assumed shape arrays
Goto page 1, 2  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
wronski11



Joined: 15 Jun 2011
Posts: 8

PostPosted: Thu Feb 23, 2012 9:07 am    Post subject: Assumed shape arrays Reply with quote

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:


Code:
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 (
Code:
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]
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6208
Location: The Portland Group Inc.

PostPosted: Thu Feb 23, 2012 10:07 am    Post subject: Reply with quote

Hi wronski11

Quote:
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
Back to top
View user's profile
wronski11



Joined: 15 Jun 2011
Posts: 8

PostPosted: Mon Feb 27, 2012 5:25 am    Post subject: Reply with quote

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.



Code:
     #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
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6208
Location: The Portland Group Inc.

PostPosted: Mon Feb 27, 2012 11:41 am    Post subject: Reply with quote

Hi A. Ivanov,

Quote:
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
Back to top
View user's profile
wronski11



Joined: 15 Jun 2011
Posts: 8

PostPosted: Tue Feb 28, 2012 7:01 am    Post subject: Reply with quote

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.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group