Fortran 'get' command

[Old posts from the commercial version of ArrayFire] Discussion of ArrayFire using CUDA or OpenCL.

Moderator: pavanky

Fortran 'get' command

Postby hazm13 » Wed Feb 19, 2014 5:37 pm

In the 'array_get' function, is there a reason why d3 must be an integer rather than another array? I would like to index a 3D portion of a 3D array rather than 2D slices if possible.

Code: Select all
type(array) array_get    (    type(array),intent(in)     in,
      type(array),intent(in)             d1,
      type(array),intent(in),optional     d2,
      integer,intent(in),optional     d3,
      integer,intent(in),optional     d4
   )       [inherited]


Thanks, Harry
hazm13
 
Posts: 12
Joined: Wed Feb 12, 2014 3:22 pm
Location: Southampton

Re: Fortran 'get' command

Postby pavanky » Thu Feb 20, 2014 4:20 pm

Hi Harry,

We can not do this right now. We can add this in the next release.

For now you can use moddims to squish the array into 2 dimensions and use get, and then reshape them after indexing.

Sorry about the terrible hack. But there is no easy way to do this before the next release.
Pavan Yalamanchili,
ArrayFire
--
~ If it is not broken, you have not tried hard enough ~
User avatar
pavanky
Site Admin
 
Posts: 1123
Joined: Mon Mar 15, 2010 7:39 pm
Location: Atlanta, GA

Re: Fortran 'get' command

Postby hazm13 » Sat Feb 22, 2014 8:07 am

Hi,

Ok, I will give that a try for now, thanks for the response.

Can you say when the new release is scheduled for?

Thanks
hazm13
 
Posts: 12
Joined: Wed Feb 12, 2014 3:22 pm
Location: Southampton

Re: Fortran 'get' command

Postby pavanky » Mon Feb 24, 2014 2:31 pm

We do not have a set date yet. But we will have a release in March.
Pavan Yalamanchili,
ArrayFire
--
~ If it is not broken, you have not tried hard enough ~
User avatar
pavanky
Site Admin
 
Posts: 1123
Joined: Mon Mar 15, 2010 7:39 pm
Location: Atlanta, GA

Re: Fortran 'get' command

Postby pavanky » Thu Mar 06, 2014 5:48 pm

Hi Harry,

Are you indexing random locations or are you using sequences as in A(1:3, 2:4, 3:5) ?
Pavan Yalamanchili,
ArrayFire
--
~ If it is not broken, you have not tried hard enough ~
User avatar
pavanky
Site Admin
 
Posts: 1123
Joined: Mon Mar 15, 2010 7:39 pm
Location: Atlanta, GA

Re: Fortran 'get' command

Postby hazm13 » Sun Mar 09, 2014 10:16 am

Hi,

We are indexing using sequences, more detail as follows:

Our non CUDA code has a 'point' subroutine that points to a subset of data in a 2D or 3D array - by default it points to everything apart from the outside 'faces', e.g. in 2D it would point to the central value of a 3x3 array, the middle 2x2 values of a 4x4 array etc. We also have built shifting into the point function which can shift the point in any dimension depending on input. We would like to be able to move the original array over to the GPU and then perform the points and shifted points on the device rather than having to point on the host and transfer over as this leads to far too many memory copies and makes memory management trickier.

Thanks, Harry
hazm13
 
Posts: 12
Joined: Wed Feb 12, 2014 3:22 pm
Location: Southampton

Re: Fortran 'get' command

Postby pavanky » Mon Mar 10, 2014 11:15 am

Hi Harry,

I just made a commit that should fix the issue. You can get the latest version of the fortran wrapper from here: https://github.com/arrayfire/arrayfire_fortran

You can followup on the issue over here: https://github.com/arrayfire/arrayfire_fortran/issues/2
Pavan Yalamanchili,
ArrayFire
--
~ If it is not broken, you have not tried hard enough ~
User avatar
pavanky
Site Admin
 
Posts: 1123
Joined: Mon Mar 15, 2010 7:39 pm
Location: Atlanta, GA

Re: Fortran 'get' command

Postby hazm13 » Mon Mar 17, 2014 8:26 am

Hi,

Thanks, I will try this out now. Does the 'get' command support outputting to a device-side pointer rather than a whole new array?

