gcc/libgomp/icv-device.c

83 lines
2.1 KiB
C
Raw Normal View History

2022-01-03 10:42:10 +01:00
/* Copyright (C) 2005-2022 Free Software Foundation, Inc.
OpenMP offloading to NVPTX: libgomp changes * Makefile.am (libgomp_la_SOURCES): Add atomic.c, icv.c, icv-device.c. * Makefile.in. Regenerate. * configure.ac [nvptx*-*-*] (libgomp_use_pthreads): Set and use it... (LIBGOMP_USE_PTHREADS): ...here; new define. * configure: Regenerate. * config.h.in: Likewise. * config/posix/affinity.c: Move to... * affinity.c: ...here (new file). Guard use of Pthreads-specific interface by LIBGOMP_USE_PTHREADS. * critical.c: Split out GOMP_atomic_{start,end} into... * atomic.c: ...here (new file). * env.c: Split out ICV definitions into... * icv.c: ...here (new file) and... * icv-device.c: ...here. New file. * config/linux/lock.c (gomp_init_lock_30): Move to generic lock.c. (gomp_destroy_lock_30): Ditto. (gomp_set_lock_30): Ditto. (gomp_unset_lock_30): Ditto. (gomp_test_lock_30): Ditto. (gomp_init_nest_lock_30): Ditto. (gomp_destroy_nest_lock_30): Ditto. (gomp_set_nest_lock_30): Ditto. (gomp_unset_nest_lock_30): Ditto. (gomp_test_nest_lock_30): Ditto. * lock.c: New. * config/nvptx/lock.c: New. * config/nvptx/bar.c: New. * config/nvptx/bar.h: New. * config/nvptx/doacross.h: New. * config/nvptx/error.c: New. * config/nvptx/icv-device.c: New. * config/nvptx/mutex.h: New. * config/nvptx/pool.h: New. * config/nvptx/proc.c: New. * config/nvptx/ptrlock.h: New. * config/nvptx/sem.h: New. * config/nvptx/simple-bar.h: New. * config/nvptx/target.c: New. * config/nvptx/task.c: New. * config/nvptx/team.c: New. * config/nvptx/time.c: New. * config/posix/simple-bar.h: New. * libgomp.h: Guard pthread.h inclusion. Include simple-bar.h. (gomp_num_teams_var): Declare. (struct gomp_thread_pool): Change threads_dock member to gomp_simple_barrier_t. [__nvptx__] (gomp_thread): New implementation. (gomp_thread_attr): Guard by LIBGOMP_USE_PTHREADS. (gomp_thread_destructor): Ditto. (gomp_init_thread_affinity): Ditto. * team.c: Guard uses of Pthreads-specific interfaces by LIBGOMP_USE_PTHREADS. Adjust all uses of threads_dock. (gomp_free_thread) [__nvptx__]: Do not call 'free'. * config/nvptx/alloc.c: Delete. * config/nvptx/barrier.c: Ditto. * config/nvptx/fortran.c: Ditto. * config/nvptx/iter.c: Ditto. * config/nvptx/iter_ull.c: Ditto. * config/nvptx/loop.c: Ditto. * config/nvptx/loop_ull.c: Ditto. * config/nvptx/ordered.c: Ditto. * config/nvptx/parallel.c: Ditto. * config/nvptx/priority_queue.c: Ditto. * config/nvptx/sections.c: Ditto. * config/nvptx/single.c: Ditto. * config/nvptx/splay-tree.c: Ditto. * config/nvptx/work.c: Ditto. * testsuite/libgomp.fortran/fortran.exp (lang_link_flags): Pass -foffload=-lgfortran in addition to -lgfortran. * testsuite/libgomp.oacc-fortran/fortran.exp (lang_link_flags): Ditto. * plugin/plugin-nvptx.c: Include <limits.h>. (struct targ_fn_descriptor): Add new fields. (struct ptx_device): Ditto. Set them... (nvptx_open_device): ...here. (nvptx_adjust_launch_bounds): New. (nvptx_host2dev): Allow NULL 'nvthd'. (nvptx_dev2host): Ditto. (GOMP_OFFLOAD_get_caps): Add GOMP_OFFLOAD_CAP_OPENMP_400. (link_ptx): Adjust log sizes. (nvptx_host2dev): Allow NULL 'nvthd'. (nvptx_dev2host): Ditto. (nvptx_set_clocktick): New. Use it... (GOMP_OFFLOAD_load_image): ...here. Set new targ_fn_descriptor fields. (GOMP_OFFLOAD_dev2dev): New. (nvptx_adjust_launch_bounds): New. (nvptx_stacks_size): New. (nvptx_stacks_alloc): New. (nvptx_stacks_free): New. (GOMP_OFFLOAD_run): New. (GOMP_OFFLOAD_async_run): New (stub). Co-Authored-By: Dmitry Melnik <dm@ispras.ru> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r242789
2016-11-23 19:36:41 +01:00
Contributed by Richard Henderson <rth@redhat.com>.
This file is part of the GNU Offloading and Multi Processing Library
(libgomp).
Libgomp is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/* This file defines OpenMP API entry points that accelerator targets are
expected to replace. */
#include "libgomp.h"
void
omp_set_default_device (int device_num)
{
struct gomp_task_icv *icv = gomp_icv (true);
icv->default_device_var = device_num >= 0 ? device_num : 0;
}
openmp: Avoid PLT relocations for omp_* symbols in libgomp This patch avoids the following relocations: readelf -Wr libgomp.so.1.0.0 | grep omp_ 00000000000470e0 0000020700000007 R_X86_64_JUMP_SLOT 000000000001d9d0 omp_fulfill_event@@OMP_5.0.1 + 0 0000000000047170 000000b800000007 R_X86_64_JUMP_SLOT 000000000000e760 omp_display_env@@OMP_5.1 + 0 00000000000471e0 000000e800000007 R_X86_64_JUMP_SLOT 000000000000f910 omp_get_initial_device@@OMP_4.5 + 0 0000000000047280 0000019500000007 R_X86_64_JUMP_SLOT 0000000000015940 omp_get_active_level@@OMP_3.0 + 0 00000000000472c8 0000020d00000007 R_X86_64_JUMP_SLOT 0000000000035210 omp_get_team_num@@OMP_4.0 + 0 00000000000472f0 0000014700000007 R_X86_64_JUMP_SLOT 0000000000035200 omp_get_num_teams@@OMP_4.0 + 0 by using ialias{,_call,_redirect} macros as needed. We still have many acc_* PLT relocations, could somebody please fix those? readelf -Wr libgomp.so.1.0.0 | grep acc_ 0000000000046fb8 000001ed00000006 R_X86_64_GLOB_DAT 0000000000036350 acc_prof_unregister@@OACC_2.5.1 + 0 0000000000046fd8 000000a400000006 R_X86_64_GLOB_DAT 0000000000035f30 acc_prof_register@@OACC_2.5.1 + 0 0000000000046fe0 000001d100000006 R_X86_64_GLOB_DAT 0000000000035ee0 acc_prof_lookup@@OACC_2.5.1 + 0 0000000000047058 000001dd00000007 R_X86_64_JUMP_SLOT 0000000000031f40 acc_create_async@@OACC_2.5 + 0 0000000000047068 0000011500000007 R_X86_64_JUMP_SLOT 000000000002fc60 acc_get_property@@OACC_2.6 + 0 0000000000047070 000001fb00000007 R_X86_64_JUMP_SLOT 0000000000032ce0 acc_wait_all@@OACC_2.0 + 0 0000000000047080 0000006500000007 R_X86_64_JUMP_SLOT 000000000002f990 acc_on_device@@OACC_2.0 + 0 0000000000047088 000000ae00000007 R_X86_64_JUMP_SLOT 0000000000032140 acc_attach_async@@OACC_2.6 + 0 0000000000047090 0000021900000007 R_X86_64_JUMP_SLOT 000000000002f550 acc_get_device_type@@OACC_2.0 + 0 0000000000047098 000001cb00000007 R_X86_64_JUMP_SLOT 0000000000032090 acc_copyout_finalize@@OACC_2.5 + 0 00000000000470a8 0000005200000007 R_X86_64_JUMP_SLOT 0000000000031f80 acc_copyin@@OACC_2.0 + 0 00000000000470b8 000001ad00000007 R_X86_64_JUMP_SLOT 0000000000032030 acc_delete_finalize@@OACC_2.5 + 0 00000000000470e8 0000010900000007 R_X86_64_JUMP_SLOT 0000000000031f00 acc_create@@OACC_2.0 + 0 00000000000470f8 0000005900000007 R_X86_64_JUMP_SLOT 0000000000032b70 acc_wait_async@@OACC_2.0 + 0 0000000000047110 0000013100000007 R_X86_64_JUMP_SLOT 0000000000032860 acc_async_test@@OACC_2.0 + 0 0000000000047118 000001ff00000007 R_X86_64_JUMP_SLOT 000000000002f720 acc_get_device_num@@OACC_2.0 + 0 0000000000047128 0000019100000007 R_X86_64_JUMP_SLOT 0000000000032020 acc_delete_async@@OACC_2.5 + 0 0000000000047130 000001d200000007 R_X86_64_JUMP_SLOT 000000000002efa0 acc_shutdown@@OACC_2.0 + 0 0000000000047150 000000d000000007 R_X86_64_JUMP_SLOT 0000000000031f00 acc_present_or_create@@OACC_2.0 + 0 0000000000047188 0000019200000007 R_X86_64_JUMP_SLOT 0000000000031910 acc_is_present@@OACC_2.0 + 0 0000000000047190 000001aa00000007 R_X86_64_JUMP_SLOT 000000000002fca0 acc_get_property_string@@OACC_2.6 + 0 00000000000471d0 000001bf00000007 R_X86_64_JUMP_SLOT 0000000000032120 acc_update_self_async@@OACC_2.5 + 0 0000000000047200 0000020500000007 R_X86_64_JUMP_SLOT 0000000000032e00 acc_wait_all_async@@OACC_2.0 + 0 0000000000047208 000000a600000007 R_X86_64_JUMP_SLOT 0000000000031790 acc_deviceptr@@OACC_2.0 + 0 0000000000047218 0000007500000007 R_X86_64_JUMP_SLOT 0000000000032000 acc_delete@@OACC_2.0 + 0 0000000000047238 000001e900000007 R_X86_64_JUMP_SLOT 000000000002f3a0 acc_set_device_type@@OACC_2.0 + 0 0000000000047240 000001f600000007 R_X86_64_JUMP_SLOT 000000000002ef20 acc_init@@OACC_2.0 + 0 0000000000047248 0000018800000007 R_X86_64_JUMP_SLOT 0000000000032060 acc_copyout@@OACC_2.0 + 0 0000000000047258 0000021f00000007 R_X86_64_JUMP_SLOT 0000000000032a80 acc_wait@@OACC_2.0 + 0 0000000000047270 000001bc00000007 R_X86_64_JUMP_SLOT 0000000000032100 acc_update_self@@OACC_2.0 + 0 0000000000047288 0000011400000007 R_X86_64_JUMP_SLOT 0000000000032080 acc_copyout_async@@OACC_2.5 + 0 0000000000047290 0000013d00000007 R_X86_64_JUMP_SLOT 000000000002f850 acc_set_device_num@@OACC_2.0 + 0 00000000000472a8 000000c500000007 R_X86_64_JUMP_SLOT 00000000000320e0 acc_update_device_async@@OACC_2.5 + 0 00000000000472c0 0000014600000007 R_X86_64_JUMP_SLOT 0000000000031fc0 acc_copyin_async@@OACC_2.5 + 0 00000000000472f8 0000006a00000007 R_X86_64_JUMP_SLOT 000000000002f310 acc_get_num_devices@@OACC_2.0 + 0 0000000000047350 0000021700000007 R_X86_64_JUMP_SLOT 0000000000031f80 acc_present_or_copyin@@OACC_2.0 + 0 0000000000047360 0000020900000007 R_X86_64_JUMP_SLOT 00000000000320c0 acc_update_device@@OACC_2.0 + 0 0000000000047380 0000008400000007 R_X86_64_JUMP_SLOT 0000000000032950 acc_async_test_all@@OACC_2.0 + 0 2021-10-01 Jakub Jelinek <jakub@redhat.com> * affinity-fmt.c (omp_get_team_num, omp_get_num_teams): Add ialias_redirect. * env.c (handle_omp_display_env): Use ialias_call. * icv-device.c: Move ialias right below each function. (omp_get_device_num): Use ialias_call. * fortran.c (omp_fulfill_event): Add ialias_redirect. * icv.c (omp_get_active_level): Add ialias_redirect.
2021-10-01 10:42:07 +02:00
ialias (omp_set_default_device)
OpenMP offloading to NVPTX: libgomp changes * Makefile.am (libgomp_la_SOURCES): Add atomic.c, icv.c, icv-device.c. * Makefile.in. Regenerate. * configure.ac [nvptx*-*-*] (libgomp_use_pthreads): Set and use it... (LIBGOMP_USE_PTHREADS): ...here; new define. * configure: Regenerate. * config.h.in: Likewise. * config/posix/affinity.c: Move to... * affinity.c: ...here (new file). Guard use of Pthreads-specific interface by LIBGOMP_USE_PTHREADS. * critical.c: Split out GOMP_atomic_{start,end} into... * atomic.c: ...here (new file). * env.c: Split out ICV definitions into... * icv.c: ...here (new file) and... * icv-device.c: ...here. New file. * config/linux/lock.c (gomp_init_lock_30): Move to generic lock.c. (gomp_destroy_lock_30): Ditto. (gomp_set_lock_30): Ditto. (gomp_unset_lock_30): Ditto. (gomp_test_lock_30): Ditto. (gomp_init_nest_lock_30): Ditto. (gomp_destroy_nest_lock_30): Ditto. (gomp_set_nest_lock_30): Ditto. (gomp_unset_nest_lock_30): Ditto. (gomp_test_nest_lock_30): Ditto. * lock.c: New. * config/nvptx/lock.c: New. * config/nvptx/bar.c: New. * config/nvptx/bar.h: New. * config/nvptx/doacross.h: New. * config/nvptx/error.c: New. * config/nvptx/icv-device.c: New. * config/nvptx/mutex.h: New. * config/nvptx/pool.h: New. * config/nvptx/proc.c: New. * config/nvptx/ptrlock.h: New. * config/nvptx/sem.h: New. * config/nvptx/simple-bar.h: New. * config/nvptx/target.c: New. * config/nvptx/task.c: New. * config/nvptx/team.c: New. * config/nvptx/time.c: New. * config/posix/simple-bar.h: New. * libgomp.h: Guard pthread.h inclusion. Include simple-bar.h. (gomp_num_teams_var): Declare. (struct gomp_thread_pool): Change threads_dock member to gomp_simple_barrier_t. [__nvptx__] (gomp_thread): New implementation. (gomp_thread_attr): Guard by LIBGOMP_USE_PTHREADS. (gomp_thread_destructor): Ditto. (gomp_init_thread_affinity): Ditto. * team.c: Guard uses of Pthreads-specific interfaces by LIBGOMP_USE_PTHREADS. Adjust all uses of threads_dock. (gomp_free_thread) [__nvptx__]: Do not call 'free'. * config/nvptx/alloc.c: Delete. * config/nvptx/barrier.c: Ditto. * config/nvptx/fortran.c: Ditto. * config/nvptx/iter.c: Ditto. * config/nvptx/iter_ull.c: Ditto. * config/nvptx/loop.c: Ditto. * config/nvptx/loop_ull.c: Ditto. * config/nvptx/ordered.c: Ditto. * config/nvptx/parallel.c: Ditto. * config/nvptx/priority_queue.c: Ditto. * config/nvptx/sections.c: Ditto. * config/nvptx/single.c: Ditto. * config/nvptx/splay-tree.c: Ditto. * config/nvptx/work.c: Ditto. * testsuite/libgomp.fortran/fortran.exp (lang_link_flags): Pass -foffload=-lgfortran in addition to -lgfortran. * testsuite/libgomp.oacc-fortran/fortran.exp (lang_link_flags): Ditto. * plugin/plugin-nvptx.c: Include <limits.h>. (struct targ_fn_descriptor): Add new fields. (struct ptx_device): Ditto. Set them... (nvptx_open_device): ...here. (nvptx_adjust_launch_bounds): New. (nvptx_host2dev): Allow NULL 'nvthd'. (nvptx_dev2host): Ditto. (GOMP_OFFLOAD_get_caps): Add GOMP_OFFLOAD_CAP_OPENMP_400. (link_ptx): Adjust log sizes. (nvptx_host2dev): Allow NULL 'nvthd'. (nvptx_dev2host): Ditto. (nvptx_set_clocktick): New. Use it... (GOMP_OFFLOAD_load_image): ...here. Set new targ_fn_descriptor fields. (GOMP_OFFLOAD_dev2dev): New. (nvptx_adjust_launch_bounds): New. (nvptx_stacks_size): New. (nvptx_stacks_alloc): New. (nvptx_stacks_free): New. (GOMP_OFFLOAD_run): New. (GOMP_OFFLOAD_async_run): New (stub). Co-Authored-By: Dmitry Melnik <dm@ispras.ru> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r242789
2016-11-23 19:36:41 +01:00
int
omp_get_default_device (void)
{
struct gomp_task_icv *icv = gomp_icv (false);
return icv->default_device_var;
}
openmp: Avoid PLT relocations for omp_* symbols in libgomp This patch avoids the following relocations: readelf -Wr libgomp.so.1.0.0 | grep omp_ 00000000000470e0 0000020700000007 R_X86_64_JUMP_SLOT 000000000001d9d0 omp_fulfill_event@@OMP_5.0.1 + 0 0000000000047170 000000b800000007 R_X86_64_JUMP_SLOT 000000000000e760 omp_display_env@@OMP_5.1 + 0 00000000000471e0 000000e800000007 R_X86_64_JUMP_SLOT 000000000000f910 omp_get_initial_device@@OMP_4.5 + 0 0000000000047280 0000019500000007 R_X86_64_JUMP_SLOT 0000000000015940 omp_get_active_level@@OMP_3.0 + 0 00000000000472c8 0000020d00000007 R_X86_64_JUMP_SLOT 0000000000035210 omp_get_team_num@@OMP_4.0 + 0 00000000000472f0 0000014700000007 R_X86_64_JUMP_SLOT 0000000000035200 omp_get_num_teams@@OMP_4.0 + 0 by using ialias{,_call,_redirect} macros as needed. We still have many acc_* PLT relocations, could somebody please fix those? readelf -Wr libgomp.so.1.0.0 | grep acc_ 0000000000046fb8 000001ed00000006 R_X86_64_GLOB_DAT 0000000000036350 acc_prof_unregister@@OACC_2.5.1 + 0 0000000000046fd8 000000a400000006 R_X86_64_GLOB_DAT 0000000000035f30 acc_prof_register@@OACC_2.5.1 + 0 0000000000046fe0 000001d100000006 R_X86_64_GLOB_DAT 0000000000035ee0 acc_prof_lookup@@OACC_2.5.1 + 0 0000000000047058 000001dd00000007 R_X86_64_JUMP_SLOT 0000000000031f40 acc_create_async@@OACC_2.5 + 0 0000000000047068 0000011500000007 R_X86_64_JUMP_SLOT 000000000002fc60 acc_get_property@@OACC_2.6 + 0 0000000000047070 000001fb00000007 R_X86_64_JUMP_SLOT 0000000000032ce0 acc_wait_all@@OACC_2.0 + 0 0000000000047080 0000006500000007 R_X86_64_JUMP_SLOT 000000000002f990 acc_on_device@@OACC_2.0 + 0 0000000000047088 000000ae00000007 R_X86_64_JUMP_SLOT 0000000000032140 acc_attach_async@@OACC_2.6 + 0 0000000000047090 0000021900000007 R_X86_64_JUMP_SLOT 000000000002f550 acc_get_device_type@@OACC_2.0 + 0 0000000000047098 000001cb00000007 R_X86_64_JUMP_SLOT 0000000000032090 acc_copyout_finalize@@OACC_2.5 + 0 00000000000470a8 0000005200000007 R_X86_64_JUMP_SLOT 0000000000031f80 acc_copyin@@OACC_2.0 + 0 00000000000470b8 000001ad00000007 R_X86_64_JUMP_SLOT 0000000000032030 acc_delete_finalize@@OACC_2.5 + 0 00000000000470e8 0000010900000007 R_X86_64_JUMP_SLOT 0000000000031f00 acc_create@@OACC_2.0 + 0 00000000000470f8 0000005900000007 R_X86_64_JUMP_SLOT 0000000000032b70 acc_wait_async@@OACC_2.0 + 0 0000000000047110 0000013100000007 R_X86_64_JUMP_SLOT 0000000000032860 acc_async_test@@OACC_2.0 + 0 0000000000047118 000001ff00000007 R_X86_64_JUMP_SLOT 000000000002f720 acc_get_device_num@@OACC_2.0 + 0 0000000000047128 0000019100000007 R_X86_64_JUMP_SLOT 0000000000032020 acc_delete_async@@OACC_2.5 + 0 0000000000047130 000001d200000007 R_X86_64_JUMP_SLOT 000000000002efa0 acc_shutdown@@OACC_2.0 + 0 0000000000047150 000000d000000007 R_X86_64_JUMP_SLOT 0000000000031f00 acc_present_or_create@@OACC_2.0 + 0 0000000000047188 0000019200000007 R_X86_64_JUMP_SLOT 0000000000031910 acc_is_present@@OACC_2.0 + 0 0000000000047190 000001aa00000007 R_X86_64_JUMP_SLOT 000000000002fca0 acc_get_property_string@@OACC_2.6 + 0 00000000000471d0 000001bf00000007 R_X86_64_JUMP_SLOT 0000000000032120 acc_update_self_async@@OACC_2.5 + 0 0000000000047200 0000020500000007 R_X86_64_JUMP_SLOT 0000000000032e00 acc_wait_all_async@@OACC_2.0 + 0 0000000000047208 000000a600000007 R_X86_64_JUMP_SLOT 0000000000031790 acc_deviceptr@@OACC_2.0 + 0 0000000000047218 0000007500000007 R_X86_64_JUMP_SLOT 0000000000032000 acc_delete@@OACC_2.0 + 0 0000000000047238 000001e900000007 R_X86_64_JUMP_SLOT 000000000002f3a0 acc_set_device_type@@OACC_2.0 + 0 0000000000047240 000001f600000007 R_X86_64_JUMP_SLOT 000000000002ef20 acc_init@@OACC_2.0 + 0 0000000000047248 0000018800000007 R_X86_64_JUMP_SLOT 0000000000032060 acc_copyout@@OACC_2.0 + 0 0000000000047258 0000021f00000007 R_X86_64_JUMP_SLOT 0000000000032a80 acc_wait@@OACC_2.0 + 0 0000000000047270 000001bc00000007 R_X86_64_JUMP_SLOT 0000000000032100 acc_update_self@@OACC_2.0 + 0 0000000000047288 0000011400000007 R_X86_64_JUMP_SLOT 0000000000032080 acc_copyout_async@@OACC_2.5 + 0 0000000000047290 0000013d00000007 R_X86_64_JUMP_SLOT 000000000002f850 acc_set_device_num@@OACC_2.0 + 0 00000000000472a8 000000c500000007 R_X86_64_JUMP_SLOT 00000000000320e0 acc_update_device_async@@OACC_2.5 + 0 00000000000472c0 0000014600000007 R_X86_64_JUMP_SLOT 0000000000031fc0 acc_copyin_async@@OACC_2.5 + 0 00000000000472f8 0000006a00000007 R_X86_64_JUMP_SLOT 000000000002f310 acc_get_num_devices@@OACC_2.0 + 0 0000000000047350 0000021700000007 R_X86_64_JUMP_SLOT 0000000000031f80 acc_present_or_copyin@@OACC_2.0 + 0 0000000000047360 0000020900000007 R_X86_64_JUMP_SLOT 00000000000320c0 acc_update_device@@OACC_2.0 + 0 0000000000047380 0000008400000007 R_X86_64_JUMP_SLOT 0000000000032950 acc_async_test_all@@OACC_2.0 + 0 2021-10-01 Jakub Jelinek <jakub@redhat.com> * affinity-fmt.c (omp_get_team_num, omp_get_num_teams): Add ialias_redirect. * env.c (handle_omp_display_env): Use ialias_call. * icv-device.c: Move ialias right below each function. (omp_get_device_num): Use ialias_call. * fortran.c (omp_fulfill_event): Add ialias_redirect. * icv.c (omp_get_active_level): Add ialias_redirect.
2021-10-01 10:42:07 +02:00
ialias (omp_get_default_device)
openmp: Change omp_get_initial_device () to match OpenMP 5.1 requirements > Therefore, I think until omp_get_initial_device () value is changed, we The following so far untested patch implements that change. OpenMP 4.5 said for omp_get_initial_device: The value of the device number is implementation defined. If it is between 0 and one less than omp_get_num_devices() then it is valid for use with all device constructs and routines; if it is outside that range, then it is only valid for use with the device memory routines and not in the device clause. and OpenMP 5.0 similarly, but OpenMP 5.1 says: The value of the device number is the value returned by the omp_get_num_devices routine. As the new value is compatible with what has been required earlier, I think we can change it already now. 2020-10-22 Jakub Jelinek <jakub@redhat.com> * icv.c (omp_get_initial_device): Remove including corresponding ialias. * icv-device.c (omp_get_initial_device): New function. Return gomp_get_num_devices (). Add ialias. * target.c (resolve_device): Don't fail with OMP_TARGET_OFFLOAD=mandatory if device_id is equal to gomp_get_num_devices (). (omp_target_alloc, omp_target_free, omp_target_is_present, omp_target_memcpy, omp_target_memcpy_rect, omp_target_associate_ptr, omp_target_disassociate_ptr, omp_pause_resource): Use gomp_get_num_devices () instead of GOMP_DEVICE_HOST_FALLBACK on the first use in the functions, in uses dominated by the gomp_get_num_devices call use num_devices_openmp instead. * libgomp.texi (omp_get_initial_device): Document. * config/gcn/icv-device.c (omp_get_initial_device): New function. Add ialias. * config/nvptx/icv-device.c (omp_get_initial_device): Likewise. * testsuite/libgomp.c/target-40.c: New test.
2020-10-22 09:31:01 +02:00
int
omp_get_initial_device (void)
{
return gomp_get_num_devices ();
}
openmp: Avoid PLT relocations for omp_* symbols in libgomp This patch avoids the following relocations: readelf -Wr libgomp.so.1.0.0 | grep omp_ 00000000000470e0 0000020700000007 R_X86_64_JUMP_SLOT 000000000001d9d0 omp_fulfill_event@@OMP_5.0.1 + 0 0000000000047170 000000b800000007 R_X86_64_JUMP_SLOT 000000000000e760 omp_display_env@@OMP_5.1 + 0 00000000000471e0 000000e800000007 R_X86_64_JUMP_SLOT 000000000000f910 omp_get_initial_device@@OMP_4.5 + 0 0000000000047280 0000019500000007 R_X86_64_JUMP_SLOT 0000000000015940 omp_get_active_level@@OMP_3.0 + 0 00000000000472c8 0000020d00000007 R_X86_64_JUMP_SLOT 0000000000035210 omp_get_team_num@@OMP_4.0 + 0 00000000000472f0 0000014700000007 R_X86_64_JUMP_SLOT 0000000000035200 omp_get_num_teams@@OMP_4.0 + 0 by using ialias{,_call,_redirect} macros as needed. We still have many acc_* PLT relocations, could somebody please fix those? readelf -Wr libgomp.so.1.0.0 | grep acc_ 0000000000046fb8 000001ed00000006 R_X86_64_GLOB_DAT 0000000000036350 acc_prof_unregister@@OACC_2.5.1 + 0 0000000000046fd8 000000a400000006 R_X86_64_GLOB_DAT 0000000000035f30 acc_prof_register@@OACC_2.5.1 + 0 0000000000046fe0 000001d100000006 R_X86_64_GLOB_DAT 0000000000035ee0 acc_prof_lookup@@OACC_2.5.1 + 0 0000000000047058 000001dd00000007 R_X86_64_JUMP_SLOT 0000000000031f40 acc_create_async@@OACC_2.5 + 0 0000000000047068 0000011500000007 R_X86_64_JUMP_SLOT 000000000002fc60 acc_get_property@@OACC_2.6 + 0 0000000000047070 000001fb00000007 R_X86_64_JUMP_SLOT 0000000000032ce0 acc_wait_all@@OACC_2.0 + 0 0000000000047080 0000006500000007 R_X86_64_JUMP_SLOT 000000000002f990 acc_on_device@@OACC_2.0 + 0 0000000000047088 000000ae00000007 R_X86_64_JUMP_SLOT 0000000000032140 acc_attach_async@@OACC_2.6 + 0 0000000000047090 0000021900000007 R_X86_64_JUMP_SLOT 000000000002f550 acc_get_device_type@@OACC_2.0 + 0 0000000000047098 000001cb00000007 R_X86_64_JUMP_SLOT 0000000000032090 acc_copyout_finalize@@OACC_2.5 + 0 00000000000470a8 0000005200000007 R_X86_64_JUMP_SLOT 0000000000031f80 acc_copyin@@OACC_2.0 + 0 00000000000470b8 000001ad00000007 R_X86_64_JUMP_SLOT 0000000000032030 acc_delete_finalize@@OACC_2.5 + 0 00000000000470e8 0000010900000007 R_X86_64_JUMP_SLOT 0000000000031f00 acc_create@@OACC_2.0 + 0 00000000000470f8 0000005900000007 R_X86_64_JUMP_SLOT 0000000000032b70 acc_wait_async@@OACC_2.0 + 0 0000000000047110 0000013100000007 R_X86_64_JUMP_SLOT 0000000000032860 acc_async_test@@OACC_2.0 + 0 0000000000047118 000001ff00000007 R_X86_64_JUMP_SLOT 000000000002f720 acc_get_device_num@@OACC_2.0 + 0 0000000000047128 0000019100000007 R_X86_64_JUMP_SLOT 0000000000032020 acc_delete_async@@OACC_2.5 + 0 0000000000047130 000001d200000007 R_X86_64_JUMP_SLOT 000000000002efa0 acc_shutdown@@OACC_2.0 + 0 0000000000047150 000000d000000007 R_X86_64_JUMP_SLOT 0000000000031f00 acc_present_or_create@@OACC_2.0 + 0 0000000000047188 0000019200000007 R_X86_64_JUMP_SLOT 0000000000031910 acc_is_present@@OACC_2.0 + 0 0000000000047190 000001aa00000007 R_X86_64_JUMP_SLOT 000000000002fca0 acc_get_property_string@@OACC_2.6 + 0 00000000000471d0 000001bf00000007 R_X86_64_JUMP_SLOT 0000000000032120 acc_update_self_async@@OACC_2.5 + 0 0000000000047200 0000020500000007 R_X86_64_JUMP_SLOT 0000000000032e00 acc_wait_all_async@@OACC_2.0 + 0 0000000000047208 000000a600000007 R_X86_64_JUMP_SLOT 0000000000031790 acc_deviceptr@@OACC_2.0 + 0 0000000000047218 0000007500000007 R_X86_64_JUMP_SLOT 0000000000032000 acc_delete@@OACC_2.0 + 0 0000000000047238 000001e900000007 R_X86_64_JUMP_SLOT 000000000002f3a0 acc_set_device_type@@OACC_2.0 + 0 0000000000047240 000001f600000007 R_X86_64_JUMP_SLOT 000000000002ef20 acc_init@@OACC_2.0 + 0 0000000000047248 0000018800000007 R_X86_64_JUMP_SLOT 0000000000032060 acc_copyout@@OACC_2.0 + 0 0000000000047258 0000021f00000007 R_X86_64_JUMP_SLOT 0000000000032a80 acc_wait@@OACC_2.0 + 0 0000000000047270 000001bc00000007 R_X86_64_JUMP_SLOT 0000000000032100 acc_update_self@@OACC_2.0 + 0 0000000000047288 0000011400000007 R_X86_64_JUMP_SLOT 0000000000032080 acc_copyout_async@@OACC_2.5 + 0 0000000000047290 0000013d00000007 R_X86_64_JUMP_SLOT 000000000002f850 acc_set_device_num@@OACC_2.0 + 0 00000000000472a8 000000c500000007 R_X86_64_JUMP_SLOT 00000000000320e0 acc_update_device_async@@OACC_2.5 + 0 00000000000472c0 0000014600000007 R_X86_64_JUMP_SLOT 0000000000031fc0 acc_copyin_async@@OACC_2.5 + 0 00000000000472f8 0000006a00000007 R_X86_64_JUMP_SLOT 000000000002f310 acc_get_num_devices@@OACC_2.0 + 0 0000000000047350 0000021700000007 R_X86_64_JUMP_SLOT 0000000000031f80 acc_present_or_copyin@@OACC_2.0 + 0 0000000000047360 0000020900000007 R_X86_64_JUMP_SLOT 00000000000320c0 acc_update_device@@OACC_2.0 + 0 0000000000047380 0000008400000007 R_X86_64_JUMP_SLOT 0000000000032950 acc_async_test_all@@OACC_2.0 + 0 2021-10-01 Jakub Jelinek <jakub@redhat.com> * affinity-fmt.c (omp_get_team_num, omp_get_num_teams): Add ialias_redirect. * env.c (handle_omp_display_env): Use ialias_call. * icv-device.c: Move ialias right below each function. (omp_get_device_num): Use ialias_call. * fortran.c (omp_fulfill_event): Add ialias_redirect. * icv.c (omp_get_active_level): Add ialias_redirect.
2021-10-01 10:42:07 +02:00
ialias (omp_get_initial_device)
OpenMP offloading to NVPTX: libgomp changes * Makefile.am (libgomp_la_SOURCES): Add atomic.c, icv.c, icv-device.c. * Makefile.in. Regenerate. * configure.ac [nvptx*-*-*] (libgomp_use_pthreads): Set and use it... (LIBGOMP_USE_PTHREADS): ...here; new define. * configure: Regenerate. * config.h.in: Likewise. * config/posix/affinity.c: Move to... * affinity.c: ...here (new file). Guard use of Pthreads-specific interface by LIBGOMP_USE_PTHREADS. * critical.c: Split out GOMP_atomic_{start,end} into... * atomic.c: ...here (new file). * env.c: Split out ICV definitions into... * icv.c: ...here (new file) and... * icv-device.c: ...here. New file. * config/linux/lock.c (gomp_init_lock_30): Move to generic lock.c. (gomp_destroy_lock_30): Ditto. (gomp_set_lock_30): Ditto. (gomp_unset_lock_30): Ditto. (gomp_test_lock_30): Ditto. (gomp_init_nest_lock_30): Ditto. (gomp_destroy_nest_lock_30): Ditto. (gomp_set_nest_lock_30): Ditto. (gomp_unset_nest_lock_30): Ditto. (gomp_test_nest_lock_30): Ditto. * lock.c: New. * config/nvptx/lock.c: New. * config/nvptx/bar.c: New. * config/nvptx/bar.h: New. * config/nvptx/doacross.h: New. * config/nvptx/error.c: New. * config/nvptx/icv-device.c: New. * config/nvptx/mutex.h: New. * config/nvptx/pool.h: New. * config/nvptx/proc.c: New. * config/nvptx/ptrlock.h: New. * config/nvptx/sem.h: New. * config/nvptx/simple-bar.h: New. * config/nvptx/target.c: New. * config/nvptx/task.c: New. * config/nvptx/team.c: New. * config/nvptx/time.c: New. * config/posix/simple-bar.h: New. * libgomp.h: Guard pthread.h inclusion. Include simple-bar.h. (gomp_num_teams_var): Declare. (struct gomp_thread_pool): Change threads_dock member to gomp_simple_barrier_t. [__nvptx__] (gomp_thread): New implementation. (gomp_thread_attr): Guard by LIBGOMP_USE_PTHREADS. (gomp_thread_destructor): Ditto. (gomp_init_thread_affinity): Ditto. * team.c: Guard uses of Pthreads-specific interfaces by LIBGOMP_USE_PTHREADS. Adjust all uses of threads_dock. (gomp_free_thread) [__nvptx__]: Do not call 'free'. * config/nvptx/alloc.c: Delete. * config/nvptx/barrier.c: Ditto. * config/nvptx/fortran.c: Ditto. * config/nvptx/iter.c: Ditto. * config/nvptx/iter_ull.c: Ditto. * config/nvptx/loop.c: Ditto. * config/nvptx/loop_ull.c: Ditto. * config/nvptx/ordered.c: Ditto. * config/nvptx/parallel.c: Ditto. * config/nvptx/priority_queue.c: Ditto. * config/nvptx/sections.c: Ditto. * config/nvptx/single.c: Ditto. * config/nvptx/splay-tree.c: Ditto. * config/nvptx/work.c: Ditto. * testsuite/libgomp.fortran/fortran.exp (lang_link_flags): Pass -foffload=-lgfortran in addition to -lgfortran. * testsuite/libgomp.oacc-fortran/fortran.exp (lang_link_flags): Ditto. * plugin/plugin-nvptx.c: Include <limits.h>. (struct targ_fn_descriptor): Add new fields. (struct ptx_device): Ditto. Set them... (nvptx_open_device): ...here. (nvptx_adjust_launch_bounds): New. (nvptx_host2dev): Allow NULL 'nvthd'. (nvptx_dev2host): Ditto. (GOMP_OFFLOAD_get_caps): Add GOMP_OFFLOAD_CAP_OPENMP_400. (link_ptx): Adjust log sizes. (nvptx_host2dev): Allow NULL 'nvthd'. (nvptx_dev2host): Ditto. (nvptx_set_clocktick): New. Use it... (GOMP_OFFLOAD_load_image): ...here. Set new targ_fn_descriptor fields. (GOMP_OFFLOAD_dev2dev): New. (nvptx_adjust_launch_bounds): New. (nvptx_stacks_size): New. (nvptx_stacks_alloc): New. (nvptx_stacks_free): New. (GOMP_OFFLOAD_run): New. (GOMP_OFFLOAD_async_run): New (stub). Co-Authored-By: Dmitry Melnik <dm@ispras.ru> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r242789
2016-11-23 19:36:41 +01:00
int
omp_get_num_devices (void)
{
return gomp_get_num_devices ();
}
openmp: Avoid PLT relocations for omp_* symbols in libgomp This patch avoids the following relocations: readelf -Wr libgomp.so.1.0.0 | grep omp_ 00000000000470e0 0000020700000007 R_X86_64_JUMP_SLOT 000000000001d9d0 omp_fulfill_event@@OMP_5.0.1 + 0 0000000000047170 000000b800000007 R_X86_64_JUMP_SLOT 000000000000e760 omp_display_env@@OMP_5.1 + 0 00000000000471e0 000000e800000007 R_X86_64_JUMP_SLOT 000000000000f910 omp_get_initial_device@@OMP_4.5 + 0 0000000000047280 0000019500000007 R_X86_64_JUMP_SLOT 0000000000015940 omp_get_active_level@@OMP_3.0 + 0 00000000000472c8 0000020d00000007 R_X86_64_JUMP_SLOT 0000000000035210 omp_get_team_num@@OMP_4.0 + 0 00000000000472f0 0000014700000007 R_X86_64_JUMP_SLOT 0000000000035200 omp_get_num_teams@@OMP_4.0 + 0 by using ialias{,_call,_redirect} macros as needed. We still have many acc_* PLT relocations, could somebody please fix those? readelf -Wr libgomp.so.1.0.0 | grep acc_ 0000000000046fb8 000001ed00000006 R_X86_64_GLOB_DAT 0000000000036350 acc_prof_unregister@@OACC_2.5.1 + 0 0000000000046fd8 000000a400000006 R_X86_64_GLOB_DAT 0000000000035f30 acc_prof_register@@OACC_2.5.1 + 0 0000000000046fe0 000001d100000006 R_X86_64_GLOB_DAT 0000000000035ee0 acc_prof_lookup@@OACC_2.5.1 + 0 0000000000047058 000001dd00000007 R_X86_64_JUMP_SLOT 0000000000031f40 acc_create_async@@OACC_2.5 + 0 0000000000047068 0000011500000007 R_X86_64_JUMP_SLOT 000000000002fc60 acc_get_property@@OACC_2.6 + 0 0000000000047070 000001fb00000007 R_X86_64_JUMP_SLOT 0000000000032ce0 acc_wait_all@@OACC_2.0 + 0 0000000000047080 0000006500000007 R_X86_64_JUMP_SLOT 000000000002f990 acc_on_device@@OACC_2.0 + 0 0000000000047088 000000ae00000007 R_X86_64_JUMP_SLOT 0000000000032140 acc_attach_async@@OACC_2.6 + 0 0000000000047090 0000021900000007 R_X86_64_JUMP_SLOT 000000000002f550 acc_get_device_type@@OACC_2.0 + 0 0000000000047098 000001cb00000007 R_X86_64_JUMP_SLOT 0000000000032090 acc_copyout_finalize@@OACC_2.5 + 0 00000000000470a8 0000005200000007 R_X86_64_JUMP_SLOT 0000000000031f80 acc_copyin@@OACC_2.0 + 0 00000000000470b8 000001ad00000007 R_X86_64_JUMP_SLOT 0000000000032030 acc_delete_finalize@@OACC_2.5 + 0 00000000000470e8 0000010900000007 R_X86_64_JUMP_SLOT 0000000000031f00 acc_create@@OACC_2.0 + 0 00000000000470f8 0000005900000007 R_X86_64_JUMP_SLOT 0000000000032b70 acc_wait_async@@OACC_2.0 + 0 0000000000047110 0000013100000007 R_X86_64_JUMP_SLOT 0000000000032860 acc_async_test@@OACC_2.0 + 0 0000000000047118 000001ff00000007 R_X86_64_JUMP_SLOT 000000000002f720 acc_get_device_num@@OACC_2.0 + 0 0000000000047128 0000019100000007 R_X86_64_JUMP_SLOT 0000000000032020 acc_delete_async@@OACC_2.5 + 0 0000000000047130 000001d200000007 R_X86_64_JUMP_SLOT 000000000002efa0 acc_shutdown@@OACC_2.0 + 0 0000000000047150 000000d000000007 R_X86_64_JUMP_SLOT 0000000000031f00 acc_present_or_create@@OACC_2.0 + 0 0000000000047188 0000019200000007 R_X86_64_JUMP_SLOT 0000000000031910 acc_is_present@@OACC_2.0 + 0 0000000000047190 000001aa00000007 R_X86_64_JUMP_SLOT 000000000002fca0 acc_get_property_string@@OACC_2.6 + 0 00000000000471d0 000001bf00000007 R_X86_64_JUMP_SLOT 0000000000032120 acc_update_self_async@@OACC_2.5 + 0 0000000000047200 0000020500000007 R_X86_64_JUMP_SLOT 0000000000032e00 acc_wait_all_async@@OACC_2.0 + 0 0000000000047208 000000a600000007 R_X86_64_JUMP_SLOT 0000000000031790 acc_deviceptr@@OACC_2.0 + 0 0000000000047218 0000007500000007 R_X86_64_JUMP_SLOT 0000000000032000 acc_delete@@OACC_2.0 + 0 0000000000047238 000001e900000007 R_X86_64_JUMP_SLOT 000000000002f3a0 acc_set_device_type@@OACC_2.0 + 0 0000000000047240 000001f600000007 R_X86_64_JUMP_SLOT 000000000002ef20 acc_init@@OACC_2.0 + 0 0000000000047248 0000018800000007 R_X86_64_JUMP_SLOT 0000000000032060 acc_copyout@@OACC_2.0 + 0 0000000000047258 0000021f00000007 R_X86_64_JUMP_SLOT 0000000000032a80 acc_wait@@OACC_2.0 + 0 0000000000047270 000001bc00000007 R_X86_64_JUMP_SLOT 0000000000032100 acc_update_self@@OACC_2.0 + 0 0000000000047288 0000011400000007 R_X86_64_JUMP_SLOT 0000000000032080 acc_copyout_async@@OACC_2.5 + 0 0000000000047290 0000013d00000007 R_X86_64_JUMP_SLOT 000000000002f850 acc_set_device_num@@OACC_2.0 + 0 00000000000472a8 000000c500000007 R_X86_64_JUMP_SLOT 00000000000320e0 acc_update_device_async@@OACC_2.5 + 0 00000000000472c0 0000014600000007 R_X86_64_JUMP_SLOT 0000000000031fc0 acc_copyin_async@@OACC_2.5 + 0 00000000000472f8 0000006a00000007 R_X86_64_JUMP_SLOT 000000000002f310 acc_get_num_devices@@OACC_2.0 + 0 0000000000047350 0000021700000007 R_X86_64_JUMP_SLOT 0000000000031f80 acc_present_or_copyin@@OACC_2.0 + 0 0000000000047360 0000020900000007 R_X86_64_JUMP_SLOT 00000000000320c0 acc_update_device@@OACC_2.0 + 0 0000000000047380 0000008400000007 R_X86_64_JUMP_SLOT 0000000000032950 acc_async_test_all@@OACC_2.0 + 0 2021-10-01 Jakub Jelinek <jakub@redhat.com> * affinity-fmt.c (omp_get_team_num, omp_get_num_teams): Add ialias_redirect. * env.c (handle_omp_display_env): Use ialias_call. * icv-device.c: Move ialias right below each function. (omp_get_device_num): Use ialias_call. * fortran.c (omp_fulfill_event): Add ialias_redirect. * icv.c (omp_get_active_level): Add ialias_redirect.
2021-10-01 10:42:07 +02:00
ialias (omp_get_num_devices)
OpenMP offloading to NVPTX: libgomp changes * Makefile.am (libgomp_la_SOURCES): Add atomic.c, icv.c, icv-device.c. * Makefile.in. Regenerate. * configure.ac [nvptx*-*-*] (libgomp_use_pthreads): Set and use it... (LIBGOMP_USE_PTHREADS): ...here; new define. * configure: Regenerate. * config.h.in: Likewise. * config/posix/affinity.c: Move to... * affinity.c: ...here (new file). Guard use of Pthreads-specific interface by LIBGOMP_USE_PTHREADS. * critical.c: Split out GOMP_atomic_{start,end} into... * atomic.c: ...here (new file). * env.c: Split out ICV definitions into... * icv.c: ...here (new file) and... * icv-device.c: ...here. New file. * config/linux/lock.c (gomp_init_lock_30): Move to generic lock.c. (gomp_destroy_lock_30): Ditto. (gomp_set_lock_30): Ditto. (gomp_unset_lock_30): Ditto. (gomp_test_lock_30): Ditto. (gomp_init_nest_lock_30): Ditto. (gomp_destroy_nest_lock_30): Ditto. (gomp_set_nest_lock_30): Ditto. (gomp_unset_nest_lock_30): Ditto. (gomp_test_nest_lock_30): Ditto. * lock.c: New. * config/nvptx/lock.c: New. * config/nvptx/bar.c: New. * config/nvptx/bar.h: New. * config/nvptx/doacross.h: New. * config/nvptx/error.c: New. * config/nvptx/icv-device.c: New. * config/nvptx/mutex.h: New. * config/nvptx/pool.h: New. * config/nvptx/proc.c: New. * config/nvptx/ptrlock.h: New. * config/nvptx/sem.h: New. * config/nvptx/simple-bar.h: New. * config/nvptx/target.c: New. * config/nvptx/task.c: New. * config/nvptx/team.c: New. * config/nvptx/time.c: New. * config/posix/simple-bar.h: New. * libgomp.h: Guard pthread.h inclusion. Include simple-bar.h. (gomp_num_teams_var): Declare. (struct gomp_thread_pool): Change threads_dock member to gomp_simple_barrier_t. [__nvptx__] (gomp_thread): New implementation. (gomp_thread_attr): Guard by LIBGOMP_USE_PTHREADS. (gomp_thread_destructor): Ditto. (gomp_init_thread_affinity): Ditto. * team.c: Guard uses of Pthreads-specific interfaces by LIBGOMP_USE_PTHREADS. Adjust all uses of threads_dock. (gomp_free_thread) [__nvptx__]: Do not call 'free'. * config/nvptx/alloc.c: Delete. * config/nvptx/barrier.c: Ditto. * config/nvptx/fortran.c: Ditto. * config/nvptx/iter.c: Ditto. * config/nvptx/iter_ull.c: Ditto. * config/nvptx/loop.c: Ditto. * config/nvptx/loop_ull.c: Ditto. * config/nvptx/ordered.c: Ditto. * config/nvptx/parallel.c: Ditto. * config/nvptx/priority_queue.c: Ditto. * config/nvptx/sections.c: Ditto. * config/nvptx/single.c: Ditto. * config/nvptx/splay-tree.c: Ditto. * config/nvptx/work.c: Ditto. * testsuite/libgomp.fortran/fortran.exp (lang_link_flags): Pass -foffload=-lgfortran in addition to -lgfortran. * testsuite/libgomp.oacc-fortran/fortran.exp (lang_link_flags): Ditto. * plugin/plugin-nvptx.c: Include <limits.h>. (struct targ_fn_descriptor): Add new fields. (struct ptx_device): Ditto. Set them... (nvptx_open_device): ...here. (nvptx_adjust_launch_bounds): New. (nvptx_host2dev): Allow NULL 'nvthd'. (nvptx_dev2host): Ditto. (GOMP_OFFLOAD_get_caps): Add GOMP_OFFLOAD_CAP_OPENMP_400. (link_ptx): Adjust log sizes. (nvptx_host2dev): Allow NULL 'nvthd'. (nvptx_dev2host): Ditto. (nvptx_set_clocktick): New. Use it... (GOMP_OFFLOAD_load_image): ...here. Set new targ_fn_descriptor fields. (GOMP_OFFLOAD_dev2dev): New. (nvptx_adjust_launch_bounds): New. (nvptx_stacks_size): New. (nvptx_stacks_alloc): New. (nvptx_stacks_free): New. (GOMP_OFFLOAD_run): New. (GOMP_OFFLOAD_async_run): New (stub). Co-Authored-By: Dmitry Melnik <dm@ispras.ru> Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r242789
2016-11-23 19:36:41 +01:00
int
omp_is_initial_device (void)
{
/* Hardcoded to 1 on host, should be 0 on MIC, HSAIL, PTX. */
return 1;
}
openmp: Avoid PLT relocations for omp_* symbols in libgomp This patch avoids the following relocations: readelf -Wr libgomp.so.1.0.0 | grep omp_ 00000000000470e0 0000020700000007 R_X86_64_JUMP_SLOT 000000000001d9d0 omp_fulfill_event@@OMP_5.0.1 + 0 0000000000047170 000000b800000007 R_X86_64_JUMP_SLOT 000000000000e760 omp_display_env@@OMP_5.1 + 0 00000000000471e0 000000e800000007 R_X86_64_JUMP_SLOT 000000000000f910 omp_get_initial_device@@OMP_4.5 + 0 0000000000047280 0000019500000007 R_X86_64_JUMP_SLOT 0000000000015940 omp_get_active_level@@OMP_3.0 + 0 00000000000472c8 0000020d00000007 R_X86_64_JUMP_SLOT 0000000000035210 omp_get_team_num@@OMP_4.0 + 0 00000000000472f0 0000014700000007 R_X86_64_JUMP_SLOT 0000000000035200 omp_get_num_teams@@OMP_4.0 + 0 by using ialias{,_call,_redirect} macros as needed. We still have many acc_* PLT relocations, could somebody please fix those? readelf -Wr libgomp.so.1.0.0 | grep acc_ 0000000000046fb8 000001ed00000006 R_X86_64_GLOB_DAT 0000000000036350 acc_prof_unregister@@OACC_2.5.1 + 0 0000000000046fd8 000000a400000006 R_X86_64_GLOB_DAT 0000000000035f30 acc_prof_register@@OACC_2.5.1 + 0 0000000000046fe0 000001d100000006 R_X86_64_GLOB_DAT 0000000000035ee0 acc_prof_lookup@@OACC_2.5.1 + 0 0000000000047058 000001dd00000007 R_X86_64_JUMP_SLOT 0000000000031f40 acc_create_async@@OACC_2.5 + 0 0000000000047068 0000011500000007 R_X86_64_JUMP_SLOT 000000000002fc60 acc_get_property@@OACC_2.6 + 0 0000000000047070 000001fb00000007 R_X86_64_JUMP_SLOT 0000000000032ce0 acc_wait_all@@OACC_2.0 + 0 0000000000047080 0000006500000007 R_X86_64_JUMP_SLOT 000000000002f990 acc_on_device@@OACC_2.0 + 0 0000000000047088 000000ae00000007 R_X86_64_JUMP_SLOT 0000000000032140 acc_attach_async@@OACC_2.6 + 0 0000000000047090 0000021900000007 R_X86_64_JUMP_SLOT 000000000002f550 acc_get_device_type@@OACC_2.0 + 0 0000000000047098 000001cb00000007 R_X86_64_JUMP_SLOT 0000000000032090 acc_copyout_finalize@@OACC_2.5 + 0 00000000000470a8 0000005200000007 R_X86_64_JUMP_SLOT 0000000000031f80 acc_copyin@@OACC_2.0 + 0 00000000000470b8 000001ad00000007 R_X86_64_JUMP_SLOT 0000000000032030 acc_delete_finalize@@OACC_2.5 + 0 00000000000470e8 0000010900000007 R_X86_64_JUMP_SLOT 0000000000031f00 acc_create@@OACC_2.0 + 0 00000000000470f8 0000005900000007 R_X86_64_JUMP_SLOT 0000000000032b70 acc_wait_async@@OACC_2.0 + 0 0000000000047110 0000013100000007 R_X86_64_JUMP_SLOT 0000000000032860 acc_async_test@@OACC_2.0 + 0 0000000000047118 000001ff00000007 R_X86_64_JUMP_SLOT 000000000002f720 acc_get_device_num@@OACC_2.0 + 0 0000000000047128 0000019100000007 R_X86_64_JUMP_SLOT 0000000000032020 acc_delete_async@@OACC_2.5 + 0 0000000000047130 000001d200000007 R_X86_64_JUMP_SLOT 000000000002efa0 acc_shutdown@@OACC_2.0 + 0 0000000000047150 000000d000000007 R_X86_64_JUMP_SLOT 0000000000031f00 acc_present_or_create@@OACC_2.0 + 0 0000000000047188 0000019200000007 R_X86_64_JUMP_SLOT 0000000000031910 acc_is_present@@OACC_2.0 + 0 0000000000047190 000001aa00000007 R_X86_64_JUMP_SLOT 000000000002fca0 acc_get_property_string@@OACC_2.6 + 0 00000000000471d0 000001bf00000007 R_X86_64_JUMP_SLOT 0000000000032120 acc_update_self_async@@OACC_2.5 + 0 0000000000047200 0000020500000007 R_X86_64_JUMP_SLOT 0000000000032e00 acc_wait_all_async@@OACC_2.0 + 0 0000000000047208 000000a600000007 R_X86_64_JUMP_SLOT 0000000000031790 acc_deviceptr@@OACC_2.0 + 0 0000000000047218 0000007500000007 R_X86_64_JUMP_SLOT 0000000000032000 acc_delete@@OACC_2.0 + 0 0000000000047238 000001e900000007 R_X86_64_JUMP_SLOT 000000000002f3a0 acc_set_device_type@@OACC_2.0 + 0 0000000000047240 000001f600000007 R_X86_64_JUMP_SLOT 000000000002ef20 acc_init@@OACC_2.0 + 0 0000000000047248 0000018800000007 R_X86_64_JUMP_SLOT 0000000000032060 acc_copyout@@OACC_2.0 + 0 0000000000047258 0000021f00000007 R_X86_64_JUMP_SLOT 0000000000032a80 acc_wait@@OACC_2.0 + 0 0000000000047270 000001bc00000007 R_X86_64_JUMP_SLOT 0000000000032100 acc_update_self@@OACC_2.0 + 0 0000000000047288 0000011400000007 R_X86_64_JUMP_SLOT 0000000000032080 acc_copyout_async@@OACC_2.5 + 0 0000000000047290 0000013d00000007 R_X86_64_JUMP_SLOT 000000000002f850 acc_set_device_num@@OACC_2.0 + 0 00000000000472a8 000000c500000007 R_X86_64_JUMP_SLOT 00000000000320e0 acc_update_device_async@@OACC_2.5 + 0 00000000000472c0 0000014600000007 R_X86_64_JUMP_SLOT 0000000000031fc0 acc_copyin_async@@OACC_2.5 + 0 00000000000472f8 0000006a00000007 R_X86_64_JUMP_SLOT 000000000002f310 acc_get_num_devices@@OACC_2.0 + 0 0000000000047350 0000021700000007 R_X86_64_JUMP_SLOT 0000000000031f80 acc_present_or_copyin@@OACC_2.0 + 0 0000000000047360 0000020900000007 R_X86_64_JUMP_SLOT 00000000000320c0 acc_update_device@@OACC_2.0 + 0 0000000000047380 0000008400000007 R_X86_64_JUMP_SLOT 0000000000032950 acc_async_test_all@@OACC_2.0 + 0 2021-10-01 Jakub Jelinek <jakub@redhat.com> * affinity-fmt.c (omp_get_team_num, omp_get_num_teams): Add ialias_redirect. * env.c (handle_omp_display_env): Use ialias_call. * icv-device.c: Move ialias right below each function. (omp_get_device_num): Use ialias_call. * fortran.c (omp_fulfill_event): Add ialias_redirect. * icv.c (omp_get_active_level): Add ialias_redirect.
2021-10-01 10:42:07 +02:00
ialias (omp_is_initial_device)
openmp: Implement omp_get_device_num routine This patch implements the omp_get_device_num library routine, specified in OpenMP 5.0. GOMP_DEVICE_NUM_VAR is a macro symbol which defines name of a "device number" variable, is defined on the device-side libgomp, has it's address returned to host-side libgomp during device initialization, and the host libgomp then sets its value to the designated device number. libgomp/ChangeLog: * icv-device.c (omp_get_device_num): New API function, host side. * fortran.c (omp_get_device_num_): New interface function. * libgomp-plugin.h (GOMP_DEVICE_NUM_VAR): Define macro symbol. * libgomp.map (OMP_5.0.2): New version space with omp_get_device_num, omp_get_device_num_. * libgomp.texi (omp_get_device_num): Add documentation for new API function. * omp.h.in (omp_get_device_num): Add declaration. * omp_lib.f90.in (omp_get_device_num): Likewise. * omp_lib.h.in (omp_get_device_num): Likewise. * target.c (gomp_load_image_to_device): If additional entry for device number exists at end of returned entries from 'load_image_func' hook, copy the assigned device number over to the device variable. * config/gcn/icv-device.c (GOMP_DEVICE_NUM_VAR): Define static global. (omp_get_device_num): New API function, device side. * plugin/plugin-gcn.c ("symcat.h"): Add include. (GOMP_OFFLOAD_load_image): Add addresses of device GOMP_DEVICE_NUM_VAR at end of returned 'target_table' entries. * config/nvptx/icv-device.c (GOMP_DEVICE_NUM_VAR): Define static global. (omp_get_device_num): New API function, device side. * plugin/plugin-nvptx.c ("symcat.h"): Add include. (GOMP_OFFLOAD_load_image): Add addresses of device GOMP_DEVICE_NUM_VAR at end of returned 'target_table' entries. * testsuite/lib/libgomp.exp (check_effective_target_offload_target_intelmic): New function for testing for intelmic offloading. * testsuite/libgomp.c-c++-common/target-45.c: New test. * testsuite/libgomp.fortran/target10.f90: New test.
2021-08-05 17:29:03 +02:00
int
omp_get_device_num (void)
{
/* By specification, this is equivalent to omp_get_initial_device
on the host. */
openmp: Avoid PLT relocations for omp_* symbols in libgomp This patch avoids the following relocations: readelf -Wr libgomp.so.1.0.0 | grep omp_ 00000000000470e0 0000020700000007 R_X86_64_JUMP_SLOT 000000000001d9d0 omp_fulfill_event@@OMP_5.0.1 + 0 0000000000047170 000000b800000007 R_X86_64_JUMP_SLOT 000000000000e760 omp_display_env@@OMP_5.1 + 0 00000000000471e0 000000e800000007 R_X86_64_JUMP_SLOT 000000000000f910 omp_get_initial_device@@OMP_4.5 + 0 0000000000047280 0000019500000007 R_X86_64_JUMP_SLOT 0000000000015940 omp_get_active_level@@OMP_3.0 + 0 00000000000472c8 0000020d00000007 R_X86_64_JUMP_SLOT 0000000000035210 omp_get_team_num@@OMP_4.0 + 0 00000000000472f0 0000014700000007 R_X86_64_JUMP_SLOT 0000000000035200 omp_get_num_teams@@OMP_4.0 + 0 by using ialias{,_call,_redirect} macros as needed. We still have many acc_* PLT relocations, could somebody please fix those? readelf -Wr libgomp.so.1.0.0 | grep acc_ 0000000000046fb8 000001ed00000006 R_X86_64_GLOB_DAT 0000000000036350 acc_prof_unregister@@OACC_2.5.1 + 0 0000000000046fd8 000000a400000006 R_X86_64_GLOB_DAT 0000000000035f30 acc_prof_register@@OACC_2.5.1 + 0 0000000000046fe0 000001d100000006 R_X86_64_GLOB_DAT 0000000000035ee0 acc_prof_lookup@@OACC_2.5.1 + 0 0000000000047058 000001dd00000007 R_X86_64_JUMP_SLOT 0000000000031f40 acc_create_async@@OACC_2.5 + 0 0000000000047068 0000011500000007 R_X86_64_JUMP_SLOT 000000000002fc60 acc_get_property@@OACC_2.6 + 0 0000000000047070 000001fb00000007 R_X86_64_JUMP_SLOT 0000000000032ce0 acc_wait_all@@OACC_2.0 + 0 0000000000047080 0000006500000007 R_X86_64_JUMP_SLOT 000000000002f990 acc_on_device@@OACC_2.0 + 0 0000000000047088 000000ae00000007 R_X86_64_JUMP_SLOT 0000000000032140 acc_attach_async@@OACC_2.6 + 0 0000000000047090 0000021900000007 R_X86_64_JUMP_SLOT 000000000002f550 acc_get_device_type@@OACC_2.0 + 0 0000000000047098 000001cb00000007 R_X86_64_JUMP_SLOT 0000000000032090 acc_copyout_finalize@@OACC_2.5 + 0 00000000000470a8 0000005200000007 R_X86_64_JUMP_SLOT 0000000000031f80 acc_copyin@@OACC_2.0 + 0 00000000000470b8 000001ad00000007 R_X86_64_JUMP_SLOT 0000000000032030 acc_delete_finalize@@OACC_2.5 + 0 00000000000470e8 0000010900000007 R_X86_64_JUMP_SLOT 0000000000031f00 acc_create@@OACC_2.0 + 0 00000000000470f8 0000005900000007 R_X86_64_JUMP_SLOT 0000000000032b70 acc_wait_async@@OACC_2.0 + 0 0000000000047110 0000013100000007 R_X86_64_JUMP_SLOT 0000000000032860 acc_async_test@@OACC_2.0 + 0 0000000000047118 000001ff00000007 R_X86_64_JUMP_SLOT 000000000002f720 acc_get_device_num@@OACC_2.0 + 0 0000000000047128 0000019100000007 R_X86_64_JUMP_SLOT 0000000000032020 acc_delete_async@@OACC_2.5 + 0 0000000000047130 000001d200000007 R_X86_64_JUMP_SLOT 000000000002efa0 acc_shutdown@@OACC_2.0 + 0 0000000000047150 000000d000000007 R_X86_64_JUMP_SLOT 0000000000031f00 acc_present_or_create@@OACC_2.0 + 0 0000000000047188 0000019200000007 R_X86_64_JUMP_SLOT 0000000000031910 acc_is_present@@OACC_2.0 + 0 0000000000047190 000001aa00000007 R_X86_64_JUMP_SLOT 000000000002fca0 acc_get_property_string@@OACC_2.6 + 0 00000000000471d0 000001bf00000007 R_X86_64_JUMP_SLOT 0000000000032120 acc_update_self_async@@OACC_2.5 + 0 0000000000047200 0000020500000007 R_X86_64_JUMP_SLOT 0000000000032e00 acc_wait_all_async@@OACC_2.0 + 0 0000000000047208 000000a600000007 R_X86_64_JUMP_SLOT 0000000000031790 acc_deviceptr@@OACC_2.0 + 0 0000000000047218 0000007500000007 R_X86_64_JUMP_SLOT 0000000000032000 acc_delete@@OACC_2.0 + 0 0000000000047238 000001e900000007 R_X86_64_JUMP_SLOT 000000000002f3a0 acc_set_device_type@@OACC_2.0 + 0 0000000000047240 000001f600000007 R_X86_64_JUMP_SLOT 000000000002ef20 acc_init@@OACC_2.0 + 0 0000000000047248 0000018800000007 R_X86_64_JUMP_SLOT 0000000000032060 acc_copyout@@OACC_2.0 + 0 0000000000047258 0000021f00000007 R_X86_64_JUMP_SLOT 0000000000032a80 acc_wait@@OACC_2.0 + 0 0000000000047270 000001bc00000007 R_X86_64_JUMP_SLOT 0000000000032100 acc_update_self@@OACC_2.0 + 0 0000000000047288 0000011400000007 R_X86_64_JUMP_SLOT 0000000000032080 acc_copyout_async@@OACC_2.5 + 0 0000000000047290 0000013d00000007 R_X86_64_JUMP_SLOT 000000000002f850 acc_set_device_num@@OACC_2.0 + 0 00000000000472a8 000000c500000007 R_X86_64_JUMP_SLOT 00000000000320e0 acc_update_device_async@@OACC_2.5 + 0 00000000000472c0 0000014600000007 R_X86_64_JUMP_SLOT 0000000000031fc0 acc_copyin_async@@OACC_2.5 + 0 00000000000472f8 0000006a00000007 R_X86_64_JUMP_SLOT 000000000002f310 acc_get_num_devices@@OACC_2.0 + 0 0000000000047350 0000021700000007 R_X86_64_JUMP_SLOT 0000000000031f80 acc_present_or_copyin@@OACC_2.0 + 0 0000000000047360 0000020900000007 R_X86_64_JUMP_SLOT 00000000000320c0 acc_update_device@@OACC_2.0 + 0 0000000000047380 0000008400000007 R_X86_64_JUMP_SLOT 0000000000032950 acc_async_test_all@@OACC_2.0 + 0 2021-10-01 Jakub Jelinek <jakub@redhat.com> * affinity-fmt.c (omp_get_team_num, omp_get_num_teams): Add ialias_redirect. * env.c (handle_omp_display_env): Use ialias_call. * icv-device.c: Move ialias right below each function. (omp_get_device_num): Use ialias_call. * fortran.c (omp_fulfill_event): Add ialias_redirect. * icv.c (omp_get_active_level): Add ialias_redirect.
2021-10-01 10:42:07 +02:00
return ialias_call (omp_get_initial_device) ();
openmp: Implement omp_get_device_num routine This patch implements the omp_get_device_num library routine, specified in OpenMP 5.0. GOMP_DEVICE_NUM_VAR is a macro symbol which defines name of a "device number" variable, is defined on the device-side libgomp, has it's address returned to host-side libgomp during device initialization, and the host libgomp then sets its value to the designated device number. libgomp/ChangeLog: * icv-device.c (omp_get_device_num): New API function, host side. * fortran.c (omp_get_device_num_): New interface function. * libgomp-plugin.h (GOMP_DEVICE_NUM_VAR): Define macro symbol. * libgomp.map (OMP_5.0.2): New version space with omp_get_device_num, omp_get_device_num_. * libgomp.texi (omp_get_device_num): Add documentation for new API function. * omp.h.in (omp_get_device_num): Add declaration. * omp_lib.f90.in (omp_get_device_num): Likewise. * omp_lib.h.in (omp_get_device_num): Likewise. * target.c (gomp_load_image_to_device): If additional entry for device number exists at end of returned entries from 'load_image_func' hook, copy the assigned device number over to the device variable. * config/gcn/icv-device.c (GOMP_DEVICE_NUM_VAR): Define static global. (omp_get_device_num): New API function, device side. * plugin/plugin-gcn.c ("symcat.h"): Add include. (GOMP_OFFLOAD_load_image): Add addresses of device GOMP_DEVICE_NUM_VAR at end of returned 'target_table' entries. * config/nvptx/icv-device.c (GOMP_DEVICE_NUM_VAR): Define static global. (omp_get_device_num): New API function, device side. * plugin/plugin-nvptx.c ("symcat.h"): Add include. (GOMP_OFFLOAD_load_image): Add addresses of device GOMP_DEVICE_NUM_VAR at end of returned 'target_table' entries. * testsuite/lib/libgomp.exp (check_effective_target_offload_target_intelmic): New function for testing for intelmic offloading. * testsuite/libgomp.c-c++-common/target-45.c: New test. * testsuite/libgomp.fortran/target10.f90: New test.
2021-08-05 17:29:03 +02:00
}
ialias (omp_get_device_num)