Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / mapping / declare_mapper_api.cpp
blob041c7f64be21945602e39bd1160baac4e8d9309c
1 // RUN: %libomptarget-compilexx-run-and-check-generic
3 #include <cinttypes>
4 #include <cstdio>
5 #include <cstdlib>
6 #include <vector>
8 // Data structure definitions copied from OpenMP RTL.
9 struct MapComponentInfoTy {
10 void *Base;
11 void *Begin;
12 int64_t Size;
13 int64_t Type;
14 void *Name;
15 MapComponentInfoTy() = default;
16 MapComponentInfoTy(void *Base, void *Begin, int64_t Size, int64_t Type,
17 void *Name)
18 : Base(Base), Begin(Begin), Size(Size), Type(Type), Name(Name) {}
21 struct MapperComponentsTy {
22 std::vector<MapComponentInfoTy> Components;
25 // OpenMP RTL interfaces
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 int64_t __tgt_mapper_num_components(void *rt_mapper_handle);
30 void __tgt_push_mapper_component(void *rt_mapper_handle, void *base,
31 void *begin, int64_t size, int64_t type,
32 void *name);
33 #ifdef __cplusplus
35 #endif
37 int main(int argc, char *argv[]) {
38 MapperComponentsTy MC;
39 void *base, *begin;
40 int64_t size, type;
41 // Push 2 elements into MC.
42 __tgt_push_mapper_component((void *)&MC, base, begin, size, type, nullptr);
43 __tgt_push_mapper_component((void *)&MC, base, begin, size, type, nullptr);
44 int64_t num = __tgt_mapper_num_components((void *)&MC);
45 // CHECK: num=2
46 printf("num=%" PRId64 "\n", num);
47 return 0;