Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC: neighbor search #61

Closed
wants to merge 29 commits into from
Closed

POC: neighbor search #61

wants to merge 29 commits into from

Conversation

raimis
Copy link
Collaborator

@raimis raimis commented Mar 3, 2022

This is a proof-of-concept. DO NOT MERGER!

  • Python wrapper
  • CPU
    • Forward pass
  • CUDA
    • Forward pass
    • Backward pass
  • Tests
  • Documentation

@raimis raimis self-assigned this Mar 3, 2022
@peastman
Copy link
Collaborator

You've structured the kernel so that every thread computes only a single interaction:

    const int32_t index = blockIdx.x * blockDim.x + threadIdx.x;
    if (index >= num_all_pairs) return;

    int32_t row = floor((sqrtf(8 * index + 1) + 1) / 2);
    if (row * (row - 1) > 2 * index) row--;
    const int32_t column = index - row * (row - 1) / 2;

    const scalar_t delta_x = positions[row][0] - positions[column][0];
    const scalar_t delta_y = positions[row][1] - positions[column][1];
    const scalar_t delta_z = positions[row][2] - positions[column][2];

Usually it's better to use a smaller number of thread blocks and have each thread loop over interactions. For one thing, there's overhead to each thread block. For another, it allows lots of optimization. In the above code, if you can arrange that each thread will compute multiple pairs all in the same row, then you can skip the row and column computations, and also you only need to load positions[row] once.

Of course, it all depends what size you're optimizing for. With 50 atoms, the number of pairs is much too small to fill a large GPU even with only one pair per thread. For larger systems with thousands of atoms and millions of pairs, it will make more of a difference.

@raimis
Copy link
Collaborator Author

raimis commented May 18, 2022

This PR is discontinued. The code is being move to NNPOps (openmm/NNPOps#58)

@raimis raimis marked this pull request as draft May 17, 2023 13:22
@raimis
Copy link
Collaborator Author

raimis commented Jan 4, 2024

This is obsolted

@raimis raimis closed this Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants