On Wed, Sep 23, 2015 at 08:22:22PM +0300, Alexander Monakov wrote: > This patch ports env.c to NVPTX. It drops all environment parsing routines > since there's no "environment" on the device. For now, the useful effect of > the patch is providing 'omp_is_initial_device' to distinguish host execution > from target execution in user code. > > Several functions use gomp_icv, which is not adjusted for NVPTX and thus will > try to use EMUTLS. The intended way forward is to provide a custom > implementation of gomp_icv on NVPTX, likely via pre-allocating storage prior > to spawning a team. > > * config/nvptx/env.c: New file.
I don't like this, there is just too much code duplication in this case and it is going to be a maintainance nightmare going forward (e.g. gomp-4_1-branch adds further functions, etc.). I'd suggest split the toplevel env.c into two files, icv.c which would contain the global variables and most of the small API functions, and env.c which would contain the global constructor, env var parsing, printing and perhaps omp_is_initial_device (). Then nvptx.c would use the toplevel icv.c and provide its own env.c with just omp_is_initial_device () (which of course eventually can be inlined by the compiler on NVPTX target or perhaps any ACCEL_COMPILER, but we need to provide a library version anyway, you can take address of the function etc.). Are you ok with that? Jakub