brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · e4470a5 Raw
77 lines · c
1// clang-format off2// RUN: %libomp-compile && %libomp-run | FileCheck %s3// REQUIRES: ompt4// clang-format on5#include "callback.h"6#include <omp.h>7 8int main() {9#pragma omp parallel num_threads(1)10  {11    // ompt_get_callback()12    ompt_callback_t callback;13    ompt_get_callback(ompt_callback_thread_begin, &callback);14    printf("%" PRIu64 ": &on_ompt_callback_thread_begin=%p\n",15           ompt_get_thread_data()->value, &on_ompt_callback_thread_begin);16    printf("%" PRIu64 ": ompt_get_callback() result=%p\n",17           ompt_get_thread_data()->value, callback);18 19    // ompt_get_state()20    printf("%" PRIu64 ": ompt_get_state()=%d\n", ompt_get_thread_data()->value,21           ompt_get_state(NULL));22 23    // ompt_enumerate_states()24    int state = ompt_state_undefined;25    const char *state_name;26    int steps = 0;27    while (ompt_enumerate_states(state, &state, &state_name) && steps < 1000) {28      steps++;29      if (!state_name)30        printf("%" PRIu64 ": state_name is NULL\n",31               ompt_get_thread_data()->value);32    }33    if (steps >= 1000) {34      // enumeration did not end after 1000 steps35      printf("%" PRIu64 ": states enumeration did not end\n",36             ompt_get_thread_data()->value);37    }38 39    // ompt_enumerate_mutex_impls()40    int impl = ompt_mutex_impl_none;41    const char *impl_name;42    steps = 0;43    while (ompt_enumerate_mutex_impls(impl, &impl, &impl_name) &&44           steps < 1000) {45      steps++;46      if (!impl_name)47        printf("%" PRIu64 ": impl_name is NULL\n",48               ompt_get_thread_data()->value);49    }50    if (steps >= 1000) {51      // enumeration did not end after 1000 steps52      printf("%" PRIu64 ": mutex_impls enumeration did not end\n",53             ompt_get_thread_data()->value);54    }55  }56 57  // clang-format off58  // Check if libomp supports the callbacks for this test.59 60  // CHECK: 0: NULL_POINTER=[[NULL:.*$]]61 62  // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: &on_ompt_callback_thread_begin63  // CHECK-SAME: =[[FUNCTION_POINTER:(0x)?[0-f]+]]64  // CHECK: {{^}}[[THREAD_ID]]: ompt_get_callback() result=[[FUNCTION_POINTER]]65 66  // CHECK: {{^}}[[THREAD_ID]]: ompt_get_state()=167 68  // CHECK-NOT: {{^}}[[THREAD_ID]]: state_name is NULL69  // CHECK-NOT: {{^}}[[THREAD_ID]]: states enumeration did not end70 71  // CHECK-NOT: {{^}}[[THREAD_ID]]: impl_name is NULL72  // CHECK-NOT: {{^}}[[THREAD_ID]]: mutex_impls enumeration did not end73  // clang-format on74 75  return 0;76}77