Community
cancel
Showing results for 
Search instead for 
Did you mean: 
baoyun_p_
Beginner
94 Views

undefined reference to std::sort() in offload on mic

Jump to solution

I want to execute std::sort() in offload method on MIC, the code as following:

#include <stdlib.h>
#include <algorithm>
#define data_num 100000
#pragma offload_attribute(push,target(mic)) 
struct T{
	float fea;
	int pos;
} ;
bool myGreater(T i, T j){
	return i.fea > j.fea;
}
T *data;
#pragma offload_attribute(pop) 

void main(){
	#pragma offload target(mic:0) in(data:length(data_num) alloc_if(1))
            {
                data = (T*) malloc(sizeof(T) * data_num);
                ....
		std::sort(data, data+data_num, myGreater);
            }
}

 I use icc compiler to compile, and it give the error informantion: "undefined reference to std::sort<T*, bool(*)>..." , but when I remove the all "#pragma...", it can  go through compile. 

I guess that the std::sort algorithm cannot be used in MIC, 

0 Kudos
1 Solution
Kevin_D_Intel
Employee
94 Views

Encapsulate at least <algorithm> within an offload_attribute push/pop. i.e.

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

View solution in original post

1 Reply
Kevin_D_Intel
Employee
95 Views

Encapsulate at least <algorithm> within an offload_attribute push/pop. i.e.

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

View solution in original post

Reply