Enter the matrix. Fast.

  • Thread starter Thread starter Heandel
  • Start date Start date
H

Heandel

Hello,

I'm working on a processor-intensive application that does a lot of matrix
multiplications (read : really a WHOLE lot). To increase efficiency, it
would be good to access SIMD instructions.

I see Mono can use SIMD instructions, but I really need to use .NET to do
the work.
I've searched quite a lot and apparently there's no easy nor stable way to
do this. Stumbled upon a dead project called .NETAsm, unfortunately broken
by 3.5SP1 and SlimGen, but it's in a very early stage.

I've tried calling unmanaged code that uses SIMD , but it's even slower.

Any suggestions that could help me increase performance ? Knowing that my
code is already really pure maths, only possible improvement would be
directly writing asm.

Thank you,

Heandel
 
NVidia has a library which allows to use the GPUs to perform parallel
operations (matrix multiplication but on single precision floating point
number, though, if memory serves), but in C/C++, not in C#. And you need an
NVidia graphic card, not an ATI one. See
http://www.nvidia.com/object/cuda_home.html. and
http://www.nvidia.com/object/cuda_develop.html

Note that a NVidia GPU is itself made of multiple processors with an
architecture of multiple computers sharing memory.


Vanderghast, Access MVP
 
My guess is that you're losing speed on the data transfer to the
unmanaged SIMD code. I think you could write an unmanaged function
that used SIMD in fairly straight order. Pass your array into that and
pin it instead of doing an array copy. You will need to write a
managed and unmanaged C++ class to make this happen. You will want to
use the cache line loader intrinsics as well, so we're definitely
talking about an unmanaged function.

Is this a lot of 4x4 matrix multiplications or a 100k x 100k matrix
multiplication? I assume you would be breaking it down into small
matrix multiplies for SIMD. Which matrix multiplication breakdown are
you using? LU? What data type are you using? int, float, double?
 
Hello,

Thanks for your reply !

I multiply huge matrices (2^n side, and d dimensions) of bytes, but break
them into 4x4 matrices for SIMD.
I do not use LU decomposition, more something like projecting the original
d-dimensions matrix into several planes, and then multiplying what is
needed.

I'm going to try your suggestion, thank you ;)

--
Still, I think SIMD should be implemented in .NET by Microsoft. Not only it
would ease development, but would also encourage using the platform.



"not_a_commie" <[email protected]> a écrit dans le message de groupe de
discussion :
(e-mail address removed)...
 
Back
Top