File: openmp_tools.c

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-10.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,999,140 kB
  • sloc: cpp: 6,951,711; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,033; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,252; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (57 lines) | stat: -rw-r--r-- 1,151 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Test OpenMP Tools support
// RUN: %clang -fopenmp -DTOOLS %s -shared -o %t_Tools.so
// RUN: %clang -fopenmp -UTOOLS %s -o %t
// RUN: OMP_TOOL_LIBRARIES=%t_Tools.so %t | grep "INIT"
// REQUIRES: clang, libomp
#ifdef TOOLS

// OpenMP Tools are only supported starting OpenMP 5
#if _OPENMP >= 201811
#include <stdio.h>
#include <ompt.h>

int ompt_initialize(
        ompt_function_lookup_t lookup,
        int initial_device_num,
        ompt_data_t *data)
{
  puts("[INIT]");
  return 1;
}

void ompt_finalize(ompt_data_t* data)
{
  puts("[FINAL]");
}

ompt_start_tool_result_t* ompt_start_tool(
  unsigned int omp_version,
  const char *runtime_version)
{
  printf("[START] %s, OMP%u\n", runtime_version, omp_version);
  static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize, &ompt_finalize, {.ptr=NULL}};
  return &ompt_start_tool_result;
}

#endif


#else
#include <stdio.h>

int main() {
#pragma omp parallel
#pragma omp single
  {
    // if we don't have support for ompt, default to an output that satisfies
    // the test check
#if _OPENMP < 201811
  puts("INIT");
#else
  puts("hello");
#endif
  }
  return 0;
}

#endif