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

Some fixes for cudaCoord (group-to-group) #1152

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
326 changes: 179 additions & 147 deletions plugins/cudaCoord/Coordination.cu

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions plugins/cudaCoord/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,42 @@ This is the optimized version of the lesson that I presented in the [plumed-scho
The files `cudaHelpers.cuh` and `cudaHelpers.cu` contains a few support functions for helping in interfacing `PLMD::Vector` and `PLMD::Tensor` with Cuda's thrust,
along with the reduction functions baked with Cuda's cub building blocks and their drivers.

### Compile



##### as developer

With a ready to run plumed:
- `nvcc-MakeFile.sh`
- `make`

In this way you do not need to recompile everithing if you change part of the sources

you may need to specify the SM of your GPU by modifying the `Makefile`, for example with:

```Makefile
NVCCCFLAGS = -dc -dlto --gpu-architecture=sm_75
NVCCLDFLAGS = -shared -dlto --gpu-architecture=sm_75
```
If you are using a T1000

#### as a user

Running `nvcc-mklib.sh` should be enought to get the `CudaCoordination.so`.

you may need to uncomment and modifly the lines
```bash
#compile="$compile --gpu-architecture=sm_75 "
#link_command="$link_command -shared -dlto --gpu-architecture=sm_75"
```
near the bottom of the script

### How to tests

- `cd regtest; ln -s ../../../regtest/scripts .`
- `make check`

## Limitations

`CUDACOORDINATION` and `CUDACOORDINATIONFLOAT` work more or less as the standard `COORDINATION`, except from:
Expand Down
7 changes: 7 additions & 0 deletions plugins/cudaCoord/nvcc-mklib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ for opt in -f; do
link_command=${link_command//${opt}/-Xcompiler ${opt}}
done

#this may be necessary for succesfully run on your GPU
# search your GPU here https://developer.nvidia.com/cuda-gpus and specify sm_number
# where "number" is the compute capability with no dots (the T1000 has CC of 7.5, so you write sm_75)

#compile="$compile --gpu-architecture=sm_75 "
#link_command="$link_command -shared -dlto --gpu-architecture=sm_75"

eval "$compile" -o "$obj" "$file" && \
eval "$compile" -o "ndReduction.o" "ndReduction.cu" && \
eval "$link_command" -o "$lib" "ndReduction.o" "$obj"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
LOAD FILE=../../../../CudaCoordination.so
gpu: CUDACOORDINATION GROUPA=1-108,1-108 GROUPB=1-108,1-108 R_0=1 NOPBC
gpu512: CUDACOORDINATION GROUPA=1-108,1-108 GROUPB=1-108,1-108 R_0=1 THREADS=512 NOPBC
gpu256: CUDACOORDINATION GROUPA=1-108,1-108 GROUPB=1-108,1-108 R_0=1 THREADS=256 NOPBC
gpu128: CUDACOORDINATION GROUPA=1-108,1-108 GROUPB=1-108,1-108 R_0=1 THREADS=128 NOPBC
gpu64: CUDACOORDINATION GROUPA=1-108,1-108 GROUPB=1-108,1-108 R_0=1 THREADS=64 NOPBC
cpu: COORDINATION GROUPA=1-108,1-108 GROUPB=1-108,1-108 R_0=1 NOPBC
gpu: CUDACOORDINATION GROUPA=108-1:-1,108-50:-1,1-49 GROUPB=1-108,1-108 R_0=1 NOPBC
gpu512: CUDACOORDINATION GROUPA=108-1:-1,108-50:-1,1-49 GROUPB=1-108,1-108 R_0=1 THREADS=512 NOPBC
gpu256: CUDACOORDINATION GROUPA=108-1:-1,108-50:-1,1-49 GROUPB=1-108,1-108 R_0=1 THREADS=256 NOPBC
gpu128: CUDACOORDINATION GROUPA=108-1:-1,108-50:-1,1-49 GROUPB=1-108,1-108 R_0=1 THREADS=128 NOPBC
gpu64: CUDACOORDINATION GROUPA=108-1:-1,108-50:-1,1-49 GROUPB=1-108,1-108 R_0=1 THREADS=64 NOPBC
cpu: COORDINATION GROUPA=108-1:-1,108-50:-1,1-49 GROUPB=1-108,1-108 R_0=1 NOPBC

diff: CUSTOM ARG=gpu,cpu FUNC=y-x PERIODIC=NO
diff: CUSTOM ARG=gpu,cpu FUNC=y-x PERIODIC=NO
diff512: CUSTOM ARG=gpu512,cpu FUNC=y-x PERIODIC=NO
diff256: CUSTOM ARG=gpu256,cpu FUNC=y-x PERIODIC=NO
diff128: CUSTOM ARG=gpu128,cpu FUNC=y-x PERIODIC=NO
diff64: CUSTOM ARG=gpu64,cpu FUNC=y-x PERIODIC=NO
diff64: CUSTOM ARG=gpu64,cpu FUNC=y-x PERIODIC=NO

#PRINT ARG=gpu,cpu FILE=colvar FMT=%8.4f STRIDE=1
PRINT ARG=diff FILE=colvar FMT=%8.4f STRIDE=1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../../scripts/test.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! FIELDS time diff
0.000000 -0.0000
1.000000 0.0000
2.000000 0.0000
3.000000 0.0000
4.000000 -0.0000
5.000000 -0.0000
6.000000 -0.0000
7.000000 -0.0000
8.000000 -0.0000
9.000000 -0.0000
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type=driver
# this is to test a different name
arg="--plumed plumed.dat --ixyz traj-ortho.xyz"

plumed_regtest_after() {
{
echo '#! FIELDS time parameter cpu-gpu'
awk 'NR>1{print $1, $2, $4-$3} ' <deriv
} >deriv_delta
}
extra_files="../../trajectories/traj-ortho.xyz"
Loading