Home | History | Annotate | Line # | Download | only in nvptx
target.c revision 1.1.1.8
      1  1.1.1.8  mrg /* Copyright (C) 2013-2022 Free Software Foundation, Inc.
      2  1.1.1.2  mrg    Contributed by Jakub Jelinek <jakub (at) redhat.com>.
      3  1.1.1.2  mrg 
      4  1.1.1.2  mrg    This file is part of the GNU Offloading and Multi Processing Library
      5  1.1.1.2  mrg    (libgomp).
      6  1.1.1.2  mrg 
      7  1.1.1.2  mrg    Libgomp is free software; you can redistribute it and/or modify it
      8  1.1.1.2  mrg    under the terms of the GNU General Public License as published by
      9  1.1.1.2  mrg    the Free Software Foundation; either version 3, or (at your option)
     10  1.1.1.2  mrg    any later version.
     11  1.1.1.2  mrg 
     12  1.1.1.2  mrg    Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
     13  1.1.1.2  mrg    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     14  1.1.1.2  mrg    FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
     15  1.1.1.2  mrg    more details.
     16  1.1.1.2  mrg 
     17  1.1.1.2  mrg    Under Section 7 of GPL version 3, you are granted additional
     18  1.1.1.2  mrg    permissions described in the GCC Runtime Library Exception, version
     19  1.1.1.2  mrg    3.1, as published by the Free Software Foundation.
     20  1.1.1.2  mrg 
     21  1.1.1.2  mrg    You should have received a copy of the GNU General Public License and
     22  1.1.1.2  mrg    a copy of the GCC Runtime Library Exception along with this program;
     23  1.1.1.2  mrg    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
     24  1.1.1.2  mrg    <http://www.gnu.org/licenses/>.  */
     25  1.1.1.2  mrg 
     26  1.1.1.2  mrg #include "libgomp.h"
     27  1.1.1.2  mrg #include <limits.h>
     28  1.1.1.2  mrg 
     29  1.1.1.8  mrg extern int __gomp_team_num __attribute__((shared));
     30  1.1.1.8  mrg 
     31  1.1.1.8  mrg bool
     32  1.1.1.8  mrg GOMP_teams4 (unsigned int num_teams_lower, unsigned int num_teams_upper,
     33  1.1.1.8  mrg 	     unsigned int thread_limit, bool first)
     34  1.1.1.2  mrg {
     35  1.1.1.8  mrg   unsigned int num_blocks, block_id;
     36  1.1.1.8  mrg   asm ("mov.u32 %0, %%nctaid.x;" : "=r" (num_blocks));
     37  1.1.1.8  mrg   if (!first)
     38  1.1.1.8  mrg     {
     39  1.1.1.8  mrg       unsigned int team_num;
     40  1.1.1.8  mrg       if (num_blocks > gomp_num_teams_var)
     41  1.1.1.8  mrg 	return false;
     42  1.1.1.8  mrg       team_num = __gomp_team_num;
     43  1.1.1.8  mrg       if (team_num > gomp_num_teams_var - num_blocks)
     44  1.1.1.8  mrg 	return false;
     45  1.1.1.8  mrg       __gomp_team_num = team_num + num_blocks;
     46  1.1.1.8  mrg       return true;
     47  1.1.1.8  mrg     }
     48  1.1.1.2  mrg   if (thread_limit)
     49  1.1.1.2  mrg     {
     50  1.1.1.2  mrg       struct gomp_task_icv *icv = gomp_icv (true);
     51  1.1.1.2  mrg       icv->thread_limit_var
     52  1.1.1.2  mrg 	= thread_limit > INT_MAX ? UINT_MAX : thread_limit;
     53  1.1.1.2  mrg     }
     54  1.1.1.8  mrg   if (!num_teams_upper)
     55  1.1.1.8  mrg     num_teams_upper = num_blocks;
     56  1.1.1.8  mrg   else if (num_blocks < num_teams_lower)
     57  1.1.1.8  mrg     num_teams_upper = num_teams_lower;
     58  1.1.1.8  mrg   else if (num_blocks < num_teams_upper)
     59  1.1.1.8  mrg     num_teams_upper = num_blocks;
     60  1.1.1.2  mrg   asm ("mov.u32 %0, %%ctaid.x;" : "=r" (block_id));
     61  1.1.1.8  mrg   if (block_id >= num_teams_upper)
     62  1.1.1.8  mrg     return false;
     63  1.1.1.8  mrg   __gomp_team_num = block_id;
     64  1.1.1.8  mrg   gomp_num_teams_var = num_teams_upper - 1;
     65  1.1.1.8  mrg   return true;
     66  1.1.1.2  mrg }
     67  1.1.1.6  mrg 
     68  1.1.1.6  mrg int
     69  1.1.1.6  mrg omp_pause_resource (omp_pause_resource_t kind, int device_num)
     70  1.1.1.6  mrg {
     71  1.1.1.6  mrg   (void) kind;
     72  1.1.1.6  mrg   (void) device_num;
     73  1.1.1.6  mrg   return -1;
     74  1.1.1.6  mrg }
     75  1.1.1.6  mrg 
     76  1.1.1.6  mrg int
     77  1.1.1.6  mrg omp_pause_resource_all (omp_pause_resource_t kind)
     78  1.1.1.6  mrg {
     79  1.1.1.6  mrg   (void) kind;
     80  1.1.1.6  mrg   return -1;
     81  1.1.1.6  mrg }
     82  1.1.1.6  mrg 
     83  1.1.1.6  mrg ialias (omp_pause_resource)
     84  1.1.1.6  mrg ialias (omp_pause_resource_all)
     85  1.1.1.8  mrg 
     86  1.1.1.8  mrg void
     87  1.1.1.8  mrg GOMP_target_ext (int device, void (*fn) (void *), size_t mapnum,
     88  1.1.1.8  mrg 		 void **hostaddrs, size_t *sizes, unsigned short *kinds,
     89  1.1.1.8  mrg 		 unsigned int flags, void **depend, void **args)
     90  1.1.1.8  mrg {
     91  1.1.1.8  mrg   (void) device;
     92  1.1.1.8  mrg   (void) fn;
     93  1.1.1.8  mrg   (void) mapnum;
     94  1.1.1.8  mrg   (void) hostaddrs;
     95  1.1.1.8  mrg   (void) sizes;
     96  1.1.1.8  mrg   (void) kinds;
     97  1.1.1.8  mrg   (void) flags;
     98  1.1.1.8  mrg   (void) depend;
     99  1.1.1.8  mrg   (void) args;
    100  1.1.1.8  mrg   __builtin_unreachable ();
    101  1.1.1.8  mrg }
    102  1.1.1.8  mrg 
    103  1.1.1.8  mrg void
    104  1.1.1.8  mrg GOMP_target_data_ext (int device, size_t mapnum, void **hostaddrs,
    105  1.1.1.8  mrg 		      size_t *sizes, unsigned short *kinds)
    106  1.1.1.8  mrg {
    107  1.1.1.8  mrg   (void) device;
    108  1.1.1.8  mrg   (void) mapnum;
    109  1.1.1.8  mrg   (void) hostaddrs;
    110  1.1.1.8  mrg   (void) sizes;
    111  1.1.1.8  mrg   (void) kinds;
    112  1.1.1.8  mrg   __builtin_unreachable ();
    113  1.1.1.8  mrg }
    114  1.1.1.8  mrg 
    115  1.1.1.8  mrg void
    116  1.1.1.8  mrg GOMP_target_end_data (void)
    117  1.1.1.8  mrg {
    118  1.1.1.8  mrg   __builtin_unreachable ();
    119  1.1.1.8  mrg }
    120  1.1.1.8  mrg 
    121  1.1.1.8  mrg void
    122  1.1.1.8  mrg GOMP_target_update_ext (int device, size_t mapnum, void **hostaddrs,
    123  1.1.1.8  mrg 			size_t *sizes, unsigned short *kinds,
    124  1.1.1.8  mrg 			unsigned int flags, void **depend)
    125  1.1.1.8  mrg {
    126  1.1.1.8  mrg   (void) device;
    127  1.1.1.8  mrg   (void) mapnum;
    128  1.1.1.8  mrg   (void) hostaddrs;
    129  1.1.1.8  mrg   (void) sizes;
    130  1.1.1.8  mrg   (void) kinds;
    131  1.1.1.8  mrg   (void) flags;
    132  1.1.1.8  mrg   (void) depend;
    133  1.1.1.8  mrg   __builtin_unreachable ();
    134  1.1.1.8  mrg }
    135  1.1.1.8  mrg 
    136  1.1.1.8  mrg void
    137  1.1.1.8  mrg GOMP_target_enter_exit_data (int device, size_t mapnum, void **hostaddrs,
    138  1.1.1.8  mrg 			     size_t *sizes, unsigned short *kinds,
    139  1.1.1.8  mrg 			     unsigned int flags, void **depend)
    140  1.1.1.8  mrg {
    141  1.1.1.8  mrg   (void) device;
    142  1.1.1.8  mrg   (void) mapnum;
    143  1.1.1.8  mrg   (void) hostaddrs;
    144  1.1.1.8  mrg   (void) sizes;
    145  1.1.1.8  mrg   (void) kinds;
    146  1.1.1.8  mrg   (void) flags;
    147  1.1.1.8  mrg   (void) depend;
    148  1.1.1.8  mrg   __builtin_unreachable ();
    149  1.1.1.8  mrg }
    150