Alexey Bataev | c10180e | 2019-08-06 18:13:39 +0000 | [diff] [blame] | 1 | // 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 Kruse | 2c7a8ea | 2019-08-04 04:18:28 +0000 | [diff] [blame] | 5 | |
| 6 | #include <cstdio> |
| 7 | #include <cstdlib> |
Alexey Bataev | c10180e | 2019-08-06 18:13:39 +0000 | [diff] [blame] | 8 | #include <vector> |
Michael Kruse | 2c7a8ea | 2019-08-04 04:18:28 +0000 | [diff] [blame] | 9 | |
| 10 | // Data structure definitions copied from OpenMP RTL. |
| 11 | struct 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 | |
| 21 | struct MapperComponentsTy { |
| 22 | std::vector<MapComponentInfoTy> Components; |
| 23 | }; |
| 24 | |
| 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 | #ifdef __cplusplus |
| 33 | } |
| 34 | #endif |
| 35 | |
| 36 | int 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 | } |