- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
i've encountered a weird issue when I tried to use a thread_local std::vector as a member variable inside a templated class/struct. The code compiles with icl but the linker says that the object file is basically corrupted (see pictures).
This is the minimal example that reproduces the issue on my machines:
#include <vector>
template<typename TA>
struct A {
static thread_local std::vector<int> s;
};
template<typename TA>
thread_local std::vector<int> A<TA>::s;
template struct A<double>;
int main() {
return 0;
}
This works in gcc, clang, icc, msvc (all versions that support thread_local). Through a bit of testing I found out that the issue vanishes if:
- the struct is not templated.
- the variable is a global variable outside of the class
- std::vector is replace by std::array (all other containers fail though)
Additional information:
OS Name: Microsoft Windows 10 Enterprise LTSC (64bit)
OS Version: 10.0.17763 Build 17763
Processor: Intel(R) Xeon(R) Gold 5218 CPU
Compiler Version: 19.0.5.281 Build 20190815 and 19.1.3.311 Build 20201010_000000
VS Version: 2017 (Linker Version 14.16.27045.0) and 2019 (Linker Version 14.28.29335.0)
Compile command: icl test.cpp
The dumbin.exe output is attached.
Best regards,
Simon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for reaching out to us.
Could you please try compiling the code using icx compiler on windows as it is working fine without giving any such errors.
icx is intel's oneAPI compiler which comes with oneAPI toolkits.
You can download it from the below links
oneAPI Base toolkit:
https://software.intel.com/content/www/us/en/develop/tools/oneapi/base-toolkit/download.html
oneAPI HPC toolkit:
https://software.intel.com/content/www/us/en/develop/tools/oneapi/hpc-toolkit/download.html
We suggest you to try using latest oneAPI compilers and let us know if you face any issues.
Regards,
Vidya.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for reaching out to us.
Could you please try compiling the code using icx compiler on windows as it is working fine without giving any such errors.
icx is intel's oneAPI compiler which comes with oneAPI toolkits.
You can download it from the below links
oneAPI Base toolkit:
https://software.intel.com/content/www/us/en/develop/tools/oneapi/base-toolkit/download.html
oneAPI HPC toolkit:
https://software.intel.com/content/www/us/en/develop/tools/oneapi/hpc-toolkit/download.html
We suggest you to try using latest oneAPI compilers and let us know if you face any issues.
Regards,
Vidya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for the reply.
icx works indeed, thanks for the suggestion.
For my icl pipeline I'll use __declspec(thread) for now since that seems to work:
#ifdef __ICL
#define MY_THREAD_LOCAL __declspec(thread)
#else
#define MY_THREAD_LOCAL thread_local
#endif
Best regards,
Simon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
>>since that seems to work
Glad to know that your issue is resolved.
As your issue has beed resolved could you please confirm whether we can close this thread from our.
Regards,
Vidya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Best regards,
Simon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Thanks for accepting our solution.
As the issue is resolved we are closing this thread from our end.
Please raise a new thread if you have any other queries.
Regards,
Vidya.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page