Re: [julia-users] Gibbs sampling 10x slower than c++

2014-08-14 Thread Ivar Nesje
I have not heard it explicitly from the developers, but it seems obvious to me that implementing slicing as a view into the original array, is hard to do right, while a copy is simple. They probably wanted to do the simple thing first, and then solve the harder problem when things settle down.

Re: [julia-users] Gibbs sampling 10x slower than c++

2014-08-14 Thread Tobias Knopp
Regarding the need for annotation. There is a good reason for this and its that the type should be kept stable during calculations. `a = 0` will set a to be an Int with value 0. Later it is updated with Float64 values and therefore the performance loss. You can solve this in different variants a

Re: [julia-users] Gibbs sampling 10x slower than c++

2014-08-14 Thread Andrew Wrigley
Excellent, thanks. Replacing `@inbounds a = dot(W[:,n], state)` with the following gave a ~5x improvement: a::Float64 = 0 for k in 1:N @inbounds a += W[k, n] * state[k] end The ::Float64 annotation was necessary or it was really slow. Why does

Re: [julia-users] Gibbs sampling 10x slower than c++

2014-08-13 Thread John Myles White
Here are some things you might try: (1) Don’t use a global const. Pass N as an argument to all functions. (2) Use in-place multiplication via functions like A_mul_B! in lines like `@inbounds a = dot(W[:,n], state)`. In Julia 0.3, W[:,n] creates a copy of that column of W on every iteration. (3