problems using stl in implicit model

problems using stl in implicit model


I am writing this very simple program using implicit offload model. wherein I make use of cilk_plus lib. I run into trouble when I do the following, my code doesn't run, can anyone please help me understand what I am doing incorrect here,

I am not including the definitions because when I do so somehow my message gets spammed. but if you look at the class body it is very straightforward.

#include <iostream>
#include <cilk/cilk.h>

#pragma offload_attribute(push,_Cilk_shared)
#include <vector>
#include "offload.h"
#pragma offload_attribute(pop)

#include "omp.h"

class _Cilk_shared Test
        unsigned long long GetNumElems(); 
        vector<int>& GetVec(); 
        unsigned long long PerformAdd(); 
        unsigned long long m_res; 
        void SimulateData(); 
        //void SimulateData(); 
        vector<int> m_vec; 

Test* _Cilk_shared tt1;

int main()
    tt1 = new _Cilk_shared Test(); 
    _Cilk_offload_to(0) tt1->SimulateData(); 
    tt1->m_res = _Cilk_offload_to(0) tt1->PerformAdd(); 
    cout << tt1->m_res << endl;
    // auto clean up on MIC I presume !! 
    return 0; 


Following is what I get when I compile

 icc -openmp  -offload-option,mic,compiler,"-z defs" cpSimple.cpp -o cpOO
/tmp/iccgh0xCb.o: In function `Test::Test()':
cpSimple.cpp:(.text+0x82): undefined reference to `std::vector<int, std::allocator<int> >::vector()'
/tmp/iccgh0xCb.o: In function `Test::SimulateData()':
cpSimple.cpp:(.text+0xf5): undefined reference to `std::vector<int, std::allocator<int> >::push_back(int const&)'
/tmp/iccgh0xCb.o: In function `Test::PerformAdd()':
cpSimple.cpp:(.text+0x37b): undefined reference to `std::vector<int, std::allocator<int> >::operator[](unsigned long)'
/tmp/iccgh0xCb.o: In function `Test::~Test()':
cpSimple.cpp:(.text+0x532): undefined reference to `std::vector<int, std::allocator<int> >::~vector()'
/tmp/iccgh0xCb.o: In function `Test::GetNumElems()':
cpSimple.cpp:(.text+0x587): undefined reference to `std::vector<int, std::allocator<int> >::size() const'


Thank you



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

Why not use icpc to link? This isn't MIcrosoft Windows; icc is a real C compiler driver, not C++.

I cannot reproduce the same errors despite trying to fill in for the missing definitions so it would be difficult to understand the errors without have the complete code.

Could you try attaching a file containing the complete source that includes the definitions for the missing functions and that produces the errors you showed?

Hello Kevin, 

Thank you for all your help in troubleshooting this. Attached is the src file.

I am running into troubles with stl and generally unsure of what headers need to go in my scr file at the time of offload. 

e.g. should I use offload.h or <new> 

#pragma offload_attribute(push,_Cilk_shared)
#include <vector>
#include "offload.h"
#pragma offload_attribute(pop) 

Also, following is what I do to compile my program

 icpc -openmp  -offload-option,mic,compiler,"-z defs" cpSimple2.cpp -o ss2++

I have included -offload-option to understand what is happening at the MIC side but when I use this trigger I see a lot more error messages than mentioned in my earlier post.  

I really appreciate all your help here. 




Downloadtext/x-c++src cpSimple_0.cpp1.37 KB

Thank you AM. The attached test case does not compile "as is" but we understand your interest and with some small changes can reproduce the link errors mentioned. Developers are looking into this case now and a run-time failure that has surfaced with it so I'll update again when I know more.

Leave a Comment

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