jkrijthe / Rtsne

R wrapper for Van der Maaten's Barnes-Hut implementation of t-Distributed Stochastic Neighbor Embedding
Other
255 stars 66 forks source link

Is num_threads = 1.0 really using all the threads? #46

Closed SamGG closed 4 years ago

SamGG commented 4 years ago

Hi, In my hands (Windows 10, Rtsne 0.15), when I set num_threads = 4, the elapsed time is shorter and all cores seem to used. If I let the default (1.0), the computation takes longer although the doc says that the default will use all available threads. As a player, I set num_threads to 0. It detects and use all cores. If I set it to -1, R crashes, althought I thought it will all available cores minus 1 ;-) Is 0 usage undocumented or Windows specific? Best.

jkrijthe commented 4 years ago

Thanks. This is the intended behaviour. Perhaps it is not quite clearly formulated in the documentation. The doc says: "Number of threads to use using OpenMP, default 1. 0 corresponds to using all available cores" So the default is 1 (notice the space) which uses 1 thread, and setting num_threads to 0 should use all available cores. I agree, perhaps a different formulation makes this less confusing.

The crash with -1 is indeed a bug: it should just return an error instead.

Does that help?

SamGG commented 4 years ago

Reading too fast :-) What about "To use all available cores, set it to 0."? Thanks for parallelization.

jkrijthe commented 4 years ago

Thanks: I'll change it to: "Number of threads to use when using OpenMP, default is 1. Setting to 0 corresponds to detecting and using all available cores"

jkrijthe commented 4 years ago

Thanks: I'll change it to: "Number of threads to use when using OpenMP, default is 1. Setting to 0 corresponds to detecting and using all available cores"

SamGG commented 4 years ago

Fine. BTW, the 3rd reference of the README.md points to an error. May be it will be interesting to point to https://lvdmaaten.github.io/tsne/ instead, which carries all valuable references. I like a lot the page of the smallvis package as it gives a lot of information on how tuning tSNE arguments. Up to you. https://jlmelville.github.io/smallvis/ Thanks.

jkrijthe commented 4 years ago

It is indeed supposed to link to that page, but I apparently the old url no longer works. Thanks for pointing this out. Updated now.