xref: /llvm-project/openmp/runtime/test/ompt/misc/runtime_error.c (revision a6f9cb6adc591d19a6c43234245de1e2048ed373)
1 // RUN: %libomp-compile-and-run 2>&1 | sort | FileCheck %s
2 // REQUIRES: ompt
3 
4 #include <string.h>
5 #include <stdio.h>
6 #include "callback.h"
7 
8 // TODO: use error directive when compiler suppors
9 typedef void ident_t;
10 extern void __kmpc_error(ident_t *, int, const char *);
11 
main()12 int main() {
13 #pragma omp parallel num_threads(2)
14   {
15     if (omp_get_thread_num() == 0) {
16       const char *msg = "User message goes here";
17       printf("0: Message length=%" PRIu64 "\n", (uint64_t)strlen(msg));
18       __kmpc_error(NULL, ompt_warning, msg);
19     }
20   }
21   return 0;
22 }
23 
24 // CHECK: {{^}}0: Message length=[[LENGTH:[0-9]+]]
25 // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
26 
27 // CHECK: {{^}}[[PRIMARY_ID:[0-9]+]]: ompt_event_implicit_task_begin
28 // CHECK: {{^}}[[PRIMARY_ID]]: ompt_event_runtime_error
29 // CHECK-SAME: severity=1
30 // CHECK-SAME: message=User message goes here
31 // CHECK-SAME: length=[[LENGTH]]
32 // CHECK-SAME: codeptr_ra={{0x[0-f]+}}
33 
34 // Message from runtime
35 // CHECK: {{^}}OMP: Warning{{.*}}User message goes here
36