[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: OpenMP, OMP_NUM_THREADS and putenv - not working as expected.
From: |
Søren Hauberg |
Subject: |
Re: OpenMP, OMP_NUM_THREADS and putenv - not working as expected. |
Date: |
Wed, 14 Apr 2010 09:57:16 -0700 |
ons, 14 04 2010 kl. 05:38 -0800, skrev coccoinomane:
> I am successfully using Octave to run a parallel C++ code trough the
> oct-file interface. I implemented the parallellism at the C++ level with
> OpenMP and its #pragma directives.
I hope you realise that Octave itself is not thread-safe.
> I control the number of threads used by my program through the environment
> variable OMP_NUM_THREADS. When I launch Octave from a shell where
> OMP_NUM_THREADS is correctly exported, my program correctly uses the
> specified number of threads.
>
> However, when I try to change the environment variable from within Octave
> with putenv - for example putenv ("OMP_NUM_THREADS", "1") - and then re-run
> the oct-file function, the latter keeps using the initial number of threads
> (i.e. the one specified prior to launching Octave at the shell level). It is
> like my "putenv" command was ignored. However, "getenv ("OMP_NUM_THREADS")"
> correctly returns the modified value, i.e. "1".
My guess is that the OMP_NUM_VARIABLE is only read when OpenMP is
initialised. So, why not just use the
omp_set_num_threads
function from C++?
Søren
- OpenMP, OMP_NUM_THREADS and putenv - not working as expected., coccoinomane, 2010/04/14
- Re: OpenMP, OMP_NUM_THREADS and putenv - not working as expected.,
Søren Hauberg <=
- Re: OpenMP, OMP_NUM_THREADS and putenv - not working as expected., coccoinomane, 2010/04/19
- Re: OpenMP, OMP_NUM_THREADS and putenv - not working as expected., Søren Hauberg, 2010/04/19
- Re: OpenMP, OMP_NUM_THREADS and putenv - not working as expected., John W. Eaton, 2010/04/19
- Re: OpenMP, OMP_NUM_THREADS and putenv - not working as expected., Guido Walter Pettinari, 2010/04/20
- Re: OpenMP, OMP_NUM_THREADS and putenv - not working as expected., Rayson Ho, 2010/04/20
Re: OpenMP, OMP_NUM_THREADS and putenv - not working as expected., Chi Chan, 2010/04/19