Category Archives: Julia

Using Juno for Interactive Test-Driven Package Development

By: Christopher Rackauckas

Re-posted from: http://www.stochasticlifestyle.com/using-juno-interactive-test-driven-package-development/

I found myself explaining my development workflow all of the time, so I thought I’d show it in a video. This is some of the stuff I do. You can do it other ways. I like this way.

The post Using Juno for Interactive Test-Driven Package Development appeared first on Stochastic Lifestyle.

DifferentialEquations.jl 4.1: New ReactionDSL and KLU Sundials

By: JuliaDiffEq

Re-posted from: http://juliadiffeq.org/2018/02/17/Reactions.html

Alright, that syntax change was painful but now everything seems to have
calmed down. We thank everyone for sticking with us and helping file issues
as necessary. It seems most people have done the syntax update and now we’re
moving on. In this release we are back to our usual and focused on feature
updates. There are changes, but we can once again be deprecating any of our
changes so that’s much easier on users.

When Julia is faster than C, digging deeper

By: perfectionatic

Re-posted from: http://perfectionatic.org/?p=591

In my earlier post I showed an example where Julia is significantly faster than c. I got this insightful response

So I decided to dig deeper. Basically the standard c rand() is not that good. So instead I searched for the fastest Mersenne Twister there is. I downloaded the latest code and compiled it in the fastest way for my architecture.

/* eurler2.c */
#include <stdio.h>      /* printf, NULL */
#include <stdlib.h>     /* srand, rand */
#include "SFMT.h"       /* fast Mersenne Twister */
 
sfmt_t sfmt;
 
double r2()
{
    return sfmt_genrand_res53(&sfmt);
 
}
 
double euler(long int n)
{
    long int m=0;
    long int i;
    for(i=0; i<n; i++){
        double the_sum=0;
        while(1) {
            m++;
            the_sum+=r2();
            if(the_sum>1.0) break;
        }
    }
    return (double)m/(double)n;
}
 
 
int main ()
{
  sfmt_init_gen_rand(&sfmt,123456);
  printf ("Euler : %2.5f\n", euler(1000000000));
 
  return 0;
}

I had to compile with a whole bunch of flags which I induced from SFMT‘s Makefile to get faster performance.

gcc -O3 -finline-functions -fomit-frame-pointer -DNDEBUG -fno-strict-aliasing --param max-inline-insns-single=1800  -Wall -std=c99 -msse2 -DHAVE_SSE2 -DSFMT_MEXP=1279 -ISFMT-src-1.5.1 -o eulerfast SFMT.c euler2.c

And after all that trouble we got the performance down to 18 seconds. Still slower that Julia‘s 16 seconds.

$ time ./eulerfast 
Euler : 2.71824
 
real    0m18.075s
user    0m18.085s
sys 0m0.001s

Probably, we could do a bit better with more tweaks, and probably exceed Julia‘s performance with some effort. But at that point, I got tired of pushing this further. The thing I love about Julia is how well it is engineered and hassle free. It is quite phenomenal the performance you get out of it, with so little effort. And for basic technical computing things, like random number generation, you don’t have to dig hard for a better library. The “batteries included” choices in the Julia‘s standard library are pretty good.