Skip to content

Commit d0f3c7e

Browse files
mhalkronlieb
authored andcommitted
[OpenMP][DeviceRTL][NFC] Move diff into DevRTLExtras.h
While keeping the structure of the upstream Types.h, we move the additional declarations into their own ASO-exclusive header. Change-Id: If9530e987cf0bd44efa35754e2c43e758eb9f5ab
1 parent d683a85 commit d0f3c7e

File tree

2 files changed

+93
-61
lines changed

2 files changed

+93
-61
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
//===---------- DevRTLExtras.h - OpenMP types --------------------- C++ -*-===//
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+
// Additional OpenMP type definitions, in conjunction with Types.h.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef OPENMP_LIBOMPTARGET_DEVICERTL_INCLUDE_DEVRTLEXTRAS_H
14+
#define OPENMP_LIBOMPTARGET_DEVICERTL_INCLUDE_DEVRTLEXTRAS_H
15+
16+
/// Base type declarations for freestanding mode
17+
///
18+
///{
19+
using uint64_t = unsigned long;
20+
// TODO: Properly implement this
21+
using uintptr_t = uint64_t;
22+
///}
23+
24+
/// Macros for allocating variables in different address spaces.
25+
///{
26+
27+
// Follows the pattern in interface.h
28+
// Same definitions as in host runtime
29+
// TODO: move these definitions to a common
30+
// place between host and device runtimes (e.g. in LLVM)
31+
typedef enum omp_memspace_handle_t {
32+
omp_default_mem_space = 0,
33+
omp_large_cap_mem_space = 1,
34+
omp_const_mem_space = 2,
35+
omp_high_bw_mem_space = 3,
36+
omp_low_lat_mem_space = 4,
37+
llvm_omp_target_host_mem_space = 100,
38+
llvm_omp_target_shared_mem_space = 101,
39+
llvm_omp_target_device_mem_space = 102,
40+
KMP_MEMSPACE_MAX_HANDLE = ~(0u)
41+
} omp_memspace_handle_t;
42+
43+
typedef enum {
44+
omp_atk_sync_hint = 1,
45+
omp_atk_alignment = 2,
46+
omp_atk_access = 3,
47+
omp_atk_pool_size = 4,
48+
omp_atk_fallback = 5,
49+
omp_atk_fb_data = 6,
50+
omp_atk_pinned = 7,
51+
omp_atk_partition = 8
52+
} omp_alloctrait_key_t;
53+
54+
typedef enum {
55+
omp_atv_false = 0,
56+
omp_atv_true = 1,
57+
omp_atv_contended = 3,
58+
omp_atv_uncontended = 4,
59+
omp_atv_serialized = 5,
60+
omp_atv_sequential = omp_atv_serialized, // (deprecated)
61+
omp_atv_private = 6,
62+
omp_atv_all = 7,
63+
omp_atv_thread = 8,
64+
omp_atv_pteam = 9,
65+
omp_atv_cgroup = 10,
66+
omp_atv_default_mem_fb = 11,
67+
omp_atv_null_fb = 12,
68+
omp_atv_abort_fb = 13,
69+
omp_atv_allocator_fb = 14,
70+
omp_atv_environment = 15,
71+
omp_atv_nearest = 16,
72+
omp_atv_blocked = 17,
73+
omp_atv_interleaved = 18
74+
} omp_alloctrait_value_t;
75+
#define omp_atv_default ((uintptr_t)-1)
76+
77+
typedef struct {
78+
omp_alloctrait_key_t key;
79+
uintptr_t value;
80+
} omp_alloctrait_t;
81+
82+
// Attribute to keep alive certain definition for the bitcode library.
83+
#ifdef LIBOMPTARGET_BC_TARGET
84+
#define KEEP_ALIVE __attribute__((used, retain))
85+
#else
86+
#define KEEP_ALIVE
87+
#endif
88+
89+
///}
90+
91+
#endif // OPENMP_LIBOMPTARGET_DEVICERTL_INCLUDE_DEVRTLEXTRAS_H

