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 5 // RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda 6 7 #include <cstdio> 8 #include <cstdlib> 9 #include <vector> 10 #include <cinttypes> 11 12 // Data structure definitions copied from OpenMP RTL. 13 struct MapComponentInfoTy { 14 void *Base; 15 void *Begin; 16 int64_t Size; 17 int64_t Type; 18 MapComponentInfoTy() = default; 19 MapComponentInfoTy(void *Base, void *Begin, int64_t Size, int64_t Type) 20 : Base(Base), Begin(Begin), Size(Size), Type(Type) {} 21 }; 22 23 struct MapperComponentsTy { 24 std::vector<MapComponentInfoTy> Components; 25 }; 26 27 // OpenMP RTL interfaces 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 int64_t __tgt_mapper_num_components(void *rt_mapper_handle); 32 void __tgt_push_mapper_component(void *rt_mapper_handle, void *base, 33 void *begin, int64_t size, int64_t type); 34 #ifdef __cplusplus 35 } 36 #endif 37 38 int main(int argc, char *argv[]) { 39 MapperComponentsTy MC; 40 void *base, *begin; 41 int64_t size, type; 42 // Push 2 elements into MC. 43 __tgt_push_mapper_component((void *)&MC, base, begin, size, type); 44 __tgt_push_mapper_component((void *)&MC, base, begin, size, type); 45 int64_t num = __tgt_mapper_num_components((void *)&MC); 46 // CHECK: num=2 47 printf("num=%" PRId64 "\n", num); 48 return 0; 49 } 50