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

Submitter:  Carnë Draug <carandraug>
Submitted:  Wed 02 Aug 2017 06:55:07 PM UTC
 
Category:  Libraries Severity:  1 - Wish
Priority:  5 - Normal Item Group:  Inaccurate Result
Status:  Postponed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

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: 
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 Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.

     

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-03-20 mtmiller CategoryNone Libraries
        Item GroupNone Inaccurate Result
        StatusNone Postponed

    Back to the top

    Powered by Savane 3.10