This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fwd: [RFC][gomp4] Offloading patches (2/3): Add tables generation
- From: Bernd Schmidt <bernds at codesourcery dot com>
- To: Ilya Verbin <iverbin at gmail dot com>
- Cc: Thomas Schwinge <thomas at codesourcery dot com>, "Michael V. Zolotukhin" <michael dot v dot zolotukhin at gmail dot com>, Jakub Jelinek <jakub at redhat dot com>, Richard Biener <rguenther at suse dot de>, Kirill Yukhin <kirill dot yukhin at gmail dot com>, Andrey Turetskiy <andrey dot turetskiy at gmail dot com>, Ilya Tocar <tocarip dot intel at gmail dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>, Nathan Sidwell <nathan_sidwell at mentor dot com>
- Date: Thu, 6 Mar 2014 12:53:23 +0100
- Subject: Re: Fwd: [RFC][gomp4] Offloading patches (2/3): Add tables generation
- Authentication-results: sourceware.org; auth=none
- References: <20131217113957 dot GA39975 at msticlxl57 dot ims dot intel dot com> <52E7927B dot 8030509 at codesourcery dot com> <CADG=Z0GQ8ORLe1XRUU7VMYeLhwuWisMyCcGLQj-nY_bhkbD_1Q at mail dot gmail dot com> <CADG=Z0HRb1ojtTc4xEAG=hH_GcfAARDAmn70XGB5khF0mME4pQ at mail dot gmail dot com> <52E9137C dot 4020706 at codesourcery dot com> <CADG=Z0HkhefrBJ_tKyhEHv+p+AMTvpbxf=Md6JOCv6rAUu1u9g at mail dot gmail dot com> <CADG=Z0GW==Wax+3B5Z2JiieOWoz_gWpqtdhHA_L9-Nzb6u4bnA at mail dot gmail dot com> <530648F8 dot 2010409 at codesourcery dot com> <CADG=Z0HE6AudmZuQK2vWz+E4fh8PnqoJ-aq9GXjZXgn-ZRW0kw at mail dot gmail dot com> <5310B791 dot 1000703 at codesourcery dot com> <20140305171518 dot GA26771 at msticlxl57 dot ims dot intel dot com> <53183604 dot 3080603 at codesourcery dot com> <CADG=Z0F+376umvFiCWP3hqEMKpgu4Y+HpEDVrB60OVJf8h29Sw at mail dot gmail dot com>
On 03/06/2014 12:11 PM, Ilya Verbin wrote:
Do I understand correctly, that you propose to do so:
extern void *_omp_host_func_table[];
extern void *_omp_host_var_table[];
extern void *_omp_host_funcs_end[];
extern void *_omp_host_vars_end[];
void *__OPENMP_TARGET_HOST__[]
__attribute__ ((visibility ("protected"))) =
{
&_omp_host_func_table, &_omp_host_funcs_end,
&_omp_host_var_table, &_omp_host_vars_end
};
So far, yes (maybe just call it __OPENMP_HOST_TABLE__).
extern void *__OPENMP_TARGET_MIC__[];
extern void *__OPENMP_TARGET_PTX__[];
extern void GOMP_offload_register_host (const void *);
extern void GOMP_offload_register_target (const void *);
__attribute__ ((constructor))
static void
init (void)
{
GOMP_offload_register_host (__OPENMP_TARGET_HOST__);
GOMP_offload_register_target (__OPENMP_TARGET_MIC__);
GOMP_offload_register_target (__OPENMP_TARGET_PTX__);
}
Where __OPENMP_TARGET_MIC__ and __OPENMP_TARGET_PTX__ descriptors
should be generated in the corresponding mkoffload tools.
No. I don't think we need a global constructor for registering
__OPENMP_TARGET_HOST__ - this would unnecessarily bloat crtbegin/crtend.
We also shouldn't need to have the target tables known outside of the
image constructed by the mkoffload tools. The way I imagine it, every
mkoffload tool creates its own constructor that looks like something
like this:
__attribute__ ((constructor)) static void
init (void)
{
GOMP_offload_register_target (__OPENMP_TARGET_HOST__,
PTX_ID, ptx_target_table);
}
That creates a mapping between host and target table for PTX_ID. If
there are multiple shared libraries with offload support, you can still
obtain the ordering you want from these GOMP_offload_register_target
calls. Everything is nicely private to the mkoffload-generated image.
It's implemented in almost this fashion (slightly different naming and
args, and no real support in libgomp) in the patch kit I sent.
Bernd