Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Multiply 2 big matrixes using OpenGL

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2006
    Posts
    8

    Multiply 2 big matrixes using OpenGL

    Hi,Is it possible to multiply 2 big matrixes using OpenGL as fast as possible? In the other word, I want to do so by using GPU. Thanks

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Multiply 2 big matrixes using OpenGL

    It is not the intended use, especially if you want precise results.
    Anyway, here is a good site about general "General-Purpose computation on GPUs" :
    http://www.gpgpu.org/
    http://www.gpgpu.org/wiki/FAQ

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2006
    Posts
    8

    Re: Multiply 2 big matrixes using OpenGL

    Why do you think it is not intended use? In fact, I want to multiply 2 double matrixes faster than writting a simple and normal code. Someone says that OpenGL can be used as an interface to GPU. Is it true?

  4. #4
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Multiply 2 big matrixes using OpenGL

    Of course it is possible, and for GPGPU computations OpenGL is a good API to use, see the FAQ link I posted for more details.

    What I mean is that graphic accelerators are not intented to be used as high performance scientific clusters, basically you will have to trade off precision and flexibility to get cheap processing power.

    EDIT : ie. it is already hard to get float precision, for double it will be even harder.

  5. #5
    Junior Member Newbie
    Join Date
    Jul 2006
    Posts
    8

    Re: Multiply 2 big matrixes using OpenGL

    OK, By using OpenGL as an Interface to GPGPU programming, I think there is no need to tackle with GPGPU directly.I mean that we write our codes in OpenGL and this is the OpenGL who runs the codes in GPU. Is it true? If so, could you please give me an example to show how can I multiply 2 matrixes in OpenGL? Thank you very much!

  6. #6
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Multiply 2 big matrixes using OpenGL

    Read The Links.

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Dec 2000
    Location
    Reutlingen, Germany
    Posts
    2,052

    Re: Multiply 2 big matrixes using OpenGL

    1. RTFM

    2. What is your exact definition of "big"? Don't tell me it's 4x4.
    GLIM - Immediate Mode Emulation for GL3

  8. #8
    Member Regular Contributor
    Join Date
    Jun 2005
    Location
    USA
    Posts
    277

    Re: Multiply 2 big matrixes using OpenGL

    Originally posted by Jan:
    1. RTFM

    2. What is your exact definition of "big"? Don't tell me it's 4x4.
    1.OUCH


  9. #9
    Intern Contributor
    Join Date
    Jun 2006
    Posts
    98

    Re: Multiply 2 big matrixes using OpenGL

    The links that Zbuffer provided are quite good.

    Anyway, to my knowledge there is no native support for matrix multiplication beyond 4x4. However, matrix multiplication is inherently vectorizable, meaning it is possible to compute the product of matrices as the product of sub-matrices or vectors.

    For instance, a matrix-vector product can be vectorized as 4 vector scales and 4 vector adds. A matrix-matrix multiply can likewise be coded as 4 matrix-vector multiplies. An NxM-MxQ multiply can be perhaps optimally coded as combination of 4x4 sub-matrices. For starters, I would try to decompose the input matrix into a blocked matrix consisting of 4x4 sub-matrix entries. For example, given 2 8x8 matrices P and Q,

    Code :
    PQ = ( A B )(E F) = (AE+BG AF+BH)
         ( C D )(G H)   (CE+DG CF+DH)
     
    where A, B, C, D, E, F, G and H are each 4x4 sub-matrices of P and Q.
    If your matrix dimensions are not already multiples of 4, consider padding them with zeros as necessary.

    At any rate, the trick to computational speed with GPUs is vectorizing your operations. Bear in mind this speed has to be weighed against time needed to transfer the operations to and from the GPU, assuming that you need the results in you app.

    Alternatively, SSE or 3DNOW! intrinsics could be leveraged in place of GPU processing, scenario permitting. You may find an introduction to these intrinsics helpful in understanding the general concepts in SIMD architectures.

    I hope this helps.

  10. #10
    Junior Member Newbie
    Join Date
    Jul 2006
    Posts
    8

    Re: Multiply 2 big matrixes using OpenGL

    I want to multiply a 50000x9 matrix by a 9x9 matrix. Now, is it possible to do it in GPU? If so, is it possible to do it by using OpenGL?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •