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

  • SEARCH
  • Home
  • 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 8335101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:33:48+00:00 2026-06-09T03:33:48+00:00

I have a lot of random floating point numbers residing in global GPU memory.

  • 0

I have a lot of random floating point numbers residing in global GPU memory. I also have “buckets” that specify ranges of numbers they will accept and a capacity of numbers they will accept.

ie:
numbers: -2 0 2 4
buckets(size=1): [-2, 0], [1, 5]

I want to run a filtration process that yields me

filtered_nums: -2 2
(where filtered_nums can be a new block of memory)

But every approach I take runs into a huge overhead of trying to synchronize threads across bucket counters. If I try to use a single-thread, the algorithm completes successfully, but takes frighteningly long (over 100 times slower than generating the numbers in the first place).

What I am asking for is a general high-level, efficient, as-simple-as-possible approach algorithm that you would use to filter these numbers.

edit
I will be dealing with 10 buckets and half a million numbers. Where all the numbers fall into exactly 1 of the 10 bucket ranges. Each bucket will hold 43000 elements. (There are excess elements, since the objective is to fill every bucket, and many numbers will be discarded).

2nd edit
It’s important to point out that the buckets do not have to be stored individually. The objective is just to discard elements that would not fit into a bucket.

  • 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-09T03:33:51+00:00Added an answer on June 9, 2026 at 3:33 am

    You can use thrust::remove_copy_if

    struct within_limit
    {
        __host__ __device__
        bool operator()(const int x)
            {
                return (x >=lo && x < hi);
            }
    };
    thrust::remove_copy_if(input, input + N, result, within_limit());
    

    You will have to replace lo and hi with constants for each bin..
    I think you can templatize the kernel, but then again you will have to instantiate the template with actual constants. I can’t see an easy way at it, but I may be missing something.

    If you are willing to look at third party libraries, arrayfire may offer an easier solution.

    array I = array(N, input, afDevice);
    float **Res = (float **)malloc(sizeof(float *) * nbins);
    for(int i = 0; i < nbins; i++) {
       array res = where(I >= lo[i] && I < hi[i]);
       Res[i] = res.device<float>(); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a multi-threaded Java program that generates lot of random numbers. Additional
I have a lot of pages that are setup like so from an old
We have a lot of queries for which we append a random alias at
I have found an API that'll make working with CANVAS a lot easier. It
I have to edit a lot of source codes similar to each other. random
I have a simple Matlab program that uses a set of random number lists
I have this algorithm that are drawing a lot of pixels on a Canvas
I have text files with a lot of uniform rows that I'd like to
I have an app that has a lot of views including tableViews but one
Just started reading on random way point mobility for MANET. I found a lot

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.