blob: 275b6c3c5702503c439b3a6bb9fd15b914ad2fad [file] [log] [blame]
Alexey Bataevc10180e2019-08-06 18:13:39 +00001// RUN: %libomptarget-compilexx-run-and-check-aarch64-unknown-linux-gnu
2// RUN: %libomptarget-compilexx-run-and-check-powerpc64-ibm-linux-gnu
3// RUN: %libomptarget-compilexx-run-and-check-powerpc64le-ibm-linux-gnu
4// RUN: %libomptarget-compilexx-run-and-check-x86_64-pc-linux-gnu
Michael Kruse2c7a8ea2019-08-04 04:18:28 +00005
6#include <cstdio>
7#include <cstdlib>
Alexey Bataevc10180e2019-08-06 18:13:39 +00008#include <vector>
Michael Kruse2c7a8ea2019-08-04 04:18:28 +00009
10// Data structure definitions copied from OpenMP RTL.
11struct MapComponentInfoTy {
12 void *Base;
13 void *Begin;
14 int64_t Size;
15 int64_t Type;
16 MapComponentInfoTy() = default;
17 MapComponentInfoTy(void *Base, void *Begin, int64_t Size, int64_t Type)
18 : Base(Base), Begin(Begin), Size(Size), Type(Type) {}
19};
20
21struct MapperComponentsTy {
22 std::vector<MapComponentInfoTy> Components;
23};
24
25// OpenMP RTL interfaces
26#ifdef __cplusplus
27extern "C" {
28#endif
29int64_t __tgt_mapper_num_components(void *rt_mapper_handle);
30void __tgt_push_mapper_component(void *rt_mapper_handle, void *base,
31 void *begin, int64_t size, int64_t type);
32#ifdef __cplusplus
33}
34#endif
35
36int main(int argc, char *argv[]) {
37 MapperComponentsTy MC;
38 void *base, *begin;
39 int64_t size, type;
40 // Push 2 elements into MC.
41 __tgt_push_mapper_component((void *)&MC, base, begin, size, type);
42 __tgt_push_mapper_component((void *)&MC, base, begin, size, type);
43 int64_t num = __tgt_mapper_num_components((void *)&MC);
44 // CHECK: num=2
45 printf("num=%lld\n", num);
46 return 0;
47}