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
|