Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Feeding raw CUDA pointer to thrust::lower_bound fails #554

Closed
lodhb opened this issue Sep 10, 2014 · 1 comment
Closed

Feeding raw CUDA pointer to thrust::lower_bound fails #554

lodhb opened this issue Sep 10, 2014 · 1 comment

Comments

@lodhb
Copy link

lodhb commented Sep 10, 2014

Despite specifying the thrust::cuda::par parallel execution policy, thrust::lower_bound returns the following error:

error: no suitable constructor exists to convert from "float *" to "thrust::detail::normal_iteratorthrust::device_ptr"

Code is the following:

float * raw_ptr;
int length;
...
... (allocate memory on the device at raw_ptr)
...
thrust::device_vector::iterator iter = thrust::lower_bound(thrust::cuda::par, raw_ptr, raw_ptr+length, some_value, some_comp);

Using pgcpp 14.3-0 64-bit target on x86-64 Linux and Cuda compilation tools, release 6.5, V6.5.12.

@jaredhoberock
Copy link
Contributor

Hi lodhb,

When I compile the following program against the latest development version of Thrust, it succeeds without error on my system:

$ cat test.cu 
#include <thrust/device_vector.h>
#include <thrust/sequence.h>
#include <thrust/binary_search.h>
#include <thrust/system/cuda/execution_policy.h>

int main()
{
  thrust::device_vector<int> v(10);

  thrust::sequence(v.begin(), v.end());

  int *ptr = raw_pointer_cast(v.data());

  thrust::lower_bound(thrust::cuda::par, ptr, ptr + v.size(), 0);

  return 0;
}

$ nvcc -arch=sm_35 -I. test.cu -run

If you still observe the error with the latest development version of Thrust, please submit a small, self-contained program which reproduces the error.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants