Software Archive
Read-only legacy content
17061 Discussions

*MIC* namespace "std::this_thread" has no member "sleep_for"

ankit_m_1
Beginner
1,103 Views

Hello,

I am trying to offload some data onto the phi card and then I want my thread to sleep on the host for a few seconds but when I try to do so, I get the following error, the sleeping section is strictly on the host and is not offloaded to mic in anyway.

SomeFunction is executed by a separate thread.

----------------------------------------------------------------------------------------------------------------------------

int main()

{ thread t1 (SomeFunction); ti.join();

}

void SomeFunction()

{
    auto start = std::chrono::high_resolution_clock::now();
    
    #pragma offload_transfer target(mic:nn) \
    in( g_in[startInd:numElems:1]: alloc_if(0) free_if(freeval) )
    {}
    
    auto elapsed = std::chrono::high_resolution_clock::now() - start;
    long ms = (std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count())/1000.0;
     std::this_thread::sleep_for(std::chrono::milliseconds(ms));

}

----------------------------------------------------------------------------------------------------------------------------

Now, when I compile this code I get the following error,

using the following command

----------------------------------------------------------------------------------------------------------------------------

icpc -lpthread -std=c++11 -openmp -vec-report=3 try5.cpp -o t5

------------------------------------------------------------------------------------------------------------------------

try5.cpp(166): error: *MIC* namespace "std::this_thread" has no member "sleep_for"
                                std::this_thread::sleep_for(std::chrono::milliseconds(ms));
                                                  ^

compilation aborted for try5.cpp (code 2)

----------------------------------------------------------------------------------------------------------------------------

Why do I get  a MIC error ? why is icpc confusing between std and MIC namespaces ? am I doing something wrong here ? Kindly advise.

Thank you in advance

Sincerely,

AM

0 Kudos
2 Replies
Kevin_D_Intel
Employee
1,103 Views

When a source file contains offload language extensions (e.g. #pragma offload) the Intel compiler automatically compiles the file for both the host and coprocessor.

The *MIC* tag appears in all compiler diagnostic issued during the coprocessor compilation; it does not relate to a namespace.

The issue here is the lack of support for std::this_thread in the gcc 4.7 (experimental) used in conjunction with the coprocessor compilation. Your host  has a version that supports this. I do not know which version of gcc support this, it may be 4.7.1.

Try using a #ifndef __MIC__ to exclude the specific problematic source line from the coprocessor compilation. The alternative is isolating the offload code into function in a separate source file.

0 Kudos
ankit_m_1
Beginner
1,103 Views

Thank you Kevin, will try doing what you suggested. Appreciate your help.

0 Kudos
Reply