I am currently using CUDA 7.5 under VS 2013.
Today I needed to remove some of the elements from a device_vector
, thus decided to use remove_if
. But however I modify the code, the program just compiles well but throws "thrust::system::system_error" at run time.
Firstly I tried my own code:
int main()
{
thrust::host_vector<int> AA(10, 1);
thrust::sequence(AA.begin(), AA.end());
thrust::host_vector<bool> SS(10,false);
thrust::fill(SS.begin(), SS.begin() + 5, true);
thrust::device_vector<int> devAA=AA;
thrust::device_vector<bool> devSS = SS;
thrust::device_vector<int>::iterator new_end = thrust::remove_if(thrust::device,
devAA.begin(), devAA.end(), devSS.begin(), thrust::identity<int>());
}
But it throws thrust::system::system_error
at run time. However, if I use two host_vector
, i.e. AA
and SS
to perform remove_if
, everything goes fine.
Then, I tried the code I found on stackoverflow here, the code in Robert Crovella's answer seemed work fine, but on my machine, it still throws thrust::system::system_error
.
Did new version of thrust modify anything? Or I should try some other way? I am using cmake to organise the code, is there any thing special?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…