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