How to know that a function is run inside a TBB task

TCE Options

TCE Open Date: 

Thursday, January 2, 2020 - 05:45

How to know that a function is run inside a TBB task


#define __TBB_VERSION_STRINGS(N) \
#N": BUILD_HOST        imbeu025 (x86_64)" ENDL \
#N": BUILD_OS        Ubuntu 18.04.2 LTS" ENDL \
#N": BUILD_KERNEL    Linux 4.15.0-45-generic #48-Ubuntu SMP Tue Jan 29 16:28:13 UTC 2019" ENDL \
#N": BUILD_GCC        g++ (GCC) 7.4.0" ENDL \
#N": BUILD_LIBC    2.27" ENDL \
#N": BUILD_LD        " ENDL \
#N": BUILD_TARGET    intel64 on cc7.4.0_libc2.27_kernel4.15.0" ENDL \

Hello.

I want to use tbb::task::suspend/resume if I'm inside a TBB task and a regular semaphore otherwise. How can I check if the current function is run from inside a TBB task? Is the condition "tbb::task::self().state() == tbb::task::executing" good enough?

1 post / 0 new