-
Notifications
You must be signed in to change notification settings - Fork 1
add common nonbonded force kernel #72
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
base: feature/qgpu
Are you sure you want to change the base?
Changes from all commits
559e2e3
1b55f75
ceec572
455fa53
43deca1
3c13a21
fbab8ad
b216862
7a804b8
5d7422b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #pragma once | ||
| #include "system.h" | ||
|
|
||
| void init_nonbonded_force_kernel_data(); | ||
|
|
||
| std::pair<double, double> calc_nonbonded_force_host( | ||
| int nx, | ||
| int ny, | ||
| int* x_idx_list, | ||
| int* y_idx_list, | ||
| bool symmetric, | ||
|
|
||
| const int* x_charges_types, | ||
| const int* y_charges_types, | ||
| const ccharge_t* ccharges_table, | ||
|
|
||
| const int* x_atypes_types, | ||
| const int* y_atypes_types, | ||
| const catype_t* catypes_table, | ||
| bool disable_water_h_lj = false | ||
| ); | ||
|
|
||
| void cleanup_nonbonded_force(); |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -21,7 +21,6 @@ void CudaContext::init() { | |||
| check_cudaMalloc((void**)&d_atypes, sizeof(atype_t) * n_atypes); | ||||
| check_cudaMalloc((void**)&d_catypes, sizeof(catype_t) * n_catypes); | ||||
|
|
||||
|
|
||||
| check_cudaMalloc((void**)&d_q_atoms, sizeof(q_atom_t) * n_qatoms); | ||||
| check_cudaMalloc((void**)&d_q_charges, sizeof(q_charge_t) * n_qatoms * n_lambdas); | ||||
| check_cudaMalloc((void**)&d_LJ_matrix, sizeof(int) * n_atoms_solute * n_atoms_solute); | ||||
|
|
@@ -54,6 +53,10 @@ void CudaContext::init() { | |||
| check_cudaMalloc((void**)&d_charges, sizeof(charge_t) * n_charges); | ||||
| check_cudaMalloc((void**)&d_p_atoms, sizeof(p_atom_t) * n_patoms); | ||||
|
|
||||
| initialize_atom_lists_host(); | ||||
| initialize_charge_tables_host(); | ||||
| initialize_catype_tables_host(); | ||||
|
|
||||
| sync_all_to_device(); | ||||
| } | ||||
|
|
||||
|
|
@@ -208,10 +211,251 @@ void CudaContext::free() { | |||
| cudaFree(d_ccharges); | ||||
| cudaFree(d_charges); | ||||
| cudaFree(d_p_atoms); | ||||
| cudaFree(d_charge_table_all); | ||||
| cudaFree(d_catype_table_all); | ||||
| cudaFree(d_p_charge_types); | ||||
| cudaFree(d_w_charge_types); | ||||
| cudaFree(d_q_charge_types); | ||||
| cudaFree(d_p_catype_types); | ||||
| cudaFree(d_w_catype_types); | ||||
| cudaFree(d_q_catype_types); | ||||
|
|
||||
| d_charge_table_all = nullptr; | ||||
| d_catype_table_all = nullptr; | ||||
| d_p_charge_types = nullptr; | ||||
| d_w_charge_types = nullptr; | ||||
| d_q_charge_types = nullptr; | ||||
| d_p_catype_types = nullptr; | ||||
| d_w_catype_types = nullptr; | ||||
| d_q_catype_types = nullptr; | ||||
| } | ||||
|
|
||||
| void CudaContext::reset_energies() { | ||||
| cudaMemset(d_dvelocities, 0, sizeof(dvel_t) * n_atoms); | ||||
| cudaMemset(d_EQ_nonbond_qq, 0, sizeof(E_nonbonded_t) * n_lambdas); | ||||
| cudaMemset(d_EQ_restraint, 0, sizeof(E_restraint_t) * n_lambdas); | ||||
| } | ||||
|
|
||||
| void CudaContext::initialize_atom_lists_host() { | ||||
| h_p_atoms_list.clear(); | ||||
| for (int i = 0; i < n_patoms; i++) { | ||||
| int id = p_atoms[i].a - 1; | ||||
| if (!excluded[id]) { | ||||
| h_p_atoms_list.push_back(id); | ||||
| } | ||||
| } | ||||
|
|
||||
| h_w_atoms_list.clear(); | ||||
| for (int i = n_atoms_solute; i < n_atoms; i++) { | ||||
| int id = i; | ||||
| if (!excluded[id]) { | ||||
| h_w_atoms_list.push_back(id); | ||||
| } | ||||
| } | ||||
| printf("Number of water atoms: %d, number of all water atoms: %d\n", (int)h_w_atoms_list.size(), n_atoms - n_atoms_solute); | ||||
|
||||
| printf("Number of water atoms: %d, number of all water atoms: %d\n", (int)h_w_atoms_list.size(), n_atoms - n_atoms_solute); |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debug print statement left in production code. This should be removed or placed behind a debug flag to avoid cluttering logs.
| printf("Total water atom number: %d, w_catype_types size: %lu\n", h_w_atoms_size, w_catype_types.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing cudaFree calls for d_p_atoms_list, d_w_atoms_list, and d_q_atoms_list. These device memory allocations are created in initialize_atom_lists_host but never freed, causing a memory leak.