Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 56d941a

Browse files
[libomptarget][nfc] Make interface.h target independent
Summary: [libomptarget][nfc] Make interface.h target independent Move interface.h under a top level include directory. Remove #includes to avoid the interface depending on the implementation. Reviewers: ABataev, jdoerfert, grokos, ronlieb, RaviNarayanaswamy Reviewed By: jdoerfert Subscribers: mgorny, openmp-commits Tags: #openmp Differential Revision: https://reviews.llvm.org/D68615 git-svn-id: https://llvm.org/svn/llvm-project/openmp/trunk@374919 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent cb6f3c4 commit 56d941a

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

libomptarget/deviceRTLs/nvptx/src/interface.h renamed to libomptarget/deviceRTLs/interface.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
//===------- interface.h - NVPTX OpenMP interface definitions ---- CUDA -*-===//
1+
//===------- interface.h - OpenMP interface definitions ---------- CUDA -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This file contains debug macros to be used in the application.
10-
//
119
// This file contains all the definitions that are relevant to
1210
// the interface. The first section contains the interface as
1311
// declared by OpenMP. The second section includes the compiler
@@ -18,8 +16,11 @@
1816
#ifndef _INTERFACES_H_
1917
#define _INTERFACES_H_
2018

21-
#include "option.h"
22-
#include "target_impl.h"
19+
#include <stdint.h>
20+
21+
#ifdef __CUDACC__
22+
#include "nvptx/src/nvptx_interface.h"
23+
#endif
2324

2425
////////////////////////////////////////////////////////////////////////////////
2526
// OpenMP interface

libomptarget/deviceRTLs/nvptx/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ if(CUDA_HOST_COMPILER MATCHES clang)
3535
set(CUDA_HOST_COMPILER "${LIBOMPTARGET_NVPTX_ALTERNATE_GCC_HOST_COMPILER}" CACHE FILEPATH "" FORCE)
3636
endif()
3737

38+
get_filename_component(devicertl_base_directory
39+
${CMAKE_CURRENT_SOURCE_DIR}
40+
DIRECTORY)
41+
3842
if(LIBOMPTARGET_DEP_CUDA_FOUND)
3943
libomptarget_say("Building CUDA offloading device RTL.")
4044

@@ -83,7 +87,7 @@ if(LIBOMPTARGET_DEP_CUDA_FOUND)
8387
# yet supported by the CUDA toolchain on the device.
8488
set(BUILD_SHARED_LIBS OFF)
8589
set(CUDA_SEPARABLE_COMPILATION ON)
86-
90+
list(APPEND CUDA_NVCC_FLAGS -I${devicertl_base_directory})
8791
cuda_add_library(omptarget-nvptx STATIC ${cuda_src_files} ${omp_data_objects}
8892
OPTIONS ${CUDA_ARCH} ${CUDA_DEBUG})
8993

@@ -117,7 +121,8 @@ if(LIBOMPTARGET_DEP_CUDA_FOUND)
117121
libomptarget_say("Building CUDA LLVM bitcode offloading device RTL.")
118122

119123
# Set flags for LLVM Bitcode compilation.
120-
set(bc_flags ${LIBOMPTARGET_NVPTX_SELECTED_CUDA_COMPILER_FLAGS})
124+
set(bc_flags ${LIBOMPTARGET_NVPTX_SELECTED_CUDA_COMPILER_FLAGS}
125+
-I${devicertl_base_directory})
121126
if(${LIBOMPTARGET_NVPTX_DEBUG})
122127
set(bc_flags ${bc_flags} -DOMPTARGET_NVPTX_DEBUG=-1)
123128
else()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===--- nvptx_interface.h - OpenMP interface definitions -------- 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+
#ifndef _NVPTX_INTERFACE_H_
10+
#define _NVPTX_INTERFACE_H_
11+
12+
#include <stdint.h>
13+
14+
#define EXTERN extern "C" __device__
15+
typedef uint32_t __kmpc_impl_lanemask_t;
16+
17+
#endif

libomptarget/deviceRTLs/nvptx/src/option.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#ifndef _OPTION_H_
1313
#define _OPTION_H_
1414

15+
#include "interface.h"
16+
1517
////////////////////////////////////////////////////////////////////////////////
1618
// Kernel options
1719
////////////////////////////////////////////////////////////////////////////////
@@ -54,7 +56,6 @@
5456
// misc options (by def everythig here is device)
5557
////////////////////////////////////////////////////////////////////////////////
5658

57-
#define EXTERN extern "C" __device__
5859
#define INLINE __forceinline__ __device__
5960
#define NOINLINE __noinline__ __device__
6061
#ifndef TRUE

libomptarget/deviceRTLs/nvptx/src/target_impl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ INLINE uint64_t __kmpc_impl_pack(uint32_t lo, uint32_t hi) {
2626
return val;
2727
}
2828

29-
typedef uint32_t __kmpc_impl_lanemask_t;
3029
static const __kmpc_impl_lanemask_t __kmpc_impl_all_lanes =
3130
UINT32_C(0xffffffff);
3231

0 commit comments

Comments
 (0)