Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Rob_Ottenhoff
New Contributor I
74 Views

Is there a way to check whether a task_schedular_init object is available in the current thread ?

Hi All,

Or must I do this administation myself ?

Regards,

Rob

0 Kudos
5 Replies
RafSchietekat
Black Belt
74 Views

A thread can have multiple active task_scheduler_init instances, so if you don't know just add a new one.

Rob_Ottenhoff
New Contributor I
74 Views

Quoting - Raf Schietekat
A thread can have multiple active task_scheduler_init instances, so if you don't know just add a new one.

Hi Raf,

That seemes rather wasteful: I want to check this in a function which can be called from different threads. The function is part of a video tracking system, so it can be called millions of times. If I have to add a task_scheduler_init instance for every call...

Regards,

Rob

Dmitry_Vyukov
Valued Contributor I
74 Views

Quoting - Rob Ottenhoff

That seemes rather wasteful: I want to check this in a function which can be called from different threads. The function is part of a video tracking system, so it can be called millions of times. If I have to add a task_scheduler_init instance for every call...

constructor of task_scheduler_init object will do exactly what you want to do. I.e. check whether scheduler already initialized for current thread, and, if yes, just exit.

RafSchietekat
Black Belt
74 Views

Why do you need a task_scheduler_init if the code does so little that you are concerned about its cost? Ifthe codeonly uses, e.g., atomics and containers, you don't need task_scheduler_init, but maybe a microbenchmark might help you decide whether you need to worry about this.

Rob_Ottenhoff
New Contributor I
74 Views

Quoting - Raf Schietekat
Why do you need a task_scheduler_init if the code does so little that you are concerned about its cost? Ifthe codeonly uses, e.g., atomics and containers, you don't need task_scheduler_init, but maybe a microbenchmark might help you decide whether you need to worry about this.

Hi Raf,

Thank for your answer, it is most helpful. The behavior of the constructor was not clear to me from the documentation.

I need the task_scheduler_init class to use parallel_reduce. It makes a loop that evaluates the particles in a particle filter parallel. The loop was a performance bottleneck found with a profiler.

Thanks,

Rob

Reply