I am quite used to work with Matlab, hence my code is fully vectorized, however : - some parts of my code cannot be vectorized (optimization loops, etc) - some other parts are really not natural when written in a vectorized way. Thus writting, reading, debugging and maintaining them is a pain.
But basically, I just would like to see the speed gain I can achieve with a lower level language on some parts of my code. Then depending on the performances of the forthcoming JIT compiler of Scilab, I may consider to translate (or not) my code in fortran. Pierre Vuillemin Le mercredi 05 février 2014 à 12:38 +0000, Carrico, Paul a écrit : > All > > before using fortan code, did you have a look to the "vectorization" in > order to avoid loops (that drastically decrease speed) and to increase > speedup consequently ? > > Just an advice > > Paul > > -----Message d'origine----- > De : users [mailto:users-boun...@lists.scilab.org] De la part de Pierre > Vuillemin > Envoyé : mercredi 5 février 2014 09:56 > À : users@lists.scilab.org > Objet : [Scilab-users] Interfacing fortran code with scilab > > Hello all, > > I am currently learning fortran in order to speed up some part o my code and > I would like to interface it with Scilab. > > To make some tests, I have used this fortran code : > > subroutine matmul(C,A,B,m,n,p) > integer ::m,n,p,i,j,k > real(kind=8),dimension(m,n),intent(in)::A > real(kind=8),dimension(n,p),intent(in)::B > real(kind=8),dimension(m,p),intent(out)::C > real(kind=8):: temp > C = 0 > do j =1,p > do k=1,n > temp = B(k,j) > do i=1,m > C(i,j)=C(i,j) + A(i,k)*temp > end do > end do > end do > end subroutine matmul > > which performs a matrix multiplication. Then I have used 'ilib_for_link' > to create the link. > It works but I have some questions : > > - I did the same thing in Python with f2py and the code is seemingly faster > in python, I was wondering why ? (the precision is the same) > > - If I change the 'kind = 8' to 'kind = 4' in the fortran code, the function > returns a result which completely wrong. > I expected it to be wrong, but not that much : for instance, with A = 10 and > B = 20, the call to the fortran function gives me '6.36D-314' > What is the reason? (My comprehension of how fortran types work with the kind > parameter is still limited, I know that kind=8 and kind=4 is not a very > portable expression though) > > - If I replace > real(kind=8),dimension(m,p),intent(out)::C > by > real(kind=8),dimension(:,:),intent(out)::C > I get a segfault in Scilab or it just closes. I was wondering why ? (I > thought it was something valid since gfortran still compiles) > > - Is it possible to keep the upper case in the name of fortran functions when > linked to scilab ? (At the beginning, my function was called 'matMul' and it > took me some time to figure out what the error message 'matMul is not an > entry point' meant) > > Best regards, > > Pierre Vuillemin > > _______________________________________________ > users mailing list > users@lists.scilab.org > https://urldefense.proofpoint.com/v1/url?u=http://lists.scilab.org/mailman/listinfo/users&k=b2vlTQszY8VIpYRvaG%2By2A%3D%3D%0A&r=SzPQe21KEY%2BPdUhJge5w%2FdtbtLgIXw5YTsnbzx%2F7JYE%3D%0A&m=ULVia0lWcxnisV%2BYAJ894mfD5PBI7UEZDeqeSqE9PQw%3D%0A&s=4501ea13ac011e234cb1dd1cdf1810c4388736b832cf43301a84c41f80b767f5 > -------------------------------------------------------------------------------- > > > Le présent mail et ses pièces jointes sont confidentiels et destinés à la > personne ou aux personnes visée(s) ci-dessus. Si vous avez reçu cet e-mail > par erreur, veuillez contacter immédiatement l'expéditeur et effacer le > message de votre système. Toute divulgation, copie ou distribution de cet > e-mail est strictement interdite. > > This email and any files transmitted with it are confidential and intended > solely for the use of the individual or entity to whom they are addressed. If > you have received this email in error, please contact the sender and delete > the email from your system. If you are not the named addressee you should not > disseminate, distribute or copy this email. > _______________________________________________ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users