Operation similar to matrix multiplication

[Old posts from the commercial version of ArrayFire] Issues and comments for download and installation. Getting up and running.

Moderators: melonakos, pavanky

Operation similar to matrix multiplication

Postby carlos.phillips » Thu Sep 22, 2011 5:05 pm

Hello,

I am new to Jacket. I am exploring using Jacket to optimize the following function. This function is very close to multiplying a matrix with its transpose, but the min of two elements is used instead of the product. Because this function is very close to matrix multiplication, it stands to reason that it should perform well on a GPU. Unfortunately, I do not know how to convert this function to a format that is well suited for Jacket.

Any help would be appreciated.

Code: Select all
function y = jackettest( x )
m = size(x,2);
y = nan( size(x), class(x) );
for j = 1 : m
    for k = 1 : m
        y(k,j) = sum( min( x(:,k), x(:,j) ) );
    end
end


------------------------------------------------------------------------
Windows Vista on i7 CPU with 8 GB RAM
CUDA driver 270.81, CUDA toolkit 4.0
GPU0 Quadro 2000 D, 994 MB, Compute 2.1 (single,double)
carlos.phillips
 
Posts: 2
Joined: Thu Sep 22, 2011 4:43 pm

Re: Operation similar to matrix multiplication

Postby vishy » Fri Sep 23, 2011 2:40 pm

Carlos,
To me the function already looks well-written. Are you encountering slowdowns? Is that why you want an alternate approach?
--------------------------------------------------
Vish Venugopalakrishnan
Software Engineer (Q/A)
AccelerEyes LLC
vishy.v@accelereyes.com

--------------------------------------------------
Resources:
Getting Started, FAQ, Tips, Syntax
User avatar
vishy
 
Posts: 411
Joined: Thu Apr 16, 2009 11:46 am

Re: Operation similar to matrix multiplication

Postby carlos.phillips » Thu Sep 29, 2011 5:22 pm

I'm so sorry for the late reply. I could not find my post because I put it in the wrong forum.

I am experiencing significant slowdowns for a 500x400 matrix input. It takes less than a second on the CPU and over a minute on the GPU.
carlos.phillips
 
Posts: 2
Joined: Thu Sep 22, 2011 4:43 pm

Re: Operation similar to matrix multiplication

Postby vishy » Thu Sep 29, 2011 6:35 pm

Carlos,

When investigating slowdowns such as this, the first step is to find out what data sizes the operation is being performed on. In this case, it looks like you are performing the min() on single vectors of that large array?

The GPU is typically sensitive to data sizes, and performing GPU computing operations on small data is not an efficient use of the GPU resources. Read more about this here.
--------------------------------------------------
Vish Venugopalakrishnan
Software Engineer (Q/A)
AccelerEyes LLC
vishy.v@accelereyes.com

--------------------------------------------------
Resources:
Getting Started, FAQ, Tips, Syntax
User avatar
vishy
 
Posts: 411
Joined: Thu Apr 16, 2009 11:46 am


Return to [archive-commercial] Download & Installation