From: Andrew Stubbs Date: Wed, 13 Nov 2019 12:37:50 +0000 (+0000) Subject: Move generic libgomp files from nvptx to accel X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b3d14b3aa343eb7fc656e7f4d3c9b2dc04be63be;p=gcc.git Move generic libgomp files from nvptx to accel 2019-11-13 Andrew Stubbs libgomp/ * configure.tgt (nvptx*-*-*): Add "accel" directory. * config/nvptx/libgomp-plugin.c: Move ... * config/accel/libgomp-plugin.c: ... to here. * config/nvptx/lock.c: Move ... * config/accel/lock.c: ... to here. * config/nvptx/mutex.c: Move ... * config/accel/mutex.c: ... to here. * config/nvptx/mutex.h: Move ... * config/accel/mutex.h: ... to here. * config/nvptx/oacc-async.c: Move ... * config/accel/oacc-async.c: ... to here. * config/nvptx/oacc-cuda.c: Move ... * config/accel/oacc-cuda.c: ... to here. * config/nvptx/oacc-host.c: Move ... * config/accel/oacc-host.c: ... to here. * config/nvptx/oacc-init.c: Move ... * config/accel/oacc-init.c: ... to here. * config/nvptx/oacc-mem.c: Move ... * config/accel/oacc-mem.c: ... to here. * config/nvptx/oacc-plugin.c: Move ... * config/accel/oacc-plugin.c: ... to here. * config/nvptx/omp-lock.h: Move ... * config/accel/omp-lock.h: ... to here. * config/nvptx/openacc.f90: Move ... * config/accel/openacc.f90: ... to here. * config/nvptx/pool.h: Move ... * config/accel/pool.h: ... to here. * config/nvptx/proc.c: Move ... * config/accel/proc.c: ... to here. * config/nvptx/ptrlock.c: Move ... * config/accel/ptrlock.c: ... to here. * config/nvptx/ptrlock.h: Move ... * config/accel/ptrlock.h: ... to here. * config/nvptx/sem.c: Move ... * config/accel/sem.c: ... to here. * config/nvptx/sem.h: Move ... * config/accel/sem.h: ... to here. * config/nvptx/thread-stacksize.h: Move ... * config/accel/thread-stacksize.h: ... to here. From-SVN: r278132 --- diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 734395936f0..ad9fdeaeac2 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,45 @@ +2019-11-13 Andrew Stubbs + + * configure.tgt (nvptx*-*-*): Add "accel" directory. + * config/nvptx/libgomp-plugin.c: Move ... + * config/accel/libgomp-plugin.c: ... to here. + * config/nvptx/lock.c: Move ... + * config/accel/lock.c: ... to here. + * config/nvptx/mutex.c: Move ... + * config/accel/mutex.c: ... to here. + * config/nvptx/mutex.h: Move ... + * config/accel/mutex.h: ... to here. + * config/nvptx/oacc-async.c: Move ... + * config/accel/oacc-async.c: ... to here. + * config/nvptx/oacc-cuda.c: Move ... + * config/accel/oacc-cuda.c: ... to here. + * config/nvptx/oacc-host.c: Move ... + * config/accel/oacc-host.c: ... to here. + * config/nvptx/oacc-init.c: Move ... + * config/accel/oacc-init.c: ... to here. + * config/nvptx/oacc-mem.c: Move ... + * config/accel/oacc-mem.c: ... to here. + * config/nvptx/oacc-plugin.c: Move ... + * config/accel/oacc-plugin.c: ... to here. + * config/nvptx/omp-lock.h: Move ... + * config/accel/omp-lock.h: ... to here. + * config/nvptx/openacc.f90: Move ... + * config/accel/openacc.f90: ... to here. + * config/nvptx/pool.h: Move ... + * config/accel/pool.h: ... to here. + * config/nvptx/proc.c: Move ... + * config/accel/proc.c: ... to here. + * config/nvptx/ptrlock.c: Move ... + * config/accel/ptrlock.c: ... to here. + * config/nvptx/ptrlock.h: Move ... + * config/accel/ptrlock.h: ... to here. + * config/nvptx/sem.c: Move ... + * config/accel/sem.c: ... to here. + * config/nvptx/sem.h: Move ... + * config/accel/sem.h: ... to here. + * config/nvptx/thread-stacksize.h: Move ... + * config/accel/thread-stacksize.h: ... to here. + 2019-11-12 Maciej W. Rozycki Tobias Burnus Frederik Harwath diff --git a/libgomp/config/accel/libgomp-plugin.c b/libgomp/config/accel/libgomp-plugin.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/libgomp/config/accel/lock.c b/libgomp/config/accel/lock.c new file mode 100644 index 00000000000..6ee6957b0d5 --- /dev/null +++ b/libgomp/config/accel/lock.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2016-2019 Free Software Foundation, Inc. + Contributed by Alexander Monakov . + + 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 + . */ + +/* This is a NVPTX specific implementation of the public OpenMP locking + primitives. */ + +/* Reuse the generic implementation in terms of gomp_mutex_t. */ +#include "../../lock.c" + +ialias (omp_init_lock) +ialias (omp_init_nest_lock) +ialias (omp_destroy_lock) +ialias (omp_destroy_nest_lock) +ialias (omp_set_lock) +ialias (omp_set_nest_lock) +ialias (omp_unset_lock) +ialias (omp_unset_nest_lock) +ialias (omp_test_lock) +ialias (omp_test_nest_lock) diff --git a/libgomp/config/accel/mutex.c b/libgomp/config/accel/mutex.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/libgomp/config/accel/mutex.h b/libgomp/config/accel/mutex.h new file mode 100644 index 00000000000..3feae56b464 --- /dev/null +++ b/libgomp/config/accel/mutex.h @@ -0,0 +1,60 @@ +/* Copyright (C) 2015-2019 Free Software Foundation, Inc. + Contributed by Alexander Monakov + + 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 + . */ + +/* This is an NVPTX specific implementation of a mutex synchronization + mechanism for libgomp. This type is private to the library. This + implementation uses atomic instructions and busy waiting. */ + +#ifndef GOMP_MUTEX_H +#define GOMP_MUTEX_H 1 + +typedef int gomp_mutex_t; + +#define GOMP_MUTEX_INIT_0 1 + +static inline void +gomp_mutex_init (gomp_mutex_t *mutex) +{ + *mutex = 0; +} + +static inline void +gomp_mutex_destroy (gomp_mutex_t *mutex) +{ +} + +static inline void +gomp_mutex_lock (gomp_mutex_t *mutex) +{ + while (__sync_lock_test_and_set (mutex, 1)) + /* spin */ ; +} + +static inline void +gomp_mutex_unlock (gomp_mutex_t *mutex) +{ + __sync_lock_release (mutex); +} +#endif /* GOMP_MUTEX_H */ diff --git a/libgomp/config/accel/oacc-async.c b/libgomp/config/accel/oacc-async.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/libgomp/config/accel/oacc-cuda.c b/libgomp/config/accel/oacc-cuda.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/libgomp/config/accel/oacc-host.c b/libgomp/config/accel/oacc-host.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/libgomp/config/accel/oacc-init.c b/libgomp/config/accel/oacc-init.c new file mode 100644 index 00000000000..c7dc64eb0a8 --- /dev/null +++ b/libgomp/config/accel/oacc-init.c @@ -0,0 +1,42 @@ +/* OpenACC Runtime initialization routines + + Copyright (C) 2014-2019 Free Software Foundation, Inc. + + Contributed by Mentor Embedded. + + 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 + . */ + +#include "openacc.h" + +/* For -O and higher, the compiler always attempts to expand acc_on_device, but + if the user disables the builtin, or calls it via a pointer, we'll need this + version. + + Compile this with optimization, so that the compiler expands + this, rather than generating infinitely recursive code. */ + +int __attribute__ ((__optimize__ ("O2"))) +acc_on_device (acc_device_t dev) +{ + return __builtin_acc_on_device (dev); +} diff --git a/libgomp/config/accel/oacc-mem.c b/libgomp/config/accel/oacc-mem.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/libgomp/config/accel/oacc-plugin.c b/libgomp/config/accel/oacc-plugin.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/libgomp/config/accel/omp-lock.h b/libgomp/config/accel/omp-lock.h new file mode 100644 index 00000000000..2ca7c5e1d60 --- /dev/null +++ b/libgomp/config/accel/omp-lock.h @@ -0,0 +1,12 @@ +/* This header is used during the build process to find the size and + alignment of the public OpenMP locks, so that we can export data + structures without polluting the namespace. + + When using the Linux futex primitive, non-recursive locks require + one int. Recursive locks require we identify the owning task + and so require in addition one int and a pointer. */ + +typedef int omp_lock_t; +typedef struct { int lock, count; void *owner; } omp_nest_lock_t; +typedef int omp_lock_25_t; +typedef struct { int owner, count; } omp_nest_lock_25_t; diff --git a/libgomp/config/accel/openacc.f90 b/libgomp/config/accel/openacc.f90 new file mode 100644 index 00000000000..a7f690e1572 --- /dev/null +++ b/libgomp/config/accel/openacc.f90 @@ -0,0 +1,102 @@ +! OpenACC Runtime Library Definitions. + +! Copyright (C) 2014-2019 Free Software Foundation, Inc. + +! Contributed by Tobias Burnus +! and Mentor Embedded. + +! 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 +! . + +! Wrapper functions will be built from openacc.f90. We use a separate file +! here, because for using ../../openacc.f90, implementations are required for +! all the functions that it wraps, which we currently don't provide, so linking +! would fail. + +module openacc_kinds + use iso_fortran_env, only: int32 + implicit none + + private :: int32 + public :: acc_device_kind + + integer, parameter :: acc_device_kind = int32 + + public :: acc_device_none, acc_device_default, acc_device_host + public :: acc_device_not_host, acc_device_nvidia + + ! Keep in sync with include/gomp-constants.h. + integer (acc_device_kind), parameter :: acc_device_none = 0 + integer (acc_device_kind), parameter :: acc_device_default = 1 + integer (acc_device_kind), parameter :: acc_device_host = 2 + ! integer (acc_device_kind), parameter :: acc_device_host_nonshm = 3 removed. + integer (acc_device_kind), parameter :: acc_device_not_host = 4 + integer (acc_device_kind), parameter :: acc_device_nvidia = 5 + +end module + +module openacc_internal + use openacc_kinds + implicit none + + interface + function acc_on_device_h (d) + import + integer (acc_device_kind) d + logical acc_on_device_h + end function + end interface + + interface + function acc_on_device_l (d) & + bind (C, name = "acc_on_device") + use iso_c_binding, only: c_int + integer (c_int) :: acc_on_device_l + integer (c_int), value :: d + end function + end interface +end module + +module openacc + use openacc_kinds + use openacc_internal + implicit none + + public :: acc_on_device + + interface acc_on_device + procedure :: acc_on_device_h + end interface + +end module openacc + +function acc_on_device_h (d) + use openacc_internal, only: acc_on_device_l + use openacc_kinds + integer (acc_device_kind) d + logical acc_on_device_h + if (acc_on_device_l (d) .eq. 1) then + acc_on_device_h = .TRUE. + else + acc_on_device_h = .FALSE. + end if +end function diff --git a/libgomp/config/accel/pool.h b/libgomp/config/accel/pool.h new file mode 100644 index 00000000000..20c2e62f7c8 --- /dev/null +++ b/libgomp/config/accel/pool.h @@ -0,0 +1,49 @@ +/* Copyright (C) 2015-2019 Free Software Foundation, Inc. + Contributed by Alexander Monakov + + 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 + . */ + +/* This is the NVPTX implementation of the thread pool management + for libgomp. This type is private to the library. */ + +#ifndef GOMP_POOL_H +#define GOMP_POOL_H 1 + +#include "libgomp.h" + +/* Get the thread pool. */ + +static inline struct gomp_thread_pool * +gomp_get_thread_pool (struct gomp_thread *thr, unsigned nthreads) +{ + /* NVPTX is running with a fixed pool of pre-started threads. */ + return thr->thread_pool; +} + +static inline void +gomp_release_thread_pool (struct gomp_thread_pool *pool) +{ + /* Do nothing. */ +} + +#endif /* GOMP_POOL_H */ diff --git a/libgomp/config/accel/proc.c b/libgomp/config/accel/proc.c new file mode 100644 index 00000000000..8ca0b0a1ee1 --- /dev/null +++ b/libgomp/config/accel/proc.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2015-2019 Free Software Foundation, Inc. + Contributed by Alexander Monakov + + 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 + . */ + +/* This file contains system specific routines related to counting + online processors and dynamic load balancing. */ + +#include "libgomp.h" + +unsigned +gomp_dynamic_max_threads (void) +{ + return gomp_icv (false)->nthreads_var; +} + +int +omp_get_num_procs (void) +{ + return gomp_icv (false)->nthreads_var; +} diff --git a/libgomp/config/accel/ptrlock.c b/libgomp/config/accel/ptrlock.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/libgomp/config/accel/ptrlock.h b/libgomp/config/accel/ptrlock.h new file mode 100644 index 00000000000..69ff2e26359 --- /dev/null +++ b/libgomp/config/accel/ptrlock.h @@ -0,0 +1,73 @@ +/* Copyright (C) 2015-2019 Free Software Foundation, Inc. + Contributed by Alexander Monakov + + 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 + . */ + +/* This is an NVPTX specific implementation of a mutex synchronization + mechanism for libgomp. This type is private to the library. This + implementation uses atomic instructions and busy waiting. + + A ptrlock has four states: + 0/NULL Initial + 1 Owned by me, I get to write a pointer to ptrlock. + 2 Some thread is waiting on the ptrlock. + >2 Ptrlock contains a valid pointer. + It is not valid to gain the ptrlock and then write a NULL to it. */ + +#ifndef GOMP_PTRLOCK_H +#define GOMP_PTRLOCK_H 1 + +typedef void *gomp_ptrlock_t; + +static inline void gomp_ptrlock_init (gomp_ptrlock_t *ptrlock, void *ptr) +{ + *ptrlock = ptr; +} + +static inline void *gomp_ptrlock_get (gomp_ptrlock_t *ptrlock) +{ + uintptr_t v = (uintptr_t) __atomic_load_n (ptrlock, MEMMODEL_ACQUIRE); + if (v > 2) + return (void *) v; + + if (v == 0 + && __atomic_compare_exchange_n (ptrlock, &v, 1, false, + MEMMODEL_ACQUIRE, MEMMODEL_ACQUIRE)) + return NULL; + + while (v == 1) + v = (uintptr_t) __atomic_load_n (ptrlock, MEMMODEL_ACQUIRE); + + return (void *) v; +} + +static inline void gomp_ptrlock_set (gomp_ptrlock_t *ptrlock, void *ptr) +{ + __atomic_store_n (ptrlock, ptr, MEMMODEL_RELEASE); +} + +static inline void gomp_ptrlock_destroy (gomp_ptrlock_t *ptrlock) +{ +} + +#endif /* GOMP_PTRLOCK_H */ diff --git a/libgomp/config/accel/sem.c b/libgomp/config/accel/sem.c new file mode 100644 index 00000000000..e69de29bb2d diff --git a/libgomp/config/accel/sem.h b/libgomp/config/accel/sem.h new file mode 100644 index 00000000000..574945ca998 --- /dev/null +++ b/libgomp/config/accel/sem.h @@ -0,0 +1,65 @@ +/* Copyright (C) 2015-2019 Free Software Foundation, Inc. + Contributed by Alexander Monakov + + 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 + . */ + +/* This is an NVPTX specific implementation of a semaphore synchronization + mechanism for libgomp. This type is private to the library. This + semaphore implementation uses atomic instructions and busy waiting. */ + +#ifndef GOMP_SEM_H +#define GOMP_SEM_H 1 + +typedef int gomp_sem_t; + +static inline void +gomp_sem_init (gomp_sem_t *sem, int value) +{ + *sem = value; +} + +static inline void +gomp_sem_destroy (gomp_sem_t *sem) +{ +} + +static inline void +gomp_sem_wait (gomp_sem_t *sem) +{ + int count = __atomic_load_n (sem, MEMMODEL_ACQUIRE); + for (;;) + { + while (count == 0) + count = __atomic_load_n (sem, MEMMODEL_ACQUIRE); + if (__atomic_compare_exchange_n (sem, &count, count - 1, false, + MEMMODEL_ACQUIRE, MEMMODEL_RELAXED)) + return; + } +} + +static inline void +gomp_sem_post (gomp_sem_t *sem) +{ + (void) __atomic_add_fetch (sem, 1, MEMMODEL_RELEASE); +} +#endif /* GOMP_SEM_H */ diff --git a/libgomp/config/accel/thread-stacksize.h b/libgomp/config/accel/thread-stacksize.h new file mode 100644 index 00000000000..de89519eb27 --- /dev/null +++ b/libgomp/config/accel/thread-stacksize.h @@ -0,0 +1,27 @@ +/* Copyright (C) 2017-2019 Free Software Foundation, Inc. + Contributed by Jakub Jelinek + + 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 + . */ + +/* Not really applicable to NVPTX. */ +#define GOMP_DEFAULT_STACKSIZE 0 diff --git a/libgomp/config/nvptx/libgomp-plugin.c b/libgomp/config/nvptx/libgomp-plugin.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/libgomp/config/nvptx/lock.c b/libgomp/config/nvptx/lock.c deleted file mode 100644 index 6ee6957b0d5..00000000000 --- a/libgomp/config/nvptx/lock.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2016-2019 Free Software Foundation, Inc. - Contributed by Alexander Monakov . - - 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 - . */ - -/* This is a NVPTX specific implementation of the public OpenMP locking - primitives. */ - -/* Reuse the generic implementation in terms of gomp_mutex_t. */ -#include "../../lock.c" - -ialias (omp_init_lock) -ialias (omp_init_nest_lock) -ialias (omp_destroy_lock) -ialias (omp_destroy_nest_lock) -ialias (omp_set_lock) -ialias (omp_set_nest_lock) -ialias (omp_unset_lock) -ialias (omp_unset_nest_lock) -ialias (omp_test_lock) -ialias (omp_test_nest_lock) diff --git a/libgomp/config/nvptx/mutex.c b/libgomp/config/nvptx/mutex.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/libgomp/config/nvptx/mutex.h b/libgomp/config/nvptx/mutex.h deleted file mode 100644 index 3feae56b464..00000000000 --- a/libgomp/config/nvptx/mutex.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (C) 2015-2019 Free Software Foundation, Inc. - Contributed by Alexander Monakov - - 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 - . */ - -/* This is an NVPTX specific implementation of a mutex synchronization - mechanism for libgomp. This type is private to the library. This - implementation uses atomic instructions and busy waiting. */ - -#ifndef GOMP_MUTEX_H -#define GOMP_MUTEX_H 1 - -typedef int gomp_mutex_t; - -#define GOMP_MUTEX_INIT_0 1 - -static inline void -gomp_mutex_init (gomp_mutex_t *mutex) -{ - *mutex = 0; -} - -static inline void -gomp_mutex_destroy (gomp_mutex_t *mutex) -{ -} - -static inline void -gomp_mutex_lock (gomp_mutex_t *mutex) -{ - while (__sync_lock_test_and_set (mutex, 1)) - /* spin */ ; -} - -static inline void -gomp_mutex_unlock (gomp_mutex_t *mutex) -{ - __sync_lock_release (mutex); -} -#endif /* GOMP_MUTEX_H */ diff --git a/libgomp/config/nvptx/oacc-async.c b/libgomp/config/nvptx/oacc-async.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/libgomp/config/nvptx/oacc-cuda.c b/libgomp/config/nvptx/oacc-cuda.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/libgomp/config/nvptx/oacc-host.c b/libgomp/config/nvptx/oacc-host.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/libgomp/config/nvptx/oacc-init.c b/libgomp/config/nvptx/oacc-init.c deleted file mode 100644 index c7dc64eb0a8..00000000000 --- a/libgomp/config/nvptx/oacc-init.c +++ /dev/null @@ -1,42 +0,0 @@ -/* OpenACC Runtime initialization routines - - Copyright (C) 2014-2019 Free Software Foundation, Inc. - - Contributed by Mentor Embedded. - - 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 - . */ - -#include "openacc.h" - -/* For -O and higher, the compiler always attempts to expand acc_on_device, but - if the user disables the builtin, or calls it via a pointer, we'll need this - version. - - Compile this with optimization, so that the compiler expands - this, rather than generating infinitely recursive code. */ - -int __attribute__ ((__optimize__ ("O2"))) -acc_on_device (acc_device_t dev) -{ - return __builtin_acc_on_device (dev); -} diff --git a/libgomp/config/nvptx/oacc-mem.c b/libgomp/config/nvptx/oacc-mem.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/libgomp/config/nvptx/oacc-plugin.c b/libgomp/config/nvptx/oacc-plugin.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/libgomp/config/nvptx/omp-lock.h b/libgomp/config/nvptx/omp-lock.h deleted file mode 100644 index 2ca7c5e1d60..00000000000 --- a/libgomp/config/nvptx/omp-lock.h +++ /dev/null @@ -1,12 +0,0 @@ -/* This header is used during the build process to find the size and - alignment of the public OpenMP locks, so that we can export data - structures without polluting the namespace. - - When using the Linux futex primitive, non-recursive locks require - one int. Recursive locks require we identify the owning task - and so require in addition one int and a pointer. */ - -typedef int omp_lock_t; -typedef struct { int lock, count; void *owner; } omp_nest_lock_t; -typedef int omp_lock_25_t; -typedef struct { int owner, count; } omp_nest_lock_25_t; diff --git a/libgomp/config/nvptx/openacc.f90 b/libgomp/config/nvptx/openacc.f90 deleted file mode 100644 index a7f690e1572..00000000000 --- a/libgomp/config/nvptx/openacc.f90 +++ /dev/null @@ -1,102 +0,0 @@ -! OpenACC Runtime Library Definitions. - -! Copyright (C) 2014-2019 Free Software Foundation, Inc. - -! Contributed by Tobias Burnus -! and Mentor Embedded. - -! 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 -! . - -! Wrapper functions will be built from openacc.f90. We use a separate file -! here, because for using ../../openacc.f90, implementations are required for -! all the functions that it wraps, which we currently don't provide, so linking -! would fail. - -module openacc_kinds - use iso_fortran_env, only: int32 - implicit none - - private :: int32 - public :: acc_device_kind - - integer, parameter :: acc_device_kind = int32 - - public :: acc_device_none, acc_device_default, acc_device_host - public :: acc_device_not_host, acc_device_nvidia - - ! Keep in sync with include/gomp-constants.h. - integer (acc_device_kind), parameter :: acc_device_none = 0 - integer (acc_device_kind), parameter :: acc_device_default = 1 - integer (acc_device_kind), parameter :: acc_device_host = 2 - ! integer (acc_device_kind), parameter :: acc_device_host_nonshm = 3 removed. - integer (acc_device_kind), parameter :: acc_device_not_host = 4 - integer (acc_device_kind), parameter :: acc_device_nvidia = 5 - -end module - -module openacc_internal - use openacc_kinds - implicit none - - interface - function acc_on_device_h (d) - import - integer (acc_device_kind) d - logical acc_on_device_h - end function - end interface - - interface - function acc_on_device_l (d) & - bind (C, name = "acc_on_device") - use iso_c_binding, only: c_int - integer (c_int) :: acc_on_device_l - integer (c_int), value :: d - end function - end interface -end module - -module openacc - use openacc_kinds - use openacc_internal - implicit none - - public :: acc_on_device - - interface acc_on_device - procedure :: acc_on_device_h - end interface - -end module openacc - -function acc_on_device_h (d) - use openacc_internal, only: acc_on_device_l - use openacc_kinds - integer (acc_device_kind) d - logical acc_on_device_h - if (acc_on_device_l (d) .eq. 1) then - acc_on_device_h = .TRUE. - else - acc_on_device_h = .FALSE. - end if -end function diff --git a/libgomp/config/nvptx/pool.h b/libgomp/config/nvptx/pool.h deleted file mode 100644 index 20c2e62f7c8..00000000000 --- a/libgomp/config/nvptx/pool.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2015-2019 Free Software Foundation, Inc. - Contributed by Alexander Monakov - - 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 - . */ - -/* This is the NVPTX implementation of the thread pool management - for libgomp. This type is private to the library. */ - -#ifndef GOMP_POOL_H -#define GOMP_POOL_H 1 - -#include "libgomp.h" - -/* Get the thread pool. */ - -static inline struct gomp_thread_pool * -gomp_get_thread_pool (struct gomp_thread *thr, unsigned nthreads) -{ - /* NVPTX is running with a fixed pool of pre-started threads. */ - return thr->thread_pool; -} - -static inline void -gomp_release_thread_pool (struct gomp_thread_pool *pool) -{ - /* Do nothing. */ -} - -#endif /* GOMP_POOL_H */ diff --git a/libgomp/config/nvptx/proc.c b/libgomp/config/nvptx/proc.c deleted file mode 100644 index 8ca0b0a1ee1..00000000000 --- a/libgomp/config/nvptx/proc.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2015-2019 Free Software Foundation, Inc. - Contributed by Alexander Monakov - - 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 - . */ - -/* This file contains system specific routines related to counting - online processors and dynamic load balancing. */ - -#include "libgomp.h" - -unsigned -gomp_dynamic_max_threads (void) -{ - return gomp_icv (false)->nthreads_var; -} - -int -omp_get_num_procs (void) -{ - return gomp_icv (false)->nthreads_var; -} diff --git a/libgomp/config/nvptx/ptrlock.c b/libgomp/config/nvptx/ptrlock.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/libgomp/config/nvptx/ptrlock.h b/libgomp/config/nvptx/ptrlock.h deleted file mode 100644 index 69ff2e26359..00000000000 --- a/libgomp/config/nvptx/ptrlock.h +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright (C) 2015-2019 Free Software Foundation, Inc. - Contributed by Alexander Monakov - - 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 - . */ - -/* This is an NVPTX specific implementation of a mutex synchronization - mechanism for libgomp. This type is private to the library. This - implementation uses atomic instructions and busy waiting. - - A ptrlock has four states: - 0/NULL Initial - 1 Owned by me, I get to write a pointer to ptrlock. - 2 Some thread is waiting on the ptrlock. - >2 Ptrlock contains a valid pointer. - It is not valid to gain the ptrlock and then write a NULL to it. */ - -#ifndef GOMP_PTRLOCK_H -#define GOMP_PTRLOCK_H 1 - -typedef void *gomp_ptrlock_t; - -static inline void gomp_ptrlock_init (gomp_ptrlock_t *ptrlock, void *ptr) -{ - *ptrlock = ptr; -} - -static inline void *gomp_ptrlock_get (gomp_ptrlock_t *ptrlock) -{ - uintptr_t v = (uintptr_t) __atomic_load_n (ptrlock, MEMMODEL_ACQUIRE); - if (v > 2) - return (void *) v; - - if (v == 0 - && __atomic_compare_exchange_n (ptrlock, &v, 1, false, - MEMMODEL_ACQUIRE, MEMMODEL_ACQUIRE)) - return NULL; - - while (v == 1) - v = (uintptr_t) __atomic_load_n (ptrlock, MEMMODEL_ACQUIRE); - - return (void *) v; -} - -static inline void gomp_ptrlock_set (gomp_ptrlock_t *ptrlock, void *ptr) -{ - __atomic_store_n (ptrlock, ptr, MEMMODEL_RELEASE); -} - -static inline void gomp_ptrlock_destroy (gomp_ptrlock_t *ptrlock) -{ -} - -#endif /* GOMP_PTRLOCK_H */ diff --git a/libgomp/config/nvptx/sem.c b/libgomp/config/nvptx/sem.c deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/libgomp/config/nvptx/sem.h b/libgomp/config/nvptx/sem.h deleted file mode 100644 index 574945ca998..00000000000 --- a/libgomp/config/nvptx/sem.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (C) 2015-2019 Free Software Foundation, Inc. - Contributed by Alexander Monakov - - 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 - . */ - -/* This is an NVPTX specific implementation of a semaphore synchronization - mechanism for libgomp. This type is private to the library. This - semaphore implementation uses atomic instructions and busy waiting. */ - -#ifndef GOMP_SEM_H -#define GOMP_SEM_H 1 - -typedef int gomp_sem_t; - -static inline void -gomp_sem_init (gomp_sem_t *sem, int value) -{ - *sem = value; -} - -static inline void -gomp_sem_destroy (gomp_sem_t *sem) -{ -} - -static inline void -gomp_sem_wait (gomp_sem_t *sem) -{ - int count = __atomic_load_n (sem, MEMMODEL_ACQUIRE); - for (;;) - { - while (count == 0) - count = __atomic_load_n (sem, MEMMODEL_ACQUIRE); - if (__atomic_compare_exchange_n (sem, &count, count - 1, false, - MEMMODEL_ACQUIRE, MEMMODEL_RELAXED)) - return; - } -} - -static inline void -gomp_sem_post (gomp_sem_t *sem) -{ - (void) __atomic_add_fetch (sem, 1, MEMMODEL_RELEASE); -} -#endif /* GOMP_SEM_H */ diff --git a/libgomp/config/nvptx/thread-stacksize.h b/libgomp/config/nvptx/thread-stacksize.h deleted file mode 100644 index de89519eb27..00000000000 --- a/libgomp/config/nvptx/thread-stacksize.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 2017-2019 Free Software Foundation, Inc. - Contributed by Jakub Jelinek - - 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 - . */ - -/* Not really applicable to NVPTX. */ -#define GOMP_DEFAULT_STACKSIZE 0 diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt index b88bf72fe3d..c5ae9a9e39a 100644 --- a/libgomp/configure.tgt +++ b/libgomp/configure.tgt @@ -154,7 +154,7 @@ case "${target}" in ;; nvptx*-*-*) - config_path="nvptx" + config_path="nvptx accel" ;; *-*-rtems*)