├── platforms └── metal │ ├── src │ ├── kernels │ │ ├── customExternalForce.metal │ │ ├── harmonicBondForce.metal │ │ ├── harmonicAngleForce.metal │ │ ├── periodicTorsionForce.metal │ │ ├── customNonbondedComputedValues.metal │ │ ├── bondForce.metal │ │ ├── customGBChainRule.metal │ │ ├── customGBValuePerParticle.metal │ │ ├── nonbondedExceptions.metal │ │ ├── customNonbonded.metal │ │ ├── angleForce.metal │ │ ├── rbTorsionForce.metal │ │ ├── customGBGradientChainRule.metal │ │ ├── customGBEnergyPerParticle.metal │ │ ├── andersenThermostat.metal │ │ ├── constraints.metal │ │ ├── pointFunctions.metal │ │ ├── gbsaObc2.metal │ │ ├── torsionForce.metal │ │ ├── pmeExclusions.metal │ │ ├── monteCarloBarostat.metal │ │ ├── customCVForce.metal │ │ ├── fft.metal │ │ ├── gbsaObcReductions.metal │ │ ├── brownian.metal │ │ ├── removeCM.metal │ │ └── customIntegratorPerDof.metal │ ├── MetalKernelSources.cpp.in │ ├── MetalEvent.cpp │ ├── MetalProgram.cpp │ ├── MetalKernelSources.h.in │ ├── MetalParameterSet.cpp │ └── MetalCompact.cpp │ ├── include │ ├── MetalLogging.h │ ├── MetalCompact.h │ ├── MetalKernelFactory.h │ ├── MetalExpressionUtilities.h │ ├── MetalEvent.h │ ├── MetalProgram.h │ └── MetalForceInfo.h │ ├── tests │ ├── water_box.py │ ├── CMakeLists.txt │ ├── TestMetalSettle.cpp │ ├── TestMetalRMSDForce.cpp │ ├── TestMetalGBSAOBCForce.cpp │ ├── TestMetalCustomCVForce.cpp │ ├── TestMetalCustomGBForce.cpp │ ├── TestMetalGayBerneForce.cpp │ ├── TestMetalCMAPTorsionForce.cpp │ ├── TestMetalCMMotionRemover.cpp │ ├── TestMetalCompoundIntegrator.cpp │ ├── TestMetalCustomCentroidBondForce.cpp │ ├── TestMetalVariableVerletIntegrator.cpp │ ├── TestMetalCustomHbondForce.cpp │ ├── has_opencl_gpu.c │ └── MetalTests.h │ ├── long_tests │ ├── CMakeLists.txt │ ├── TestMetalEwald.cpp │ ├── TestMetalDispersionPME.cpp │ ├── TestMetalVerletIntegrator.cpp │ ├── TestMetalAndersenThermostat.cpp │ ├── TestMetalLangevinIntegrator.cpp │ ├── TestMetalLocalEnergyMinimizer.cpp │ ├── TestMetalCustomManyParticleForce.cpp │ ├── TestMetalLangevinMiddleIntegrator.cpp │ └── TestMetalMonteCarloFlexibleBarostat.cpp │ └── very_long_tests │ ├── CMakeLists.txt │ ├── TestMetalBrownianIntegrator.cpp │ ├── TestMetalNoseHooverIntegrator.cpp │ ├── TestMetalVariableLangevinIntegrator.cpp │ ├── TestMetalMonteCarloAnisotropicBarostat.cpp │ └── TestMetalMonteCarloBarostat.cpp ├── plugins ├── drude │ └── platforms │ │ └── metal │ │ ├── tests │ │ ├── CMakeLists.txt │ │ ├── TestMetalDrudeForce.cpp │ │ └── MetalDrudeTests.h │ │ ├── long_tests │ │ ├── CMakeLists.txt │ │ └── TestMetalDrudeNoseHoover.cpp │ │ ├── very_long_tests │ │ ├── CMakeLists.txt │ │ ├── TestMetalDrudeSCFIntegrator.cpp │ │ └── TestMetalDrudeLangevinIntegrator.cpp │ │ ├── src │ │ └── common_kernels │ │ │ ├── drudeParticleForce.cc │ │ │ └── drudePairForce.cc │ │ └── include │ │ └── MetalDrudeKernelFactory.h ├── amoeba │ └── platforms │ │ └── metal │ │ ├── tests │ │ ├── CMakeLists.txt │ │ ├── TestMetalHippoNonbondedForce.cpp │ │ ├── TestMetalWcaDispersionForce.cpp │ │ ├── TestMetalAmoebaTorsionTorsionForce.cpp │ │ ├── TestMetalAmoebaExtrapolatedPolarization.cpp │ │ ├── TestMetalAmoebaGeneralizedKirkwoodForce.cpp │ │ ├── TestMetalAmoebaMultipoleForce.cpp │ │ └── MetalAmoebaTests.h │ │ ├── src │ │ └── common_kernels │ │ │ ├── hippoMutualField.cc │ │ │ ├── amoebaVdwForce2.cc │ │ │ ├── amoebaVdwForce1.cc │ │ │ ├── bicubic.cc │ │ │ └── hippoFixedField.cc │ │ └── include │ │ └── AmoebaMetalKernelFactory.h └── rpmd │ └── platforms │ └── metal │ ├── very_long_tests │ ├── CMakeLists.txt │ └── TestMetalRpmdParaHydrogen.cpp │ ├── include │ └── MetalRpmdKernelFactory.h │ └── src │ └── MetalRpmdKernelFactory.cpp ├── licenses ├── MIT.txt └── MIT-VkFFT.txt ├── LICENSE └── .gitignore /platforms/metal/src/kernels/customExternalForce.metal: -------------------------------------------------------------------------------- 1 | COMPUTE_FORCE 2 | real3 force1 = make_real3(-dEdX, -dEdY, -dEdZ); 3 | -------------------------------------------------------------------------------- /platforms/metal/include/MetalLogging.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENMM_METALLOGGING_H_ 2 | #define OPENMM_METALLOGGING_H_ 3 | 4 | #define METAL_LOG_HEADER "\e[0;36m[Metal]\e[0m " 5 | 6 | #endif /*OPENMM_METALLOGGING_H_*/ 7 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/harmonicBondForce.metal: -------------------------------------------------------------------------------- 1 | float2 bondParams = PARAMS[index]; 2 | real deltaIdeal = r-bondParams.x; 3 | energy += 0.5f * bondParams.y*deltaIdeal*deltaIdeal; 4 | real dEdR = bondParams.y * deltaIdeal; 5 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/harmonicAngleForce.metal: -------------------------------------------------------------------------------- 1 | float2 angleParams = PARAMS[index]; 2 | real deltaIdeal = theta-angleParams.x; 3 | energy += 0.5f*angleParams.y*deltaIdeal*deltaIdeal; 4 | real dEdAngle = angleParams.y*deltaIdeal; 5 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/periodicTorsionForce.metal: -------------------------------------------------------------------------------- 1 | float4 torsionParams = PARAMS[index]; 2 | real deltaAngle = torsionParams.z*theta-torsionParams.y; 3 | energy += torsionParams.x*(1.0f+COS(deltaAngle)); 4 | real sinDeltaAngle = SIN(deltaAngle); 5 | real dEdAngle = -torsionParams.x*torsionParams.z*sinDeltaAngle; 6 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/customNonbondedComputedValues.metal: -------------------------------------------------------------------------------- 1 | /** 2 | * Calculate per-particle computed values for a CustomNonbondedForce. 3 | */ 4 | 5 | KERNEL void computePerParticleValues(PARAMETER_ARGUMENTS) { 6 | for (int index = GLOBAL_ID; index < NUM_ATOMS; index += GLOBAL_SIZE) { 7 | COMPUTE_VALUES 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/bondForce.metal: -------------------------------------------------------------------------------- 1 | real3 delta = make_real3(pos2.x-pos1.x, pos2.y-pos1.y, pos2.z-pos1.z); 2 | #if APPLY_PERIODIC 3 | APPLY_PERIODIC_TO_DELTA(delta) 4 | #endif 5 | real r = SQRT(delta.x*delta.x + delta.y*delta.y + delta.z*delta.z); 6 | COMPUTE_FORCE 7 | dEdR = (r > 0) ? (dEdR / r) : 0; 8 | delta *= dEdR; 9 | real3 force1 = delta; 10 | real3 force2 = -delta; 11 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/customGBChainRule.metal: -------------------------------------------------------------------------------- 1 | #ifdef USE_CUTOFF 2 | if (atom1 < NUM_ATOMS && atom2 < NUM_ATOMS && atom1 != atom2 && r2 < CUTOFF_SQUARED) { 3 | #else 4 | if (atom1 < NUM_ATOMS && atom2 < NUM_ATOMS && atom1 != atom2) { 5 | #endif 6 | #ifdef USE_SYMMETRIC 7 | real tempForce = 0; 8 | #else 9 | real3 tempForce1 = make_real3(0); 10 | real3 tempForce2 = make_real3(0); 11 | #endif 12 | COMPUTE_FORCE 13 | #ifdef USE_SYMMETRIC 14 | dEdR += tempForce*invR; 15 | #else 16 | dEdR1 += tempForce1; 17 | dEdR2 += tempForce2; 18 | #endif 19 | } 20 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/customGBValuePerParticle.metal: -------------------------------------------------------------------------------- 1 | /** 2 | * Reduce a pairwise computed value, and compute per-particle values. 3 | */ 4 | 5 | KERNEL void computePerParticleValues(GLOBAL real4* posq, 6 | GLOBAL mm_long* valueBuffers 7 | PARAMETER_ARGUMENTS) { 8 | for (int index = GLOBAL_ID; index < NUM_ATOMS; index += GLOBAL_SIZE) { 9 | // Reduce the pairwise value 10 | 11 | real sum = valueBuffers[index]/(real) 0x100000000; 12 | REDUCE_PARAM0_DERIV 13 | 14 | // Now calculate other values 15 | 16 | real4 pos = posq[index]; 17 | COMPUTE_VALUES 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/nonbondedExceptions.metal: -------------------------------------------------------------------------------- 1 | float4 exceptionParams = PARAMS[index]; 2 | real3 delta = make_real3(pos2.x-pos1.x, pos2.y-pos1.y, pos2.z-pos1.z); 3 | #if APPLY_PERIODIC 4 | APPLY_PERIODIC_TO_DELTA(delta) 5 | #endif 6 | real r2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z; 7 | real invR = RSQRT(r2); 8 | real sig2 = invR*exceptionParams.y; 9 | sig2 *= sig2; 10 | real sig6 = sig2*sig2*sig2; 11 | real dEdR = exceptionParams.z*(12.0f*sig6-6.0f)*sig6; 12 | real tempEnergy = exceptionParams.z*(sig6-1.0f)*sig6; 13 | dEdR += exceptionParams.x*invR; 14 | dEdR *= invR*invR; 15 | tempEnergy += exceptionParams.x*invR; 16 | energy += tempEnergy; 17 | delta *= dEdR; 18 | real3 force1 = -delta; 19 | real3 force2 = delta; 20 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/customNonbonded.metal: -------------------------------------------------------------------------------- 1 | #ifdef USE_CUTOFF 2 | if (!isExcluded && r2 < CUTOFF_SQUARED) { 3 | #else 4 | if (!isExcluded) { 5 | #endif 6 | real tempForce = 0; 7 | real switchValue = 1, switchDeriv = 0; 8 | #if USE_SWITCH 9 | if (r > SWITCH_CUTOFF) { 10 | real x = r-SWITCH_CUTOFF; 11 | switchValue = 1+x*x*x*(SWITCH_C3+x*(SWITCH_C4+x*SWITCH_C5)); 12 | switchDeriv = x*x*(3*SWITCH_C3+x*(4*SWITCH_C4+x*5*SWITCH_C5)); 13 | } 14 | #endif 15 | COMPUTE_FORCE 16 | #if USE_SWITCH 17 | tempForce = tempForce*switchValue - customEnergy*switchDeriv; 18 | tempEnergy += customEnergy*switchValue; 19 | #else 20 | tempEnergy += customEnergy; 21 | #endif 22 | dEdR += tempForce*invR; 23 | } 24 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/angleForce.metal: -------------------------------------------------------------------------------- 1 | real3 v0 = make_real3(pos2.x-pos1.x, pos2.y-pos1.y, pos2.z-pos1.z); 2 | real3 v1 = make_real3(pos2.x-pos3.x, pos2.y-pos3.y, pos2.z-pos3.z); 3 | #if APPLY_PERIODIC 4 | APPLY_PERIODIC_TO_DELTA(v0) 5 | APPLY_PERIODIC_TO_DELTA(v1) 6 | #endif 7 | real3 cp = cross(v0, v1); 8 | real rp = cp.x*cp.x + cp.y*cp.y + cp.z*cp.z; 9 | rp = max(SQRT(rp), (real) 1.0e-06f); 10 | real r21 = v0.x*v0.x + v0.y*v0.y + v0.z*v0.z; 11 | real r23 = v1.x*v1.x + v1.y*v1.y + v1.z*v1.z; 12 | real dot = v0.x*v1.x + v0.y*v1.y + v0.z*v1.z; 13 | real cosine = min(max(dot*RSQRT(r21*r23), (real) -1), (real) 1); 14 | real theta = ACOS(cosine); 15 | COMPUTE_FORCE 16 | real3 force1 = cross(v0, cp)*(dEdAngle/(r21*rp)); 17 | real3 force3 = cross(cp, v1)*(dEdAngle/(r23*rp)); 18 | real3 force2 = -force1-force3; 19 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/rbTorsionForce.metal: -------------------------------------------------------------------------------- 1 | float4 torsionParams1 = PARAMS1[index]; 2 | float2 torsionParams2 = PARAMS2[index]; 3 | if (theta < 0) 4 | theta += PI; 5 | else 6 | theta -= PI; 7 | cosangle = -cosangle; 8 | real cosFactor = cosangle; 9 | real dEdAngle = -torsionParams1.y; 10 | real rbEnergy = torsionParams1.x; 11 | rbEnergy += torsionParams1.y*cosFactor; 12 | dEdAngle -= 2.0f*torsionParams1.z*cosFactor; 13 | cosFactor *= cosangle; 14 | dEdAngle -= 3.0f*torsionParams1.w*cosFactor; 15 | rbEnergy += torsionParams1.z*cosFactor; 16 | cosFactor *= cosangle; 17 | dEdAngle -= 4.0f*torsionParams2.x*cosFactor; 18 | rbEnergy += torsionParams1.w*cosFactor; 19 | cosFactor *= cosangle; 20 | dEdAngle -= 5.0f*torsionParams2.y*cosFactor; 21 | rbEnergy += torsionParams2.x*cosFactor; 22 | rbEnergy += torsionParams2.y*cosFactor*cosangle; 23 | energy += rbEnergy; 24 | dEdAngle *= SIN(theta); 25 | -------------------------------------------------------------------------------- /plugins/drude/platforms/metal/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Testing 3 | # 4 | 5 | ENABLE_TESTING() 6 | 7 | INCLUDE_DIRECTORIES(${OPENMM_SOURCE_DIR}/plugins/drude/tests) 8 | INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/platforms/metal/tests) 9 | 10 | # Automatically create tests using files named "Test*.cpp" 11 | FILE(GLOB TEST_PROGS "*Test*.cpp") 12 | FOREACH(TEST_PROG ${TEST_PROGS}) 13 | GET_FILENAME_COMPONENT(TEST_ROOT ${TEST_PROG} NAME_WE) 14 | 15 | # Link with shared library 16 | ADD_EXECUTABLE(${TEST_ROOT} ${TEST_PROG}) 17 | TARGET_LINK_LIBRARIES(${TEST_ROOT} ${SHARED_DRUDE_TARGET} ${SHARED_TARGET}) 18 | SET_TARGET_PROPERTIES(${TEST_ROOT} PROPERTIES LINK_FLAGS "${EXTRA_LINK_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS}") 19 | 20 | ADD_TEST(${TEST_ROOT}Single ${EXECUTABLE_OUTPUT_PATH}/${TEST_ROOT} single ${OPENCL_TEST_PLATFORM_INDEX} ${OPENCL_TEST_DEVICE_INDEX}) 21 | 22 | ENDFOREACH(TEST_PROG ${TEST_PROGS}) 23 | -------------------------------------------------------------------------------- /plugins/amoeba/platforms/metal/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Testing 3 | # 4 | 5 | ENABLE_TESTING() 6 | 7 | INCLUDE_DIRECTORIES(${OPENMM_SOURCE_DIR}/plugins/amoeba/tests) 8 | INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/platforms/metal/tests) 9 | 10 | # Automatically create tests using files named "Test*.cpp" 11 | FILE(GLOB TEST_PROGS "*Test*.cpp") 12 | FOREACH(TEST_PROG ${TEST_PROGS}) 13 | GET_FILENAME_COMPONENT(TEST_ROOT ${TEST_PROG} NAME_WE) 14 | 15 | # Link with shared library 16 | ADD_EXECUTABLE(${TEST_ROOT} ${TEST_PROG}) 17 | TARGET_LINK_LIBRARIES(${TEST_ROOT} ${SHARED_AMOEBA_TARGET} ${SHARED_TARGET}) 18 | SET_TARGET_PROPERTIES(${TEST_ROOT} PROPERTIES LINK_FLAGS "${EXTRA_LINK_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS}") 19 | 20 | ADD_TEST(${TEST_ROOT}Single ${EXECUTABLE_OUTPUT_PATH}/${TEST_ROOT} single ${OPENCL_TEST_PLATFORM_INDEX} ${OPENCL_TEST_DEVICE_INDEX}) 21 | 22 | ENDFOREACH(TEST_PROG ${TEST_PROGS}) 23 | -------------------------------------------------------------------------------- /plugins/drude/platforms/metal/long_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Testing 3 | # 4 | 5 | ENABLE_TESTING() 6 | 7 | INCLUDE_DIRECTORIES(${OPENMM_SOURCE_DIR}/plugins/drude/tests) 8 | INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/platforms/metal/tests) 9 | 10 | # Automatically create tests using files named "Test*.cpp" 11 | FILE(GLOB TEST_PROGS "*Test*.cpp") 12 | FOREACH(TEST_PROG ${TEST_PROGS}) 13 | GET_FILENAME_COMPONENT(TEST_ROOT ${TEST_PROG} NAME_WE) 14 | 15 | # Link with shared library 16 | ADD_EXECUTABLE(${TEST_ROOT} ${TEST_PROG}) 17 | TARGET_LINK_LIBRARIES(${TEST_ROOT} ${SHARED_DRUDE_TARGET} ${SHARED_TARGET}) 18 | SET_TARGET_PROPERTIES(${TEST_ROOT} PROPERTIES LINK_FLAGS "${EXTRA_LINK_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS}") 19 | 20 | ADD_TEST(${TEST_ROOT}Single ${EXECUTABLE_OUTPUT_PATH}/${TEST_ROOT} single ${OPENCL_TEST_PLATFORM_INDEX} ${OPENCL_TEST_DEVICE_INDEX}) 21 | 22 | ENDFOREACH(TEST_PROG ${TEST_PROGS}) 23 | 24 | -------------------------------------------------------------------------------- /plugins/drude/platforms/metal/very_long_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Testing 3 | # 4 | 5 | ENABLE_TESTING() 6 | 7 | INCLUDE_DIRECTORIES(${OPENMM_SOURCE_DIR}/plugins/drude/tests) 8 | INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/platforms/metal/tests) 9 | 10 | # Automatically create tests using files named "Test*.cpp" 11 | FILE(GLOB TEST_PROGS "*Test*.cpp") 12 | FOREACH(TEST_PROG ${TEST_PROGS}) 13 | GET_FILENAME_COMPONENT(TEST_ROOT ${TEST_PROG} NAME_WE) 14 | 15 | # Link with shared library 16 | ADD_EXECUTABLE(${TEST_ROOT} ${TEST_PROG}) 17 | TARGET_LINK_LIBRARIES(${TEST_ROOT} ${SHARED_DRUDE_TARGET} ${SHARED_TARGET}) 18 | SET_TARGET_PROPERTIES(${TEST_ROOT} PROPERTIES LINK_FLAGS "${EXTRA_LINK_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS}") 19 | 20 | ADD_TEST(${TEST_ROOT}Single ${EXECUTABLE_OUTPUT_PATH}/${TEST_ROOT} single ${OPENCL_TEST_PLATFORM_INDEX} ${OPENCL_TEST_DEVICE_INDEX}) 21 | 22 | ENDFOREACH(TEST_PROG ${TEST_PROGS}) 23 | 24 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/customGBGradientChainRule.metal: -------------------------------------------------------------------------------- 1 | /** 2 | * Compute chain rule terms for computed values that depend explicitly on particle coordinates. 3 | */ 4 | 5 | KERNEL void computeGradientChainRuleTerms(GLOBAL const real4* RESTRICT posq, 6 | GLOBAL mm_long* RESTRICT forceBuffers 7 | PARAMETER_ARGUMENTS) { 8 | INIT_PARAM_DERIVS 9 | const real scale = RECIP((real) 0x100000000); 10 | for (int index = GLOBAL_ID; index < NUM_ATOMS; index += GLOBAL_SIZE) { 11 | real4 pos = posq[index]; 12 | real3 force = make_real3(scale*forceBuffers[index], scale*forceBuffers[index+PADDED_NUM_ATOMS], scale*forceBuffers[index+PADDED_NUM_ATOMS*2]); 13 | COMPUTE_FORCES 14 | forceBuffers[index] = realToFixedPoint(force.x); 15 | forceBuffers[index+PADDED_NUM_ATOMS] = realToFixedPoint(force.y); 16 | forceBuffers[index+PADDED_NUM_ATOMS*2] = realToFixedPoint(force.z); 17 | } 18 | SAVE_PARAM_DERIVS 19 | } 20 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/customGBEnergyPerParticle.metal: -------------------------------------------------------------------------------- 1 | #define REDUCE_VALUE(NAME, TYPE) {\ 2 | TYPE sum = NAME[index]; \ 3 | for (int i = index+bufferSize; i < totalSize; i += bufferSize) \ 4 | sum += NAME[i]; \ 5 | NAME[index] = sum; \ 6 | } 7 | 8 | /** 9 | * Reduce the derivatives computed in the N^2 energy kernel, and compute all per-particle energy terms. 10 | */ 11 | 12 | KERNEL void computePerParticleEnergy(GLOBAL mixed* RESTRICT energyBuffer, GLOBAL const real4* RESTRICT posq, 13 | GLOBAL mm_long* RESTRICT forceBuffers 14 | PARAMETER_ARGUMENTS) { 15 | mixed energy = 0; 16 | INIT_PARAM_DERIVS 17 | for (int index = GLOBAL_ID; index < NUM_ATOMS; index += GLOBAL_SIZE) { 18 | // Reduce the derivatives 19 | 20 | REDUCE_DERIVATIVES 21 | 22 | // Now calculate the per-particle energy terms. 23 | 24 | real4 pos = posq[index]; 25 | real3 force = make_real3(0, 0, 0); 26 | COMPUTE_ENERGY 27 | } 28 | energyBuffer[GLOBAL_ID] += energy; 29 | SAVE_PARAM_DERIVS 30 | } 31 | -------------------------------------------------------------------------------- /platforms/metal/tests/water_box.py: -------------------------------------------------------------------------------- 1 | from openmm import * 2 | from openmm.app import * 3 | from openmm.unit import * 4 | import sys 5 | 6 | Platform.loadPluginsFromDirectory(Platform.getDefaultPluginsDirectory()) 7 | 8 | width = float(sys.argv[1]) 9 | ff = ForceField('tip3pfb.xml') 10 | modeller = Modeller(Topology(), []) 11 | modeller.addSolvent(ff, boxSize=Vec3(width, width, width)*nanometers) 12 | #system = ff.createSystem(modeller.topology,nonbondedMethod=NoCutoff)#PME,nonbondedCutoff=0.5) 13 | system = ff.createSystem(modeller.topology, nonbondedMethod=PME, nonbondedCutoff=1.0) 14 | print(system.getNumParticles()) 15 | integrator = LangevinMiddleIntegrator(300, 1.0, 0.004) 16 | platform = Platform.getPlatformByName('HIP') 17 | simulation = Simulation(modeller.topology, system, integrator, platform) 18 | simulation.reporters.append(StateDataReporter(sys.stdout, 1000, step=True, 19 | temperature=True, elapsedTime=True, speed=True)) 20 | simulation.context.setPositions(modeller.positions) 21 | simulation.minimizeEnergy(tolerance=100*kilojoules_per_mole/nanometer) 22 | simulation.step(5000) 23 | 24 | -------------------------------------------------------------------------------- /licenses/MIT.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject 9 | to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included 12 | in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Philip Turner 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/andersenThermostat.metal: -------------------------------------------------------------------------------- 1 | /** 2 | * Apply the Andersen thermostat to adjust particle velocities. 3 | */ 4 | 5 | KERNEL void applyAndersenThermostat(int numAtoms, float collisionFrequency, float kT, GLOBAL mixed4* velm, real stepSize, GLOBAL const float4* RESTRICT random, 6 | unsigned int randomIndex, GLOBAL const int* RESTRICT atomGroups) { 7 | float collisionProbability = (float) (1-EXP(-collisionFrequency*stepSize)); 8 | float randomRange = (float) erf(collisionProbability/SQRT(2.0f)); 9 | for (int index = GLOBAL_ID; index < numAtoms; index += GLOBAL_SIZE) { 10 | mixed4 velocity = velm[index]; 11 | float4 selectRand = random[randomIndex+atomGroups[index]]; 12 | float4 velRand = random[randomIndex+index]; 13 | real scale = (selectRand.w > -randomRange && selectRand.w < randomRange ? 0 : 1); 14 | real add = (1-scale)*SQRT(kT*velocity.w); 15 | velocity.x = scale*velocity.x + add*velRand.x; 16 | velocity.y = scale*velocity.y + add*velRand.y; 17 | velocity.z = scale*velocity.z + add*velRand.z; 18 | velm[index] = velocity; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/constraints.metal: -------------------------------------------------------------------------------- 1 | KERNEL void applyPositionDeltas(int numAtoms, GLOBAL real4* RESTRICT posq, GLOBAL mixed4* RESTRICT posDelta 2 | #ifdef USE_MIXED_PRECISION 3 | , GLOBAL real4* RESTRICT posqCorrection 4 | #endif 5 | ) { 6 | for (unsigned int index = GLOBAL_ID; index < numAtoms; index += GLOBAL_SIZE) { 7 | #ifdef USE_DOUBLE_SINGLE 8 | FP64_APPLY_POS_DELTA 9 | #else 10 | #ifdef USE_MIXED_PRECISION 11 | real4 pos1 = posq[index]; 12 | real4 pos2 = posqCorrection[index]; 13 | mixed4 pos = make_mixed4(pos1.x+(mixed)pos2.x, pos1.y+(mixed)pos2.y, pos1.z+(mixed)pos2.z, pos1.w); 14 | #else 15 | mixed4 pos = posq[index]; 16 | #endif 17 | pos.x += posDelta[index].x; 18 | pos.y += posDelta[index].y; 19 | pos.z += posDelta[index].z; 20 | #ifdef USE_MIXED_PRECISION 21 | posq[index] = make_real4((real) pos.x, (real) pos.y, (real) pos.z, (real) pos.w); 22 | posqCorrection[index] = make_real4(pos.x-(real) pos.x, pos.y-(real) pos.y, pos.z-(real) pos.z, 0); 23 | #else 24 | posq[index] = pos; 25 | #endif 26 | #endif 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /licenses/MIT-VkFFT.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 - present Dmitrii Tolmachev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/pointFunctions.metal: -------------------------------------------------------------------------------- 1 | /** 2 | * Compute the angle between two vectors. The w component of each vector should contain the squared magnitude. 3 | */ 4 | DEVICE real computeAngle(real4 vec1, real4 vec2) { 5 | real dotProduct = vec1.x*vec2.x + vec1.y*vec2.y + vec1.z*vec2.z; 6 | real cosine = dotProduct*RSQRT(vec1.w*vec2.w); 7 | real angle; 8 | if (cosine > 0.99f || cosine < -0.99f) { 9 | // We're close to the singularity in acos(), so take the cross product and use asin() instead. 10 | 11 | real3 crossProduct = cross(trimTo3(vec1), trimTo3(vec2)); 12 | real scale = vec1.w*vec2.w; 13 | angle = ASIN(SQRT(dot(crossProduct, crossProduct)/scale)); 14 | if (cosine < 0) 15 | angle = M_PI-angle; 16 | } 17 | else 18 | angle = ACOS(cosine); 19 | return angle; 20 | } 21 | 22 | /** 23 | * Compute the cross product of two vectors, setting the fourth component to the squared magnitude. 24 | */ 25 | DEVICE real4 computeCross(real4 vec1, real4 vec2) { 26 | real3 cp = cross(trimTo3(vec1), trimTo3(vec2)); 27 | return make_real4(cp.x, cp.y, cp.z, cp.x*cp.x+cp.y*cp.y+cp.z*cp.z); 28 | } 29 | 30 | -------------------------------------------------------------------------------- /plugins/rpmd/platforms/metal/very_long_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Testing 3 | # 4 | 5 | ENABLE_TESTING() 6 | 7 | INCLUDE_DIRECTORIES(${OPENMM_SOURCE_DIR}/plugins/rpmd/tests) 8 | INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/platforms/metal/tests) 9 | 10 | # Automatically create tests using files named "Test*.cpp" 11 | FILE(GLOB TEST_PROGS "*Test*.cpp") 12 | FOREACH(TEST_PROG ${TEST_PROGS}) 13 | GET_FILENAME_COMPONENT(TEST_ROOT ${TEST_PROG} NAME_WE) 14 | 15 | # Link with shared library 16 | ADD_EXECUTABLE(${TEST_ROOT} ${TEST_PROG}) 17 | TARGET_LINK_LIBRARIES(${TEST_ROOT} ${SHARED_RPMD_TARGET} ${SHARED_TARGET}) 18 | SET_TARGET_PROPERTIES(${TEST_ROOT} PROPERTIES LINK_FLAGS "${EXTRA_LINK_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS}") 19 | 20 | # RPMD tests take way too long. 21 | # 22 | # This is causing problems; becoming part of the quick tests when I don't 23 | # want that. I don't have much use for RPMD right now, and this is 24 | # excessively long even for a "very long test". I will not be maintaining 25 | # support for this. 26 | # ADD_TEST(${TEST_ROOT}Single ${EXECUTABLE_OUTPUT_PATH}/${TEST_ROOT} single ${OPENCL_TEST_PLATFORM_INDEX} ${OPENCL_TEST_DEVICE_INDEX}) 27 | 28 | 29 | ENDFOREACH(TEST_PROG ${TEST_PROGS}) 30 | 31 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/gbsaObc2.metal: -------------------------------------------------------------------------------- 1 | { 2 | real invRSquaredOver4 = 0.25f*invR*invR; 3 | real rScaledRadiusJ = r+OBC_PARAMS2.y; 4 | real rScaledRadiusI = r+OBC_PARAMS1.y; 5 | real l_ijJ = RECIP(max((real) OBC_PARAMS1.x, fabs(r-OBC_PARAMS2.y))); 6 | real l_ijI = RECIP(max((real) OBC_PARAMS2.x, fabs(r-OBC_PARAMS1.y))); 7 | real u_ijJ = RECIP(rScaledRadiusJ); 8 | real u_ijI = RECIP(rScaledRadiusI); 9 | real l_ij2J = l_ijJ*l_ijJ; 10 | real l_ij2I = l_ijI*l_ijI; 11 | real u_ij2J = u_ijJ*u_ijJ; 12 | real u_ij2I = u_ijI*u_ijI; 13 | real t1J = LOG(u_ijJ*RECIP(l_ijJ)); 14 | real t1I = LOG(u_ijI*RECIP(l_ijI)); 15 | real t2J = (l_ij2J-u_ij2J); 16 | real t2I = (l_ij2I-u_ij2I); 17 | real term1 = (0.5f*(0.25f+OBC_PARAMS2.y*OBC_PARAMS2.y*invRSquaredOver4)*t2J + t1J*invRSquaredOver4)*invR; 18 | real term2 = (0.5f*(0.25f+OBC_PARAMS1.y*OBC_PARAMS1.y*invRSquaredOver4)*t2I + t1I*invRSquaredOver4)*invR; 19 | real tempdEdR = (OBC_PARAMS1.x < rScaledRadiusJ ? BORN_FORCE1*term1/0x100000000 : 0); 20 | tempdEdR += (OBC_PARAMS2.x < rScaledRadiusI ? BORN_FORCE2*term2/0x100000000 : 0); 21 | #ifdef USE_CUTOFF 22 | unsigned int includeInteraction = (atom1 < NUM_ATOMS && atom2 < NUM_ATOMS && atom1 != atom2 && r2 < CUTOFF_SQUARED); 23 | #else 24 | unsigned int includeInteraction = (atom1 < NUM_ATOMS && atom2 < NUM_ATOMS && atom1 != atom2); 25 | #endif 26 | dEdR += (includeInteraction ? tempdEdR : (real) 0); 27 | } 28 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/torsionForce.metal: -------------------------------------------------------------------------------- 1 | const real PI = (real) 3.14159265358979323846; 2 | real3 v0 = make_real3(pos1.x-pos2.x, pos1.y-pos2.y, pos1.z-pos2.z); 3 | real3 v1 = make_real3(pos3.x-pos2.x, pos3.y-pos2.y, pos3.z-pos2.z); 4 | real3 v2 = make_real3(pos3.x-pos4.x, pos3.y-pos4.y, pos3.z-pos4.z); 5 | #if APPLY_PERIODIC 6 | APPLY_PERIODIC_TO_DELTA(v0) 7 | APPLY_PERIODIC_TO_DELTA(v1) 8 | APPLY_PERIODIC_TO_DELTA(v2) 9 | #endif 10 | real3 cp0 = cross(v0, v1); 11 | real3 cp1 = cross(v1, v2); 12 | real cosangle = dot(normalize(cp0), normalize(cp1)); 13 | real theta; 14 | if (cosangle > 0.99f || cosangle < -0.99f) { 15 | // We're close to the singularity in acos(), so take the cross product and use asin() instead. 16 | 17 | real3 cross_prod = cross(cp0, cp1); 18 | real scale = dot(cp0, cp0)*dot(cp1, cp1); 19 | theta = ASIN(SQRT(dot(cross_prod, cross_prod)/scale)); 20 | if (cosangle < 0) 21 | theta = PI-theta; 22 | } 23 | else 24 | theta = ACOS(cosangle); 25 | theta = (dot(v0, cp1) >= 0 ? theta : -theta); 26 | COMPUTE_FORCE 27 | real normCross1 = dot(cp0, cp0); 28 | real normSqrBC = dot(v1, v1); 29 | real normBC = SQRT(normSqrBC); 30 | real normCross2 = dot(cp1, cp1); 31 | real dp = RECIP(normSqrBC); 32 | real4 ff = make_real4((-dEdAngle*normBC)/normCross1, dot(v0, v1)*dp, dot(v2, v1)*dp, (dEdAngle*normBC)/normCross2); 33 | real3 force1 = ff.x*cp0; 34 | real3 force4 = ff.w*cp1; 35 | real3 s = ff.y*force1 - ff.z*force4; 36 | real3 force2 = s-force1; 37 | real3 force3 = -s-force4; 38 | -------------------------------------------------------------------------------- /platforms/metal/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Testing 3 | # 4 | 5 | ENABLE_TESTING() 6 | 7 | INCLUDE_DIRECTORIES(${OPENMM_SOURCE_DIR}/tests) 8 | 9 | set(OPENCL_TEST_PLATFORM_INDEX -1 CACHE STRING "Metal platform index used for running Metal test cases. The default, -1, selects the fastest platform") 10 | set(OPENCL_TEST_DEVICE_INDEX -1 CACHE STRING "Metal device index used for running Metal test cases. The default, -1, selects the fastest device") 11 | MARK_AS_ADVANCED(OPENCL_TEST_PLATFORM_INDEX) 12 | MARK_AS_ADVANCED(OPENCL_TEST_DEVICE_INDEX) 13 | 14 | 15 | SET( INCLUDE_SERIALIZATION FALSE ) 16 | #SET( INCLUDE_SERIALIZATION TRUE ) 17 | 18 | IF( INCLUDE_SERIALIZATION ) 19 | INCLUDE_DIRECTORIES(${OPENMM_DIR}/serialization/include) 20 | SET( SHARED_OPENMM_SERIALIZATION "OpenMMSerialization" ) 21 | ENDIF( INCLUDE_SERIALIZATION ) 22 | 23 | # Automatically create tests using files named "Test*.cpp" 24 | FILE(GLOB TEST_PROGS "*Test*.cpp") 25 | FOREACH(TEST_PROG ${TEST_PROGS}) 26 | GET_FILENAME_COMPONENT(TEST_ROOT ${TEST_PROG} NAME_WE) 27 | 28 | # Link with shared library 29 | ADD_EXECUTABLE(${TEST_ROOT} ${TEST_PROG}) 30 | TARGET_LINK_LIBRARIES(${TEST_ROOT} ${SHARED_TARGET}) 31 | SET_TARGET_PROPERTIES(${TEST_ROOT} PROPERTIES LINK_FLAGS "${EXTRA_LINK_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS}") 32 | 33 | ADD_TEST(${TEST_ROOT}Single ${EXECUTABLE_OUTPUT_PATH}/${TEST_ROOT} single ${OPENCL_TEST_PLATFORM_INDEX} ${OPENCL_TEST_DEVICE_INDEX}) 34 | 35 | ENDFOREACH(TEST_PROG ${TEST_PROGS}) 36 | -------------------------------------------------------------------------------- /plugins/amoeba/platforms/metal/src/common_kernels/hippoMutualField.cc: -------------------------------------------------------------------------------- 1 | real fdamp3, fdamp5; 2 | computeMutualFieldDampingFactors(alpha1, alpha2, r, &fdamp3, &fdamp5); 3 | #ifdef COMPUTING_EXCEPTIONS 4 | fdamp3 *= scale; 5 | fdamp5 *= scale; 6 | #endif 7 | real invR2 = invR*invR; 8 | real invR3 = invR*invR2; 9 | #if USE_EWALD 10 | real ralpha = PME_ALPHA*r; 11 | real exp2a = EXP(-(ralpha*ralpha)); 12 | #ifdef USE_DOUBLE_PRECISION 13 | const real erfcAlphaR = erfc(ralpha); 14 | #else 15 | // This approximation for erfc is from Abramowitz and Stegun (1964) p. 299. They cite the following as 16 | // the original source: C. Hastings, Jr., Approximations for Digital Computers (1955). It has a maximum 17 | // error of 1.5e-7. 18 | 19 | const real t = RECIP(1.0f+0.3275911f*ralpha); 20 | const real erfcAlphaR = (0.254829592f+(-0.284496736f+(1.421413741f+(-1.453152027f+1.061405429f*t)*t)*t)*t)*t*exp2a; 21 | #endif 22 | real bn0 = erfcAlphaR*invR; 23 | real alsq2 = 2*PME_ALPHA*PME_ALPHA; 24 | real alsq2n = 1/(SQRT_PI*PME_ALPHA); 25 | alsq2n *= alsq2; 26 | real bn1 = (bn0+alsq2n*exp2a)*invR2; 27 | alsq2n *= alsq2; 28 | real bn2 = (3*bn1+alsq2n*exp2a)*invR2; 29 | real scale3 = -bn1 + (1-fdamp3)*invR3; 30 | real scale5 = bn2 - 3*(1-fdamp5)*invR3*invR2; 31 | #else 32 | real scale3 = -fdamp3*invR3; 33 | real scale5 = 3*fdamp5*invR3*invR2; 34 | #endif 35 | tempField1 = inducedDipole2*scale3 + delta*scale5*dot(inducedDipole2, delta); 36 | tempField2 = inducedDipole1*scale3 + delta*scale5*dot(inducedDipole1, delta); 37 | -------------------------------------------------------------------------------- /platforms/metal/long_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Testing 3 | # 4 | 5 | ENABLE_TESTING() 6 | 7 | INCLUDE_DIRECTORIES(${OPENMM_SOURCE_DIR}/tests) 8 | 9 | set(OPENCL_TEST_PLATFORM_INDEX -1 CACHE STRING "Metal platform index used for running Metal test cases. The default, -1, selects the fastest platform") 10 | set(OPENCL_TEST_DEVICE_INDEX -1 CACHE STRING "Metal device index used for running Metal test cases. The default, -1, selects the fastest device") 11 | MARK_AS_ADVANCED(OPENCL_TEST_PLATFORM_INDEX) 12 | MARK_AS_ADVANCED(OPENCL_TEST_DEVICE_INDEX) 13 | 14 | 15 | SET( INCLUDE_SERIALIZATION FALSE ) 16 | #SET( INCLUDE_SERIALIZATION TRUE ) 17 | 18 | IF( INCLUDE_SERIALIZATION ) 19 | INCLUDE_DIRECTORIES(${OPENMM_DIR}/serialization/include) 20 | SET( SHARED_OPENMM_SERIALIZATION "OpenMMSerialization" ) 21 | ENDIF( INCLUDE_SERIALIZATION ) 22 | 23 | # Automatically create tests using files named "Test*.cpp" 24 | FILE(GLOB TEST_PROGS "*Test*.cpp") 25 | FOREACH(TEST_PROG ${TEST_PROGS}) 26 | GET_FILENAME_COMPONENT(TEST_ROOT ${TEST_PROG} NAME_WE) 27 | 28 | # Link with shared library 29 | ADD_EXECUTABLE(${TEST_ROOT} ${TEST_PROG}) 30 | TARGET_LINK_LIBRARIES(${TEST_ROOT} ${SHARED_TARGET}) 31 | SET_TARGET_PROPERTIES(${TEST_ROOT} PROPERTIES LINK_FLAGS "${EXTRA_LINK_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS}") 32 | 33 | ADD_TEST(${TEST_ROOT}Single ${EXECUTABLE_OUTPUT_PATH}/${TEST_ROOT} single ${OPENCL_TEST_PLATFORM_INDEX} ${OPENCL_TEST_DEVICE_INDEX}) 34 | 35 | ENDFOREACH(TEST_PROG ${TEST_PROGS}) 36 | 37 | -------------------------------------------------------------------------------- /platforms/metal/very_long_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Testing 3 | # 4 | 5 | ENABLE_TESTING() 6 | 7 | INCLUDE_DIRECTORIES(${OPENMM_SOURCE_DIR}/tests) 8 | 9 | set(OPENCL_TEST_PLATFORM_INDEX -1 CACHE STRING "Metal platform index used for running Metal test cases. The default, -1, selects the fastest platform") 10 | set(OPENCL_TEST_DEVICE_INDEX -1 CACHE STRING "Metal device index used for running Metal test cases. The default, -1, selects the fastest device") 11 | MARK_AS_ADVANCED(OPENCL_TEST_PLATFORM_INDEX) 12 | MARK_AS_ADVANCED(OPENCL_TEST_DEVICE_INDEX) 13 | 14 | 15 | SET( INCLUDE_SERIALIZATION FALSE ) 16 | #SET( INCLUDE_SERIALIZATION TRUE ) 17 | 18 | IF( INCLUDE_SERIALIZATION ) 19 | INCLUDE_DIRECTORIES(${OPENMM_DIR}/serialization/include) 20 | SET( SHARED_OPENMM_SERIALIZATION "OpenMMSerialization" ) 21 | ENDIF( INCLUDE_SERIALIZATION ) 22 | 23 | # Automatically create tests using files named "Test*.cpp" 24 | FILE(GLOB TEST_PROGS "*Test*.cpp") 25 | FOREACH(TEST_PROG ${TEST_PROGS}) 26 | GET_FILENAME_COMPONENT(TEST_ROOT ${TEST_PROG} NAME_WE) 27 | 28 | # Link with shared library 29 | ADD_EXECUTABLE(${TEST_ROOT} ${TEST_PROG}) 30 | TARGET_LINK_LIBRARIES(${TEST_ROOT} ${SHARED_TARGET}) 31 | SET_TARGET_PROPERTIES(${TEST_ROOT} PROPERTIES LINK_FLAGS "${EXTRA_LINK_FLAGS}" COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS}") 32 | 33 | ADD_TEST(${TEST_ROOT}Single ${EXECUTABLE_OUTPUT_PATH}/${TEST_ROOT} single ${OPENCL_TEST_PLATFORM_INDEX} ${OPENCL_TEST_DEVICE_INDEX}) 34 | 35 | ENDFOREACH(TEST_PROG ${TEST_PROGS}) 36 | 37 | 38 | -------------------------------------------------------------------------------- /plugins/drude/platforms/metal/src/common_kernels/drudeParticleForce.cc: -------------------------------------------------------------------------------- 1 | real3 delta = make_real3(pos1.x-pos2.x, pos1.y-pos2.y, pos1.z-pos2.z); 2 | real r2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z; 3 | float4 drudeParams = PARAMS[index]; 4 | float k1 = drudeParams.x; 5 | float k2 = drudeParams.y; 6 | float k3 = drudeParams.z; 7 | 8 | // Compute the isotropic force. 9 | 10 | energy += 0.5f*k3*r2; 11 | real3 force1 = -delta*k3; 12 | real3 force2 = delta*k3; 13 | real3 force3 = make_real3(0); 14 | real3 force4 = make_real3(0); 15 | real3 force5 = make_real3(0); 16 | 17 | // Compute the first anisotropic force. 18 | 19 | if (k1 != 0) { 20 | real3 dir = make_real3(pos2.x-pos3.x, pos2.y-pos3.y, pos2.z-pos3.z); 21 | real invDist = RSQRT(dot(dir, dir)); 22 | dir *= invDist; 23 | real rprime = dot(dir, delta); 24 | energy += 0.5f*k1*rprime*rprime; 25 | real3 f1 = dir*(k1*rprime); 26 | real3 f2 = (delta-dir*rprime)*(k1*rprime*invDist); 27 | force1 -= f1; 28 | force2 += f1-f2; 29 | force3 += f2; 30 | } 31 | 32 | // Compute the second anisotropic force. 33 | 34 | if (k2 != 0) { 35 | real3 dir = make_real3(pos4.x-pos5.x, pos4.y-pos5.y, pos4.z-pos5.z); 36 | real invDist = RSQRT(dot(dir, dir)); 37 | dir *= invDist; 38 | real rprime = dot(dir, delta); 39 | energy += 0.5f*k2*rprime*rprime; 40 | real3 f1 = dir*(k2*rprime); 41 | real3 f2 = (delta-dir*rprime)*(k2*rprime*invDist); 42 | force1 -= f1; 43 | force2 += f1; 44 | force4 -= f2; 45 | force5 += f2; 46 | } 47 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/pmeExclusions.metal: -------------------------------------------------------------------------------- 1 | const float4 exclusionParams = PARAMS[index]; 2 | real3 delta = make_real3(pos2.x-pos1.x, pos2.y-pos1.y, pos2.z-pos1.z); 3 | #if USE_PERIODIC 4 | APPLY_PERIODIC_TO_DELTA(delta) 5 | #endif 6 | const real r2 = delta.x*delta.x + delta.y*delta.y + delta.z*delta.z; 7 | const real r = SQRT(r2); 8 | const real invR = RECIP(r); 9 | const real alphaR = EWALD_ALPHA*r; 10 | const real expAlphaRSqr = EXP(-alphaR*alphaR); 11 | real tempForce = 0.0f; 12 | if (alphaR > 1e-6f) { 13 | const real erfAlphaR = ERF(alphaR); 14 | const real prefactor = exclusionParams.x*invR; 15 | tempForce = -prefactor*(erfAlphaR-alphaR*expAlphaRSqr*TWO_OVER_SQRT_PI); 16 | energy -= prefactor*erfAlphaR; 17 | } 18 | else { 19 | energy -= TWO_OVER_SQRT_PI*EWALD_ALPHA*exclusionParams.x; 20 | } 21 | #if DO_LJPME 22 | const real dispersionAlphaR = EWALD_DISPERSION_ALPHA*r; 23 | const real dar2 = dispersionAlphaR*dispersionAlphaR; 24 | const real dar4 = dar2*dar2; 25 | const real dar6 = dar4*dar2; 26 | const real invR2 = invR*invR; 27 | const real expDar2 = EXP(-dar2); 28 | const real c6 = 64*exclusionParams.y*exclusionParams.y*exclusionParams.y*exclusionParams.z; 29 | const real coef = invR2*invR2*invR2*c6; 30 | const real eprefac = 1.0f + dar2 + 0.5f*dar4; 31 | const real dprefac = eprefac + dar6/6.0f; 32 | energy += coef*(1.0f - expDar2*eprefac); 33 | tempForce += 6.0f*coef*(1.0f - expDar2*dprefac); 34 | #endif 35 | if (r > 0) 36 | delta *= tempForce*invR*invR; 37 | real3 force1 = -delta; 38 | real3 force2 = delta; 39 | 40 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/monteCarloBarostat.metal: -------------------------------------------------------------------------------- 1 | /** 2 | * Scale the particle positions with each axis independent. 3 | */ 4 | 5 | KERNEL void scalePositions(float scaleX, float scaleY, float scaleZ, int numMolecules, real4 periodicBoxSize, 6 | real4 invPeriodicBoxSize, real4 periodicBoxVecX, real4 periodicBoxVecY, real4 periodicBoxVecZ, GLOBAL real4* RESTRICT posq, 7 | GLOBAL const int* RESTRICT moleculeAtoms, GLOBAL const int* RESTRICT moleculeStartIndex) { 8 | for (int index = GLOBAL_ID; index < numMolecules; index += GLOBAL_SIZE) { 9 | int first = moleculeStartIndex[index]; 10 | int last = moleculeStartIndex[index+1]; 11 | int numAtoms = last-first; 12 | 13 | // Find the center of each molecule. 14 | 15 | real3 center = make_real3(0, 0, 0); 16 | for (int atom = first; atom < last; atom++) { 17 | real4 pos = posq[moleculeAtoms[atom]]; 18 | center.x += pos.x; 19 | center.y += pos.y; 20 | center.z += pos.z; 21 | } 22 | real invNumAtoms = RECIP((real) numAtoms); 23 | center.x *= invNumAtoms; 24 | center.y *= invNumAtoms; 25 | center.z *= invNumAtoms; 26 | 27 | // Now scale the position of the molecule center. 28 | 29 | real3 delta; 30 | delta.x = center.x*(scaleX-1); 31 | delta.y = center.y*(scaleY-1); 32 | delta.z = center.z*(scaleZ-1); 33 | for (int atom = first; atom < last; atom++) { 34 | real4 pos = posq[moleculeAtoms[atom]]; 35 | pos.x += delta.x; 36 | pos.y += delta.y; 37 | pos.z += delta.z; 38 | posq[moleculeAtoms[atom]] = pos; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/customCVForce.metal: -------------------------------------------------------------------------------- 1 | /** 2 | * Copy the positions and velocities to the inner context. 3 | */ 4 | KERNEL void copyState(GLOBAL real4* RESTRICT posq, GLOBAL real4* RESTRICT innerPosq, 5 | #ifdef USE_MIXED_PRECISION 6 | GLOBAL real4* RESTRICT posqCorrection, GLOBAL real4* RESTRICT innerPosqCorrection, 7 | #endif 8 | GLOBAL mixed4* RESTRICT velm, GLOBAL mixed4* RESTRICT innerVelm, GLOBAL int* RESTRICT atomOrder, GLOBAL int* RESTRICT innerInvAtomOrder, int numAtoms) { 9 | for (int i = GLOBAL_ID; i < numAtoms; i += GLOBAL_SIZE) { 10 | int index = innerInvAtomOrder[atomOrder[i]]; 11 | real4 p = posq[i]; 12 | p.w = innerPosq[index].w; 13 | innerPosq[index] = p; 14 | mixed4 v = velm[i]; 15 | v.w = innerVelm[index].w; 16 | innerVelm[index] = v; 17 | #ifdef USE_MIXED_PRECISION 18 | innerPosqCorrection[index] = posqCorrection[i]; 19 | #endif 20 | } 21 | } 22 | 23 | /** 24 | * Copy the forces back to the main context. 25 | */ 26 | KERNEL void copyForces(GLOBAL mm_long* RESTRICT forces, GLOBAL int* RESTRICT invAtomOrder, GLOBAL mm_long* RESTRICT innerForces, 27 | GLOBAL int* RESTRICT innerAtomOrder, int numAtoms, int paddedNumAtoms) { 28 | for (int i = GLOBAL_ID; i < numAtoms; i += GLOBAL_SIZE) { 29 | int index = invAtomOrder[innerAtomOrder[i]]; 30 | forces[index] = innerForces[i]; 31 | forces[index+paddedNumAtoms] = innerForces[i+paddedNumAtoms]; 32 | forces[index+paddedNumAtoms*2] = innerForces[i+paddedNumAtoms*2]; 33 | } 34 | } 35 | 36 | /** 37 | * Add all the forces from the CVs. 38 | */ 39 | KERNEL void addForces(GLOBAL mm_long* RESTRICT forces, int bufferSize 40 | PARAMETER_ARGUMENTS) { 41 | for (int i = GLOBAL_ID; i < bufferSize; i += GLOBAL_SIZE) { 42 | ADD_FORCES 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /plugins/drude/platforms/metal/src/common_kernels/drudePairForce.cc: -------------------------------------------------------------------------------- 1 | float2 drudeParams = PARAMS[index]; 2 | real3 force1 = make_real3(0); 3 | real3 force2 = make_real3(0); 4 | real3 force3 = make_real3(0); 5 | real3 force4 = make_real3(0); 6 | 7 | // First pair. 8 | 9 | real3 delta = make_real3(pos1.x-pos3.x, pos1.y-pos3.y, pos1.z-pos3.z); 10 | real rInv = RSQRT(dot(delta, delta)); 11 | real r = RECIP(rInv); 12 | real u = drudeParams.x*r; 13 | real screening = 1-(1+0.5f*u)*EXP(-u); 14 | real pairEnergy = drudeParams.y*screening*rInv; 15 | energy += pairEnergy; 16 | real3 f = delta*(drudeParams.y*rInv*rInv*(screening*rInv-0.5f*(1+u)*EXP(-u)*drudeParams.x)); 17 | force1 += f; 18 | force3 -= f; 19 | 20 | // Second pair. 21 | 22 | delta = make_real3(pos1.x-pos4.x, pos1.y-pos4.y, pos1.z-pos4.z); 23 | rInv = RSQRT(dot(delta, delta)); 24 | r = RECIP(rInv); 25 | u = drudeParams.x*r; 26 | screening = 1-(1+0.5f*u)*EXP(-u); 27 | pairEnergy = -drudeParams.y*screening*rInv; 28 | energy += pairEnergy; 29 | f = delta*(-drudeParams.y*rInv*rInv*(screening*rInv-0.5f*(1+u)*EXP(-u)*drudeParams.x)); 30 | force1 += f; 31 | force4 -= f; 32 | 33 | // Third pair. 34 | 35 | delta = make_real3(pos2.x-pos3.x, pos2.y-pos3.y, pos2.z-pos3.z); 36 | rInv = RSQRT(dot(delta, delta)); 37 | r = RECIP(rInv); 38 | u = drudeParams.x*r; 39 | screening = 1-(1+0.5f*u)*EXP(-u); 40 | pairEnergy = -drudeParams.y*screening*rInv; 41 | energy += pairEnergy; 42 | f = delta*(-drudeParams.y*rInv*rInv*(screening*rInv-0.5f*(1+u)*EXP(-u)*drudeParams.x)); 43 | force2 += f; 44 | force3 -= f; 45 | 46 | // Fourth pair. 47 | 48 | delta = make_real3(pos2.x-pos4.x, pos2.y-pos4.y, pos2.z-pos4.z); 49 | rInv = RSQRT(dot(delta, delta)); 50 | r = RECIP(rInv); 51 | u = drudeParams.x*r; 52 | screening = 1-(1+0.5f*u)*EXP(-u); 53 | pairEnergy = drudeParams.y*screening*rInv; 54 | energy += pairEnergy; 55 | f = delta*(drudeParams.y*rInv*rInv*(screening*rInv-0.5f*(1+u)*EXP(-u)*drudeParams.x)); 56 | force2 += f; 57 | force4 -= f; 58 | -------------------------------------------------------------------------------- /platforms/metal/include/MetalCompact.h: -------------------------------------------------------------------------------- 1 | #ifndef __OPENMM_OPENCLCOMPACT_H__ 2 | #define __OPENMM_OPENCLCOMPACT_H__ 3 | 4 | /* Code for OPENCL stream compaction. Roughly based on: 5 | Billeter M, Olsson O, Assarsson U. Efficient Stream Compaction on Wide SIMD Many-Core Architectures. 6 | High Performance Graphics 2009. 7 | 8 | Notes: 9 | - paper recommends 128 threads/block, so this is hard coded. 10 | - I only implement the prefix-sum based compact primitive, and not the POPC one, as that is more 11 | complicated and performs poorly on current hardware 12 | - I only implement the scattered- and staged-write variant of phase III as it they have reasonable 13 | performance across most of the tested workloads in the paper. The selective variant is not 14 | implemented. 15 | - The prefix sum of per-block element counts (phase II) is not done in a particularly efficient 16 | manner. It is, however, done in a very easy to program manner, and integrated into the top of 17 | phase III, reducing the number of kernel invocations required. If one wanted to use existing code, 18 | it'd be easy to take the CUDA SDK scanLargeArray sample, and do a prefix sum over dgBlockCounts in 19 | a phase II kernel. You could also adapt the existing prescan128 to take an initial value, and scan 20 | dgBlockCounts in stages. 21 | 22 | Date: 23 Aug 2009 23 | Author: CUDA version by Imran Haque (ihaque@cs.stanford.edu), converted to Metal by Peter Eastman 24 | Affiliation: Stanford University 25 | License: Public Domain 26 | */ 27 | 28 | #include "MetalArray.h" 29 | #include "MetalContext.h" 30 | 31 | namespace OpenMM { 32 | 33 | class OPENMM_EXPORT_COMMON MetalCompact { 34 | public: 35 | MetalCompact(MetalContext& context); 36 | void compactStream(MetalArray& dOut, MetalArray& dIn, MetalArray& dValid, MetalArray& numValid); 37 | private: 38 | MetalContext& context; 39 | MetalArray dgBlockCounts; 40 | cl::Kernel countKernel; 41 | cl::Kernel moveValidKernel; 42 | }; 43 | 44 | } // namespace OpenMM 45 | 46 | #endif // __OPENMM_OPENCLCOMPACT_H__ 47 | -------------------------------------------------------------------------------- /platforms/metal/src/MetalKernelSources.cpp.in: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2010 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * This program is free software: you can redistribute it and/or modify * 14 | * it under the terms of the GNU Lesser General Public License as published * 15 | * by the Free Software Foundation, either version 3 of the License, or * 16 | * (at your option) any later version. * 17 | * * 18 | * This program is distributed in the hope that it will be useful, * 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 21 | * GNU Lesser General Public License for more details. * 22 | * * 23 | * You should have received a copy of the GNU Lesser General Public License * 24 | * along with this program. If not, see . * 25 | * -------------------------------------------------------------------------- */ 26 | 27 | #include "MetalKernelSources.h" 28 | 29 | using namespace OpenMM; 30 | using namespace std; 31 | 32 | -------------------------------------------------------------------------------- /platforms/metal/src/MetalEvent.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2019 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * This program is free software: you can redistribute it and/or modify * 14 | * it under the terms of the GNU Lesser General Public License as published * 15 | * by the Free Software Foundation, either version 3 of the License, or * 16 | * (at your option) any later version. * 17 | * * 18 | * This program is distributed in the hope that it will be useful, * 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 21 | * GNU Lesser General Public License for more details. * 22 | * * 23 | * You should have received a copy of the GNU Lesser General Public License * 24 | * along with this program. If not, see . * 25 | * -------------------------------------------------------------------------- */ 26 | 27 | #include "MetalEvent.h" 28 | 29 | using namespace OpenMM; 30 | 31 | MetalEvent::MetalEvent(MetalContext& context) : context(context) { 32 | } 33 | 34 | void MetalEvent::enqueue() { 35 | context.getQueue().enqueueMarkerWithWaitList(NULL, &event); 36 | } 37 | 38 | void MetalEvent::wait() { 39 | event.wait(); 40 | } 41 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/fft.metal: -------------------------------------------------------------------------------- 1 | real2 multiplyComplex(real2 c1, real2 c2) { 2 | return (real2) (c1.x*c2.x-c1.y*c2.y, c1.x*c2.y+c1.y*c2.x); 3 | } 4 | 5 | /** 6 | * Load a value from the half-complex grid produces by a real-to-complex transform. 7 | */ 8 | real2 loadComplexValue(__global const real2* restrict in, int x, int y, int z) { 9 | const int inputZSize = ZSIZE/2+1; 10 | if (z < inputZSize) 11 | return in[x*YSIZE*inputZSize+y*inputZSize+z]; 12 | int xp = (x == 0 ? 0 : XSIZE-x); 13 | int yp = (y == 0 ? 0 : YSIZE-y); 14 | real2 value = in[xp*YSIZE*inputZSize+yp*inputZSize+(ZSIZE-z)]; 15 | return (real2) (value.x, -value.y); 16 | } 17 | 18 | /** 19 | * Perform a 1D FFT on each row along one axis. 20 | */ 21 | 22 | __kernel void execFFT(__global const INPUT_TYPE* restrict in, __global OUTPUT_TYPE* restrict out, __local real2* restrict w, 23 | __local real2* restrict data0, __local real2* restrict data1) { 24 | for (int i = get_local_id(0); i < ZSIZE; i += get_local_size(0)) 25 | w[i] = (real2) (cos(-(SIGN)*i*2*M_PI/ZSIZE), sin(-(SIGN)*i*2*M_PI/ZSIZE)); 26 | barrier(CLK_LOCAL_MEM_FENCE); 27 | 28 | for (int baseIndex = get_group_id(0)*BLOCKS_PER_GROUP; baseIndex < XSIZE*YSIZE; baseIndex += get_num_groups(0)*BLOCKS_PER_GROUP) { 29 | int index = baseIndex+get_local_id(0)/ZSIZE; 30 | int x = index/YSIZE; 31 | int y = index-x*YSIZE; 32 | #if OUTPUT_IS_PACKED 33 | if (x < XSIZE/2+1) { 34 | #endif 35 | #if LOOP_REQUIRED 36 | for (int z = get_local_id(0); z < ZSIZE; z += get_local_size(0)) 37 | #if INPUT_IS_REAL 38 | data0[z] = (real2) (in[x*(YSIZE*ZSIZE)+y*ZSIZE+z], 0); 39 | #elif INPUT_IS_PACKED 40 | data0[z] = loadComplexValue(in, x, y, z); 41 | #else 42 | data0[z] = in[x*(YSIZE*ZSIZE)+y*ZSIZE+z]; 43 | #endif 44 | #else 45 | if (index < XSIZE*YSIZE) 46 | #if INPUT_IS_REAL 47 | data0[get_local_id(0)] = (real2) (in[x*(YSIZE*ZSIZE)+y*ZSIZE+get_local_id(0)%ZSIZE], 0); 48 | #elif INPUT_IS_PACKED 49 | data0[get_local_id(0)] = loadComplexValue(in, x, y, get_local_id(0)%ZSIZE); 50 | #else 51 | data0[get_local_id(0)] = in[x*(YSIZE*ZSIZE)+y*ZSIZE+get_local_id(0)%ZSIZE]; 52 | #endif 53 | #endif 54 | #if OUTPUT_IS_PACKED 55 | } 56 | #endif 57 | barrier(CLK_LOCAL_MEM_FENCE); 58 | COMPUTE_FFT 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/gbsaObcReductions.metal: -------------------------------------------------------------------------------- 1 | #define DIELECTRIC_OFFSET 0.009f 2 | #define PROBE_RADIUS 0.14f 3 | 4 | /** 5 | * Reduce the Born sums to compute the Born radii. 6 | */ 7 | 8 | KERNEL void reduceBornSum(float alpha, float beta, float gamma, 9 | GLOBAL const mm_long* RESTRICT bornSum, 10 | GLOBAL const float2* RESTRICT params, GLOBAL real* RESTRICT bornRadii, GLOBAL real* RESTRICT obcChain) { 11 | for (unsigned int index = GLOBAL_ID; index < NUM_ATOMS; index += GLOBAL_SIZE) { 12 | // Get summed Born data 13 | 14 | real sum = RECIP((real) 0x100000000)*bornSum[index]; 15 | 16 | // Now calculate Born radius and OBC term. 17 | 18 | float offsetRadius = params[index].x; 19 | sum *= 0.5f*offsetRadius; 20 | real sum2 = sum*sum; 21 | real sum3 = sum*sum2; 22 | real tanhSum = tanh(alpha*sum - beta*sum2 + gamma*sum3); 23 | real nonOffsetRadius = offsetRadius + DIELECTRIC_OFFSET; 24 | real radius = RECIP(RECIP(offsetRadius) - tanhSum/nonOffsetRadius); 25 | real chain = offsetRadius*(alpha - 2*beta*sum + 3*gamma*sum2); 26 | chain = (1-tanhSum*tanhSum)*chain / nonOffsetRadius; 27 | bornRadii[index] = radius; 28 | obcChain[index] = chain; 29 | } 30 | } 31 | 32 | /** 33 | * Reduce the Born force. 34 | */ 35 | 36 | KERNEL void reduceBornForce( 37 | GLOBAL mm_long* RESTRICT bornForce, 38 | GLOBAL mixed* RESTRICT energyBuffer, GLOBAL const float2* RESTRICT params, GLOBAL const real* RESTRICT bornRadii, GLOBAL const real* RESTRICT obcChain) { 39 | mixed energy = 0; 40 | for (unsigned int index = GLOBAL_ID; index < NUM_ATOMS; index += GLOBAL_SIZE) { 41 | // Get summed Born force 42 | 43 | real force = RECIP((real) 0x100000000)*bornForce[index]; 44 | 45 | // Now calculate the actual force 46 | 47 | float offsetRadius = params[index].x; 48 | real bornRadius = bornRadii[index]; 49 | real r = offsetRadius+DIELECTRIC_OFFSET+PROBE_RADIUS; 50 | real ratio6 = POW((offsetRadius+DIELECTRIC_OFFSET)/bornRadius, (real) 6); 51 | real saTerm = SURFACE_AREA_FACTOR*r*r*ratio6; 52 | force += saTerm/bornRadius; 53 | energy += saTerm; 54 | force *= bornRadius*bornRadius*obcChain[index]; 55 | bornForce[index] = realToFixedPoint(force); 56 | } 57 | energyBuffer[GLOBAL_ID] += energy/-6; 58 | } 59 | -------------------------------------------------------------------------------- /plugins/amoeba/platforms/metal/src/common_kernels/amoebaVdwForce2.cc: -------------------------------------------------------------------------------- 1 | { 2 | #ifdef USE_CUTOFF 3 | unsigned int includeInteraction = (!isExcluded && r2 < CUTOFF_SQUARED); 4 | #else 5 | unsigned int includeInteraction = (!isExcluded); 6 | #endif 7 | real tempForce = 0.0f; 8 | float2 pairSigmaEpsilon = sigmaEpsilon[atomType1+atomType2*NUM_TYPES]; 9 | real sigma = pairSigmaEpsilon.x; 10 | real epsilon = pairSigmaEpsilon.y; 11 | real softcore = 0.0f; 12 | #if VDW_ALCHEMICAL_METHOD == 1 13 | if (isAlchemical1 != isAlchemical2) { 14 | #elif VDW_ALCHEMICAL_METHOD == 2 15 | if (isAlchemical1 || isAlchemical2) { 16 | #endif 17 | #if VDW_ALCHEMICAL_METHOD != 0 18 | real lambda = vdwLambda[0]; 19 | epsilon = epsilon * POW(lambda, VDW_SOFTCORE_POWER); 20 | softcore = VDW_SOFTCORE_ALPHA * (1.0f - lambda) * (1.0f - lambda); 21 | } 22 | #endif 23 | #if POTENTIAL_FUNCTION == 1 24 | real pp1 = sigma / r; 25 | real pp2 = pp1 * pp1; 26 | real pp3 = pp2 * pp1; 27 | real pp6 = pp3 * pp3; 28 | real pp12 = pp6 * pp6; 29 | real termEnergy = 4 * epsilon * (pp12 - pp6); 30 | real deltaE = -24 * epsilon * (2*pp12 - pp6) / r; 31 | #else 32 | real dhal = 0.07f; 33 | real ghal = 0.12f; 34 | real dhal1 = 1.07f; 35 | real ghal1 = 1.12f; 36 | real rho = r / sigma; 37 | real rho2 = rho * rho; 38 | real rho6 = rho2 * rho2 * rho2; 39 | real rhoplus = rho + dhal; 40 | real rhodec2 = rhoplus * rhoplus; 41 | real rhodec = rhodec2 * rhodec2 * rhodec2; 42 | real s1 = 1.0f / (softcore + rhodec * rhoplus); 43 | real s2 = 1.0f / (softcore + rho6 * rho + ghal); 44 | real point72 = dhal1 * dhal1; 45 | real t1 = dhal1 * point72 * point72 * point72 * s1; 46 | real t2 = ghal1 * s2; 47 | real t2min = t2 - 2.0f; 48 | real dt1 = -7.0f * rhodec * t1 * s1; 49 | real dt2 = -7.0f * rho6 * t2 * s2; 50 | real termEnergy = epsilon * t1 * t2min; 51 | real deltaE = epsilon * (dt1 * t2min + t1 * dt2) / sigma; 52 | #endif 53 | #ifdef USE_CUTOFF 54 | if (r > TAPER_CUTOFF) { 55 | real x = r-TAPER_CUTOFF; 56 | real taper = 1+x*x*x*(TAPER_C3+x*(TAPER_C4+x*TAPER_C5)); 57 | real dtaper = x*x*(3*TAPER_C3+x*(4*TAPER_C4+x*5*TAPER_C5)); 58 | deltaE = termEnergy*dtaper + deltaE*taper; 59 | termEnergy *= taper; 60 | } 61 | #endif 62 | tempEnergy += (includeInteraction ? termEnergy : 0); 63 | dEdR -= (includeInteraction ? deltaE*invR : 0); 64 | } 65 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/brownian.metal: -------------------------------------------------------------------------------- 1 | /** 2 | * Perform the first step of Brownian integration. 3 | */ 4 | 5 | KERNEL void integrateBrownianPart1(int numAtoms, int paddedNumAtoms, mixed tauDeltaT, mixed noiseAmplitude, GLOBAL const mm_long* RESTRICT force, 6 | GLOBAL mixed4* RESTRICT posDelta, GLOBAL const mixed4* RESTRICT velm, GLOBAL const float4* RESTRICT random, unsigned int randomIndex) { 7 | randomIndex += GLOBAL_ID; 8 | const mixed fscale = tauDeltaT/(mixed) 0x100000000; 9 | for (int index = GLOBAL_ID; index < numAtoms; index += GLOBAL_SIZE) { 10 | mixed invMass = velm[index].w; 11 | if (invMass != 0) { 12 | posDelta[index].x = fscale*invMass*force[index] + noiseAmplitude*SQRT(invMass)*random[randomIndex].x; 13 | posDelta[index].y = fscale*invMass*force[index+paddedNumAtoms] + noiseAmplitude*SQRT(invMass)*random[randomIndex].y; 14 | posDelta[index].z = fscale*invMass*force[index+paddedNumAtoms*2] + noiseAmplitude*SQRT(invMass)*random[randomIndex].z; 15 | } 16 | randomIndex += GLOBAL_SIZE; 17 | } 18 | } 19 | 20 | /** 21 | * Perform the second step of Brownian integration. 22 | */ 23 | 24 | KERNEL void integrateBrownianPart2(int numAtoms, mixed oneOverDeltaT, GLOBAL real4* posq, GLOBAL mixed4* velm, GLOBAL const mixed4* RESTRICT posDelta 25 | #ifdef USE_MIXED_PRECISION 26 | , GLOBAL real4* RESTRICT posqCorrection 27 | #endif 28 | ) { 29 | for (int index = GLOBAL_ID; index < numAtoms; index += GLOBAL_SIZE) { 30 | if (velm[index].w != 0) { 31 | mixed4 delta = posDelta[index]; 32 | velm[index].x = oneOverDeltaT*delta.x; 33 | velm[index].y = oneOverDeltaT*delta.y; 34 | velm[index].z = oneOverDeltaT*delta.z; 35 | #ifdef USE_MIXED_PRECISION 36 | real4 pos1 = posq[index]; 37 | real4 pos2 = posqCorrection[index]; 38 | mixed4 pos = make_mixed4(pos1.x+(mixed)pos2.x, pos1.y+(mixed)pos2.y, pos1.z+(mixed)pos2.z, pos1.w); 39 | #else 40 | real4 pos = posq[index]; 41 | #endif 42 | pos.x += delta.x; 43 | pos.y += delta.y; 44 | pos.z += delta.z; 45 | #ifdef USE_MIXED_PRECISION 46 | posq[index] = make_real4((real) pos.x, (real) pos.y, (real) pos.z, (real) pos.w); 47 | posqCorrection[index] = make_real4(pos.x-(real) pos.x, pos.y-(real) pos.y, pos.z-(real) pos.z, 0); 48 | #else 49 | posq[index] = pos; 50 | #endif 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /platforms/metal/src/MetalProgram.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2019 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * This program is free software: you can redistribute it and/or modify * 14 | * it under the terms of the GNU Lesser General Public License as published * 15 | * by the Free Software Foundation, either version 3 of the License, or * 16 | * (at your option) any later version. * 17 | * * 18 | * This program is distributed in the hope that it will be useful, * 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 21 | * GNU Lesser General Public License for more details. * 22 | * * 23 | * You should have received a copy of the GNU Lesser General Public License * 24 | * along with this program. If not, see . * 25 | * -------------------------------------------------------------------------- */ 26 | 27 | #include "MetalProgram.h" 28 | #include "MetalKernel.h" 29 | 30 | using namespace OpenMM; 31 | using namespace std; 32 | 33 | MetalProgram::MetalProgram(MetalContext& context, cl::Program program) : context(context), program(program) { 34 | } 35 | 36 | ComputeKernel MetalProgram::createKernel(const string& name) { 37 | cl::Kernel kernel = cl::Kernel(program, name.c_str()); 38 | return shared_ptr(new MetalKernel(context, kernel)); 39 | } 40 | -------------------------------------------------------------------------------- /platforms/metal/tests/TestMetalSettle.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalTests.h" 33 | #include "TestSettle.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/include/MetalKernelFactory.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENMM_OPENCLKERNELFACTORY_H_ 2 | #define OPENMM_OPENCLKERNELFACTORY_H_ 3 | 4 | /* -------------------------------------------------------------------------- * 5 | * OpenMM * 6 | * -------------------------------------------------------------------------- * 7 | * This is part of the OpenMM molecular simulation toolkit originating from * 8 | * Simbios, the NIH National Center for Physics-Based Simulation of * 9 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 10 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 11 | * * 12 | * Portions copyright (c) 2008 Stanford University and the Authors. * 13 | * Authors: Peter Eastman * 14 | * Contributors: * 15 | * * 16 | * This program is free software: you can redistribute it and/or modify * 17 | * it under the terms of the GNU Lesser General Public License as published * 18 | * by the Free Software Foundation, either version 3 of the License, or * 19 | * (at your option) any later version. * 20 | * * 21 | * This program is distributed in the hope that it will be useful, * 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 24 | * GNU Lesser General Public License for more details. * 25 | * * 26 | * You should have received a copy of the GNU Lesser General Public License * 27 | * along with this program. If not, see . * 28 | * -------------------------------------------------------------------------- */ 29 | 30 | #include "openmm/KernelFactory.h" 31 | 32 | namespace OpenMM { 33 | 34 | /** 35 | * This KernelFactory creates all kernels for MetalPlatform. 36 | */ 37 | 38 | class MetalKernelFactory : public KernelFactory { 39 | public: 40 | KernelImpl* createKernelImpl(std::string name, const Platform& platform, ContextImpl& context) const; 41 | }; 42 | 43 | } // namespace OpenMM 44 | 45 | #endif /*OPENMM_OPENCLKERNELFACTORY_H_*/ 46 | -------------------------------------------------------------------------------- /platforms/metal/tests/TestMetalRMSDForce.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2018 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalTests.h" 33 | #include "TestRMSDForce.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/long_tests/TestMetalEwald.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalTests.h" 33 | #include "TestEwald.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/tests/TestMetalGBSAOBCForce.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalTests.h" 33 | #include "TestGBSAOBCForce.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/tests/TestMetalCustomCVForce.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2017 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalTests.h" 33 | #include "TestCustomCVForce.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/tests/TestMetalCustomGBForce.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalTests.h" 33 | #include "TestCustomGBForce.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/tests/TestMetalGayBerneForce.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2016 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalTests.h" 33 | #include "TestGayBerneForce.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /plugins/amoeba/platforms/metal/src/common_kernels/amoebaVdwForce1.cc: -------------------------------------------------------------------------------- 1 | /** 2 | * Clear the forces, and compute the position to use for each atom based on the bond reduction factors. 3 | */ 4 | KERNEL void prepareToComputeForce(GLOBAL mm_ulong* RESTRICT forceBuffers, GLOBAL real4* RESTRICT posq, GLOBAL const real4* RESTRICT tempPosq, 5 | GLOBAL const int* RESTRICT bondReductionAtoms, GLOBAL const float* RESTRICT bondReductionFactors) { 6 | for (unsigned int atom = GLOBAL_ID; atom < PADDED_NUM_ATOMS; atom += GLOBAL_SIZE) { 7 | forceBuffers[atom] = 0; 8 | forceBuffers[atom+PADDED_NUM_ATOMS] = 0; 9 | forceBuffers[atom+PADDED_NUM_ATOMS*2] = 0; 10 | real4 pos1 = tempPosq[atom]; 11 | real4 pos2 = tempPosq[bondReductionAtoms[atom]]; 12 | real factor = (real) bondReductionFactors[atom]; 13 | posq[atom] = make_real4(factor*pos1.x + (1-factor)*pos2.x, 14 | factor*pos1.y + (1-factor)*pos2.y, 15 | factor*pos1.z + (1-factor)*pos2.z, pos1.w); 16 | } 17 | } 18 | 19 | /** 20 | * Spread the forces between atoms based on the bond reduction factors. 21 | */ 22 | KERNEL void spreadForces(GLOBAL const mm_ulong* RESTRICT forceBuffers, GLOBAL mm_ulong* RESTRICT tempForceBuffers, 23 | GLOBAL const int* RESTRICT bondReductionAtoms, GLOBAL const float* RESTRICT bondReductionFactors) { 24 | for (unsigned int atom1 = GLOBAL_ID; atom1 < PADDED_NUM_ATOMS; atom1 += GLOBAL_SIZE) { 25 | int atom2 = bondReductionAtoms[atom1]; 26 | mm_long fx1 = forceBuffers[atom1]; 27 | mm_long fy1 = forceBuffers[atom1+PADDED_NUM_ATOMS]; 28 | mm_long fz1 = forceBuffers[atom1+PADDED_NUM_ATOMS*2]; 29 | if (atom1 != atom2) { 30 | real factor = (real) bondReductionFactors[atom1]; 31 | mm_long fx2 = (mm_long) ((1-factor)*fx1); 32 | mm_long fy2 = (mm_long) ((1-factor)*fy1); 33 | mm_long fz2 = (mm_long) ((1-factor)*fz1); 34 | ATOMIC_ADD(&tempForceBuffers[atom2], (mm_ulong) fx2); 35 | ATOMIC_ADD(&tempForceBuffers[atom2+PADDED_NUM_ATOMS], (mm_ulong) fy2); 36 | ATOMIC_ADD(&tempForceBuffers[atom2+PADDED_NUM_ATOMS*2], (mm_ulong) fz2); 37 | fx1 = (mm_long) (factor*fx1); 38 | fy1 = (mm_long) (factor*fy1); 39 | fz1 = (mm_long) (factor*fz1); 40 | } 41 | ATOMIC_ADD(&tempForceBuffers[atom1], (mm_ulong) fx1); 42 | ATOMIC_ADD(&tempForceBuffers[atom1+PADDED_NUM_ATOMS], (mm_ulong) fy1); 43 | ATOMIC_ADD(&tempForceBuffers[atom1+PADDED_NUM_ATOMS*2], (mm_ulong) fz1); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /platforms/metal/tests/TestMetalCMAPTorsionForce.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalTests.h" 33 | #include "TestCMAPTorsionForce.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/tests/TestMetalCMMotionRemover.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalTests.h" 33 | #include "TestCMMotionRemover.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /plugins/drude/platforms/metal/tests/TestMetalDrudeForce.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2013 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalDrudeTests.h" 33 | #include "TestDrudeForce.h" 34 | 35 | void runPlatformTests() {} 36 | -------------------------------------------------------------------------------- /platforms/metal/tests/TestMetalCompoundIntegrator.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalTests.h" 33 | #include "TestCompoundIntegrator.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/long_tests/TestMetalDispersionPME.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2017 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalTests.h" 33 | #include "TestDispersionPME.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/long_tests/TestMetalVerletIntegrator.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalTests.h" 33 | #include "TestVerletIntegrator.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/tests/TestMetalCustomCentroidBondForce.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalTests.h" 33 | #include "TestCustomCentroidBondForce.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/tests/TestMetalVariableVerletIntegrator.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalTests.h" 33 | #include "TestVariableVerletIntegrator.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/long_tests/TestMetalAndersenThermostat.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalTests.h" 33 | #include "TestAndersenThermostat.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/long_tests/TestMetalLangevinIntegrator.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalTests.h" 33 | #include "TestLangevinIntegrator.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/long_tests/TestMetalLocalEnergyMinimizer.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalTests.h" 33 | #include "TestLocalEnergyMinimizer.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /plugins/amoeba/platforms/metal/tests/TestMetalHippoNonbondedForce.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2021 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalAmoebaTests.h" 33 | #include "TestHippoNonbondedForce.h" 34 | 35 | void runPlatformTests() {} 36 | -------------------------------------------------------------------------------- /plugins/amoeba/platforms/metal/tests/TestMetalWcaDispersionForce.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2021 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalAmoebaTests.h" 33 | #include "TestWcaDispersionForce.h" 34 | 35 | void runPlatformTests() {} 36 | -------------------------------------------------------------------------------- /platforms/metal/very_long_tests/TestMetalBrownianIntegrator.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalTests.h" 33 | #include "TestBrownianIntegrator.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/very_long_tests/TestMetalNoseHooverIntegrator.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2019 Stanford University and the Authors. * 10 | * Authors: Andreas Krämer and Andrew C. Simmmonett * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalTests.h" 33 | #include "TestNoseHooverIntegrator.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /plugins/drude/platforms/metal/long_tests/TestMetalDrudeNoseHoover.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2013 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalDrudeTests.h" 33 | #include "TestDrudeNoseHoover.h" 34 | 35 | void runPlatformTests() {} 36 | -------------------------------------------------------------------------------- /platforms/metal/long_tests/TestMetalCustomManyParticleForce.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalTests.h" 33 | #include "TestCustomManyParticleForce.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/long_tests/TestMetalLangevinMiddleIntegrator.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2019 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalTests.h" 33 | #include "TestLangevinMiddleIntegrator.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | # Package.resolved 43 | # *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | # .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject/ 91 | 92 | .DS_Store 93 | /.build 94 | /Packages 95 | /*.xcodeproj 96 | xcuserdata/ 97 | DerivedData/ 98 | .swiftpm/xcode 99 | -------------------------------------------------------------------------------- /platforms/metal/long_tests/TestMetalMonteCarloFlexibleBarostat.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2021 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalTests.h" 33 | #include "TestMonteCarloFlexibleBarostat.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /plugins/amoeba/platforms/metal/tests/TestMetalAmoebaTorsionTorsionForce.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2021 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalAmoebaTests.h" 33 | #include "TestAmoebaTorsionTorsionForce.h" 34 | 35 | void runPlatformTests() {} 36 | -------------------------------------------------------------------------------- /plugins/drude/platforms/metal/very_long_tests/TestMetalDrudeSCFIntegrator.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2013 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalDrudeTests.h" 33 | #include "TestDrudeSCFIntegrator.h" 34 | 35 | void runPlatformTests() {} 36 | -------------------------------------------------------------------------------- /platforms/metal/very_long_tests/TestMetalVariableLangevinIntegrator.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalTests.h" 33 | #include "TestVariableLangevinIntegrator.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/very_long_tests/TestMetalMonteCarloAnisotropicBarostat.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalTests.h" 33 | #include "TestMonteCarloAnisotropicBarostat.h" 34 | 35 | void runPlatformTests() { 36 | } 37 | -------------------------------------------------------------------------------- /platforms/metal/very_long_tests/TestMetalMonteCarloBarostat.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalTests.h" 33 | #include "TestMonteCarloBarostat.h" 34 | 35 | void runPlatformTests() { 36 | testWater(); 37 | } 38 | -------------------------------------------------------------------------------- /plugins/amoeba/platforms/metal/include/AmoebaMetalKernelFactory.h: -------------------------------------------------------------------------------- 1 | #ifndef AMOEBA_OPENMM_OPENCLKERNELFACTORY_H_ 2 | #define AMOEBA_OPENMM_OPENCLKERNELFACTORY_H_ 3 | 4 | /* -------------------------------------------------------------------------- * 5 | * OpenMMAmoeba * 6 | * -------------------------------------------------------------------------- * 7 | * This is part of the OpenMM molecular simulation toolkit originating from * 8 | * Simbios, the NIH National Center for Physics-Based Simulation of * 9 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 10 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 11 | * * 12 | * Portions copyright (c) 2021 Stanford University and the Authors. * 13 | * Authors: * 14 | * Contributors: * 15 | * * 16 | * This program is free software: you can redistribute it and/or modify * 17 | * it under the terms of the GNU Lesser General Public License as published * 18 | * by the Free Software Foundation, either version 3 of the License, or * 19 | * (at your option) any later version. * 20 | * * 21 | * This program is distributed in the hope that it will be useful, * 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 24 | * GNU Lesser General Public License for more details. * 25 | * * 26 | * You should have received a copy of the GNU Lesser General Public License * 27 | * along with this program. If not, see . * 28 | * -------------------------------------------------------------------------- */ 29 | 30 | #include "openmm/KernelFactory.h" 31 | 32 | namespace OpenMM { 33 | 34 | /** 35 | * This KernelFactory creates all kernels for the AMOEBA Metal platform. 36 | */ 37 | 38 | class AmoebaMetalKernelFactory : public KernelFactory { 39 | public: 40 | KernelImpl* createKernelImpl(std::string name, const Platform& platform, ContextImpl& context) const; 41 | }; 42 | 43 | } // namespace OpenMM 44 | 45 | #endif /*AMOEBA_OPENMM_OPENCLKERNELFACTORY_H_*/ 46 | -------------------------------------------------------------------------------- /plugins/amoeba/platforms/metal/tests/TestMetalAmoebaExtrapolatedPolarization.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2021 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalAmoebaTests.h" 33 | #include "TestAmoebaExtrapolatedPolarization.h" 34 | 35 | void runPlatformTests() {} 36 | -------------------------------------------------------------------------------- /plugins/amoeba/platforms/metal/tests/TestMetalAmoebaGeneralizedKirkwoodForce.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2021 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalAmoebaTests.h" 33 | #include "TestAmoebaGeneralizedKirkwoodForce.h" 34 | 35 | void runPlatformTests() {} 36 | -------------------------------------------------------------------------------- /plugins/drude/platforms/metal/very_long_tests/TestMetalDrudeLangevinIntegrator.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2013 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalDrudeTests.h" 33 | #include "TestDrudeLangevinIntegrator.h" 34 | 35 | void runPlatformTests() {} 36 | -------------------------------------------------------------------------------- /platforms/metal/src/MetalKernelSources.h.in: -------------------------------------------------------------------------------- 1 | #ifndef OPENMM_OPENCLKERNELSOURCES_H_ 2 | #define OPENMM_OPENCLKERNELSOURCES_H_ 3 | 4 | /* -------------------------------------------------------------------------- * 5 | * OpenMM * 6 | * -------------------------------------------------------------------------- * 7 | * This is part of the OpenMM molecular simulation toolkit originating from * 8 | * Simbios, the NIH National Center for Physics-Based Simulation of * 9 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 10 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 11 | * * 12 | * Portions copyright (c) 2010 Stanford University and the Authors. * 13 | * Authors: Peter Eastman * 14 | * Contributors: * 15 | * * 16 | * This program is free software: you can redistribute it and/or modify * 17 | * it under the terms of the GNU Lesser General Public License as published * 18 | * by the Free Software Foundation, either version 3 of the License, or * 19 | * (at your option) any later version. * 20 | * * 21 | * This program is distributed in the hope that it will be useful, * 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 24 | * GNU Lesser General Public License for more details. * 25 | * * 26 | * You should have received a copy of the GNU Lesser General Public License * 27 | * along with this program. If not, see . * 28 | * -------------------------------------------------------------------------- */ 29 | 30 | #include "openmm/common/windowsExportCommon.h" 31 | #include 32 | 33 | namespace OpenMM { 34 | 35 | /** 36 | * This class is a central holding place for the source code of Metal kernels. 37 | * The CMake build script inserts declarations into it based on the .metal files 38 | * in the kernels subfolder. 39 | */ 40 | 41 | class OPENMM_EXPORT_COMMON MetalKernelSources { 42 | public: 43 | @KERNEL_FILE_DECLARATIONS@ 44 | }; 45 | 46 | } // namespace OpenMM 47 | 48 | #endif /*OPENMM_OPENCLKERNELSOURCES_H_*/ 49 | -------------------------------------------------------------------------------- /platforms/metal/tests/TestMetalCustomHbondForce.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalTests.h" 33 | 34 | // TODO: Include the new custom HBond force once OpenMM 8.1.0 releases. 35 | #include "TestCustomHbondForce.h" 36 | 37 | void runPlatformTests() { 38 | } 39 | -------------------------------------------------------------------------------- /plugins/amoeba/platforms/metal/tests/TestMetalAmoebaMultipoleForce.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2021 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalAmoebaTests.h" 33 | #include "TestAmoebaMultipoleForce.h" 34 | 35 | void runPlatformTests() { 36 | testNoQuadrupoles(false); 37 | testNoQuadrupoles(true); 38 | } 39 | -------------------------------------------------------------------------------- /platforms/metal/src/MetalParameterSet.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2009-2012 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * This program is free software: you can redistribute it and/or modify * 14 | * it under the terms of the GNU Lesser General Public License as published * 15 | * by the Free Software Foundation, either version 3 of the License, or * 16 | * (at your option) any later version. * 17 | * * 18 | * This program is distributed in the hope that it will be useful, * 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 21 | * GNU Lesser General Public License for more details. * 22 | * * 23 | * You should have received a copy of the GNU Lesser General Public License * 24 | * along with this program. If not, see . * 25 | * -------------------------------------------------------------------------- */ 26 | 27 | #include "MetalParameterSet.h" 28 | 29 | using namespace OpenMM; 30 | using namespace std; 31 | 32 | MetalParameterSet::MetalParameterSet(MetalContext& context, int numParameters, int numObjects, const string& name, bool bufferPerParameter, bool useDoublePrecision) : 33 | ComputeParameterSet(context, numParameters, numObjects, name, bufferPerParameter, useDoublePrecision) { 34 | for (auto& info : getParameterInfos()) { 35 | buffers.push_back(MetalNonbondedUtilities::ParameterInfo(info.getName(), info.getComponentType(), info.getNumComponents(), info.getSize(), context.unwrap(info.getArray()).getDeviceBuffer())); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/removeCM.metal: -------------------------------------------------------------------------------- 1 | /** 2 | * Calculate the center of mass momentum. 3 | */ 4 | 5 | KERNEL void calcCenterOfMassMomentum(int numAtoms, GLOBAL const mixed4* RESTRICT velm, GLOBAL float4* RESTRICT cmMomentum) { 6 | LOCAL float4 temp[64]; 7 | float4 cm = make_float4(0); 8 | for (int index = GLOBAL_ID; index < numAtoms; index += GLOBAL_SIZE) { 9 | mixed4 velocity = velm[index]; 10 | if (velocity.w != 0) { 11 | mixed mass = RECIP(velocity.w); 12 | cm.x += (float) (velocity.x*mass); 13 | cm.y += (float) (velocity.y*mass); 14 | cm.z += (float) (velocity.z*mass); 15 | } 16 | } 17 | 18 | // Sum the threads in this group. 19 | 20 | int thread = LOCAL_ID; 21 | temp[thread] = cm; 22 | SYNC_THREADS; 23 | if (thread < 32) 24 | temp[thread] += temp[thread+32]; 25 | SYNC_THREADS; 26 | if (thread < 16) 27 | temp[thread] += temp[thread+16]; 28 | SYNC_THREADS; 29 | if (thread < 8) 30 | temp[thread] += temp[thread+8]; 31 | SYNC_THREADS; 32 | if (thread < 4) 33 | temp[thread] += temp[thread+4]; 34 | SYNC_THREADS; 35 | if (thread < 2) 36 | temp[thread] += temp[thread+2]; 37 | SYNC_THREADS; 38 | if (thread == 0) 39 | cmMomentum[GROUP_ID] = temp[thread]+temp[thread+1]; 40 | } 41 | 42 | /** 43 | * Remove center of mass motion. 44 | */ 45 | 46 | KERNEL void removeCenterOfMassMomentum(int numAtoms, GLOBAL mixed4* RESTRICT velm, GLOBAL const float4* RESTRICT cmMomentum) { 47 | // First sum all of the momenta that were calculated by individual groups. 48 | 49 | LOCAL float4 temp[64]; 50 | float4 cm = make_float4(0); 51 | for (int index = LOCAL_ID; index < NUM_GROUPS; index += LOCAL_SIZE) 52 | cm += cmMomentum[index]; 53 | int thread = LOCAL_ID; 54 | temp[thread] = cm; 55 | SYNC_THREADS; 56 | if (thread < 32) 57 | temp[thread] += temp[thread+32]; 58 | SYNC_THREADS; 59 | if (thread < 16) 60 | temp[thread] += temp[thread+16]; 61 | SYNC_THREADS; 62 | if (thread < 8) 63 | temp[thread] += temp[thread+8]; 64 | SYNC_THREADS; 65 | if (thread < 4) 66 | temp[thread] += temp[thread+4]; 67 | SYNC_THREADS; 68 | if (thread < 2) 69 | temp[thread] += temp[thread+2]; 70 | SYNC_THREADS; 71 | cm = make_float4(INVERSE_TOTAL_MASS*(temp[0].x+temp[1].x), INVERSE_TOTAL_MASS*(temp[0].y+temp[1].y), INVERSE_TOTAL_MASS*(temp[0].z+temp[1].z), 0); 72 | 73 | // Now remove the center of mass velocity from each atom. 74 | 75 | for (int index = GLOBAL_ID; index < numAtoms; index += GLOBAL_SIZE) { 76 | velm[index].x -= cm.x; 77 | velm[index].y -= cm.y; 78 | velm[index].z -= cm.z; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /platforms/metal/include/MetalExpressionUtilities.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENMM_OPENCLEXPRESSIONUTILITIES_H_ 2 | #define OPENMM_OPENCLEXPRESSIONUTILITIES_H_ 3 | 4 | /* -------------------------------------------------------------------------- * 5 | * OpenMM * 6 | * -------------------------------------------------------------------------- * 7 | * This is part of the OpenMM molecular simulation toolkit originating from * 8 | * Simbios, the NIH National Center for Physics-Based Simulation of * 9 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 10 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 11 | * * 12 | * Portions copyright (c) 2019 Stanford University and the Authors. * 13 | * Authors: Peter Eastman * 14 | * Contributors: * 15 | * * 16 | * This program is free software: you can redistribute it and/or modify * 17 | * it under the terms of the GNU Lesser General Public License as published * 18 | * by the Free Software Foundation, either version 3 of the License, or * 19 | * (at your option) any later version. * 20 | * * 21 | * This program is distributed in the hope that it will be useful, * 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 24 | * GNU Lesser General Public License for more details. * 25 | * * 26 | * You should have received a copy of the GNU Lesser General Public License * 27 | * along with this program. If not, see . * 28 | * -------------------------------------------------------------------------- */ 29 | 30 | #include "openmm/common/ExpressionUtilities.h" 31 | #include "openmm/common/windowsExportCommon.h" 32 | 33 | namespace OpenMM { 34 | 35 | /** 36 | * This class exists only for backward compatibility. It adds no features beyond 37 | * the base ExpressionUtilities class. 38 | */ 39 | 40 | class OPENMM_EXPORT_COMMON MetalExpressionUtilities : public ExpressionUtilities { 41 | public: 42 | MetalExpressionUtilities(ComputeContext& context) : ExpressionUtilities(context) { 43 | } 44 | }; 45 | 46 | } // namespace OpenMM 47 | 48 | #endif /*OPENMM_OPENCLEXPRESSIONUTILITIES_H_*/ 49 | -------------------------------------------------------------------------------- /platforms/metal/tests/has_opencl_gpu.c: -------------------------------------------------------------------------------- 1 | /* 2 | * file has_opencl_gpu.c 3 | * created May 6, 2010 4 | * by Christopher Bruns 5 | * Returns zero if an Metal-capable GPU is found. 6 | * Returns one otherwise. 7 | */ 8 | 9 | #if defined(__APPLE__) || defined(__MACOSX) 10 | #include 11 | #else 12 | #include 13 | #endif 14 | 15 | #include 16 | 17 | /* 18 | * check_devices() looks for a GPU among all Metal devices 19 | * in a particular Metal platform. 20 | * Returns zero if a GPU is found. Returns one otherwise. 21 | */ 22 | int check_devices(cl_platform_id platform_id) 23 | { 24 | cl_int err; 25 | cl_device_id devices[10]; 26 | cl_uint num_devices; 27 | size_t d; 28 | char dname[500]; 29 | size_t namesize; 30 | 31 | err = clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU, 10, devices, &num_devices); 32 | if (err != CL_SUCCESS) { 33 | printf("clGetDeviceIDs error: %d", err); 34 | switch(err) { 35 | case CL_INVALID_PLATFORM : 36 | printf(" INVALID_PLATFORM; platform is not a valid platform.\n"); 37 | break; 38 | case CL_INVALID_DEVICE_TYPE : 39 | printf(" CL_INVALID_DEVICE_TYPE; device_type is not a valid value.\n"); 40 | break; 41 | case CL_INVALID_VALUE : 42 | printf(" CL_INVALID_VALUE; num_entries is equal to zero and device_type is not NULL or if both num_devices and device_type are NULL.\n"); 43 | break; 44 | case CL_DEVICE_NOT_FOUND : 45 | printf(" CL_DEVICE_NOT_FOUND; no Metal devices that matched device_type were found.\n"); 46 | break; 47 | default : 48 | printf(" unrecognized error code '%d'\n", err); 49 | break; 50 | } 51 | return 1; 52 | } 53 | printf("%d devices found\n", num_devices); 54 | if (num_devices < 1) 55 | return 1; 56 | for (d = 0; d < num_devices; ++d) { 57 | clGetDeviceInfo(devices[d], CL_DEVICE_NAME, 500, dname, &namesize); 58 | printf("Device #%d name = %s\n", d, dname); 59 | } 60 | return 0; 61 | } 62 | 63 | int main(int argc, char** argv) 64 | { 65 | size_t p; 66 | cl_int err; 67 | cl_platform_id platforms[10]; 68 | cl_uint num_platforms; 69 | int status; 70 | 71 | /* Investigate all valid platform IDs */ 72 | err = clGetPlatformIDs(10, platforms, &num_platforms); 73 | if (num_platforms < 1) { 74 | printf("No Metal platforms found.\n"); 75 | return 1; 76 | } 77 | for (p = 0; p < num_platforms; ++p) { 78 | printf("Checking platform ID %d\n", p); 79 | status = check_devices(platforms[p]); 80 | if (status == 0) 81 | return status; // found GPU 82 | } 83 | return 1; // did NOT find GPU 84 | } 85 | -------------------------------------------------------------------------------- /plugins/drude/platforms/metal/tests/MetalDrudeTests.h: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2013 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalTests.h" 33 | 34 | extern "C" void registerDrudeMetalKernelFactories(); 35 | 36 | using namespace OpenMM; 37 | 38 | void setupKernels (int argc, char* argv[]) { 39 | registerDrudeMetalKernelFactories(); 40 | platform = dynamic_cast(Platform::getPlatformByName("HIP")); 41 | initializeTests(argc, argv); 42 | } 43 | -------------------------------------------------------------------------------- /platforms/metal/include/MetalEvent.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENMM_OPENCLEVENT_H_ 2 | #define OPENMM_OPENCLEVENT_H_ 3 | 4 | /* -------------------------------------------------------------------------- * 5 | * OpenMM * 6 | * -------------------------------------------------------------------------- * 7 | * This is part of the OpenMM molecular simulation toolkit originating from * 8 | * Simbios, the NIH National Center for Physics-Based Simulation of * 9 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 10 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 11 | * * 12 | * Portions copyright (c) 2019 Stanford University and the Authors. * 13 | * Authors: Peter Eastman * 14 | * Contributors: * 15 | * * 16 | * This program is free software: you can redistribute it and/or modify * 17 | * it under the terms of the GNU Lesser General Public License as published * 18 | * by the Free Software Foundation, either version 3 of the License, or * 19 | * (at your option) any later version. * 20 | * * 21 | * This program is distributed in the hope that it will be useful, * 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 24 | * GNU Lesser General Public License for more details. * 25 | * * 26 | * You should have received a copy of the GNU Lesser General Public License * 27 | * along with this program. If not, see . * 28 | * -------------------------------------------------------------------------- */ 29 | 30 | #include "MetalContext.h" 31 | #include "openmm/common/ComputeEvent.h" 32 | 33 | namespace OpenMM { 34 | 35 | /** 36 | * This is the Metal implementation of the ComputeKernelImpl interface. 37 | */ 38 | 39 | class MetalEvent : public ComputeEventImpl { 40 | public: 41 | MetalEvent(MetalContext& context); 42 | /** 43 | * Place the event into the device's execution queue. 44 | */ 45 | void enqueue(); 46 | /** 47 | * Block until all operations started before the call to enqueue() have completed. 48 | */ 49 | void wait(); 50 | private: 51 | MetalContext& context; 52 | cl::Event event; 53 | }; 54 | 55 | } // namespace OpenMM 56 | 57 | #endif /*OPENMM_OPENCLEVENT_H_*/ 58 | -------------------------------------------------------------------------------- /plugins/amoeba/platforms/metal/tests/MetalAmoebaTests.h: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2013 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "MetalTests.h" 33 | 34 | extern "C" void registerAmoebaMetalKernelFactories(); 35 | 36 | using namespace OpenMM; 37 | 38 | void setupKernels (int argc, char* argv[]) { 39 | registerAmoebaMetalKernelFactories(); 40 | platform = dynamic_cast(Platform::getPlatformByName("HIP")); 41 | initializeTests(argc, argv); 42 | } 43 | -------------------------------------------------------------------------------- /plugins/rpmd/platforms/metal/very_long_tests/TestMetalRpmdParaHydrogen.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2011-2014 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #include "../tests/MetalTests.h" 33 | #include "TestRpmd.h" 34 | 35 | extern "C" void registerRPMDMetalKernelFactories(); 36 | 37 | using namespace OpenMM; 38 | 39 | void runPlatformTests() { 40 | testParaHydrogen(); 41 | } 42 | 43 | void setupKernels (int argc, char* argv[]) { 44 | registerRPMDMetalKernelFactories(); 45 | platform = dynamic_cast(Platform::getPlatformByName("HIP")); 46 | initializeTests(argc, argv); 47 | } 48 | 49 | -------------------------------------------------------------------------------- /platforms/metal/tests/MetalTests.h: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMM * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2015-2016 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * Permission is hereby granted, free of charge, to any person obtaining a * 14 | * copy of this software and associated documentation files (the "Software"), * 15 | * to deal in the Software without restriction, including without limitation * 16 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 17 | * and/or sell copies of the Software, and to permit persons to whom the * 18 | * Software is furnished to do so, subject to the following conditions: * 19 | * * 20 | * The above copyright notice and this permission notice shall be included in * 21 | * all copies or substantial portions of the Software. * 22 | * * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 26 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 27 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 28 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 29 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 30 | * -------------------------------------------------------------------------- */ 31 | 32 | #ifdef WIN32 33 | #define _USE_MATH_DEFINES // Needed to get M_PI 34 | #endif 35 | #include "MetalPlatform.h" 36 | #include 37 | 38 | OpenMM::MetalPlatform platform; 39 | 40 | void initializeTests(int argc, char* argv[]) { 41 | if (argc > 1) 42 | platform.setPropertyDefaultValue("Precision", std::string(argv[1])); 43 | if (argc > 2) 44 | platform.setPropertyDefaultValue("MetalPlatformIndex", std::string(argv[2])); 45 | if (argc > 3) 46 | platform.setPropertyDefaultValue("DeviceIndex", std::string(argv[3])); 47 | } 48 | -------------------------------------------------------------------------------- /plugins/rpmd/platforms/metal/include/MetalRpmdKernelFactory.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENMM_OPENCLRPMDKERNELFACTORY_H_ 2 | #define OPENMM_OPENCLRPMDKERNELFACTORY_H_ 3 | 4 | /* -------------------------------------------------------------------------- * 5 | * OpenMM * 6 | * -------------------------------------------------------------------------- * 7 | * This is part of the OpenMM molecular simulation toolkit originating from * 8 | * Simbios, the NIH National Center for Physics-Based Simulation of * 9 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 10 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 11 | * * 12 | * Portions copyright (c) 2011 Stanford University and the Authors. * 13 | * Authors: Peter Eastman * 14 | * Contributors: * 15 | * * 16 | * Permission is hereby granted, free of charge, to any person obtaining a * 17 | * copy of this software and associated documentation files (the "Software"), * 18 | * to deal in the Software without restriction, including without limitation * 19 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 20 | * and/or sell copies of the Software, and to permit persons to whom the * 21 | * Software is furnished to do so, subject to the following conditions: * 22 | * * 23 | * The above copyright notice and this permission notice shall be included in * 24 | * all copies or substantial portions of the Software. * 25 | * * 26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 27 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 28 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 29 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 30 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 31 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 32 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 33 | * -------------------------------------------------------------------------- */ 34 | 35 | #include "openmm/KernelFactory.h" 36 | 37 | namespace OpenMM { 38 | 39 | /** 40 | * This KernelFactory creates kernels for the Metal implementation of RPMDIntegrator. 41 | */ 42 | 43 | class MetalRpmdKernelFactory : public KernelFactory { 44 | public: 45 | KernelImpl* createKernelImpl(std::string name, const Platform& platform, ContextImpl& context) const; 46 | }; 47 | 48 | } // namespace OpenMM 49 | 50 | #endif /*OPENMM_OPENCLRPMDKERNELFACTORY_H_*/ 51 | -------------------------------------------------------------------------------- /platforms/metal/include/MetalProgram.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENMM_OPENCLPROGRAM_H_ 2 | #define OPENMM_OPENCLPROGRAM_H_ 3 | 4 | /* -------------------------------------------------------------------------- * 5 | * OpenMM * 6 | * -------------------------------------------------------------------------- * 7 | * This is part of the OpenMM molecular simulation toolkit originating from * 8 | * Simbios, the NIH National Center for Physics-Based Simulation of * 9 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 10 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 11 | * * 12 | * Portions copyright (c) 2019 Stanford University and the Authors. * 13 | * Authors: Peter Eastman * 14 | * Contributors: * 15 | * * 16 | * This program is free software: you can redistribute it and/or modify * 17 | * it under the terms of the GNU Lesser General Public License as published * 18 | * by the Free Software Foundation, either version 3 of the License, or * 19 | * (at your option) any later version. * 20 | * * 21 | * This program is distributed in the hope that it will be useful, * 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 24 | * GNU Lesser General Public License for more details. * 25 | * * 26 | * You should have received a copy of the GNU Lesser General Public License * 27 | * along with this program. If not, see . * 28 | * -------------------------------------------------------------------------- */ 29 | 30 | #include "openmm/common/ComputeProgram.h" 31 | #include "MetalContext.h" 32 | 33 | namespace OpenMM { 34 | 35 | /** 36 | * This is the Metal implementation of the ComputeProgramImpl interface. 37 | */ 38 | 39 | class MetalProgram : public ComputeProgramImpl { 40 | public: 41 | /** 42 | * Create a new MetalProgram. 43 | * 44 | * @param context the context this kernel belongs to 45 | * @param program the compiled program 46 | */ 47 | MetalProgram(MetalContext& context, cl::Program program); 48 | /** 49 | * Create a ComputeKernel for one of the kernels in this program. 50 | * 51 | * @param name the name of the kernel to get 52 | */ 53 | ComputeKernel createKernel(const std::string& name); 54 | private: 55 | MetalContext& context; 56 | cl::Program program; 57 | }; 58 | 59 | } // namespace OpenMM 60 | 61 | #endif /*OPENMM_OPENCLPROGRAM_H_*/ 62 | -------------------------------------------------------------------------------- /plugins/drude/platforms/metal/include/MetalDrudeKernelFactory.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENMM_OPENCLDRUDEKERNELFACTORY_H_ 2 | #define OPENMM_OPENCLDRUDEKERNELFACTORY_H_ 3 | 4 | /* -------------------------------------------------------------------------- * 5 | * OpenMM * 6 | * -------------------------------------------------------------------------- * 7 | * This is part of the OpenMM molecular simulation toolkit originating from * 8 | * Simbios, the NIH National Center for Physics-Based Simulation of * 9 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 10 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 11 | * * 12 | * Portions copyright (c) 2013 Stanford University and the Authors. * 13 | * Authors: Peter Eastman * 14 | * Contributors: * 15 | * * 16 | * Permission is hereby granted, free of charge, to any person obtaining a * 17 | * copy of this software and associated documentation files (the "Software"), * 18 | * to deal in the Software without restriction, including without limitation * 19 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, * 20 | * and/or sell copies of the Software, and to permit persons to whom the * 21 | * Software is furnished to do so, subject to the following conditions: * 22 | * * 23 | * The above copyright notice and this permission notice shall be included in * 24 | * all copies or substantial portions of the Software. * 25 | * * 26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * 27 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 28 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * 29 | * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 30 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 31 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * 32 | * USE OR OTHER DEALINGS IN THE SOFTWARE. * 33 | * -------------------------------------------------------------------------- */ 34 | 35 | #include "openmm/KernelFactory.h" 36 | 37 | namespace OpenMM { 38 | 39 | /** 40 | * This KernelFactory creates kernels for the Metal implementation of the Drude plugin. 41 | */ 42 | 43 | class MetalDrudeKernelFactory : public KernelFactory { 44 | public: 45 | KernelImpl* createKernelImpl(std::string name, const Platform& platform, ContextImpl& context) const; 46 | }; 47 | 48 | } // namespace OpenMM 49 | 50 | #endif /*OPENMM_OPENCLDRUDEKERNELFACTORY_H_*/ 51 | -------------------------------------------------------------------------------- /platforms/metal/include/MetalForceInfo.h: -------------------------------------------------------------------------------- 1 | #ifndef OPENMM_OPENCLFORCEINFO_H_ 2 | #define OPENMM_OPENCLFORCEINFO_H_ 3 | 4 | /* -------------------------------------------------------------------------- * 5 | * OpenMM * 6 | * -------------------------------------------------------------------------- * 7 | * This is part of the OpenMM molecular simulation toolkit originating from * 8 | * Simbios, the NIH National Center for Physics-Based Simulation of * 9 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 10 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 11 | * * 12 | * Portions copyright (c) 2009 Stanford University and the Authors. * 13 | * Authors: Peter Eastman * 14 | * Contributors: * 15 | * * 16 | * This program is free software: you can redistribute it and/or modify * 17 | * it under the terms of the GNU Lesser General Public License as published * 18 | * by the Free Software Foundation, either version 3 of the License, or * 19 | * (at your option) any later version. * 20 | * * 21 | * This program is distributed in the hope that it will be useful, * 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 24 | * GNU Lesser General Public License for more details. * 25 | * * 26 | * You should have received a copy of the GNU Lesser General Public License * 27 | * along with this program. If not, see . * 28 | * -------------------------------------------------------------------------- */ 29 | 30 | #include "openmm/common/ComputeForceInfo.h" 31 | #include "openmm/common/windowsExportCommon.h" 32 | #include 33 | 34 | namespace OpenMM { 35 | 36 | /** 37 | * This class exists primarily for backward compatibility. Beyond the features of 38 | * ComputeForceInfo, it adds the ability to specify a required number of force buffers. 39 | * Using this mechanism is equivalent to calling requestForceBuffers() on the MetalContext. 40 | */ 41 | 42 | class OPENMM_EXPORT_COMMON MetalForceInfo : public ComputeForceInfo { 43 | public: 44 | MetalForceInfo(int requiredForceBuffers) : requiredForceBuffers(requiredForceBuffers) { 45 | } 46 | /** 47 | * Get the number of force buffers this force requires. 48 | */ 49 | int getRequiredForceBuffers() { 50 | return requiredForceBuffers; 51 | } 52 | private: 53 | int requiredForceBuffers; 54 | }; 55 | 56 | } // namespace OpenMM 57 | 58 | #endif /*OPENMM_OPENCLFORCEINFO_H_*/ 59 | -------------------------------------------------------------------------------- /plugins/amoeba/platforms/metal/src/common_kernels/bicubic.cc: -------------------------------------------------------------------------------- 1 | DEVICE void bicubic(real4 y, real4 y1i, real4 y2i, real4 y12i, real x1, real x1l, real x1u, 2 | real x2, real x2l, real x2u, real* energyOut, real* dang1Out, real* dang2Out) { 3 | real c[4][4]; 4 | real d1 = x1u - x1l; 5 | real d2 = x2u - x2l; 6 | real d12 = d1*d2; 7 | real4 y1 = d1*y1i; 8 | real4 y2 = d2*y2i; 9 | real4 y12 = d12*y12i; 10 | 11 | c[0][0] = y.x; 12 | c[0][1] = y2.x; 13 | c[0][2] = 3.0f*(y.w - y.x) - (2.0f*y2.x + y2.w); 14 | c[0][3] = 2.0f*(y.x - y.w) + y2.x + y2.w; 15 | c[1][0] = y1.x; 16 | c[1][1] = y12.x; 17 | c[1][2] = 3.0f*(y1.w - y1.x) - (2.0f*y12.x + y12.w); 18 | c[1][3] = 2.0f*(y1.x - y1.w) + y12.x + y12.w; 19 | c[2][0] = 3.0f*(y.y - y.x) - (2.0f*y1.x + y1.y); 20 | c[2][1] = 3.0f*(y2.y - y2.x) - (2.0f*y12.x + y12.y); 21 | c[2][2] = 9.0f*(y.x - y.y + y.z - y.w) + 6.0f* y1.x + 3.0f* y1.y - 3.0f* y1.z - 6.0f* y1.w + 22 | 6.0f* y2.x - 6.0f* y2.y - 3.0f* y2.z + 3.0f* y2.w + 23 | 4.0f*y12.x + 2.0f*y12.y + y12.z + 2.0f*y12.w; 24 | c[2][3] = 6.0f*(y.y - y.x + y.w - y.z) + -4.0f* y1.x - 2.0f* y1.y + 2.0f* y1.z + 4.0f* y1.w + 25 | -3.0f* y2.x + 3.0f* y2.y + 3.0f* y2.z - 3.0f* y2.w 26 | -2.0f*y12.x - y12.y - y12.z - 2.0f*y12.w; 27 | c[3][0] = 2.0f*(y.x - y.y) + y1.x + y1.y; 28 | c[3][1] = 2.0f*(y2.x - y2.y) + y12.x + y12.y; 29 | c[3][2] = 6.0f*(y.y - y.x + y.w - y.z) + 30 | 3.0f*(y1.z + y1.w - y1.x - y1.y) + 31 | 2.0f*(2.0f*(y2.y - y2.x) + y2.z - y2.w) + 32 | -2.0f*(y12.x + y12.y) - y12.z - y12.w; 33 | c[3][3] = 4.0f*( y.x - y.y + y.z - y.w) + 34 | 2.0f*(y1.x + y1.y - y1.z - y1.w) + 35 | 2.0f*(y2.x - y2.y - y2.z + y2.w) + 36 | y12.x + y12.y + y12.z + y12.w; 37 | 38 | real t = (x1-x1l) / (x1u-x1l); 39 | real u = (x2-x2l) / (x2u-x2l); 40 | 41 | real energy = ((c[3][3]*u + c[3][2])*u + c[3][1])*u + c[3][0]; 42 | energy = t*energy + ((c[2][3]*u + c[2][2])*u + c[2][1])*u + c[2][0]; 43 | energy = t*energy + ((c[1][3]*u + c[1][2])*u + c[1][1])*u + c[1][0]; 44 | energy = t*energy + ((c[0][3]*u + c[0][2])*u + c[0][1])*u + c[0][0]; 45 | 46 | real dang1 = (3.0f*c[3][3]*t + 2.0f*c[2][3])*t + c[1][3]; 47 | dang1 = u*dang1 + (3.0f*c[3][2]*t + 2.0f*c[2][2])*t + c[1][2]; 48 | dang1 = u*dang1 + (3.0f*c[3][1]*t + 2.0f*c[2][1])*t + c[1][1]; 49 | dang1 = u*dang1 + (3.0f*c[3][0]*t + 2.0f*c[2][0])*t + c[1][0]; 50 | 51 | real dang2 = (3.0f*c[3][3]*u + 2.0f*c[3][2])*u + c[3][1]; 52 | dang2 = t*dang2 + (3.0f*c[2][3]*u + 2.0f*c[2][2])*u + c[2][1]; 53 | dang2 = t*dang2 + (3.0f*c[1][3]*u + 2.0f*c[1][2])*u + c[1][1]; 54 | dang2 = t*dang2 + (3.0f*c[0][3]*u + 2.0f*c[0][2])*u + c[0][1]; 55 | 56 | dang1 = dang1 / (x1u-x1l); 57 | dang2 = dang2 / (x2u-x2l); 58 | 59 | *energyOut = energy; 60 | *dang1Out = dang1; 61 | *dang2Out = dang2; 62 | } -------------------------------------------------------------------------------- /plugins/amoeba/platforms/metal/src/common_kernels/hippoFixedField.cc: -------------------------------------------------------------------------------- 1 | real invR2 = invR*invR; 2 | real invR3 = invR*invR2; 3 | real invR5 = invR3*invR2; 4 | real invR7 = invR5*invR2; 5 | 6 | #if USE_EWALD 7 | // Calculate the error function damping terms. 8 | 9 | real ralpha = PME_ALPHA*r; 10 | real exp2a = EXP(-(ralpha*ralpha)); 11 | #ifdef USE_DOUBLE_PRECISION 12 | const real erfcAlphaR = erfc(ralpha); 13 | #else 14 | // This approximation for erfc is from Abramowitz and Stegun (1964) p. 299. They cite the following as 15 | // the original source: C. Hastings, Jr., Approximations for Digital Computers (1955). It has a maximum 16 | // error of 1.5e-7. 17 | 18 | const real t = RECIP(1.0f+0.3275911f*ralpha); 19 | const real erfcAlphaR = (0.254829592f+(-0.284496736f+(1.421413741f+(-1.453152027f+1.061405429f*t)*t)*t)*t)*t*exp2a; 20 | #endif 21 | real bn0 = erfcAlphaR*invR; 22 | real alsq2 = 2*PME_ALPHA*PME_ALPHA; 23 | real alsq2n = 1/(SQRT_PI*PME_ALPHA); 24 | alsq2n *= alsq2; 25 | real bn1 = (bn0+alsq2n*exp2a)*invR2; 26 | alsq2n *= alsq2; 27 | real bn2 = (3*bn1+alsq2n*exp2a)*invR2; 28 | alsq2n *= alsq2; 29 | real bn3 = (5*bn2+alsq2n*exp2a)*invR2; 30 | #endif 31 | 32 | // Calculate the field at particle 1 due to multipoles at particle 2 33 | 34 | real fdamp3, fdamp5, fdamp7; 35 | computeDirectFieldDampingFactors(alpha2, r, &fdamp3, &fdamp5, &fdamp7); 36 | #ifndef COMPUTING_EXCEPTIONS 37 | real scale = 1; 38 | #endif 39 | #ifdef USE_EWALD 40 | real rr3 = bn1 - (1-scale)*invR3; 41 | real rr3j = bn1 - (1-scale*fdamp3)*invR3; 42 | real rr5j = bn2 - (1-scale*fdamp5)*3*invR5; 43 | real rr7j = bn3 - (1-scale*fdamp7)*15*invR7; 44 | #else 45 | real rr3 = scale*invR3; 46 | real rr3j = scale*fdamp3*invR3; 47 | real rr5j = scale*3*fdamp5*invR5; 48 | real rr7j = scale*15*fdamp7*invR7; 49 | #endif 50 | real qZZ2 = -qXX2-qYY2; 51 | real3 qDotDelta2 = make_real3(delta.x*qXX2 + delta.y*qXY2 + delta.z*qXZ2, 52 | delta.x*qXY2 + delta.y*qYY2 + delta.z*qYZ2, 53 | delta.x*qXZ2 + delta.y*qYZ2 + delta.z*qZZ2); 54 | real dipoleDelta2 = dot(dipole2, delta); 55 | real qdpoleDelta2 = dot(qDotDelta2, delta); 56 | real factor2 = rr3*coreCharge2 + rr3j*valenceCharge2 - rr5j*dipoleDelta2 + rr7j*qdpoleDelta2; 57 | tempField1 = -delta*factor2 - dipole2*rr3j + qDotDelta2*2*rr5j; 58 | 59 | // Calculate the field at particle 2 due to multipoles at particle 1 60 | 61 | computeDirectFieldDampingFactors(alpha1, r, &fdamp3, &fdamp5, &fdamp7); 62 | #ifdef USE_EWALD 63 | real rr3i = bn1 - (1-scale*fdamp3)*invR3; 64 | real rr5i = bn2 - (1-scale*fdamp5)*3*invR5; 65 | real rr7i = bn3 - (1-scale*fdamp7)*15*invR7; 66 | #else 67 | real rr3i = scale*fdamp3*invR3; 68 | real rr5i = scale*3*fdamp5*invR5; 69 | real rr7i = scale*15*fdamp7*invR7; 70 | #endif 71 | real qZZ1 = -qXX1-qYY1; 72 | real3 qDotDelta1 = make_real3(delta.x*qXX1 + delta.y*qXY1 + delta.z*qXZ1, 73 | delta.x*qXY1 + delta.y*qYY1 + delta.z*qYZ1, 74 | delta.x*qXZ1 + delta.y*qYZ1 + delta.z*qZZ1); 75 | real dipoleDelta1 = dot(dipole1, delta); 76 | real qdpoleDelta1 = dot(qDotDelta1, delta); 77 | real factor1 = rr3*coreCharge1 + rr3i*valenceCharge1 + rr5i*dipoleDelta1 + rr7i*qdpoleDelta1; 78 | tempField2 = delta*factor1 - dipole1*rr3i - qDotDelta1*2*rr5i; 79 | -------------------------------------------------------------------------------- /platforms/metal/src/kernels/customIntegratorPerDof.metal: -------------------------------------------------------------------------------- 1 | #ifdef SUPPORTS_DOUBLE_PRECISION 2 | typedef double TempType; 3 | typedef double3 TempType3; 4 | typedef double4 TempType4; 5 | 6 | #define make_TempType3 make_double3 7 | #define make_TempType4 make_double4 8 | #define convertToTempType3(a) make_double3((a).x, (a).y, (a).z) 9 | #define convertToTempType4(a) make_double4((a).x, (a).y, (a).z, (a).w) 10 | 11 | inline DEVICE mixed4 convertFromDouble4(double4 a) { 12 | return make_mixed4(a.x, a.y, a.z, a.w); 13 | } 14 | #else 15 | typedef float TempType; 16 | typedef float3 TempType3; 17 | typedef float4 TempType4; 18 | 19 | #define make_TempType3 make_float3 20 | #define make_TempType4 make_float4 21 | #define convertToTempType3(a) make_float3((a).x, (a).y, (a).z) 22 | #define convertToTempType4(a) make_float4((a).x, (a).y, (a).z, (a).w) 23 | #endif 24 | 25 | /** 26 | * Load the position of a particle. 27 | */ 28 | inline DEVICE TempType4 loadPos(GLOBAL const real4* RESTRICT posq, GLOBAL const real4* RESTRICT posqCorrection, int index) { 29 | #ifdef USE_MIXED_PRECISION 30 | real4 pos1 = posq[index]; 31 | real4 pos2 = posqCorrection[index]; 32 | return make_TempType4(pos1.x+(mixed)pos2.x, pos1.y+(mixed)pos2.y, pos1.z+(mixed)pos2.z, pos1.w); 33 | #else 34 | return convertToTempType4(posq[index]); 35 | #endif 36 | } 37 | 38 | /** 39 | * Store the position of a particle. 40 | */ 41 | inline DEVICE void storePos(GLOBAL real4* RESTRICT posq, GLOBAL real4* RESTRICT posqCorrection, int index, TempType4 pos) { 42 | #ifdef USE_MIXED_PRECISION 43 | posq[index] = make_real4((real) pos.x, (real) pos.y, (real) pos.z, (real) pos.w); 44 | posqCorrection[index] = make_real4(pos.x-(real) pos.x, pos.y-(real) pos.y, pos.z-(real) pos.z, 0); 45 | #else 46 | posq[index] = make_real4(pos.x, pos.y, pos.z, pos.w); 47 | #endif 48 | } 49 | 50 | KERNEL void computePerDof(GLOBAL real4* RESTRICT posq, GLOBAL real4* RESTRICT posqCorrection, GLOBAL mixed4* RESTRICT posDelta, 51 | GLOBAL mixed4* RESTRICT velm, GLOBAL const mm_long* RESTRICT force, GLOBAL const mixed2* RESTRICT dt, GLOBAL const mixed* RESTRICT globals, 52 | GLOBAL mixed* RESTRICT sum, GLOBAL const float4* RESTRICT gaussianValues, unsigned int gaussianBaseIndex, GLOBAL const float4* RESTRICT uniformValues, 53 | const mixed energy, GLOBAL mixed* RESTRICT energyParamDerivs 54 | PARAMETER_ARGUMENTS) { 55 | int index = GLOBAL_ID; 56 | TempType3 stepSize = make_TempType3(dt[0].y); 57 | const TempType forceScale = ((TempType) 1)/0xFFFFFFFF; 58 | while (index < NUM_ATOMS) { 59 | #ifdef LOAD_POS_AS_DELTA 60 | TempType4 position = loadPos(posq, posqCorrection, index) + convertToTempType4(posDelta[index]); 61 | #else 62 | TempType4 position = loadPos(posq, posqCorrection, index); 63 | #endif 64 | TempType4 velocity = convertToTempType4(velm[index]); 65 | TempType3 f = make_TempType3(forceScale*force[index], forceScale*force[index+PADDED_NUM_ATOMS], forceScale*force[index+PADDED_NUM_ATOMS*2]); 66 | TempType3 mass = make_TempType3(RECIP(velocity.w)); 67 | if (velocity.w != 0.0) { 68 | int gaussianIndex = gaussianBaseIndex; 69 | int uniformIndex = 0; 70 | COMPUTE_STEP 71 | } 72 | index += GLOBAL_SIZE; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /platforms/metal/src/MetalCompact.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* Code for Metal stream compaction. Roughly based on: 4 | Billeter M, Olsson O, Assarsson U. Efficient Stream Compaction on Wide SIMD Many-Core Architectures. 5 | High Performance Graphics 2009. 6 | 7 | Notes: 8 | - paper recommends 128 threads/block, so this is hard coded. 9 | - I only implement the prefix-sum based compact primitive, and not the POPC one, as that is more 10 | complicated and performs poorly on current hardware 11 | - I only implement the scattered- and staged-write variant of phase III as it they have reasonable 12 | performance across most of the tested workloads in the paper. The selective variant is not 13 | implemented. 14 | - The prefix sum of per-block element counts (phase II) is not done in a particularly efficient 15 | manner. It is, however, done in a very easy to program manner, and integrated into the top of 16 | phase III, reducing the number of kernel invocations required. If one wanted to use existing code, 17 | it'd be easy to take the CUDA SDK scanLargeArray sample, and do a prefix sum over dgBlockCounts in 18 | a phase II kernel. You could also adapt the existing prescan128 to take an initial value, and scan 19 | dgBlockCounts in stages. 20 | 21 | Date: 23 Aug 2009 22 | Author: CUDA version by Imran Haque (ihaque@cs.stanford.edu), converted to Metal by Peter Eastman 23 | Affiliation: Stanford University 24 | License: Public Domain 25 | */ 26 | 27 | #include "MetalCompact.h" 28 | #include "MetalKernelSources.h" 29 | 30 | using namespace OpenMM; 31 | 32 | MetalCompact::MetalCompact(MetalContext& context) : context(context) { 33 | dgBlockCounts.initialize(context, context.getNumThreadBlocks(), "dgBlockCounts"); 34 | cl::Program program = context.createProgram(MetalKernelSources::compact); 35 | countKernel = cl::Kernel(program, "countElts"); 36 | moveValidKernel = cl::Kernel(program, "moveValidElementsStaged"); 37 | } 38 | 39 | void MetalCompact::compactStream(MetalArray& dOut, MetalArray& dIn, MetalArray& dValid, MetalArray& numValid) { 40 | // Figure out # elements per block 41 | unsigned int len = dIn.getSize(); 42 | unsigned int numBlocks = context.getNumThreadBlocks(); 43 | if (numBlocks*128 > len) 44 | numBlocks = (len+127)/128; 45 | const size_t eltsPerBlock = len/numBlocks + ((len % numBlocks) ? 1 : 0); 46 | 47 | // TODO: implement loop over blocks of 10M 48 | // Phase 1: Calculate number of valid elements per thread block 49 | countKernel.setArg(0, dgBlockCounts.getDeviceBuffer()); 50 | countKernel.setArg(1, dValid.getDeviceBuffer()); 51 | countKernel.setArg(2, len); 52 | countKernel.setArg(3, 128*sizeof(cl_uint), NULL); 53 | context.executeKernel(countKernel, len, 128); 54 | 55 | // Phase 2/3: Move valid elements using SIMD compaction 56 | moveValidKernel.setArg(0, dIn.getDeviceBuffer()); 57 | moveValidKernel.setArg(1, dOut.getDeviceBuffer()); 58 | moveValidKernel.setArg(2, dValid.getDeviceBuffer()); 59 | moveValidKernel.setArg(3, dgBlockCounts.getDeviceBuffer()); 60 | moveValidKernel.setArg(4, len); 61 | moveValidKernel.setArg(5, numValid.getDeviceBuffer()); 62 | moveValidKernel.setArg(6, 128*sizeof(cl_uint), NULL); 63 | moveValidKernel.setArg(7, 128*sizeof(cl_uint), NULL); 64 | moveValidKernel.setArg(8, 128*sizeof(cl_uint), NULL); 65 | context.executeKernel(moveValidKernel, len, 128); 66 | } 67 | -------------------------------------------------------------------------------- /plugins/rpmd/platforms/metal/src/MetalRpmdKernelFactory.cpp: -------------------------------------------------------------------------------- 1 | /* -------------------------------------------------------------------------- * 2 | * OpenMMAmoeba * 3 | * -------------------------------------------------------------------------- * 4 | * This is part of the OpenMM molecular simulation toolkit originating from * 5 | * Simbios, the NIH National Center for Physics-Based Simulation of * 6 | * Biological Structures at Stanford, funded under the NIH Roadmap for * 7 | * Medical Research, grant U54 GM072970. See https://simtk.org. * 8 | * * 9 | * Portions copyright (c) 2011-2021 Stanford University and the Authors. * 10 | * Authors: Peter Eastman * 11 | * Contributors: * 12 | * * 13 | * This program is free software: you can redistribute it and/or modify * 14 | * it under the terms of the GNU Lesser General Public License as published * 15 | * by the Free Software Foundation, either version 3 of the License, or * 16 | * (at your option) any later version. * 17 | * * 18 | * This program is distributed in the hope that it will be useful, * 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 21 | * GNU Lesser General Public License for more details. * 22 | * * 23 | * You should have received a copy of the GNU Lesser General Public License * 24 | * along with this program. If not, see . * 25 | * -------------------------------------------------------------------------- */ 26 | 27 | #include 28 | 29 | #include "MetalRpmdKernelFactory.h" 30 | #include "CommonRpmdKernels.h" 31 | #include "MetalContext.h" 32 | #include "openmm/internal/windowsExportRpmd.h" 33 | #include "openmm/internal/ContextImpl.h" 34 | #include "openmm/OpenMMException.h" 35 | 36 | using namespace OpenMM; 37 | 38 | extern "C" OPENMM_EXPORT void registerPlatforms() { 39 | } 40 | 41 | extern "C" OPENMM_EXPORT void registerKernelFactories() { 42 | try { 43 | Platform& platform = Platform::getPlatformByName("HIP"); 44 | MetalRpmdKernelFactory* factory = new MetalRpmdKernelFactory(); 45 | platform.registerKernelFactory(IntegrateRPMDStepKernel::Name(), factory); 46 | } 47 | catch (std::exception ex) { 48 | // Ignore 49 | } 50 | } 51 | 52 | extern "C" OPENMM_EXPORT void registerRPMDMetalKernelFactories() { 53 | try { 54 | Platform::getPlatformByName("HIP"); 55 | } 56 | catch (...) { 57 | Platform::registerPlatform(new MetalPlatform()); 58 | } 59 | registerKernelFactories(); 60 | } 61 | 62 | KernelImpl* MetalRpmdKernelFactory::createKernelImpl(std::string name, const Platform& platform, ContextImpl& context) const { 63 | MetalContext& cl = *static_cast(context.getPlatformData())->contexts[0]; 64 | if (name == IntegrateRPMDStepKernel::Name()) 65 | return new CommonIntegrateRPMDStepKernel(name, platform, cl); 66 | throw OpenMMException((std::string("Tried to create kernel with illegal kernel name '")+name+"'").c_str()); 67 | } 68 | --------------------------------------------------------------------------------