[Insight-developers] suggestion: use environment variable to limit number of parallel threads

Bill Lorensen bill.lorensen at gmail.com
Thu Sep 20 13:28:51 EDT 2007


If we do add this functionality, we should use the kwsys GetEnv() even
though it just calls getenv().

Bill


On 9/20/07, Torsten Rohlfing <torsten at synapse.sri.com> wrote:
>
> Luis:
>
> Sounds pretty much like what I was envisioning.
>
> Item 2) in my opinion only serves to allow people who distribute
> pre-compiled ITK-based software to conscientiously ignore user-specified
> CPU limitations. I am not sure that's a good thing, 'cos I believe I
> know better how many CPUs a tool on my system should be using than does
> the guy who compiled it elsewhere. Also, it's probably not necessary,
> because if, as a developer, you are THAT determined to force the maximum
> number of parallel threads, you probably don't mind hacking the code a
> bit to disable the getenv().
>
> The bottom line is -- if you add option 1) alone, no one will ever
> notice any changes unless they define the environment variable. In that
> case, they probably know what they are doing. And you're not further
> cluttering the Cmake configuration options.
>
> But anyway, a combination of 1/2 would certainly work for me; I
> personally don't use any pre-compiled ITK apps, so having 1) gives me
> what I need, and 2) remains under my control.
>
> By the way -- does anyone know whether any of ITK's supported platforms
> would have trouble with the getenv() call?
>
> Thanks everyone!
> Torsten
>
> Luis Ibanez wrote:
> >
> > Hi Torsten,
> >
> > Here is one option that come to mind:
> >
> > 1) In itkMultiThreader.cxx lines 80-145 method
> >    GetGlobalDefaultNumberOfThreads()
> >
> >    insert one option where the number of Threads
> >    is taken from the environment variable, like:
> >
> >    std::string numberOfThreadsString =
> >     getenv("ITK_DEFAULT_NUMBER_OF_THREADS");
> >    m_GlobalDefaultNumberOfThreads =
> >      atoi(  numberOfThreadsString.c_str() )
> >
> > 2) Surrond that option with a CMake enabled define
> >    such as ITK_USE_NUMBER_OF_THREADS_FROM_ENVIRONMENT,
> >    this define will be set in the itkConfigure.h.in
> >    and will be controlled by an advanced option in
> >    CMake.
> >
> >
> > Note that the same can be done for the "Maximum"
> > number of Threads.
> >
> >
> > In this way, you can get ITK to choose the number of
> > threads from the environment variable, but *only* if
> > ITK was configured with that CMake variable enabled.
> >
> >
> >
> >   Regards,
> >
> >
> >      Luis
> >
> >
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.itk.org/mailman/private/insight-developers/attachments/20070920/f1c08db5/attachment.html


More information about the Insight-developers mailing list