bugGNU Octave - Bugs: bug #51643, setting OMP_NUM_THREADS at runtime...

 
 

bug #51643: setting OMP_NUM_THREADS at runtime does not chaneg number of openmp threads

Submitted by:  Carnë Draug <carandraug>
Submitted on:  Wed 02 Aug 2017 06:55:07 PM UTC  
 
Category: NoneSeverity: 1 - Wish
Priority: 5 - NormalItem Group: None
Status: NoneAssigned to: None
Originator Name: Open/Closed: Open
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 03 Aug 2017 01:10:50 AM UTC, comment #5:

We could have a function called OMP_NUM_THREADS, similar to the PAGER and PAGER_FLAGS functions. Since this is a specific function, it could override the program state omp_set_num_threads value as well as update the value in the environment for any future child processes.

Mike Miller <mtmiller>
Project Administrator
Wed 02 Aug 2017 07:33:44 PM UTC, comment #4:

> I hesitate to intercept and do special things for specific variables in Octave's putenv function.
>
> Maybe we should document that the initial value of the number of threads may be set from the environment and also offer a separate function to set the thread limit for OMP?


I am also unsure about catching special variables in setenv which is why I am asking review here. However, I am also unsure about the potential for confusion, even if documented, about the difference between OMP_NUM_THREADS, the actual current number of openmp threads, and the number of threads to be used by other processes that Octave may start.

Carnë Draug <carandraug>
Project Member
Wed 02 Aug 2017 07:31:10 PM UTC, comment #3:

> I suspect that there was a misunderstanding at some point about how this environment variable works. So instead of checking the value each time an OMP-enabled function is called, it is only checked once to set some global variable to specify the thread limit?


Yes. When a program starts, there's a set of environment variables that are read. They are never read again. Instead, if a program wants to change them, there's a set of functions to use:

http://pages.tacc.utexas.edu/~eijkhout/pcse/html/openmp.html#Runtimefunctionsandinternalcontrolvariables

> I hesitate to intercept and do special things for specific variables in Octave's putenv function.
>
> Maybe we should document that the initial value of the number of threads may be set from the environment and also offer a separate function to set the thread limit for OMP?

Carnë Draug <carandraug>
Project Member
Wed 02 Aug 2017 07:06:22 PM UTC, comment #2:

I suspect that there was a misunderstanding at some point about how this environment variable works. So instead of checking the value each time an OMP-enabled function is called, it is only checked once to set some global variable to specify the thread limit?

I hesitate to intercept and do special things for specific variables in Octave's putenv function.

Maybe we should document that the initial value of the number of threads may be set from the environment and also offer a separate function to set the thread limit for OMP?

John W. Eaton <jwe>
Project Administrator
Wed 02 Aug 2017 07:01:22 PM UTC, comment #1:

A proposed fix

https://bitbucket.org/carandraug/octave/commits/d983450a7d65f9a526cad37223efad73aef37537

Carnë Draug <carandraug>
Project Member
Wed 02 Aug 2017 06:55:07 PM UTC, original submission:

The multiple threads of an openmp program are typically initialised at the start of that program based on the OMP_NUM_THREADS variable. Changing that variable at runtime does not change the number of threads, there's a C++ function 'omp_set_num_threads' for that.

Would be nice to configure this from Octave. Since nproc already documents that the environment variable OMP_NUM_THREADS is used, I guess that maybe setenv could check if OMP_NUM_THREADS is being changed and call the appropriate omp function.

Carnë Draug <carandraug>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by carandraug (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    No Changes Have Been Made to This Item

    Back to the top


    Powered by Savane 3.1-cleanup1