madeleineudell / LowRankModels.jl

LowRankModels.jl is a julia package for modeling and fitting generalized low rank models.
Other
190 stars 65 forks source link

@threads causes massive slowdown #98

Closed baggepinnen closed 4 years ago

baggepinnen commented 5 years ago

I find, while running julia v1.2 and LowRankModels v1.0.1, that the @threads annotation here sometimes causes massive slowdowns (3x in execution time and CPU utilization very low). My problem size is m,n,k = 200,150,10 and nthreads() == 2. Removing the annotation makes everything much faster.

baggepinnen commented 5 years ago

Interestingly, when I remove the @threads, I see close to 100% CPU utilization, indicating that the function calls inside the previously threaded loop are themselves multithreaded.

mihirparadkar commented 5 years ago

Have you checked your BLAS num threads? A lot of the computation per iteration is in forming X'Y, which may be multithreaded if BLAS is.

baggepinnen commented 5 years ago

Yeah, it's BLAS running multithreaded, but since that is the default, the unsuspecting user will most likely run into this problem of oversubscribing threads on both the julia side and the BLAS side.

baggepinnen commented 4 years ago

This issue does not appear on julia v1.3-rc2 so I'm closing this issue. With 6 threads I now see about 3.5 times improvement over single threaded.