Valarray problem in an offload application

Valarray problem in an offload application

I need to use valarrays from the Standard C++ Library on the coprocessor. I can do in the native mode, no problems with that. In the past, I also could use them in offloaded code.  However, today I am getting a runtime error "undefined symbol ...valarray". I am using the Intel C++ Compiler version 2013.2.146 and MPSS version Gold Update 2. Any help is much appreciated!

#include <valarray>
int main() {
#pragma offload target(mic)
    std::valarray<double> x;

[avladim@dublin ~]$ icpc
[avladim@dublin ~]$ ./a.out 
On the remote process, dlopen() failed. The error message sent back from the sink is /tmp/coi_procs/1/12490/load_lib/icpcoutSvQfZa: undefined symbol: _ZNSt8valarrayIdEC1Ev
offload error: cannot load library to the device 0 (error code 20)
On the sink, dlopen() returned NULL. The result of dlerror() is "/tmp/coi_procs/1/12490/load_lib/icpcoutSvQfZa: undefined symbol: _ZNSt8valarrayIdEC1Ev"
[avladim@dublin ~]$

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Can you change your code to the following

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



Yes, #pragma offload_attribute(push)/(pop) fixes the problem. Thank you, Ravi! Could you please explain: is this the intended behavior of the compiler / library? When I use #include <cstdio>, I don't need to enclose it in the offload_attribute region, it just works. Why do I need to do it for #include <valarray>?

It is always best to use the pragma offload_attribute(push)/(pop). 

The compiler can recognize certain function like printf  etc in the standard header files and generate the necessary code.

Leave a Comment

Please sign in to add a comment. Not a member? Join today