Problem about GFOR and host()

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

Moderator: pavanky

Problem about GFOR and host()

Postby huahongquan2007 » Mon May 12, 2014 3:28 am

Hi,
I have a problem about using GFOR and host(). Here is my code
Code: Select all
gfor(array iPoint, num_of_landmark)
         {
            array curLand = curPoint(iPoint,span);
            
            float *t = curLand.host<float>();
      
            int curX = t[0];
            cout << " CUR X " << curX <<  endl;

            print(curLand);
         } // end for each landmark

You can see the result in the attachment. I only have 1 curX value even I have 76 version of curLand.
Please help me with the solution for this problem.
I want to convert the array value into integer because I will use the integer in the SEQ function
for example:
Code: Select all
myImg(seq(curX - 10, curX + 10), span)

Thank you very much
Attachments
Screenshot 2014-05-12 14.22.32.png
Screenshot 2014-05-12 14.22.32.png (19.05 KiB) Viewed 10234 times
huahongquan2007
 
Posts: 10
Joined: Fri May 02, 2014 1:56 pm

Re: Problem about GFOR and host()

Postby shehzan » Mon May 12, 2014 11:17 am

Hi

You cannot call the host() function inside gfor.
----
Shehzan
Developer
AccelerEyes
User avatar
shehzan
 
Posts: 121
Joined: Tue Feb 12, 2013 7:20 pm

Re: Problem about GFOR and host()

Postby huahongquan2007 » Mon May 12, 2014 11:18 am

Hi,
So are there any way that I can compute indexes and get a sub array in gfor?
Thank youy
huahongquan2007
 
Posts: 10
Joined: Fri May 02, 2014 1:56 pm

Re: Problem about GFOR and host()

Postby shehzan » Mon May 12, 2014 11:21 am

What I would suggest is that you complete the implementation using a for loop instead of gfor, then we can look at the full implementation and suggest something. Just having a print statement isn't enough to tell us what exactly is going on.
----
Shehzan
Developer
AccelerEyes
User avatar
shehzan
 
Posts: 121
Joined: Tue Feb 12, 2013 7:20 pm


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

cron