The analysis is performed on a finite element grid allowing for a spatial variable resolution and a good representation of the coastline and isobaths. #Gridded interpolation matlab softwareThe DIVA software tool (Data-Interpolating Variational Analysis) allows one to spatially interpolate (or analyse) those observations on a regular grid in an optimal way. But that's obviously unfair compared with MATLAB because you could also parallelize that (If you buy that expensive toolbox).In practice, in-situ measurements can be sparse and heterogeneously distributed. Right now I am trying to parallelize also the loop. I am stuck here, does anybody have an idea what might be going? / If I am doing something wrong in my Julia code? A hint what I could do better? In the original problem though Julia was only about 3 times faster within the loop and once I looped through MATLAB turned out be 3 times faster. If I run the whole loop apparently MATLAB catches up a lot. #Gridded interpolation matlab codeHowever, if I don't comment out the loop and run the code as posted above:ģ.205262 seconds (118.99 k allocations: 15.651 GB, 14.08% gc time) The bottom line being that in Julia the code is much faster (more than 10 times in this case), which should be since I use all my threads and the method is written in C. MATLAB on the other hand: Elapsed time is 0.007864 seconds. If I comment out the loop and just consider one iteration, Julia does it in (I ran it several times, precompiling etc)Ġ.000565 seconds (13 allocations: 1.603 MB) In the end I want to have a matrix, that's why I do all this reshaping in the Julia code. W_temp2 = reshape ( W_temp, Nalal, Naa performance () W_temp2 = Array ( Float64, Nalal, Naa ) Xx = xx + ( xmax - xx )/(( Nxx - i + 1 )^ spacing )į_util ( c ) = c. Consider the following minimal working example preserving the irregular grid of the original problem which highlights the point I think (the only action is in the loop, the other stuff is just generating the irregular grid): The interpolation itself was much faster now than MATLAB's interp1 but somewhere on the way that advantage was lost. The Julia code was still 3 times slower which left me puzzled again. Equipped with that, I went back to my original problem and reran it. He translated the interpolation method into C and made it such that it uses multiple threads (I am working with 12 threads). So I asked a friend of mine who knows a little bit of C and he was so kind to help me out. Nobody knows what exactly the interp1 is doing. The bottom line was that the Dierckx package apparently calls some Fortran code which seems to pretty old (and slow, and doesn't use multiple cores. The post is messy and you don't need to read through it I think. It gave exactly the same result but it was about 50 times slower which puzzled me. I was translating my MATLAB code into Julia and used the Dierckx package in Julia to do the interpolation (there weren't some many alternatives that did spline on an irregular grid as far as I recall). My original problem is a dynammic programming problem in which I need to interpolate the value function on an irregular grid using a cubic spline method.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |