1. 6

Working on moving some old C/Fortran files to Rust to help speed up Matlab code while making the most of what Rust has to offer.

For context the ‘slow’ part of the Matlab is typically populating large (100kx100k) dense matrices for boundary element calculations, things like inductance contributions of triangles in a mesh.

Feedback appreciated.

  1.  

  2. 1

    (100kx100k) dense matrices for boundary element

    Do you really have the 74 gigs of RAM necessary to store such a matrix? Or is there some other technique at play?

    1. 1

      Yep, typically run on a server with 128gb or so. That being said it is usually a case of iterating the sims with a simpler mesh (say 10k*10k) and running the full simulation only when we are fairly confident in the results already. There is some work being done to use hierarchal matrices to save on memory but there is a trade off there with speed.

      1. 1

        How long does it take to solve that linear system? I guess MKL knows how to parallelise, which is the reason you’re using Matlab in the first place?

        1. 1

          Typically simulations of that size take 12+ hours. Because its usually constrained optimisation rather than a direct solution. At the moment we are using a quadratic programming library written by someone in the Matlab community, this is another section I would be interested in at least attempting to rewrite for some of the HPC capacity we have here at the university. I would probably move away from qp to something which favours parallel execution a little more but that project is on the back burner for now. I think, if I’m being honest the reason Matlab is being used is because it knows how to negotiate with universities, it has become ingrained in some research groups so deeply that the switching cost tends to outweigh any benefits that may be gained from moving the codebase to another language.

    2. 1

      Hm, I tried to get hold of a trial version of Matlab, but they don’t give one for download…

      Reading the documentation for mex, shouldn’t it also be possible just to pass a static library and write mexFunction in rust?

      1. 4

        Hm, I tried to get hold of a trial version of Matlab, but they don’t give one for download…

        Try Octave, we have a mex interface.

        1. 1

          Oh, that sounds better then having a call with a Matlab sales representative.