Fortran Dimensioning Issue

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

Moderator: pavanky

Fortran Dimensioning Issue

Postby hazm13 » Wed Feb 12, 2014 3:53 pm

Hi guys,

I am currently using Arrayfire to speed up a CFD solver. In the solver we use both 2 and 3 dimensional fortran arrays. The way it is implemented means that a 2 dimensional fortran array is represented by (N,M,1) rather than just (N,M), allowing allocatable arrays to deal with either 2 or 3 dimensional fields. However, when one of these is copied to the device to become an Arrayfire Array, it seems to automatically be given the dimensions (N,M) rather than (N,M,1). This is leading to dimension mismatches when the array is copied back to the host.

Is there any way to change this behaviour? It would be rather tricky to rewrite the majority of the solver to treat 2 dimensional arrays differently.

Here is a testcase which displays this behaviour:

Code: Select all
program testcase
  use arrayfire
  implicit none
  real,dimension(4,4,1) :: a = 5.0
  real,dimension(:,:,:),allocatable :: b
  type(array) ARR1
 
  ARR1 = a
  b=ARR1

end program testcase


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

Re: Fortran Dimensioning Issue

Postby pavanky » Thu Feb 13, 2014 12:25 pm

Hi Harry,

We can change the internal check to see if the number of elements is the same instead of looking at the number of dimensions. This will rely on the end user to be aware of any automatic reshapes going on when transferring the data back.

We will make a fix and link a downloadable version soon. Thanks for reporting the issue.
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 Dimensioning Issue

Postby hazm13 » Thu Feb 13, 2014 1:00 pm

Hi Pavanky,

Thanks for your quick repsonse. It turns out that only the module unit tests in our CFD solver used these NxMx1 representations of 2D matricies and therefore this is no longer an urgent issue for the rest of the solver itself. I guess there is a chance one day that somebody else may want to represent 2D arrays in this way though so any changes you may make in that regard could help them, but I repeat that it is no longer an issue for us. :)

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

Re: Fortran Dimensioning Issue

Postby pavanky » Thu Mar 06, 2014 6:52 pm

Hi Harry,

This issue is fixed (it was a trivial thing to do).

We've also open sourced our fortran wrapper. You can download it from here: https://github.com/arrayfire/arrayfire_fortran

The relevant issue on github is here: https://github.com/arrayfire/arrayfire_fortran/issues/1

Let us know if you need anything else!
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