Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
3b8df952
Unverified
Commit
3b8df952
authored
Sep 05, 2024
by
Peter Eastman
Committed by
GitHub
Sep 05, 2024
Browse files
Merge pull request #4632 from ex-rzr/make-hip-standard-platform
HIP platform
parents
5ce6a85d
28fb2918
Changes
128
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1470 additions
and
1 deletion
+1470
-1
platforms/hip/tests/TestHipMonteCarloAnisotropicBarostat.cpp
platforms/hip/tests/TestHipMonteCarloAnisotropicBarostat.cpp
+37
-0
platforms/hip/tests/TestHipMonteCarloBarostat.cpp
platforms/hip/tests/TestHipMonteCarloBarostat.cpp
+38
-0
platforms/hip/tests/TestHipMonteCarloFlexibleBarostat.cpp
platforms/hip/tests/TestHipMonteCarloFlexibleBarostat.cpp
+37
-0
platforms/hip/tests/TestHipMultipleForces.cpp
platforms/hip/tests/TestHipMultipleForces.cpp
+114
-0
platforms/hip/tests/TestHipNonbondedForce.cpp
platforms/hip/tests/TestHipNonbondedForce.cpp
+193
-0
platforms/hip/tests/TestHipNoseHooverIntegrator.cpp
platforms/hip/tests/TestHipNoseHooverIntegrator.cpp
+37
-0
platforms/hip/tests/TestHipPeriodicTorsionForce.cpp
platforms/hip/tests/TestHipPeriodicTorsionForce.cpp
+66
-0
platforms/hip/tests/TestHipRBTorsionForce.cpp
platforms/hip/tests/TestHipRBTorsionForce.cpp
+66
-0
platforms/hip/tests/TestHipRMSDForce.cpp
platforms/hip/tests/TestHipRMSDForce.cpp
+37
-0
platforms/hip/tests/TestHipRandom.cpp
platforms/hip/tests/TestHipRandom.cpp
+150
-0
platforms/hip/tests/TestHipSettle.cpp
platforms/hip/tests/TestHipSettle.cpp
+37
-0
platforms/hip/tests/TestHipSort.cpp
platforms/hip/tests/TestHipSort.cpp
+132
-0
platforms/hip/tests/TestHipVariableLangevinIntegrator.cpp
platforms/hip/tests/TestHipVariableLangevinIntegrator.cpp
+37
-0
platforms/hip/tests/TestHipVariableVerletIntegrator.cpp
platforms/hip/tests/TestHipVariableVerletIntegrator.cpp
+37
-0
platforms/hip/tests/TestHipVerletIntegrator.cpp
platforms/hip/tests/TestHipVerletIntegrator.cpp
+37
-0
platforms/hip/tests/TestHipVirtualSites.cpp
platforms/hip/tests/TestHipVirtualSites.cpp
+144
-0
plugins/amoeba/CMakeLists.txt
plugins/amoeba/CMakeLists.txt
+14
-1
plugins/amoeba/platforms/hip/CMakeLists.txt
plugins/amoeba/platforms/hip/CMakeLists.txt
+113
-0
plugins/amoeba/platforms/hip/include/AmoebaHipKernelFactory.h
...ins/amoeba/platforms/hip/include/AmoebaHipKernelFactory.h
+46
-0
plugins/amoeba/platforms/hip/src/AmoebaHipKernelFactory.cpp
plugins/amoeba/platforms/hip/src/AmoebaHipKernelFactory.cpp
+98
-0
No files found.
platforms/hip/tests/TestHipMonteCarloAnisotropicBarostat.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2015 Stanford University and the Authors. *
* Portions copyright (c) 2020 Advanced Micro Devices, Inc. *
* Authors: Peter Eastman, Nicholas Curtis *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "HipTests.h"
#include "TestMonteCarloAnisotropicBarostat.h"
void
runPlatformTests
()
{
}
platforms/hip/tests/TestHipMonteCarloBarostat.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2015 Stanford University and the Authors. *
* Portions copyright (c) 2020 Advanced Micro Devices, Inc. *
* Authors: Peter Eastman, Nicholas Curtis *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "HipTests.h"
#include "TestMonteCarloBarostat.h"
void
runPlatformTests
()
{
testWater
();
}
platforms/hip/tests/TestHipMonteCarloFlexibleBarostat.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2021 Stanford University and the Authors. *
* Portions copyright (c) 2021 Advanced Micro Devices, Inc. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "HipTests.h"
#include "TestMonteCarloFlexibleBarostat.h"
void
runPlatformTests
()
{
}
platforms/hip/tests/TestHipMultipleForces.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2011-2012 Stanford University and the Authors. *
* Portions copyright (c) 2020 Advanced Micro Devices, Inc. *
* Authors: Peter Eastman, Nicholas Curtis *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
/**
* This tests a system with multiple forces, to make sure HipBondedUtilities is
* processing them correctly.
*/
#include "openmm/internal/AssertionUtilities.h"
#include "openmm/Context.h"
#include "HipPlatform.h"
#include "ReferencePlatform.h"
#include "openmm/HarmonicAngleForce.h"
#include "openmm/HarmonicBondForce.h"
#include "openmm/PeriodicTorsionForce.h"
#include "openmm/RBTorsionForce.h"
#include "openmm/System.h"
#include "openmm/VerletIntegrator.h"
#include "SimTKOpenMMRealType.h"
#include "sfmt/SFMT.h"
#include <iostream>
#include <vector>
using
namespace
OpenMM
;
using
namespace
std
;
HipPlatform
platform
;
const
double
TOL
=
1e-4
;
void
testForces
()
{
const
int
numParticles
=
100
;
System
system
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
system
.
addParticle
(
1.0
);
HarmonicBondForce
*
bonds
=
new
HarmonicBondForce
();
for
(
int
i
=
0
;
i
<
numParticles
-
1
;
i
++
)
bonds
->
addBond
(
i
,
i
+
1
,
1.0
,
1.5
);
system
.
addForce
(
bonds
);
HarmonicAngleForce
*
angles
=
new
HarmonicAngleForce
();
for
(
int
i
=
0
;
i
<
numParticles
-
2
;
i
++
)
angles
->
addAngle
(
i
,
i
+
1
,
i
+
2
,
2.0
,
1.5
);
system
.
addForce
(
angles
);
PeriodicTorsionForce
*
periodic
=
new
PeriodicTorsionForce
();
for
(
int
i
=
0
;
i
<
numParticles
-
3
;
i
++
)
periodic
->
addTorsion
(
i
,
i
+
1
,
i
+
2
,
i
+
3
,
2
,
PI_M
/
3
,
1.1
);
system
.
addForce
(
periodic
);
RBTorsionForce
*
rb
=
new
RBTorsionForce
();
for
(
int
i
=
0
;
i
<
numParticles
-
3
;
i
+=
3
)
rb
->
addTorsion
(
i
,
i
+
1
,
i
+
2
,
i
+
3
,
1.0
,
1.1
,
1.2
,
0.3
,
0.4
,
0.5
);
system
.
addForce
(
rb
);
ReferencePlatform
ref
;
VerletIntegrator
integrator1
(
0.01
);
Context
context1
(
system
,
integrator1
,
ref
);
VerletIntegrator
integrator2
(
0.01
);
Context
context2
(
system
,
integrator2
,
platform
);
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
vector
<
Vec3
>
positions
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
positions
[
i
]
=
Vec3
(
i
,
genrand_real2
(
sfmt
),
genrand_real2
(
sfmt
));
context1
.
setPositions
(
positions
);
context2
.
setPositions
(
positions
);
State
state1
=
context1
.
getState
(
State
::
Forces
|
State
::
Energy
);
State
state2
=
context2
.
getState
(
State
::
Forces
|
State
::
Energy
);
const
vector
<
Vec3
>&
forces1
=
state1
.
getForces
();
const
vector
<
Vec3
>&
forces2
=
state2
.
getForces
();
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
ASSERT_EQUAL_VEC
(
forces1
[
i
],
forces2
[
i
],
TOL
);
ASSERT_EQUAL_TOL
(
state1
.
getPotentialEnergy
(),
state2
.
getPotentialEnergy
(),
TOL
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"HipPrecision"
,
string
(
argv
[
1
]));
testForces
();
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
return
1
;
}
cout
<<
"Done"
<<
endl
;
return
0
;
}
platforms/hip/tests/TestHipNonbondedForce.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2021 Stanford University and the Authors. *
* Portions copyright (c) 2020 Advanced Micro Devices, Inc. *
* Authors: Peter Eastman, Nicholas Curtis *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "HipTests.h"
#include "TestNonbondedForce.h"
#include <hip/hip_runtime.h>
void
testParallelComputation
(
NonbondedForce
::
NonbondedMethod
method
)
{
System
system
;
const
int
numParticles
=
200
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
system
.
addParticle
(
1.0
);
NonbondedForce
*
force
=
new
NonbondedForce
();
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
force
->
addParticle
(
i
%
2
-
0.5
,
0.5
,
1.0
);
force
->
setNonbondedMethod
(
method
);
system
.
addForce
(
force
);
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
5
,
0
,
0
),
Vec3
(
0
,
5
,
0
),
Vec3
(
0
,
0
,
5
));
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
vector
<
Vec3
>
positions
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
positions
[
i
]
=
Vec3
(
5
*
genrand_real2
(
sfmt
),
5
*
genrand_real2
(
sfmt
),
5
*
genrand_real2
(
sfmt
));
force
->
addGlobalParameter
(
"scale"
,
0.5
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
for
(
int
j
=
0
;
j
<
i
;
++
j
)
{
Vec3
delta
=
positions
[
i
]
-
positions
[
j
];
if
(
delta
.
dot
(
delta
)
<
0.1
)
{
force
->
addException
(
i
,
j
,
0
,
1
,
0
);
}
else
if
(
delta
.
dot
(
delta
)
<
0.2
)
{
int
index
=
force
->
addException
(
i
,
j
,
0.5
,
1
,
1.0
);
force
->
addExceptionParameterOffset
(
"scale"
,
index
,
0.5
,
0.4
,
0.3
);
}
}
// Create two contexts, one with a single device and one with two devices.
VerletIntegrator
integrator1
(
0.01
);
Context
context1
(
system
,
integrator1
,
platform
);
context1
.
setPositions
(
positions
);
State
state1
=
context1
.
getState
(
State
::
Forces
|
State
::
Energy
);
VerletIntegrator
integrator2
(
0.01
);
string
deviceIndex
=
platform
.
getPropertyValue
(
context1
,
HipPlatform
::
HipDeviceIndex
());
map
<
string
,
string
>
props
;
props
[
HipPlatform
::
HipDeviceIndex
()]
=
deviceIndex
+
","
+
deviceIndex
;
Context
context2
(
system
,
integrator2
,
platform
,
props
);
context2
.
setPositions
(
positions
);
State
state2
=
context2
.
getState
(
State
::
Forces
|
State
::
Energy
);
// See if they agree.
ASSERT_EQUAL_TOL
(
state1
.
getPotentialEnergy
(),
state2
.
getPotentialEnergy
(),
1e-5
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
// Modify some particle parameters and see if they still agree.
for
(
int
i
=
0
;
i
<
numParticles
;
i
+=
5
)
{
double
charge
,
sigma
,
epsilon
;
force
->
getParticleParameters
(
i
,
charge
,
sigma
,
epsilon
);
force
->
setParticleParameters
(
i
,
0.9
*
charge
,
sigma
,
epsilon
);
}
force
->
updateParametersInContext
(
context1
);
force
->
updateParametersInContext
(
context2
);
state1
=
context1
.
getState
(
State
::
Forces
|
State
::
Energy
);
state2
=
context2
.
getState
(
State
::
Forces
|
State
::
Energy
);
ASSERT_EQUAL_TOL
(
state1
.
getPotentialEnergy
(),
state2
.
getPotentialEnergy
(),
1e-5
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
}
void
testReordering
()
{
// Check that reordering of atoms doesn't alter their positions.
const
int
numParticles
=
200
;
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
6
,
0
,
0
),
Vec3
(
2.1
,
6
,
0
),
Vec3
(
-
1.5
,
-
0.5
,
6
));
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
PME
);
system
.
addForce
(
nonbonded
);
vector
<
Vec3
>
positions
;
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
system
.
addParticle
(
1.0
);
nonbonded
->
addParticle
(
0.0
,
0.0
,
0.0
);
positions
.
push_back
(
Vec3
(
genrand_real2
(
sfmt
)
-
0.5
,
genrand_real2
(
sfmt
)
-
0.5
,
genrand_real2
(
sfmt
)
-
0.5
)
*
20
);
}
VerletIntegrator
integrator
(
0.001
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
integrator
.
step
(
1
);
State
state
=
context
.
getState
(
State
::
Positions
|
State
::
Velocities
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
ASSERT_EQUAL_VEC
(
positions
[
i
],
state
.
getPositions
()[
i
],
1e-6
);
}
}
void
testDeterministicForces
()
{
// Check that the HipDeterministicForces property works correctly.
const
int
numParticles
=
1000
;
System
system
;
system
.
setDefaultPeriodicBoxVectors
(
Vec3
(
6
,
0
,
0
),
Vec3
(
2.1
,
6
,
0
),
Vec3
(
-
1.5
,
-
0.5
,
6
));
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
PME
);
system
.
addForce
(
nonbonded
);
vector
<
Vec3
>
positions
;
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
system
.
addParticle
(
1.0
);
nonbonded
->
addParticle
(
i
%
2
==
0
?
1
:
-
1
,
1
,
0
);
positions
.
push_back
(
Vec3
(
genrand_real2
(
sfmt
)
-
0.5
,
genrand_real2
(
sfmt
)
-
0.5
,
genrand_real2
(
sfmt
)
-
0.5
)
*
6
);
}
VerletIntegrator
integrator
(
0.001
);
map
<
string
,
string
>
properties
;
properties
[
HipPlatform
::
HipDeterministicForces
()]
=
"true"
;
Context
context
(
system
,
integrator
,
platform
,
properties
);
context
.
setPositions
(
positions
);
State
state1
=
context
.
getState
(
State
::
Forces
);
State
state2
=
context
.
getState
(
State
::
Forces
);
// All forces should be *exactly* equal.
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
ASSERT_EQUAL
(
state1
.
getForces
()[
i
][
0
],
state2
.
getForces
()[
i
][
0
]);
ASSERT_EQUAL
(
state1
.
getForces
()[
i
][
1
],
state2
.
getForces
()[
i
][
1
]);
ASSERT_EQUAL
(
state1
.
getForces
()[
i
][
2
],
state2
.
getForces
()[
i
][
2
]);
}
}
bool
canRunHugeTest
()
{
// Create a minimal context just to see which device is being used.
System
system
;
system
.
addParticle
(
1.0
);
VerletIntegrator
integrator
(
1.0
);
Context
context
(
system
,
integrator
,
platform
);
int
deviceIndex
=
stoi
(
platform
.
getPropertyValue
(
context
,
HipPlatform
::
HipDeviceIndex
()));
// Find out how much memory the device has.
hipDevice_t
device
;
hipDeviceGet
(
&
device
,
deviceIndex
);
size_t
memory
;
hipDeviceTotalMem
(
&
memory
,
device
);
// Only run the huge test if the device has at least 4 GB of memory.
return
(
memory
>=
4
*
(
size_t
(
1
)
<<
30
));
}
void
runPlatformTests
()
{
testParallelComputation
(
NonbondedForce
::
NoCutoff
);
testParallelComputation
(
NonbondedForce
::
Ewald
);
testParallelComputation
(
NonbondedForce
::
PME
);
testParallelComputation
(
NonbondedForce
::
LJPME
);
testReordering
();
testDeterministicForces
();
if
(
canRunHugeTest
())
testHugeSystem
();
}
platforms/hip/tests/TestHipNoseHooverIntegrator.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2019 Stanford University and the Authors. *
* Portions copyright (c) 2020 Advanced Micro Devices, Inc. *
* Authors: Andreas Krämer and Andrew C. Simmmonett *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "HipTests.h"
#include "TestNoseHooverIntegrator.h"
void
runPlatformTests
()
{
}
platforms/hip/tests/TestHipPeriodicTorsionForce.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2015 Stanford University and the Authors. *
* Portions copyright (c) 2020 Advanced Micro Devices, Inc. *
* Authors: Peter Eastman, Nicholas Curtis *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "HipTests.h"
#include "TestPeriodicTorsionForce.h"
void
testParallelComputation
()
{
System
system
;
const
int
numParticles
=
200
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
system
.
addParticle
(
1.0
);
PeriodicTorsionForce
*
force
=
new
PeriodicTorsionForce
();
for
(
int
i
=
3
;
i
<
numParticles
;
i
++
)
force
->
addTorsion
(
i
-
3
,
i
-
2
,
i
-
1
,
i
,
2
,
1.1
,
i
);
system
.
addForce
(
force
);
vector
<
Vec3
>
positions
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
positions
[
i
]
=
Vec3
(
i
,
i
%
2
,
i
%
3
);
VerletIntegrator
integrator1
(
0.01
);
Context
context1
(
system
,
integrator1
,
platform
);
context1
.
setPositions
(
positions
);
State
state1
=
context1
.
getState
(
State
::
Forces
|
State
::
Energy
);
VerletIntegrator
integrator2
(
0.01
);
string
deviceIndex
=
platform
.
getPropertyValue
(
context1
,
HipPlatform
::
HipDeviceIndex
());
map
<
string
,
string
>
props
;
props
[
HipPlatform
::
HipDeviceIndex
()]
=
deviceIndex
+
","
+
deviceIndex
;
Context
context2
(
system
,
integrator2
,
platform
,
props
);
context2
.
setPositions
(
positions
);
State
state2
=
context2
.
getState
(
State
::
Forces
|
State
::
Energy
);
ASSERT_EQUAL_TOL
(
state1
.
getPotentialEnergy
(),
state2
.
getPotentialEnergy
(),
1e-5
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
}
void
runPlatformTests
()
{
testParallelComputation
();
}
platforms/hip/tests/TestHipRBTorsionForce.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2015 Stanford University and the Authors. *
* Portions copyright (c) 2020 Advanced Micro Devices, Inc. *
* Authors: Peter Eastman, Nicholas Curtis *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "HipTests.h"
#include "TestRBTorsionForce.h"
void
testParallelComputation
()
{
System
system
;
const
int
numParticles
=
200
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
system
.
addParticle
(
1.0
);
RBTorsionForce
*
force
=
new
RBTorsionForce
();
for
(
int
i
=
3
;
i
<
numParticles
;
i
++
)
force
->
addTorsion
(
i
-
3
,
i
-
2
,
i
-
1
,
i
,
2
,
0.1
*
i
,
0.5
*
i
,
i
,
1
,
1
);
system
.
addForce
(
force
);
vector
<
Vec3
>
positions
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
positions
[
i
]
=
Vec3
(
i
,
i
%
2
,
i
%
3
);
VerletIntegrator
integrator1
(
0.01
);
Context
context1
(
system
,
integrator1
,
platform
);
context1
.
setPositions
(
positions
);
State
state1
=
context1
.
getState
(
State
::
Forces
|
State
::
Energy
);
VerletIntegrator
integrator2
(
0.01
);
string
deviceIndex
=
platform
.
getPropertyValue
(
context1
,
HipPlatform
::
HipDeviceIndex
());
map
<
string
,
string
>
props
;
props
[
HipPlatform
::
HipDeviceIndex
()]
=
deviceIndex
+
","
+
deviceIndex
;
Context
context2
(
system
,
integrator2
,
platform
,
props
);
context2
.
setPositions
(
positions
);
State
state2
=
context2
.
getState
(
State
::
Forces
|
State
::
Energy
);
ASSERT_EQUAL_TOL
(
state1
.
getPotentialEnergy
(),
state2
.
getPotentialEnergy
(),
1e-5
);
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
ASSERT_EQUAL_VEC
(
state1
.
getForces
()[
i
],
state2
.
getForces
()[
i
],
1e-5
);
}
void
runPlatformTests
()
{
testParallelComputation
();
}
platforms/hip/tests/TestHipRMSDForce.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2018 Stanford University and the Authors. *
* Portions copyright (c) 2020 Advanced Micro Devices, Inc. *
* Authors: Peter Eastman, Nicholas Curtis *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "HipTests.h"
#include "TestRMSDForce.h"
void
runPlatformTests
()
{
}
platforms/hip/tests/TestHipRandom.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Portions copyright (c) 2020 Advanced Micro Devices, Inc. *
* Authors: Peter Eastman, Nicholas Curtis *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
/**
* This tests the Hip implementation of random number generation.
*/
#include "openmm/internal/AssertionUtilities.h"
#include "HipArray.h"
#include "HipContext.h"
#include "HipIntegrationUtilities.h"
#include "openmm/System.h"
#include "openmm/Context.h"
#include "HipPlatform.h"
#include "openmm/VerletIntegrator.h"
#include "SimTKOpenMMRealType.h"
#include <iostream>
using
namespace
OpenMM
;
using
namespace
std
;
HipPlatform
platform
;
void
testGaussian
()
{
int
numAtoms
=
5000
;
System
system
;
for
(
int
i
=
0
;
i
<
numAtoms
;
i
++
)
system
.
addParticle
(
1.0
);
HipPlatform
::
PlatformData
platformData
(
NULL
,
system
,
""
,
"true"
,
platform
.
getPropertyDefaultValue
(
"HipPrecision"
),
"false"
,
platform
.
getPropertyDefaultValue
(
HipPlatform
::
HipTempDirectory
()),
platform
.
getPropertyDefaultValue
(
HipPlatform
::
HipDisablePmeStream
()),
"false"
,
1
,
NULL
);
HipContext
&
context
=
*
platformData
.
contexts
[
0
];
context
.
initialize
();
context
.
setAsCurrent
();
context
.
getIntegrationUtilities
().
initRandomNumberGenerator
(
0
);
HipArray
&
random
=
context
.
getIntegrationUtilities
().
getRandom
();
context
.
getIntegrationUtilities
().
prepareRandomNumbers
(
random
.
getSize
());
const
int
numValues
=
random
.
getSize
()
*
4
;
vector
<
float4
>
values
(
numValues
);
random
.
download
(
values
);
float
*
data
=
reinterpret_cast
<
float
*>
(
&
values
[
0
]);
double
mean
=
0.0
;
double
var
=
0.0
;
double
skew
=
0.0
;
double
kurtosis
=
0.0
;
for
(
int
i
=
0
;
i
<
numValues
;
i
++
)
{
double
value
=
data
[
i
];
mean
+=
value
;
var
+=
value
*
value
;
skew
+=
value
*
value
*
value
;
kurtosis
+=
value
*
value
*
value
*
value
;
}
mean
/=
numValues
;
var
/=
numValues
;
skew
/=
numValues
;
kurtosis
/=
numValues
;
double
c2
=
var
-
mean
*
mean
;
double
c3
=
skew
-
3
*
var
*
mean
+
2
*
mean
*
mean
*
mean
;
double
c4
=
kurtosis
-
4
*
skew
*
mean
-
3
*
var
*
var
+
12
*
var
*
mean
*
mean
-
6
*
mean
*
mean
*
mean
*
mean
;
ASSERT_EQUAL_TOL
(
0.0
,
mean
,
3.0
/
sqrt
((
double
)
numValues
));
ASSERT_EQUAL_TOL
(
1.0
,
c2
,
3.0
/
pow
(
numValues
,
1.0
/
3.0
));
ASSERT_EQUAL_TOL
(
0.0
,
c3
,
3.0
/
pow
(
numValues
,
1.0
/
4.0
));
ASSERT_EQUAL_TOL
(
0.0
,
c4
,
3.0
/
pow
(
numValues
,
1.0
/
4.0
));
}
void
testRandomVelocities
()
{
// Create a system.
const
int
numParticles
=
10000
;
const
double
temperture
=
100.0
;
System
system
;
VerletIntegrator
integrator
(
0.01
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
system
.
addParticle
(
10.0
+
sin
(
0.1
*
i
));
for
(
int
i
=
0
;
i
<
numParticles
-
1
;
++
i
)
system
.
addConstraint
(
i
,
i
+
1
,
1.0
);
Context
context
(
system
,
integrator
,
platform
);
vector
<
Vec3
>
positions
(
numParticles
);
for
(
int
i
=
0
;
i
<
numParticles
;
++
i
)
positions
[
i
]
=
Vec3
(
i
/
2
,
(
i
+
1
)
/
2
,
0
);
context
.
setPositions
(
positions
);
// Ask the context to generate random velocities.
context
.
setVelocitiesToTemperature
(
temperture
);
State
state
=
context
.
getState
(
State
::
Velocities
);
// See if they respect constraints.
for
(
int
i
=
1
;
i
<
numParticles
;
i
++
)
{
Vec3
v1
=
state
.
getVelocities
()[
i
-
1
];
Vec3
v2
=
state
.
getVelocities
()[
i
];
double
vel
=
(
v1
-
v2
).
dot
(
positions
[
i
-
1
]
-
positions
[
i
]);
ASSERT_EQUAL_TOL
(
0.0
,
vel
,
2e-5
);
}
// See if the temperature is correct.
double
ke
=
0
;
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
{
Vec3
v
=
state
.
getVelocities
()[
i
];
ke
+=
0.5
*
system
.
getParticleMass
(
i
)
*
v
.
dot
(
v
);
}
double
expected
=
0.5
*
(
numParticles
*
3
-
system
.
getNumConstraints
())
*
BOLTZ
*
temperture
;
ASSERT_USUALLY_EQUAL_TOL
(
expected
,
ke
,
4
/
sqrt
((
double
)
numParticles
));
}
int
main
(
int
argc
,
char
*
argv
[])
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"HipPrecision"
,
string
(
argv
[
1
]));
testGaussian
();
testRandomVelocities
();
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
return
1
;
}
cout
<<
"Done"
<<
endl
;
return
0
;
}
platforms/hip/tests/TestHipSettle.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2015 Stanford University and the Authors. *
* Portions copyright (c) 2020 Advanced Micro Devices, Inc. *
* Authors: Peter Eastman, Nicholas Curtis *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "HipTests.h"
#include "TestSettle.h"
void
runPlatformTests
()
{
}
platforms/hip/tests/TestHipSort.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Portions copyright (c) 2020 Advanced Micro Devices, Inc. *
* Authors: Peter Eastman, Nicholas Curtis *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
/**
* This tests the Hip implementation of sorting.
*/
#include "openmm/internal/AssertionUtilities.h"
#include "HipArray.h"
#include "HipContext.h"
#include "HipSort.h"
#include "sfmt/SFMT.h"
#include "openmm/System.h"
#include <iostream>
#include <cmath>
#include <set>
using
namespace
OpenMM
;
using
namespace
std
;
HipPlatform
platform
;
class
SortTrait
:
public
HipSort
::
SortTrait
{
int
getDataSize
()
const
{
return
4
;}
int
getKeySize
()
const
{
return
4
;}
const
char
*
getDataType
()
const
{
return
"float"
;}
const
char
*
getKeyType
()
const
{
return
"float"
;}
const
char
*
getMinKey
()
const
{
return
"-3.40282e+38f"
;}
const
char
*
getMaxKey
()
const
{
return
"3.40282e+38f"
;}
const
char
*
getMaxValue
()
const
{
return
"3.40282e+38f"
;}
const
char
*
getSortKey
()
const
{
return
"value"
;}
};
void
verifySorting
(
vector
<
float
>
array
,
bool
uniform
)
{
// Sort the array.
System
system
;
system
.
addParticle
(
0.0
);
HipPlatform
::
PlatformData
platformData
(
NULL
,
system
,
""
,
"true"
,
platform
.
getPropertyDefaultValue
(
"HipPrecision"
),
"false"
,
platform
.
getPropertyDefaultValue
(
HipPlatform
::
HipTempDirectory
()),
platform
.
getPropertyDefaultValue
(
HipPlatform
::
HipDisablePmeStream
()),
"false"
,
1
,
NULL
);
HipContext
&
context
=
*
platformData
.
contexts
[
0
];
context
.
initialize
();
context
.
setAsCurrent
();
HipArray
data
(
context
,
array
.
size
(),
4
,
"sortData"
);
data
.
upload
(
array
);
HipSort
sort
(
context
,
new
SortTrait
(),
array
.
size
(),
uniform
);
sort
.
sort
(
data
);
vector
<
float
>
sorted
;
data
.
download
(
sorted
);
// Verify that it is in sorted order.
for
(
int
i
=
1
;
i
<
(
int
)
sorted
.
size
();
i
++
)
ASSERT
(
sorted
[
i
-
1
]
<=
sorted
[
i
]);
// Make sure the sorted array contains the same values as the original one.
multiset
<
float
>
elements1
(
array
.
begin
(),
array
.
end
());
multiset
<
float
>
elements2
(
sorted
.
begin
(),
sorted
.
end
());
ASSERT
(
elements1
==
elements2
);
}
void
testUniformValues
()
{
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
for
(
auto
size
:
{
2
,
63
,
100
,
1234
,
10000
,
60123
,
876543
})
{
vector
<
float
>
array
(
size
);
for
(
int
i
=
0
;
i
<
(
int
)
array
.
size
();
i
++
)
array
[
i
]
=
(
float
)
genrand_real2
(
sfmt
);
verifySorting
(
array
,
true
);
verifySorting
(
array
,
false
);
}
}
void
testLogValues
()
{
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
for
(
auto
size
:
{
2
,
63
,
100
,
1234
,
10000
,
60123
,
876543
})
{
vector
<
float
>
array
(
size
);
for
(
int
i
=
0
;
i
<
(
int
)
array
.
size
();
i
++
)
array
[
i
]
=
(
float
)
log
(
genrand_real2
(
sfmt
));
verifySorting
(
array
,
true
);
verifySorting
(
array
,
false
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
try
{
if
(
argc
>
1
)
platform
.
setPropertyDefaultValue
(
"HipPrecision"
,
string
(
argv
[
1
]));
testUniformValues
();
testLogValues
();
}
catch
(
const
exception
&
e
)
{
cout
<<
"exception: "
<<
e
.
what
()
<<
endl
;
return
1
;
}
cout
<<
"Done"
<<
endl
;
return
0
;
}
platforms/hip/tests/TestHipVariableLangevinIntegrator.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2015 Stanford University and the Authors. *
* Portions copyright (c) 2020 Advanced Micro Devices, Inc. *
* Authors: Peter Eastman, Nicholas Curtis *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "HipTests.h"
#include "TestVariableLangevinIntegrator.h"
void
runPlatformTests
()
{
}
platforms/hip/tests/TestHipVariableVerletIntegrator.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2015 Stanford University and the Authors. *
* Portions copyright (c) 2020 Advanced Micro Devices, Inc. *
* Authors: Peter Eastman, Nicholas Curtis *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "HipTests.h"
#include "TestVariableVerletIntegrator.h"
void
runPlatformTests
()
{
}
platforms/hip/tests/TestHipVerletIntegrator.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2015 Stanford University and the Authors. *
* Portions copyright (c) 2020 Advanced Micro Devices, Inc. *
* Authors: Peter Eastman, Nicholas Curtis *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "HipTests.h"
#include "TestVerletIntegrator.h"
void
runPlatformTests
()
{
}
platforms/hip/tests/TestHipVirtualSites.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2012-2015 Stanford University and the Authors. *
* Portions copyright (c) 2020 Advanced Micro Devices, Inc. *
* Authors: Peter Eastman, Nicholas Curtis *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "HipTests.h"
#include "TestVirtualSites.h"
/**
* Make sure that atom reordering respects virtual sites.
*/
void
testReordering
()
{
const
double
cutoff
=
2.0
;
const
double
boxSize
=
20.0
;
System
system
;
NonbondedForce
*
nonbonded
=
new
NonbondedForce
();
system
.
addForce
(
nonbonded
);
nonbonded
->
setNonbondedMethod
(
NonbondedForce
::
CutoffNonPeriodic
);
nonbonded
->
setCutoffDistance
(
cutoff
);
vector
<
Vec3
>
positions
;
OpenMM_SFMT
::
SFMT
sfmt
;
init_gen_rand
(
0
,
sfmt
);
// Create linear molecules with TwoParticleAverage virtual sites.
for
(
int
i
=
0
;
i
<
50
;
i
++
)
{
int
start
=
system
.
getNumParticles
();
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
0.0
);
system
.
setVirtualSite
(
start
+
2
,
new
TwoParticleAverageSite
(
start
,
start
+
1
,
0.4
,
0.6
));
system
.
addConstraint
(
start
,
start
+
1
,
2.0
);
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
nonbonded
->
addParticle
(
0
,
0.2
,
1
);
for
(
int
j
=
0
;
j
<
i
;
j
++
)
nonbonded
->
addException
(
start
+
i
,
start
+
j
,
0
,
1
,
0
);
}
Vec3
pos
(
boxSize
*
genrand_real2
(
sfmt
),
boxSize
*
genrand_real2
(
sfmt
),
boxSize
*
genrand_real2
(
sfmt
));
positions
.
push_back
(
pos
);
positions
.
push_back
(
pos
+
Vec3
(
2
,
0
,
0
));
positions
.
push_back
(
Vec3
());
}
// Create planar molecules with ThreeParticleAverage virtual sites.
for
(
int
i
=
0
;
i
<
50
;
i
++
)
{
int
start
=
system
.
getNumParticles
();
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
0.0
);
system
.
setVirtualSite
(
start
+
3
,
new
ThreeParticleAverageSite
(
start
,
start
+
1
,
start
+
2
,
0.3
,
0.5
,
0.2
));
system
.
addConstraint
(
start
,
start
+
1
,
1.0
);
system
.
addConstraint
(
start
,
start
+
2
,
1.0
);
system
.
addConstraint
(
start
+
1
,
start
+
2
,
sqrt
(
2.0
));
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
nonbonded
->
addParticle
(
0
,
0.2
,
1
);
for
(
int
j
=
0
;
j
<
i
;
j
++
)
nonbonded
->
addException
(
start
+
i
,
start
+
j
,
0
,
1
,
0
);
}
Vec3
pos
(
boxSize
*
genrand_real2
(
sfmt
),
boxSize
*
genrand_real2
(
sfmt
),
boxSize
*
genrand_real2
(
sfmt
));
positions
.
push_back
(
pos
);
positions
.
push_back
(
pos
+
Vec3
(
1
,
0
,
0
));
positions
.
push_back
(
pos
+
Vec3
(
0
,
1
,
0
));
positions
.
push_back
(
Vec3
());
}
// Create tetrahedral molecules with OutOfPlane virtual sites.
for
(
int
i
=
0
;
i
<
50
;
i
++
)
{
int
start
=
system
.
getNumParticles
();
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
1.0
);
system
.
addParticle
(
0.0
);
system
.
setVirtualSite
(
start
+
3
,
new
OutOfPlaneSite
(
start
,
start
+
1
,
start
+
2
,
0.3
,
0.5
,
0.2
));
system
.
addConstraint
(
start
,
start
+
1
,
1.0
);
system
.
addConstraint
(
start
,
start
+
2
,
1.0
);
system
.
addConstraint
(
start
+
1
,
start
+
2
,
sqrt
(
2.0
));
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
nonbonded
->
addParticle
(
0
,
0.2
,
1
);
for
(
int
j
=
0
;
j
<
i
;
j
++
)
nonbonded
->
addException
(
start
+
i
,
start
+
j
,
0
,
1
,
0
);
}
Vec3
pos
(
boxSize
*
genrand_real2
(
sfmt
),
boxSize
*
genrand_real2
(
sfmt
),
boxSize
*
genrand_real2
(
sfmt
));
positions
.
push_back
(
pos
);
positions
.
push_back
(
pos
+
Vec3
(
1
,
0
,
0
));
positions
.
push_back
(
pos
+
Vec3
(
0
,
1
,
0
));
positions
.
push_back
(
Vec3
());
}
// Simulate it and check conservation laws.
LangevinIntegrator
integrator
(
300.0
,
0.1
,
0.002
);
Context
context
(
system
,
integrator
,
platform
);
context
.
setPositions
(
positions
);
context
.
applyConstraints
(
0.0001
);
for
(
int
i
=
0
;
i
<
1000
;
i
++
)
{
State
state
=
context
.
getState
(
State
::
Positions
);
const
vector
<
Vec3
>&
pos
=
state
.
getPositions
();
for
(
int
j
=
0
;
j
<
150
;
j
+=
3
)
ASSERT_EQUAL_VEC
(
pos
[
j
]
*
0.4
+
pos
[
j
+
1
]
*
0.6
,
pos
[
j
+
2
],
1e-5
);
for
(
int
j
=
150
;
j
<
350
;
j
+=
4
)
ASSERT_EQUAL_VEC
(
pos
[
j
]
*
0.3
+
pos
[
j
+
1
]
*
0.5
+
pos
[
j
+
2
]
*
0.2
,
pos
[
j
+
3
],
1e-5
);
for
(
int
j
=
350
;
j
<
550
;
j
+=
4
)
{
Vec3
v12
=
pos
[
j
+
1
]
-
pos
[
j
];
Vec3
v13
=
pos
[
j
+
2
]
-
pos
[
j
];
Vec3
cross
=
v12
.
cross
(
v13
);
ASSERT_EQUAL_VEC
(
pos
[
j
]
+
v12
*
0.3
+
v13
*
0.5
+
cross
*
0.2
,
pos
[
j
+
3
],
1e-5
);
}
integrator
.
step
(
1
);
}
}
void
runPlatformTests
()
{
testReordering
();
}
plugins/amoeba/CMakeLists.txt
View file @
3b8df952
...
@@ -29,7 +29,7 @@ SET(OPENMM_AMOEBA_BUILD_VERSION 0)
...
@@ -29,7 +29,7 @@ SET(OPENMM_AMOEBA_BUILD_VERSION 0)
ADD_DEFINITIONS
(
-DOPENMM_AMOEBA_LIBRARY_NAME=
${
OPENMM_AMOEBA_LIBRARY_NAME
}
ADD_DEFINITIONS
(
-DOPENMM_AMOEBA_LIBRARY_NAME=
${
OPENMM_AMOEBA_LIBRARY_NAME
}
-DOPENMM_AMOEBA_MAJOR_VERSION=
${
OPENMM_AMOEBA_MAJOR_VERSION
}
-DOPENMM_AMOEBA_MAJOR_VERSION=
${
OPENMM_AMOEBA_MAJOR_VERSION
}
-DOPENMM_AMOEBA_MINOR_VERSION=
${
OPENMM_AMOEBA_MINOR_VERSION
}
-DOPENMM_AMOEBA_MINOR_VERSION=
${
OPENMM_AMOEBA_MINOR_VERSION
}
-DOPENMM_AMOEBA_BUILD_VERSION=
${
OPENMM_AMOEBA_BUILD_VERSION
}
)
-DOPENMM_AMOEBA_BUILD_VERSION=
${
OPENMM_AMOEBA_BUILD_VERSION
}
)
SET
(
SHARED_AMOEBA_TARGET
${
OPENMM_AMOEBA_LIBRARY_NAME
}
)
SET
(
SHARED_AMOEBA_TARGET
${
OPENMM_AMOEBA_LIBRARY_NAME
}
)
SET
(
STATIC_AMOEBA_TARGET
${
OPENMM_AMOEBA_LIBRARY_NAME
}
_static
)
SET
(
STATIC_AMOEBA_TARGET
${
OPENMM_AMOEBA_LIBRARY_NAME
}
_static
)
...
@@ -140,6 +140,12 @@ ELSE(OPENMM_BUILD_OPENCL_LIB)
...
@@ -140,6 +140,12 @@ ELSE(OPENMM_BUILD_OPENCL_LIB)
SET
(
OPENMM_BUILD_AMOEBA_OPENCL_LIB OFF CACHE BOOL
"Build OpenMMAmoebaOpenCL library"
)
SET
(
OPENMM_BUILD_AMOEBA_OPENCL_LIB OFF CACHE BOOL
"Build OpenMMAmoebaOpenCL library"
)
ENDIF
(
OPENMM_BUILD_OPENCL_LIB
)
ENDIF
(
OPENMM_BUILD_OPENCL_LIB
)
IF
(
OPENMM_BUILD_HIP_LIB
)
SET
(
OPENMM_BUILD_AMOEBA_HIP_LIB ON CACHE BOOL
"Build OpenMMAmoebaHIP library"
)
ELSE
(
OPENMM_BUILD_HIP_LIB
)
SET
(
OPENMM_BUILD_AMOEBA_HIP_LIB OFF CACHE BOOL
"Build OpenMMAmoebaHIP library"
)
ENDIF
(
OPENMM_BUILD_HIP_LIB
)
SET
(
OPENMM_BUILD_AMOEBA_CUDA_PATH
)
SET
(
OPENMM_BUILD_AMOEBA_CUDA_PATH
)
IF
(
OPENMM_BUILD_AMOEBA_CUDA_LIB
)
IF
(
OPENMM_BUILD_AMOEBA_CUDA_LIB
)
ADD_SUBDIRECTORY
(
platforms/cuda
)
ADD_SUBDIRECTORY
(
platforms/cuda
)
...
@@ -154,6 +160,13 @@ IF(OPENMM_BUILD_AMOEBA_OPENCL_LIB)
...
@@ -154,6 +160,13 @@ IF(OPENMM_BUILD_AMOEBA_OPENCL_LIB)
SET
(
OPENMM_AMOEBA_OPENCL_SOURCE_SUBDIRS . openmmapi olla platforms/opencl
)
SET
(
OPENMM_AMOEBA_OPENCL_SOURCE_SUBDIRS . openmmapi olla platforms/opencl
)
ENDIF
(
OPENMM_BUILD_AMOEBA_OPENCL_LIB
)
ENDIF
(
OPENMM_BUILD_AMOEBA_OPENCL_LIB
)
SET
(
OPENMM_BUILD_AMOEBA_HIP_PATH
)
IF
(
OPENMM_BUILD_AMOEBA_HIP_LIB
)
ADD_SUBDIRECTORY
(
platforms/hip
)
SET
(
OPENMM_BUILD_AMOEBA_HIP_PATH
${
CMAKE_CURRENT_SOURCE_DIR
}
/platforms/hip
)
SET
(
OPENMM_AMOEBA_HIP_SOURCE_SUBDIRS . openmmapi olla platforms/hip
)
ENDIF
(
OPENMM_BUILD_AMOEBA_HIP_LIB
)
INSTALL_TARGETS
(
/lib RUNTIME_DIRECTORY /lib
${
SHARED_AMOEBA_TARGET
}
)
INSTALL_TARGETS
(
/lib RUNTIME_DIRECTORY /lib
${
SHARED_AMOEBA_TARGET
}
)
IF
(
OPENMM_BUILD_STATIC_LIB
)
IF
(
OPENMM_BUILD_STATIC_LIB
)
INSTALL_TARGETS
(
/lib RUNTIME_DIRECTORY /lib
${
STATIC_AMOEBA_TARGET
}
)
INSTALL_TARGETS
(
/lib RUNTIME_DIRECTORY /lib
${
STATIC_AMOEBA_TARGET
}
)
...
...
plugins/amoeba/platforms/hip/CMakeLists.txt
0 → 100644
View file @
3b8df952
#---------------------------------------------------
# OpenMM HIP Amoeba Implementation
#
# Creates OpenMMAmoebaHIP library.
#
# Windows:
# OpenMMAmoebaHIP.dll
# OpenMMAmoebaHIP.lib
# Unix:
# libOpenMMAmoebaHIP.so
#----------------------------------------------------
# The source is organized into subdirectories, but we handle them all from
# this CMakeLists file rather than letting CMake visit them as SUBDIRS.
SET
(
OPENMM_SOURCE_SUBDIRS . ../common
)
# Collect up information about the version of the OpenMM library we're building
# and make it available to the code so it can be built into the binaries.
SET
(
OPENMMAMOEBAHIP_LIBRARY_NAME OpenMMAmoebaHIP
)
SET
(
SHARED_TARGET
${
OPENMMAMOEBAHIP_LIBRARY_NAME
}
)
SET
(
STATIC_TARGET
${
OPENMMAMOEBAHIP_LIBRARY_NAME
}
_static
)
# These are all the places to search for header files which are
# to be part of the API.
SET
(
API_INCLUDE_DIRS
)
# start empty
FOREACH
(
subdir
${
OPENMM_SOURCE_SUBDIRS
}
)
# append
SET
(
API_INCLUDE_DIRS
${
API_INCLUDE_DIRS
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/include
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/include/internal
)
ENDFOREACH
(
subdir
)
# We'll need both *relative* path names, starting with their API_INCLUDE_DIRS,
# and absolute pathnames.
SET
(
API_REL_INCLUDE_FILES
)
# start these out empty
SET
(
API_ABS_INCLUDE_FILES
)
FOREACH
(
dir
${
API_INCLUDE_DIRS
}
)
FILE
(
GLOB fullpaths
${
dir
}
/*.h
)
# returns full pathnames
SET
(
API_ABS_INCLUDE_FILES
${
API_ABS_INCLUDE_FILES
}
${
fullpaths
}
)
FOREACH
(
pathname
${
fullpaths
}
)
GET_FILENAME_COMPONENT
(
filename
${
pathname
}
NAME
)
SET
(
API_REL_INCLUDE_FILES
${
API_REL_INCLUDE_FILES
}
${
dir
}
/
${
filename
}
)
ENDFOREACH
(
pathname
)
ENDFOREACH
(
dir
)
# collect up source files
SET
(
SOURCE_FILES
)
# empty
SET
(
SOURCE_INCLUDE_FILES
)
FOREACH
(
subdir
${
OPENMM_SOURCE_SUBDIRS
}
)
FILE
(
GLOB_RECURSE src_files
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/src/*.cpp
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/src/*.c
)
FILE
(
GLOB incl_files
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/src/*.h
)
SET
(
SOURCE_FILES
${
SOURCE_FILES
}
${
src_files
}
)
#append
SET
(
SOURCE_INCLUDE_FILES
${
SOURCE_INCLUDE_FILES
}
${
incl_files
}
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
subdir
}
/include
)
ENDFOREACH
(
subdir
)
SET
(
COMMON_KERNELS_CPP
${
CMAKE_CURRENT_BINARY_DIR
}
/../common/src/CommonAmoebaKernelSources.cpp
)
SET
(
SOURCE_FILES
${
SOURCE_FILES
}
${
COMMON_KERNELS_CPP
}
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_SOURCE_DIR
}
/src
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_SOURCE_DIR
}
/../common/src
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_SOURCE_DIR
}
/platforms/hip/include
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_SOURCE_DIR
}
/platforms/hip/src
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_BINARY_DIR
}
/platforms/hip/src
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_SOURCE_DIR
}
/platforms/common/include
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_BINARY_DIR
}
/platforms/common/src
)
INCLUDE_DIRECTORIES
(
BEFORE
${
CMAKE_CURRENT_BINARY_DIR
}
/../common/src
)
# Create the library
SET_SOURCE_FILES_PROPERTIES
(
${
COMMON_KERNELS_CPP
}
PROPERTIES GENERATED TRUE
)
# Build the shared plugin library.
IF
(
OPENMM_BUILD_SHARED_LIB
)
ADD_LIBRARY
(
${
SHARED_TARGET
}
SHARED
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
ADD_DEPENDENCIES
(
${
SHARED_TARGET
}
AmoebaCommonKernels
)
TARGET_LINK_LIBRARIES
(
${
SHARED_TARGET
}
${
OPENMM_LIBRARY_NAME
}
${
PTHREADS_LIB
}
)
TARGET_LINK_LIBRARIES
(
${
SHARED_TARGET
}
${
OPENMM_LIBRARY_NAME
}
HIP
)
TARGET_LINK_LIBRARIES
(
${
SHARED_TARGET
}
${
SHARED_AMOEBA_TARGET
}
)
SET_TARGET_PROPERTIES
(
${
SHARED_TARGET
}
PROPERTIES COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
-DOPENMM_BUILDING_SHARED_LIBRARY"
)
SET_TARGET_PROPERTIES
(
${
SHARED_TARGET
}
PROPERTIES LINK_FLAGS
"
${
EXTRA_LINK_FLAGS
}
"
)
INSTALL_TARGETS
(
/lib/plugins RUNTIME_DIRECTORY /lib/plugins
${
SHARED_TARGET
}
)
ENDIF
(
OPENMM_BUILD_SHARED_LIB
)
# Build the static plugin library.
IF
(
OPENMM_BUILD_STATIC_LIB
)
ADD_LIBRARY
(
${
STATIC_TARGET
}
STATIC
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
TARGET_LINK_LIBRARIES
(
${
STATIC_TARGET
}
${
OPENMM_LIBRARY_NAME
}
${
PTHREADS_LIB
}
)
TARGET_LINK_LIBRARIES
(
${
STATIC_TARGET
}
${
OPENMM_LIBRARY_NAME
}
HIP
)
TARGET_LINK_LIBRARIES
(
${
STATIC_TARGET
}
${
STATIC_AMOEBA_TARGET
}
)
SET_TARGET_PROPERTIES
(
${
STATIC_TARGET
}
PROPERTIES COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
-DOPENMM_BUILDING_STATIC_LIBRARY"
)
SET_TARGET_PROPERTIES
(
${
STATIC_TARGET
}
PROPERTIES LINK_FLAGS
"
${
EXTRA_LINK_FLAGS
}
"
)
INSTALL_TARGETS
(
/lib/plugins RUNTIME_DIRECTORY /lib/plugins
${
STATIC_TARGET
}
)
ENDIF
(
OPENMM_BUILD_STATIC_LIB
)
INSTALL
(
TARGETS
${
SHARED_TARGET
}
DESTINATION
${
CMAKE_INSTALL_PREFIX
}
/lib/plugins
)
IF
(
BUILD_TESTING AND OPENMM_BUILD_HIP_TESTS
)
SUBDIRS
(
tests
)
ENDIF
(
BUILD_TESTING AND OPENMM_BUILD_HIP_TESTS
)
plugins/amoeba/platforms/hip/include/AmoebaHipKernelFactory.h
0 → 100644
View file @
3b8df952
#ifndef AMOEBA_OPENMM_HIPKERNELFACTORY_H_
#define AMOEBA_OPENMM_HIPKERNELFACTORY_H_
/* -------------------------------------------------------------------------- *
* OpenMMAmoeba *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Portions copyright (c) 2021 Advanced Micro Devices, Inc. *
* Authors: *
* Contributors: *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* -------------------------------------------------------------------------- */
#include "openmm/KernelFactory.h"
namespace
OpenMM
{
/**
* This KernelFactory creates all kernels for AmoebaHipPlatform.
*/
class
AmoebaHipKernelFactory
:
public
KernelFactory
{
public:
KernelImpl
*
createKernelImpl
(
std
::
string
name
,
const
Platform
&
platform
,
ContextImpl
&
context
)
const
;
};
}
// namespace OpenMM
#endif
/*AMOEBA_OPENMM_HIPKERNELFACTORY_H_*/
plugins/amoeba/platforms/hip/src/AmoebaHipKernelFactory.cpp
0 → 100644
View file @
3b8df952
/* -------------------------------------------------------------------------- *
* OpenMMAmoeba *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2019 Stanford University and the Authors. *
* Portions copyright (c) 2021 Advanced Micro Devices, Inc. *
* Authors: Mark Friedrichs, Peter Eastman *
* Contributors: *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* -------------------------------------------------------------------------- */
#include "AmoebaHipKernelFactory.h"
#include "AmoebaHipKernels.h"
#include "AmoebaCommonKernels.h"
#include "HipPlatform.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/windowsExport.h"
using
namespace
OpenMM
;
#ifdef OPENMM_BUILDING_STATIC_LIBRARY
static
void
registerPlatforms
()
{
#else
extern
"C"
OPENMM_EXPORT
void
registerPlatforms
()
{
#endif
}
#ifdef OPENMM_BUILDING_STATIC_LIBRARY
static
void
registerKernelFactories
()
{
#else
extern
"C"
OPENMM_EXPORT
void
registerKernelFactories
()
{
#endif
try
{
Platform
&
platform
=
Platform
::
getPlatformByName
(
"HIP"
);
AmoebaHipKernelFactory
*
factory
=
new
AmoebaHipKernelFactory
();
platform
.
registerKernelFactory
(
CalcAmoebaTorsionTorsionForceKernel
::
Name
(),
factory
);
platform
.
registerKernelFactory
(
CalcAmoebaMultipoleForceKernel
::
Name
(),
factory
);
platform
.
registerKernelFactory
(
CalcAmoebaGeneralizedKirkwoodForceKernel
::
Name
(),
factory
);
platform
.
registerKernelFactory
(
CalcAmoebaVdwForceKernel
::
Name
(),
factory
);
platform
.
registerKernelFactory
(
CalcAmoebaWcaDispersionForceKernel
::
Name
(),
factory
);
platform
.
registerKernelFactory
(
CalcHippoNonbondedForceKernel
::
Name
(),
factory
);
}
catch
(...)
{
// Ignore. The HIP platform isn't available.
}
}
extern
"C"
OPENMM_EXPORT
void
registerAmoebaHipKernelFactories
()
{
try
{
Platform
::
getPlatformByName
(
"HIP"
);
}
catch
(...)
{
Platform
::
registerPlatform
(
new
HipPlatform
());
}
registerKernelFactories
();
}
KernelImpl
*
AmoebaHipKernelFactory
::
createKernelImpl
(
std
::
string
name
,
const
Platform
&
platform
,
ContextImpl
&
context
)
const
{
HipPlatform
::
PlatformData
&
data
=
*
static_cast
<
HipPlatform
::
PlatformData
*>
(
context
.
getPlatformData
());
HipContext
&
cu
=
*
data
.
contexts
[
0
];
if
(
name
==
CalcAmoebaTorsionTorsionForceKernel
::
Name
())
return
new
CommonCalcAmoebaTorsionTorsionForceKernel
(
name
,
platform
,
cu
,
context
.
getSystem
());
if
(
name
==
CalcAmoebaMultipoleForceKernel
::
Name
())
return
new
HipCalcAmoebaMultipoleForceKernel
(
name
,
platform
,
cu
,
context
.
getSystem
());
if
(
name
==
CalcAmoebaGeneralizedKirkwoodForceKernel
::
Name
())
return
new
CommonCalcAmoebaGeneralizedKirkwoodForceKernel
(
name
,
platform
,
cu
,
context
.
getSystem
());
if
(
name
==
CalcAmoebaVdwForceKernel
::
Name
())
return
new
CommonCalcAmoebaVdwForceKernel
(
name
,
platform
,
cu
,
context
.
getSystem
());
if
(
name
==
CalcAmoebaWcaDispersionForceKernel
::
Name
())
return
new
CommonCalcAmoebaWcaDispersionForceKernel
(
name
,
platform
,
cu
,
context
.
getSystem
());
if
(
name
==
CalcHippoNonbondedForceKernel
::
Name
())
return
new
HipCalcHippoNonbondedForceKernel
(
name
,
platform
,
cu
,
context
.
getSystem
());
throw
OpenMMException
((
std
::
string
(
"Tried to create kernel with illegal kernel name '"
)
+
name
+
"'"
).
c_str
());
}
Prev
1
2
3
4
5
6
7
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment