Open SpinTensor opened 2 years ago
@llvm/issue-subscribers-openmp
I would not recommend calling OpenMP functions inside OMPT callbacks since this is against the OpenMP specifications:
Section 19.5 of the OpenMP Standard 5.2 specifications states the following restriction:
Tool callbacks may not use OpenMP directives or call any runtime library routines described in Chapter 18.
This includes both omp_get_level()
and omp_get_thread_num()
. Calling the functions at the wrong time can also have some side effects. For example, calling omp_get_num_devices()
before the initialization of the OMPT interface has finished will cause the function to return a value of 0.
Thanks for the hint. I was not aware of this restriction. What would be the recommended way of figuring out which thread (level and ID) issued the callback?
I don't have a perfect answer for that since I'm also just using the OMPT framework. In our software, we assign a unique thread id when the thead begin callback is called and store this id in a thread local variable. I'm not sure how we're handling the thread level right now.
Hi,
please consider the following test code:
In the code I register the implicit task callback function for the ompt_callback system. Then I compile it with the latest git version of llvm:
clang -fopenmp -o test.x test.c
When executing the resulting program I get the following output:
The segfault can be circumvented if for
ompt_scope_end
in theimplicit_task_callback
theomp_get_level()
call is omitted.