Skip to content

Commit 174967f

Browse files
[nfc][libomptarget] Decrease coupling between files
Summary: [nfc][libomptarget] Decrease coupling between files debug.h used the symbol omptarget_device_environment so implicitly required an include of omptarget-nvptx.h to compile. Similarly interface.h uses size_t. Moving this declaration to a new header means cancel, critical can now build without omptarget-nvptx.h. After this change, debug.h, cancel.cu, critical.cu could move under a common source directory. Reviewers: ABataev, jdoerfert, grokos Subscribers: openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D69473
1 parent ad4c426 commit 174967f

File tree

7 files changed

+33
-16
lines changed

7 files changed

+33
-16
lines changed

openmp/libomptarget/deviceRTLs/interface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#ifndef _INTERFACES_H_
1717
#define _INTERFACES_H_
1818

19+
#include <stddef.h>
1920
#include <stdint.h>
2021

2122
#ifdef __CUDACC__

openmp/libomptarget/deviceRTLs/nvptx/src/cancel.cu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "omptarget-nvptx.h"
13+
#include "interface.h"
14+
#include "debug.h"
1415

1516
EXTERN int32_t __kmpc_cancellationpoint(kmp_Ident *loc, int32_t global_tid,
1617
int32_t cancelVal) {

openmp/libomptarget/deviceRTLs/nvptx/src/critical.cu

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include <stdio.h>
14-
15-
#include "omptarget-nvptx.h"
13+
#include "interface.h"
14+
#include "debug.h"
1615

1716
EXTERN
1817
void __kmpc_critical(kmp_Ident *loc, int32_t global_tid,

openmp/libomptarget/deviceRTLs/nvptx/src/debug.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#ifndef _OMPTARGET_NVPTX_DEBUG_H_
2929
#define _OMPTARGET_NVPTX_DEBUG_H_
3030

31+
#include "device_environment.h"
32+
3133
////////////////////////////////////////////////////////////////////////////////
3234
// set desired level of debugging
3335
////////////////////////////////////////////////////////////////////////////////
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===---- device_environment.h - OpenMP GPU device environment --- 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+
// Global device environment
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef _OMPTARGET_DEVICE_ENVIRONMENT_H_
14+
#define _OMPTARGET_DEVICE_ENVIRONMENT_H_
15+
16+
#include "target_impl.h"
17+
18+
struct omptarget_device_environmentTy {
19+
int32_t debug_level;
20+
};
21+
22+
extern __device__ omptarget_device_environmentTy omptarget_device_environment;
23+
24+
#endif

openmp/libomptarget/deviceRTLs/nvptx/src/omp_data.cu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "omptarget-nvptx.h"
14+
#include "device_environment.h"
1415

1516
////////////////////////////////////////////////////////////////////////////////
16-
// global device envrionment
17+
// global device environment
1718
////////////////////////////////////////////////////////////////////////////////
1819

1920
__device__ omptarget_device_environmentTy omptarget_device_environment;

openmp/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,6 @@ class omptarget_nvptx_ThreadPrivateContext {
324324
uint64_t cnt;
325325
};
326326

327-
/// Device envrionment data
328-
struct omptarget_device_environmentTy {
329-
int32_t debug_level;
330-
};
331-
332327
/// Memory manager for statically allocated memory.
333328
class omptarget_nvptx_SimpleMemoryManager {
334329
private:
@@ -345,12 +340,6 @@ class omptarget_nvptx_SimpleMemoryManager {
345340
INLINE const void *Acquire(const void *buf, size_t size);
346341
};
347342

348-
////////////////////////////////////////////////////////////////////////////////
349-
// global device envrionment
350-
////////////////////////////////////////////////////////////////////////////////
351-
352-
extern __device__ omptarget_device_environmentTy omptarget_device_environment;
353-
354343
////////////////////////////////////////////////////////////////////////////////
355344

356345
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)