e.g.
Say if I have two 5x5 arrays on the device (A and B):

A
01, 02, 03, 04, 05
02, 03, 04, 05, 01
03, 04, 05, 01, 02
04, 05, 01, 02, 03
05, 01, 02, 03, 04

B
01, 02, 03, 04, 05
02, 03, 04, 05, 01
03, 04, 05, 01, 02
04, 05, 01, 02, 03
05, 01, 02, 03, 04

And I want to change A by element-wise multiplying the 3x3 subarray of A with the matching 3x3 subarray of B, to give A as:

A_new
01, 02, 03, 04, 05
02, 09, 16, 25, 01
03, 16, 25, 01, 02
04, 25, 01, 04, 03
05, 01, 02, 03, 04

Would this be possible using something like:

dptr1 => getA(required indexing)
dptr2 => getB(required indexing)
dptr1 = dptr1*dptr2

Sorry if that isn't too clear - but being able to just index subsections of the array, like you can in vanilla fortran, rather than 'getting' sections of it, would be very beneficial for how I need Arrayfire to work. Also, sorry if I have completely misunderstood how the get and set commands work!

If this isn't possible, do you have any alternatives?

EDIT: On a broader point, the ability to index/change single points or slices of an array using standard indexing methods would be great. For example if I could just type A(2,3) to refer to that element in the array, that would be very very useful. If I could write A(2,3)=7 that would be great too. I know these aren't necessarily GPU/CUDA specific tasks but the ability to do them would make integrating Arrayfire into existing code a whole lot easier. Unless i'm being particularly stupid this doesn't seem to be a feautre of ArrayFire arrays at the moment (with only 'get' and 'set' listed under the Indexing section of the guide). I have no idea how easy it would be to implement at this moment in time but if it is possible it would really help out. :D

Harry
hazm13
 
Posts: 12
Joined: Wed Feb 12, 2014 3:22 pm
Location: Southampton

Re: Fortran 'get' command

Postby pavanky » Mon Mar 17, 2014 8:42 am

Outputting offsets is not possible currently with arrayfire. We may end up doing this in the future, but currently this is not a possibility.
Pavan Yalamanchili,
ArrayFire
--
~ If it is not broken, you have not tried hard enough ~
User avatar
pavanky
Site Admin
 
Posts: 1123
Joined: Mon Mar 15, 2010 7:39 pm
Location: Atlanta, GA

Re: Fortran 'get' command

Postby hazm13 » Mon Mar 17, 2014 8:48 am

Ok, I will have to investigate further into if I can do the calculations I want to do without needing to utilise subarrays. Thanks anyway!
hazm13
 
Posts: 12
Joined: Wed Feb 12, 2014 3:22 pm
Location: Southampton

Re: Fortran 'get' command

Postby pavanky » Mon Mar 17, 2014 8:51 am

Hi Harry,

Referring to the edit, FORTRAN does not allow you to overload the indexing operator like C++ does. This can be done if we wrote our own custom compiler, but we are not in the business of compilers :)

In the future if NVIDIA ships the PGI compiler with their toolkit we will see if such operations can be done.
Pavan Yalamanchili,
ArrayFire
--
~ If it is not broken, you have not tried hard enough ~
User avatar
pavanky
Site Admin
 
Posts: 1123
Joined: Mon Mar 15, 2010 7:39 pm
Location: Atlanta, GA

Re: Fortran 'get' command

Postby hazm13 » Mon Mar 17, 2014 9:25 am

Hi,

Thanks for the response, I did not realise this - please excuse my ignorance as i'm only a student! (and not even a CompSci one - i'm an undergraduate Mechanical Engineer)

Harry
hazm13
 
Posts: 12
Joined: Wed Feb 12, 2014 3:22 pm
Location: Southampton

Re: Fortran 'get' command

Postby pavanky » Mon Mar 17, 2014 9:27 am

That is alright! I ended up figuring out by asking questions as well: http://stackoverflow.com/questions/5751 ... in-fortran
Pavan Yalamanchili,
ArrayFire
--
~ If it is not broken, you have not tried hard enough ~
User avatar
pavanky
Site Admin
 
Posts: 1123
Joined: Mon Mar 15, 2010 7:39 pm
Location: Atlanta, GA


Return to [archive-commercial] Programming & Development with ArrayFire

cron