10

What's my best bet for computing the dot product of a vector x with a large number of vectors y_i, where x and y_i are of length 10k or so.

  1. Shove the y's in a matrix and use an optimized s/dgemv routine?
  2. Or maybe try handcoding an SSE2 solution (I don't have SSE3, according to cpuinfo).

I'm just looking for general guidance here, so any suggestions will be useful.
And yes, I do need the performance. Thanks for any light.

1
  • Which compiler are you using? Jul 7, 2009 at 3:41

5 Answers 5

4

I think GPUs are specifically designed to perform operations like this quickly (among others). So you could probably make use of DirectX or OpenGL libraries to perform the vector operations. D3DXVec2Dot This will also save you CPU time.

3
  • 2
    D3DXVec2Dot does not use the GPU. And beside that, you only see a speedup from GPGPU programs when you transform very large sets of data, or use very 'expensive' programs on the GPU. This is due to the cost of setting up the GPU to do the work, and then reading back the result. Every transfer of data to/from the GPU is a very costly operation. Jul 7, 2009 at 12:41
  • It is hard to beat DirectX's dot product if floats are good enough.
    – R Ubben
    Jul 7, 2009 at 13:10
  • Current CPUs are also quite capable for doing this kind of processing. Jul 7, 2009 at 16:47
1

Alternatives for optimised BLAS routines:

  • If you use intel compilers, you may have access to intel MKL
  • For other compilers ATLAS usually provides nice performance numbers
0

Handcoding a SSE2 solution is not very difficult and will bring a nice speedup over a pure C routine. How much this will bring over a BLAS routine must be determined by you.

The greatest speedup is derived by structuring the data into a format, so that you can exploit data parallelism and alignment.

0

I use a GotoBLAS. It's the hight perfomance kernel routines. The many times better than MKL and BLAS.

1
  • there are licensing problems with gotoblas. Jul 15, 2010 at 15:31
0

The following provides BLAS level 1 (vector operations) routines using SSE.

http://www.applied-mathematics.net/miniSSEL1BLAS/miniSSEL1BLAS.html

If you have an nVidia graphics card you can get cuBLAS which will perform the operation on the graphics card.

http://developer.nvidia.com/cublas

For ATI (AMD) graphics cards

http://developer.amd.com/libraries/appmathlibs/pages/default.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.