PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Reshape intrinsic for cuda fortan

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
Sriram Chivukula



Joined: 14 Jun 2012
Posts: 5

PostPosted: Thu Oct 17, 2013 1:12 pm    Post subject: Reshape intrinsic for cuda fortan Reply with quote

Hi,

I have a 3D array on device and want to reshape it to 1D. What is the best possible option. Don't want do a data copy from location to another.

here is a example code:

HOST CODE:
Code:
integer, dimension(10,20,30),device:: temp1
integer,dimension(6000),device:temp2

temp2 = reshape(source=temp1,shape=shape(temp2))


The above code doesn't seem to work.

I was wondering whether reshape is supported in cuda fortan or not.
I tried googling but was unable to get any useful information.

Sriram
Back to top
View user's profile
mkcolg



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

PostPosted: Mon Oct 21, 2013 10:55 am    Post subject: Reply with quote

Hi Sriram,

RESHAPE isn't supported with device arrays since it would require the data to be copied back to the host, put in a temp array, perform the reshape, and then copy the data back to the device. However, even if supported, RESHAPE would copy the data.

What I think you want is that "temp1" and "temp2" both point to the same data on the device. In this case what you need to do is change temp2 to be allocatable, and then use the "c_f_pointer" to have both arrays point to the same data.

For example, something like:

Code:
...
integer, dimension(10,20,30), device:: temp1
integer,dimension(:),allocatable,device:temp2
call c_f_pointer(C_DEVLOC(temp1), temp2, SIZE(temp1))
...


Hope this helps,
Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming All times are GMT - 7 Hours
Page 1 of 1

 
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