Skip to content

Speedup of any_of and find_if operations #712

Closed as not planned
Closed as not planned

Description

@Bulat-Ziganshin

I work with Thrust shipped with CUDA 9, Linux x64, Volta GPU.

Initially we had the following code to check whether we can find value X in the array:

      auto it = thrust::find_if(p, p + num_rows, is_equal_to(X);
      return it != (p + num_rows);

but its speed was 27 GB/s, i.e. 30x slower than Volta memory speed.

I changed it to the following code, which was only 5x slower than memory speed:

      auto nulls_count = thrust::count(p, p + num_rows, X);
      return (nulls_count > 0);

Finally I tried this code, but it had the same speed as thrust::find_if:

      return thrust::any_of(p, p + num_rows, _1 == X);

Now i'm going to write my own kernel. Hopefully, you can improve at least find_if and any_of to be as fast as count, and ideally I like to see them all working at full Volta memory speed. Average array size in my tests is about 64 MB (8M elements), so i think it's not startup time problem.

Activity

  1. added
    thrust
    on Feb 22, 2023
  2. transferred this issue fromNVIDIA/thruston Nov 8, 2023
  3. added a commit that references this issue on Nov 16, 2023
  4. alliepiper commented on Mar 2, 2024

    @alliepiper
    Contributor

    Closing as a duplicate of #720. Both issues have the same underlying cause and there's more discussion on the other one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    thrust

    Type

    No type

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions