GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Allowing SHAKE/RATTLE constraints on GPU simulation by Omar-Elrefaei · Pull Request #175 · JuliaMolSim/Molly.jl

Conversation

@Omar-Elrefaei

@Omar-Elrefaei Omar-Elrefaei commented Apr 25, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

As discussed I've adapted the constraint code to allow for GPU simulation.

testing with the protein simulation in `benchmarks.jl`
using Molly, DelimitedFiles, Test
data_dir = normpath("./data")
ff = MolecularForceField(
    joinpath(data_dir, "force_fields", "ff99SBildn.xml"),
    joinpath(data_dir, "force_fields", "tip3p_standard.xml"),
    joinpath(data_dir, "force_fields", "his.xml"),
)

# takes more than 40s
sys_init = System(joinpath(data_dir, "6mrr_equil.pdb"), ff; gpu=false)
sys_init_gpu = System(joinpath(data_dir, "6mrr_equil.pdb"), ff; gpu=true)

function protein(sys_init; is_constrained=false, nsteps=100)
    println("Constraints $is_constrained, GPU $(is_on_gpu(sys_init)), nsteps $nsteps")
    constraints = []
    bond_length = 0.0872u"nm"
    for i in 1171:3:15952
        push!(constraints, DistanceConstraint(i, i + 1, bond_length))
        push!(constraints, DistanceConstraint(i, i + 2, bond_length))
    end
    if is_constrained
        cons = (SHAKE_RATTLE([constraints...], length(sys_init), 1e-4u"nm", 1e-4u"nm^2 * ps^-1"),)
        sys_init = System(sys_init; constraints=cons)
    end

    sim = VelocityVerlet(dt=0.001u"ps")
    @time "Protein Simulation" simulate!(sys_init, sim, nsteps)
end

Note: the last example is not supported and crashes on master

julia> protein(sys_cpu, is_constrained=false);
Constraints false, GPU false 
Protein Simulation: 10.376156 seconds (4.97 k allocations: 623.307 MiB) 

julia> protein(sys_cpu, is_constrained=true); 
 Constraints true, GPU false 
Protein Simulation: 10.236894 seconds (5.17 k allocations: 660.505 MiB)

julia> protein(sys_gpu, is_constrained=false);
Constraints false, GPU true
Protein Simulation:  1.846926 seconds (129.68 k allocations: 198.061 MiB)

julia> protein(sys_gpu, is_constrained=true);
Constraints true, GPU true
Protein Simulation: 1.654842 seconds (242.76 k allocations: 200.673 MiB)

I'm submitting a draft PR, because there is a few concerns I was to attend to first before this is ready.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Omar-Elrefaei and others added 3 commits April 17, 2024 16:36
@Omar-Elrefaei
initial setup to allow GPU simulation with constraints
eebb7e5
(this gpu path currently severely underperforms cpu)
@Omar-Elrefaei
add proper implementation for constraints on GPU
759c192
the core algorithms remains the same
the comments about "# Cannot parallelize this" was deemed to be about
parallelizing the computation of constraints inside a cluster not different clusters
@Omar-Elrefaei
Merge branch 'JuliaMolSim:master' into master
6a7e014
@codecov

codecov Bot commented Apr 25, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 45.71429% with 57 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.81%. Comparing base (b769838) to head (6a7e014).
⚠️ Report is 366 commits behind head on master.

Files with missing lines Patch % Lines
src/constraints/shake.jl 45.19% 57 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #175      +/-   ##
==========================================
- Coverage   72.55%   71.81%   -0.75%     
==========================================
  Files          36       36              
  Lines        5481     5542      +61     
==========================================
+ Hits         3977     3980       +3     
- Misses       1504     1562      +58     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jgreener64

jgreener64 commented Apr 26, 2024

Copy link
Copy Markdown
Member

Looks like a great start.

Would be good to change the existing test to run on GPU too.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ejmeitz

ejmeitz commented Aug 13, 2025

Copy link
Copy Markdown
Collaborator

Closed by #200

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ejmeitz ejmeitz closed this Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@Omar-Elrefaei @jgreener64 @ejmeitz
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.