Reading material / tutorials / resources on threadsafe programming

I started to use the Threads in my code when I realized there are too many things I don’t understand. I know that I need to be careful that one thread does not interfere with another ones operations, which is pretty intuitive. but other than that this is all very abstract for me. I watched the keynote speech of keno fisher on Celeste.jl where he talks about the number of nested loops that could be packed inside each thread (if i remember correctly…), and that sounds like a consideration I should be doing in my case as well. I would just need a bit more guidance. any pointers to relevant material, examples, etc, much appreciated! (also in other languages, if the main principles carry over to julia!)

5 Likes

3 quick things:

  1. Threads in Julia are still quite experimental / in development. Hence the lack of “official” resources.
  2. What level are you working at? Are you familiar with basic OpenMP usage of threads? This might help specify resources for your use case.
  3. What problem are you working on? Does it make sense to share some code?

If you’re starting bare bones, a good place to start is these video tutorials by the creator of OpenMP in C.

At any rate, I found this presentaion by @vchuravy super useful at explaining different types of parallelism in Julia and some worked examples - with some handy tooling tips and packages like Intel Architecture Compiler Analyzer, IACA.jl boot.

julia-parallelism

6 Likes

hey @miguelraz, that’s a good start I would say! thanks!

  1. I am aware of this, yes.
  2. I never used OpenMP before except maybe in some hello world context. Zero real world experience. I know my ways decently well around addprocs and traditional multicore parallelisms.
  3. i have a large codebase where I’d like to split computation not at the inner-most loop, but some levels up. so, it does not make much sense to share my code. but i’d be more than happy to contribute to something, if that’s what you had in mind.

I’ll start with the OpenMP tutorial. the slides look top as well. thanks again.

1 Like

“Tú hoy, yo mañana.”

No problem.

If you aren’t working on parallelizing the tight loops, perhaps a worthy consideration will be that of co-routines / tasks / green threads. The relevant parts of the manual are here and here.

This model is heavily inspired on the C++ Cilk coroutine model - a worthy bibliography might be this book, Structured Parallel Programming by Arch Robinson et al, an early builder in the Julia world.

Feel free to ask questions on the #parallel channel on Slack for specific doubts as well.

Me gusta!

Love the book suggestion. And I didn’t know there is a dedicated channel on slack, so that’s great. See you there! Cheers!

1 Like