Faster indexing?

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

Moderator: pavanky

Faster indexing?

Postby rm9 » Thu Feb 13, 2014 8:31 am

Hi,

I have the following function
Code: Select all
array ConvLayer::ConvolveValid3d2d(const array& a, const array& b) {
   array c = convolve(a, b, true);
   int output_size0 = a.dims(0) - b.dims(0) + 1;
   int output_size1 = a.dims(1) - b.dims(1) + 1;
   int full_size0 = a.dims(0) + b.dims(0) - 1;
   int full_size1 = a.dims(1) + b.dims(1) - 1;
   int start0 = floor(float(full_size0 - output_size0) / 2);
   int start1 = floor(float(full_size1 - output_size1) / 2);
   c = c(seq(start0, start0 + output_size0 - 1), seq(start1, start1 + output_size1 - 1), span);
   return c;
}
.

I profiled this code using Visual Studio Profiler to see if I can improve its performance.
It turns out that the slowest line in the function is the one before the end:
Code: Select all
   c = c(seq(start0, start0 + output_size0 - 1), seq(start1, start1 + output_size1 - 1), span);


Is there might be a faster alternative to this assignment?

Thanks!
rm9
 
Posts: 54
Joined: Thu Jan 30, 2014 5:44 am

Re: Faster indexing?

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

Hi,

Is there a reason you are persisting with the for version instead of the fft based convolution I posted from the other thread ?
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: Faster indexing?

Postby rm9 » Thu Feb 13, 2014 12:23 pm

Yes, when I used the other implementation in my code then my code crashes with an "unknown CUDA error" and I couldn't find a way around it.
Thank you.
rm9
 
Posts: 54
Joined: Thu Jan 30, 2014 5:44 am

Re: Faster indexing?

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

Using the visual studio profiler to profile non blocking function calls will not provide accurate results.
All CUDA calls made by arrayfire are queued up and the times you are seeing may not be the same as what the real times for each function are.

One alternative is to enable the type of convolution you are looking at so you do not need to do the extra step explicitly.

As for the other failure, are you using the same sizes mentioned in the stand alone example ? If yes, can you tell us the GPU and the NVIDIA driver you are using ?

--
Pavan
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: Faster indexing?

Postby rm9 » Fri Feb 14, 2014 4:28 am

No, I had to change the sizes to:
Code: Select all
data: 128 x 64 x 10
W: 8 x 64 x 128
output = ConvolveValid4d(data, w) : 121, 1, 10*128


Was the code specific to the previous sizes?
I have a Geforce GTX 650 Ti with driver version 332.21 on Windows 7 64bit.
Thanks.
rm9
 
Posts: 54
Joined: Thu Jan 30, 2014 5:44 am


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

cron