__kmpc_push_num_threads bug?

__kmpc_push_num_threads bug?

I use __kmpc_push_num_threads for support num_threads clause. But it is segmentation fault when call __kmp_push_num_threads.

I debug with gdb and found that __kmp_threads is null. This is __kmpc_push_num_threads bug? or I miss anything?

7884	    kmp_info_t *thr = __kmp_threads[gtid];
(gdb) p __kmp_threads
$1 = (kmp_info_t **) 0x0

Thank you


2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I think there is no bug here, there may be inappropriate usage of the routine. In general all __kmpc_* routines are designed for internal usage by the compiler, not for arbitrary usage in an application.

If __kmp_threads array is not allocated that means there are no OpenMP threads in the application. You may only ask for particular number of threads setting for OpenMP thread, not for any native thread for example.  Note the second parameter for __kmpc_push_num_threads - it is global thread id, which is assigned by the OpenMP RTL during a thread registering in the library (when the thread becomes OpenMP thread).  Compiler usually first obtain the global_tid via call to __kmpc_global_thread_num(), only then it can call other routines those work with already registered OpenMP thread.


Leave a Comment

Please sign in to add a comment. Not a member? Join today