1 //===------------ omp_data.cu - OpenMP GPU objects --------------- CUDA -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file contains the data objects used on the GPU device. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "common/omptarget.h" 14 #include "common/device_environment.h" 15 16 //////////////////////////////////////////////////////////////////////////////// 17 // global device environment 18 //////////////////////////////////////////////////////////////////////////////// 19 20 DEVICE omptarget_device_environmentTy omptarget_device_environment; 21 22 //////////////////////////////////////////////////////////////////////////////// 23 // global data holding OpenMP state information 24 //////////////////////////////////////////////////////////////////////////////// 25 26 DEVICE 27 omptarget_nvptx_Queue<omptarget_nvptx_ThreadPrivateContext, OMP_STATE_COUNT> 28 omptarget_nvptx_device_State[MAX_SM]; 29 30 DEVICE omptarget_nvptx_SimpleMemoryManager 31 omptarget_nvptx_simpleMemoryManager; 32 DEVICE SHARED uint32_t usedMemIdx; 33 DEVICE SHARED uint32_t usedSlotIdx; 34 35 DEVICE SHARED uint8_t parallelLevel[MAX_THREADS_PER_TEAM / WARPSIZE]; 36 DEVICE SHARED uint16_t threadLimit; 37 DEVICE SHARED uint16_t threadsInTeam; 38 DEVICE SHARED uint16_t nThreads; 39 // Pointer to this team's OpenMP state object 40 DEVICE SHARED 41 omptarget_nvptx_ThreadPrivateContext *omptarget_nvptx_threadPrivateContext; 42 43 //////////////////////////////////////////////////////////////////////////////// 44 // The team master sets the outlined parallel function in this variable to 45 // communicate with the workers. Since it is in shared memory, there is one 46 // copy of these variables for each kernel, instance, and team. 47 //////////////////////////////////////////////////////////////////////////////// 48 volatile DEVICE SHARED omptarget_nvptx_WorkFn omptarget_nvptx_workFn; 49 50 //////////////////////////////////////////////////////////////////////////////// 51 // OpenMP kernel execution parameters 52 //////////////////////////////////////////////////////////////////////////////// 53 DEVICE SHARED uint32_t execution_param; 54 55 //////////////////////////////////////////////////////////////////////////////// 56 // Data sharing state 57 //////////////////////////////////////////////////////////////////////////////// 58 DEVICE SHARED DataSharingStateTy DataSharingState; 59 60 //////////////////////////////////////////////////////////////////////////////// 61 // Scratchpad for teams reduction. 62 //////////////////////////////////////////////////////////////////////////////// 63 DEVICE SHARED void *ReductionScratchpadPtr; 64 65 //////////////////////////////////////////////////////////////////////////////// 66 // Data sharing related variables. 67 //////////////////////////////////////////////////////////////////////////////// 68 DEVICE SHARED omptarget_nvptx_SharedArgs omptarget_nvptx_globalArgs; 69