I am writing an OpenMP environment management module for use with perl scripts, and I ran into an issue when utilizing Inline::C for for generating bindings that allow the compiled code (in this case, C) to be called directly.
https://github.com/oodler577/p5-OpenMP-Environment/blob/master/examples/02-inline-c-omp.pl
After some research, I determined that it is expected behavor for the environment to be initialized via getenv (env.c in libgomp). In the case of a shared library (.so) it exhibits the same behavior on "load" that an a standalone binary with OpenMP exhibits on "run". This is fine, I understand.
My question is, how can I reinitialize the environment as portably as possible and without adding boiler plate code to each inlined C function? Is there a way to "force" a reinitialization of the environment?
The use case here is that, within a perl script, I'd like to update environmental variables such as OMP_NUM_THREADS and have it be respected on subsequent calls.
If I do need to resort to adding some boiler plate to read the environment, that's fine. I'd prefer that than having to account for these things as a function parameter. Is there a proper function to call to do this generally? In libgomp?
thank you