Skip to content

Instantly share code, notes, and snippets.

View saifthe1's full-sized avatar

Saif Mulla saifthe1

View GitHub Profile
/**
* This kernel is invoked by VerletIntegrator to take one time step.
*/
class IntegrateVerletStepKernel : public KernelImpl {
public:
static std::string Name() {
return "IntegrateVerletStep";
}
IntegrateVerletStepKernel(std::string name, const Platform& platform) : KernelImpl(name, platform) {
}
class Context;
class ContextImpl;
/**
* An Integrator defines a method for simulating a System by integrating the equations of motion.
* This is an abstract class. Subclasses define particular integration methods.
*
* Each Integrator object is bound to a particular Context which it integrates. This connection
* is specified by passing the Integrator as an argument to the constructor of the Context.
*/
namespace OpenMM {
/**
* This is an Integrator which simulates a System using the velocity Verlet algorithm.
*/
class OPENMM_EXPORT VelocityVerletIntegrator : public Integrator {
public:
/**
* Create a VelocityVerletIntegrator.
#ifndef OPENMM_CONTROLTOOLS_H
#define OPENMM_CONTROLTOOLS_H
#include <stdio.h>
#include <iostream>
#include "openmm/Kernel.h"
#include "internal/windowsExport.h"
using std::string;
#ifndef OPENMM_MEASUREMENTTOOLS_H
#define OPENMM_MEASUREMENTTOOLS_H
#include<iostream>
#include<cmath>
#include<math.h>
#include "openmm/Tensor.h"
#include "openmm/Kernel.h"
#include "internal/windowsExport.h"
#include <iostream>
#include "openmm/Context.h"
#include "openmm/OpenMMException.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/kernels.h"
#include "openmm/ControlTools.h"
using namespace OpenMM;
@saifthe1
saifthe1 / BinVirial.cpp
Created October 29, 2013 10:50
This class prepares relevant information for OpenCL kernel if virial is to be calculated along with forces.
void OpenCLMeasureBinVirialKernel::initialize(ContextImpl& impl){
int pna = cl_.getPaddedNumAtoms();
int numatoms = cl_.getNumAtoms();
int numForceBuffers = cl_.getNumForceBuffers();
numOfMolecules_ = cl_.getNumOfMolecules();
cl::Kernel tempkernel = cl_.getNonbondedUtilities().getForceKernel();
atomMasses_ = new OpenCLArray<mm_float4>(cl_,numOfMolecules_,"atomMasses",true);
System& system = impl.getSystem();
@saifthe1
saifthe1 / Berendsen.cl
Last active December 26, 2015 20:59
two different Berendsen thermostat implementation on GPU one performs thermosetting on whole system and other does in N bins.
/**
* @todo: replace the preprocessor with dynamic values
* using compiler prefix inside opencl
*/
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
__kernel void binMomentum(
__global const float4* restrict velm,
__global const float4* restrict posq,
@saifthe1
saifthe1 / velocityVerlet.cl
Created October 29, 2013 11:01
Velocity Verlet Integrator called from Velocity Verlet Integrator class
#ifdef SUPPORTS_DOUBLE_PRECISION
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
#endif
/**
* Perform the first step of velocity verlet integration.
*/
__kernel void velocityVerletPart1(int numAtoms,
__global const float* deltaT,
@saifthe1
saifthe1 / forcecalculation.cl
Created October 29, 2013 11:06
Force calculation function containing additional modification for virial calculation and facilitates invocation using preprocessor flags
#ifdef SUPPORTS_64_BIT_ATOMICS
#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable
#pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
#endif
#define TILE_SIZE 32
// Cannot use float3 as OpenCL defines it to be 4 DWORD aligned. This would
// cause every element of array to have DWORD of padding to make it 4 DWORD
// aligned which wastes space and causes LDS bank conflicts as stride is no