Software Archive
Read-only legacy content
17061 Discussions

offload and STL problem

Jamil_A_
Beginner
428 Views

Hi 

The following test returns an undefined reference for the target code

#include <algorithm>

void test()
{

#pragma offload target(mic)
    {
       double a=1.0;
       double b=1.0;
       double c=std::max(a,b);
    }
}

int main()
{
  test();
}

icpc -openmp -offload-option,mic,ld,'-zdefs' micstl.cxx
/tmp/icpcwXQiLo.o: In function `__offload_entry_micstl_cxx_6test_11b7a23007ddafd41960e6289788656dicpc326259940ELibIR':
micstl.cxx:(.text+0x72): undefined reference to `double const& std::max<double>(double const&, double const&)'

icpc --version
icpc (ICC) 14.0.4 20140805
Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.

Do I need to link to a specific library on the mic?

Thanks

Jamil

0 Kudos
4 Replies
TimP
Honored Contributor III
428 Views

icpc should normally generate in-line code for std::max(), avoiding a library reference.

0 Kudos
Kevin_D_Intel
Employee
428 Views

Pardon the delay, you probably already determined the system header <algorithm> requires decoration/declaration for inclusion in the coprocessor (target) compilation as follows:

#pragma offload_attribute (push, target(mic))
#include <algorithm>
#pragma offload_attribute (pop)

 

0 Kudos
Jamil_A_
Beginner
428 Views

Hi Kevin

Thanks for the tip. I assume I can follow a similar approach for header only boost functionality.

Thanks

Jamil

0 Kudos
Kevin_D_Intel
Employee
428 Views

I'm not knowledgeable on Boost but I expect that's correct. Any headers containing function declarations used within the offload code will require this style of decoration/declaration. Let me know if you run into problems and I'll solicit help from our Developers.
 

0 Kudos
Reply