openmp/libomptarget/DeviceRTL/include/Types.h

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

15+
#include "DevRTLExtras.h"
16+
1517
// Tell the compiler that we do not have any "call-like" inline assembly in the
1618
// device rutime. That means we cannot have inline assembly which will call
1719
// another function but only inline assembly that performs some operation or
@@ -178,21 +180,6 @@ using ListGlobalFnTy = void (*)(void *buffer, int idx, void *reduce_data);
178180
///{
179181

180182
// Follows the pattern in interface.h
181-
// Same definitions as in host runtime
182-
// TODO: move these definitions to a common
183-
// place between host and device runtimes (e.g. in LLVM)
184-
typedef enum omp_memspace_handle_t {
185-
omp_default_mem_space = 0,
186-
omp_large_cap_mem_space = 1,
187-
omp_const_mem_space = 2,
188-
omp_high_bw_mem_space = 3,
189-
omp_low_lat_mem_space = 4,
190-
llvm_omp_target_host_mem_space = 100,
191-
llvm_omp_target_shared_mem_space = 101,
192-
llvm_omp_target_device_mem_space = 102,
193-
KMP_MEMSPACE_MAX_HANDLE = ~(0u)
194-
} omp_memspace_handle_t;
195-
196183
typedef enum omp_allocator_handle_t {
197184
omp_null_allocator = 0,
198185
omp_default_mem_alloc = 1,
@@ -206,45 +193,6 @@ typedef enum omp_allocator_handle_t {
206193
KMP_ALLOCATOR_MAX_HANDLE = ~(0U)
207194
} omp_allocator_handle_t;
208195

209-
typedef enum {
210-
omp_atk_sync_hint = 1,
211-
omp_atk_alignment = 2,
212-
omp_atk_access = 3,
213-
omp_atk_pool_size = 4,
214-
omp_atk_fallback = 5,
215-
omp_atk_fb_data = 6,
216-
omp_atk_pinned = 7,
217-
omp_atk_partition = 8
218-
} omp_alloctrait_key_t;
219-
220-
typedef enum {
221-
omp_atv_false = 0,
222-
omp_atv_true = 1,
223-
omp_atv_contended = 3,
224-
omp_atv_uncontended = 4,
225-
omp_atv_serialized = 5,
226-
omp_atv_sequential = omp_atv_serialized, // (deprecated)
227-
omp_atv_private = 6,
228-
omp_atv_all = 7,
229-
omp_atv_thread = 8,
230-
omp_atv_pteam = 9,
231-
omp_atv_cgroup = 10,
232-
omp_atv_default_mem_fb = 11,
233-
omp_atv_null_fb = 12,
234-
omp_atv_abort_fb = 13,
235-
omp_atv_allocator_fb = 14,
236-
omp_atv_environment = 15,
237-
omp_atv_nearest = 16,
238-
omp_atv_blocked = 17,
239-
omp_atv_interleaved = 18
240-
} omp_alloctrait_value_t;
241-
#define omp_atv_default ((uintptr_t)-1)
242-
243-
typedef struct {
244-
omp_alloctrait_key_t key;
245-
uintptr_t value;
246-
} omp_alloctrait_t;
247-
248196
#define __PRAGMA(STR) _Pragma(#STR)
249197
#define OMP_PRAGMA(STR) __PRAGMA(omp STR)
250198

@@ -262,13 +210,6 @@ typedef struct {
262210
#define CONSTANT(NAME) \
263211
[[clang::address_space(4)]] NAME [[clang::loader_uninitialized]]
264212

265-
// Attribute to keep alive certain definition for the bitcode library.
266-
#ifdef LIBOMPTARGET_BC_TARGET
267-
#define KEEP_ALIVE __attribute__((used, retain))
268-
#else
269-
#define KEEP_ALIVE
270-
#endif
271-
272213
///}
273214

274215
#endif

0 commit comments

Comments
 (0)