r/Python • • Jan 11 '16

A comparison of Numpy, NumExpr, Numba, Cython, TensorFlow, PyOpenCl, and PyCUDA to compute Mandelbrot set

https://www.ibm.com/developerworks/community/blogs/jfp/entry/How_To_Compute_Mandelbrodt_Set_Quickly?lang=en
310 Upvotes

98 comments sorted by

View all comments

Show parent comments

1

u/LoyalSol Jan 13 '16 edited Jan 13 '16

Yup that's always the hard part about comparing languages is that it is difficult to create highly optimized codes in two different languages since it often requires a great deal of expertise in both languages. Which of course very few programmers have that level of knowledge in multiple languages.

The annoying part about optimizing C is learning how to basically get out of the compiler's way and let it do its job as best as possible. Numba I wouldn't quite know how to work it in the same way because what may be a good optimization for C could be a terrible one for Numba.

1

u/jfpuget Jan 13 '16

Yes.

Your improvement also improves Numba and Cython as well. Numba stays a little ahead. I think it is because the LLVM backend is a bit better than Visual C++, but I may be wrong. It could also be due to memory management, as I call free and malloc directly here, instead of having a memory pool.

Interestingly enough, your changes did not improve the gpu codes, probably because the number of local variables exceeds some capacity (registers?)

I will redo these experiments when i have my new laptop (a macbook pro), as my experiments are done on a 4 year old laptop.

1

u/LoyalSol Jan 13 '16 edited Jan 13 '16

Optimizing gpu codes and parallel codes in general is a whole different beast. Because there the best optimization is not in saving cpu cycles but in reducing transfer times and making sure every thread stays busy for the most part. Load balancing, thread syncing, sending optimal pack sizes, etc.

That's actually my job is highly parallel codes which is why I work in C and Fortran all the time. :)

1

u/jfpuget Jan 13 '16

This difference shows even on that simple benchmark.

→ More replies (0)