Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8658613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:48:40+00:00 2026-06-12T15:48:40+00:00

I tried to find the minimum element in an array: thrust::device_ptr<float> devPtr(d_ary); int minPos

  • 0

I tried to find the minimum element in an array:

 thrust::device_ptr<float> devPtr(d_ary);
 int minPos = thrust::min_element(devPtr.begin(), devPtr.end()) - devPtr.begin();

And I got the above error when compiling.

How should I fix this problem? Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:48:41+00:00Added an answer on June 12, 2026 at 3:48 pm

    The specific error you identify is because device pointers are not containers, and therefore have no .begin() or .end() members.
    your devPtr is not a container, it is a device pointer usable by Thrust.
    You wrapped a raw pointer to create devPtr, and the raw pointer carries with it no knowledge of the size of the data region that it is pointing to.

    Pointers don’t have members like begin and end.

    You could fix the problem either by:

    1. switching to using thrust vector containers which will have .begin and .end iterators defined for you
    2. manually creating begin and end pointers for the data region (d_ary) you are accessing

    Here’s some example code along the lines of the latter idea above:

    #include <thrust/device_ptr.h>
    #include <thrust/extrema.h>
    
    #define N 256
    int main()
    {
    
      float *d_a;
    
      cudaMalloc((void **) &d_a, N*sizeof(float));
    
      thrust::device_ptr<float> dPbeg(d_a);
      thrust::device_ptr<float> dPend = dPbeg + N;
      thrust::device_ptr<float> result = thrust::min_element(dPbeg, dPend);
    }
    

    There is a thrust quickstart guide which may be of interest. (In the interest of clarity, I have not wrapped the cudaMalloc call with any error-checking. It’s good practice to wrap cuda calls with error checking.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find the index position of the minimum element in a
tried to find the answer by googling and in MSDN but with no luck.
I tried to find the answer to this question but could not, to be
I tried to find the difference on Google. BUT I 'm not able to
I tried to find an easy solution for the following. I have a main
I tried to find a solution but I didn't found what I was searching
I tried to find this in the relevant RFC, IETF RFC 3986 , but
i tried to find it out with previous answers but i cannot do it
I tried to find a solution to my problem already in google and here
i tried to find how i could load kml file and I found that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.