* Akshit Sharma via Gcc-help <gcc-help@xxxxxxxxxxx> [2021-04-04 10:30]: > I am trying to profile the program with gcc. I am inserting the data into > an array which is later used to generate a file. > > I am having a problem using template class (std::atomic<int>). Program is > multithreaded. So, I need to use atomics. Depending on how you manage your threads, you might be able to avoid atomics in __cyg_profile_func_* by using thread-local variables. E.g. collect all data per-thread in thread-local variables. Then disable profiling (you can't disable the calls to __cyg_profile_func_*, but you can exit immediately at the top of the function if a flag is set), and copy the data to global storage. This can work if you have control over all your threads. Hope this helps you. Thomas