Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

multimedia timers / task_group_context

gravyjones
Beginner
282 Views
I have an interesting problem.

My application uses multimedia timers to process video from hardware devices as well as the display.

The structure of the code to support a multimedia timer requires a static callback procedure, as a hook in point, to the system generated multimedia timer. In my situation this is simply the static function in my class. I make sure to initialize the timer with "this" as the user defined data. The timer is called in the context of the multimedia timer thread, and my code will reconstruct "this" as a back pointer to the original instance of the class that caused the timer to be used.

During the callback, when I use parallel_reduce, TBB complains about an initialization problem. Basically, If I understand the docs correctly, this situation constitutes an isolated task, where the parent has no knowledge of TBB. I would like to know how to use parallel_reduce in combination with an isolated task. It seems like I have no chance of getting to initialize TBB in the multimedia timer.

Thanks!

The specific error is
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!

Program: ...
Module: tbb_debug.dll
File: ../../src/tbb/task.cpp
Line: 3113

Expression: my_owner

Thread has not activated a task_scheduler_init object?

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)
---------------------------
Abort Retry Ignore
---------------------------
0 Kudos
2 Replies
RafSchietekat
Valued Contributor III
282 Views
As long as there is at least one long-lived task_scheduler_init somewhere in the process (like in main()), it is cheap enough to have another one, not necessarily unique, on the stack of any thread that may not yet be known to TBB (like a local variable in the callback).
0 Kudos
Alexey-Kukanov
Employee
282 Views
Also to better support such situations, a new version of TBB (to be released later this year) will have automatic initialization of the TBB scheduler. The effect of automatic intialization will be as if a task_scheduler_init object was created inside the first call toa parallel algorithm in a thread, and was kept alive till the thread shuts down.
0 Kudos
Reply