#69 More on Controlling the number of threads that ATLAS uses



I am currently working on a fairly largish deployment of ATLAS, and have a question about controling the degree of parallelism. A search on this support forum unearthed a related thread, but not quite with the answer I need. The old thread is: "Controlling the number of threads" - https://sourceforge.net/tracker/index.php?func=detail&aid=1504927&group_id=23725&atid=379483 Apologies if I missed a FAQ.

I see that the max number of thread is controlled by the macro ATL_NTHREADS in include/atlas_pthreads.h . The value of the macro seems to always be passed by value, as an argument to routines specified with the Mjoin macro.

So, my question: is there a "deep" reason why this max number of threads cannot be set dynamically? To wit, would I break anything if, for example, I changed every use of the macro to a global variable "extern int atlas_nthreads", and then defined that variable in a .c file as "int atl_n_threads = ATL_NTHREADS".

Doing so would allow me, for example, to configure at program launch time the max allowed degree of parallelism, e.g. using a command-line flat. This is useful when the users are charged $$$ for the number of CPU cores they use, and can then choose to trade runtime for money.

If such a change makes sense, I'd be happy to contribute a patch, perhaps with a nicer - but equivalent - implemetation scheme than the one outlined above.

Thanks for your help


  • R. Clint Whaley

    R. Clint Whaley - 2010-01-13


    The short answer is I don't know! I have completely rewritten threads in the developer series, and I'd have to perform the experiment to figure out what would happen in the 3.8 series. So, you can certainly try it and see :)

    Unfortunately, your trick will not work in the 3.9 series for sure. There, we use processor affinity and dynamically detect crossover points at which it becomes useful to use additional processors.

    Many users have requested the ability to dynamically change NTHREADS. I'm moving this request to the "feature request" queue. I will not be able to work on this until after the release of 3.10, but I do have some ideas that might eventually lead to making dynamic NTHREADS vialbe in ATLAS . . .

    This request is still open under feature requests, so feel free to post followup questions, and if your modification of 3.8 works, please let me know!


  • R. Clint Whaley

    R. Clint Whaley - 2010-01-13
    • labels: 360152 -->
    • milestone: 148062 -->
    • assigned_to: nobody --> rwhaley
  • R. Clint Whaley

    R. Clint Whaley - 2010-01-13
    • milestone: --> Would_be_nice
  • Francesco Callari

    thanks for the quick reply. Will test the idea and let you know ASAP.

  • Steven G. Johnson

    Note that I hacked dynamic control of the #threads into ATLAS this evening for the OpenMP interface. It seems to work okay. See the tracker request 3494871 ("honor omp_get_max_threads for openmp").


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks