brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 041c7f6 Raw
49 lines · cpp
1// RUN: %libomptarget-compilexx-run-and-check-generic2 3#include <cinttypes>4#include <cstdio>5#include <cstdlib>6#include <vector>7 8// Data structure definitions copied from OpenMP RTL.9struct 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) {}19};20 21struct MapperComponentsTy {22  std::vector<MapComponentInfoTy> Components;23};24 25// OpenMP RTL interfaces26#ifdef __cplusplus27extern "C" {28#endif29int64_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                                 void *name);33#ifdef __cplusplus34}35#endif36 37int 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=246  printf("num=%" PRId64 "\n", num);47  return 0;48}49