Software Archive
Read-only legacy content
17061 Discussions

offload error: cannot load library to the device

Dario_I_
Beginner
536 Views

I am trying to program the Xeon Phi in offload mode. The program below should just construct objects from the standard library on the card, but linking fails with the following error:

On the remote process, dlopen() failed. The error message sent back from the sink is /var/volatile/tmp/coi_procs/1/27843/load_lib/icpcoutdlt28i: undefined symbol: _ZNSt6vectorIdSaIdEEC1EmRKdRKS0_

offload error: cannot load library to the device 0 (error code 20)
On the sink, dlopen() returned NULL. The result of dlerror() is "/var/volatile/tmp/coi_procs/1/27843/load_lib/icpcoutdlt28i: undefined symbol: _ZNSt6vectorIdSaIdEEC1EmRKdRKS0_"

if compiled with:

icpc -openmp example.cpp

Looks like he is not finding the std library for the mic ..... whats the correct compilation line?

Dario

 

[cpp]#include<iostream>

#include<math.h>

#include<vector>

#include<omp.h>

__attribute__((target(mic))) void  wrapper() {

std::vector<double> x(2,0.1), f(1);

}


int main () {

  #pragma omp parallel sections

  {

    #pragma omp section

    {

      std::cout << "Executing on CPUs\n";

      wrapper();

      std::cout << "I am done on CPUs\n";

    }

    #pragma omp section

    {

      std::cout << "Executing on Xeon Phi\n";

      #pragma offload target(mic)

      {

        wrapper();

      }

      std::cout << "I am done on Xeon Phi\n";

    }

  }

return 0;

}[/cpp]

0 Kudos
2 Replies
Kevin_D_Intel
Employee
536 Views

Compilation line is fine. Program needs to declare instances of headers for the MIC side. Change the include statements to something like this:

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

You may need to add other includes within the offload_attribute as you expand the code within the offload sections.

0 Kudos
Dario_I_
Beginner
536 Views

Thanks! That did it :)

0 Kudos
Reply