- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I run my program on MIC by the offload mode. However, it returns error:
/var/volatile/tmp/coi_procs/1/29947/load_lib/iccout4vLAcb: undefined symbol: _ZNSt3setIiSt4lessIiESaIiEED1Ev
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/29947/load_lb/iccout4vLAcb: undefined symbol: _ZNSt3setIiSt4lessIiESaIiEED1Ev"
The native mode works fine. Could anyone please tell me how to figure out this problem? Thanks!
The function of the program is to read numbers from a *.txt file into a vector and an ordered_map
The compile command I used is:
icc -openmp -std=c++0x -O main main.cpp A.cpp
The following are the codes:
main.h
#ifndef MAIN_H #define MAIN_H #include "A.h" #include <omp.h> #include <sys/time.h> using namespace std; __attribute__((target(mic))) static double dtime() //static double dtime() { double tseconds = 0; struct timeval mytime; gettimeofday(&mytime,(struct timezone*)0); tseconds = (double)(mytime.tv_sec+(double)mytime.tv_usec*1e-6); return tseconds; } #endif
main.cpp
#include "main.h" using namespace std; int main() { cout << "Start.\n"; //string my_str = "content_string"; int N_total = 10, index_counter = 0, numthreads = 0; double t_begin = dtime(), t_end; #pragma offload target (mic) #pragma omp parallel #pragma omp master numthreads = omp_get_num_threads(); printf("Initializing.. %d Threads",numthreads); #pragma offload target(mic) #pragma omp parallel for private (index_counter) for (index_counter=0; index_counter<N_total; index_counter++) { if (index_counter==0) printf("\n%d threads.\n", numthreads); string my_str = "content_string"; vector< vector<int> > my_vec_vec; vector<int> my_vec; set<int> my_set; unordered_map<int,int> my_u_map; int my_int = 1; double t_i_start=dtime(), t_i_end; A_func_1(my_str,my_vec_vec,my_set,my_u_map); t_i_end = dtime(); //A_func_2(my_vec_vec,my_u_map,my_int); printf("time: %9.5lf\n",(t_i_end-t_i_start)); } return 0; }
A.h
#ifndef A_H #define A_H #include <omp.h> #include <fstream> #include <iostream> #include <map> #include <set> #include <sstream> #include <stdlib.h> #include <string> #include <time.h> #include <unordered_map> #include <vector> using namespace std; __attribute__((target(mic))) void A_func_1(string my_str, vector<vector<int> >& my_vec_vec, set<int>& my_set, unordered_map<int,int>& my_u_map); __attribute__((target(mic))) void A_func_2(vector<vector<int> >& my_vec_vec, unordered_map<int,int>& my_u_map, int my_int=0); //void A_func_1(string my_str, vector<vector<int> >& my_vec_vec, set<int>& my_set, unordered_map<int,int>& my_u_map); //void A_func_2(vector<vector<int> >& my_vec_vec, unordered_map<int,int>& my_u_map, int my_int=0); #endif
A.cpp
#include "A.h" #include "stdio.h" #include "string.h" using namespace std; void A_func_1(string my_str, vector<vector<int> >& my_vec_vec, set<int>& my_set, unordered_map<int,int>& my_u_map) { FILE *pFILE = fopen(my_str.c_str(),"r"); string string_buffer; char *input_buffer_char=NULL; size_t i_b_c_length; char const_char_buffer_comma[40960] = ""; char char_buffer_comma; int int_buffer, count_buffer; vector<int> vec_buffer; unordered_map<int,int>::iterator key_pos; if (pFILE==NULL) printf("%s open fail!\n",my_str.c_str()); else { while (getline(&input_buffer_char,&i_b_c_length,pFILE)!=-1) { strcpy(const_char_buffer_comma,input_buffer_char); string_buffer = string(const_char_buffer_comma); istringstream iss(string_buffer); // each line, each transaction while (iss>>int_buffer) { vec_buffer.push_back(int_buffer); //my_set.insert(int_buffer); key_pos = my_u_map.find(int_buffer); if (key_pos!=my_u_map.end()) { count_buffer = key_pos->second; my_u_map.erase(key_pos); my_u_map.insert(pair<int,int>(int_buffer,count_buffer+1)); } else { my_u_map.insert(pair<int,int>(int_buffer,1)); } iss >> char_buffer_comma; // eliminate the "," } my_vec_vec.push_back(vec_buffer); // one transaction push_backed into transaction set vec_buffer.clear(); } fclose(pFILE); } /* srand(time(NULL)); int n_length = rand()%10+1; for (int i=0; i<n_length ;i++) { vector<int> temp_vec; int m_length = rand()%10+1; for (int j=0; j<m_length; j++) temp_vec.push_back(rand()%20); my_vec_vec.push_back(temp_vec); } string string_buffer; int int_buffer; ifstream fin(my_str.c_str(),ios::in); if (!fin.is_open()) printf("file open error.\n"); else { while (getline(fin,string_buffer,'\n')) { istringstream iss(string_buffer); while (iss>>int_buffer) { my_set.insert(int_buffer); } } } */ } void A_func_2(vector<vector<int> >& my_vec_vec, unordered_map<int,int>& my_u_map, int my_int) { int n = my_vec_vec.size(); for (int i=0; i<n; i++) for (int j=0; j<my_vec_vec.size(); j++) my_vec_vec= j; }
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe the font of the error is unreadable. Here is another font:
On the remote process, dlopen() failed. The error message sent back from the sink is /var/volatile/tmp/coi_procs/1/29947/load_lib/iccout4vLAcb: undefined symbol: _ZNSt3setIiSt4lessIiESaIiEED1Ev
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/29947/load_lb/iccout4vLAcb: undefined symbol: _ZNSt3setIiSt4lessIiESaIiEED1Ev"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The offload code/compilation requires content from various includes inside A.h. Wrapper those includes with offload_attribute push/pop as shown:
A.h:
#ifndef A_H #define A_H #pragma offload_attribute (push, target (mic)) #include <omp.h> #include <fstream> #include <iostream> #include <map> #include <set> #include <sstream> #include <stdlib.h> #include <string> #include <time.h> #include <unordered_map> #include <vector> #pragma offload_attribute (pop) using namespace std; __attribute__((target(mic))) void A_func_1(string my_str, vector<vector<int> >& my_vec_vec, set<int>& my_set, unordered_map<int,int>& my_u_map); __attribute__((target(mic))) void A_func_2(vector<vector<int> >& my_vec_vec, un ordered_map<int,int>& my_u_map, int my_int=0); //void A_func_1(string my_str, vector<vector<int> >& my_vec_vec, set<int>& my_se t, unordered_map<int,int>& my_u_map); //void A_func_2(vector<vector<int> >& my_vec_vec, unordered_map<int,int>& my_u_m ap, int my_int=0); #endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks!
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page