Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
b31196d9
Commit
b31196d9
authored
Dec 18, 2008
by
Mark Friedrichs
Browse files
Latest
parent
7ed51ce4
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
145 additions
and
376 deletions
+145
-376
platforms/brook/src/BrookBondParameters.cpp
platforms/brook/src/BrookBondParameters.cpp
+1
-0
platforms/brook/src/BrookBonded.cpp
platforms/brook/src/BrookBonded.cpp
+52
-40
platforms/brook/src/BrookCalcNonbondedForceKernel.cpp
platforms/brook/src/BrookCalcNonbondedForceKernel.cpp
+49
-82
platforms/brook/src/BrookCalcNonbondedForceKernel.h
platforms/brook/src/BrookCalcNonbondedForceKernel.h
+2
-20
platforms/brook/src/BrookNonBonded.cpp
platforms/brook/src/BrookNonBonded.cpp
+28
-23
platforms/brook/src/BrookPlatform.cpp
platforms/brook/src/BrookPlatform.cpp
+0
-5
platforms/brook/src/OpenMMBrookInterface.cpp
platforms/brook/src/OpenMMBrookInterface.cpp
+7
-4
platforms/brook/src/gpu/kforce_CDLJ.br
platforms/brook/src/gpu/kforce_CDLJ.br
+6
-21
platforms/brook/src/gpu/knlforce.br
platforms/brook/src/gpu/knlforce.br
+0
-139
platforms/brook/src/gpu/pre_test.br
platforms/brook/src/gpu/pre_test.br
+0
-42
No files found.
platforms/brook/src/BrookBondParameters.cpp
View file @
b31196d9
...
@@ -219,6 +219,7 @@ int BrookBondParameters::setBond( int bondIndex, int* particleIndices, double* b
...
@@ -219,6 +219,7 @@ int BrookBondParameters::setBond( int bondIndex, int* particleIndices, double* b
int
numberOfParametersInBond
=
getNumberOfParametersInBond
();
int
numberOfParametersInBond
=
getNumberOfParametersInBond
();
for
(
int
ii
=
0
;
ii
<
numberOfParametersInBond
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
numberOfParametersInBond
;
ii
++
){
//fprintf( stderr, "Param %s %d %e\n", getBondName().c_str(), ii, bondParameters[ii] );
_bondParameters
[
bondIndex
].
push_back
(
bondParameters
[
ii
]
);
_bondParameters
[
bondIndex
].
push_back
(
bondParameters
[
ii
]
);
}
}
...
...
platforms/brook/src/BrookBonded.cpp
View file @
b31196d9
...
@@ -61,8 +61,11 @@ BrookBonded::BrookBonded( ){
...
@@ -61,8 +61,11 @@ BrookBonded::BrookBonded( ){
_setupCompleted
=
0
;
_setupCompleted
=
0
;
_numberOfParticles
=
0
;
_numberOfParticles
=
0
;
_ljScale
=
(
BrookOpenMMFloat
)
0.83333333
;
//_ljScale = (BrookOpenMMFloat) 0.83333333;
_ljScale
=
1.0
;
//_coulombFactor = 332.0;
//_coulombFactor = 332.0;
_coulombFactor
=
(
BrookOpenMMFloat
)
138.935485
;
_coulombFactor
=
(
BrookOpenMMFloat
)
138.935485
;
_particleIndicesStream
=
NULL
;
_particleIndicesStream
=
NULL
;
...
@@ -1000,16 +1003,13 @@ int BrookBonded::addPairs( int *nbondeds, int *particles, BrookOpenMMFloat* para
...
@@ -1000,16 +1003,13 @@ int BrookBonded::addPairs( int *nbondeds, int *particles, BrookOpenMMFloat* para
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
if
(
debug
&&
getLog
()
){
if
(
debug
&&
getLog
()
){
(
void
)
fprintf
(
getLog
(),
"%s npairs=%d
\n
"
,
methodName
.
c_str
(),
bonded14Indices
.
size
()
);
(
void
)
fprintf
(
getLog
(),
"%s npairs=%d
sz=%u %u
\n
"
,
methodName
.
c_str
(),
bonded14Indices
.
size
()
,
bonded14Indices
.
size
(),
nonbondedParameters
.
size
()
);
fflush
(
getLog
()
);
}
}
for
(
unsigned
int
ii
=
0
;
ii
<
bonded14Indices
.
size
();
ii
++
){
for
(
unsigned
int
ii
=
0
;
ii
<
bonded14Indices
.
size
();
ii
++
){
std
::
vector
<
int
>
particlesIndices
=
bonded14Indices
[
ii
];
int
i
=
bonded14Indices
[
ii
][
0
];
int
j
=
bonded14Indices
[
ii
][
1
];
int
index
=
0
;
int
i
=
particlesIndices
[
index
++
];
int
j
=
particlesIndices
[
index
++
];
int
ibonded
=
matchPair
(
i
,
j
,
*
nbondeds
,
particles
);
int
ibonded
=
matchPair
(
i
,
j
,
*
nbondeds
,
particles
);
if
(
ibonded
<
0
){
if
(
ibonded
<
0
){
...
@@ -1019,13 +1019,12 @@ int BrookBonded::addPairs( int *nbondeds, int *particles, BrookOpenMMFloat* para
...
@@ -1019,13 +1019,12 @@ int BrookBonded::addPairs( int *nbondeds, int *particles, BrookOpenMMFloat* para
(
*
nbondeds
)
++
;
(
*
nbondeds
)
++
;
}
}
vector
<
double
>
iParameters
=
nonbondedParameters
[
i
];
//(void) fprintf( getLog(), "%s %d %ibonded=%d done\n", methodName.c_str(), ii, ibonded ); fflush( getLog() );
vector
<
double
>
jParameters
=
nonbondedParameters
[
j
];
double
c6
=
0.5
*
(
iParameters
[
1
]
+
jParameters
[
1
]);
//double c12 = lj14Scale*(iParameters[2] * jParameters[2]);
double
c12
=
2.0
*
(
iParameters
[
2
]
*
jParameters
[
2
]);
vector
<
double
>
iParameters
=
nonbondedParameters
[
ii
];
/*
double c6 = iParameters[1];
double c12 = 4.0*iParameters[2];
double sig, eps;
double sig, eps;
if( c12 != 0.0 ){
if( c12 != 0.0 ){
//eps = c6*c6/c12;
//eps = c6*c6/c12;
...
@@ -1036,17 +1035,17 @@ int BrookBonded::addPairs( int *nbondeds, int *particles, BrookOpenMMFloat* para
...
@@ -1036,17 +1035,17 @@ int BrookBonded::addPairs( int *nbondeds, int *particles, BrookOpenMMFloat* para
eps = 0.0;
eps = 0.0;
sig = 1.0;
sig = 1.0;
}
}
*/
PARAMS
(
ibonded
,
4
,
2
)
=
(
BrookOpenMMFloat
)
sig
;
PARAMS
(
ibonded
,
4
,
2
)
=
(
BrookOpenMMFloat
)
iParameters
[
1
]
;
PARAMS
(
ibonded
,
4
,
3
)
=
(
BrookOpenMMFloat
)
eps
;
PARAMS
(
ibonded
,
4
,
3
)
=
(
BrookOpenMMFloat
)
(
4.0
*
iParameters
[
2
])
;
// a little wasteful, but ...
// a little wasteful, but ...
charges
[
i
]
=
(
BrookOpenMMFloat
)
iParameters
[
0
];
charges
[
ibonded
]
=
(
BrookOpenMMFloat
)
iParameters
[
0
];
charges
[
j
]
=
(
BrookOpenMMFloat
)
jParameters
[
0
];
if
(
debug
){
if
(
debug
){
(
void
)
fprintf
(
getLog
(),
" %d [%d %d ] %.3e %.3e
\n
"
,
ibonded
,
i
,
j
,
sig
,
eps
);
(
void
)
fprintf
(
getLog
(),
" %d [%d %d ] %.3e %.3e
q=%.4f
\n
"
,
ibonded
,
i
,
j
,
iParameters
[
1
],
iParameters
[
2
],
charges
[
ibonded
]
);
}
}
}
}
...
@@ -1220,11 +1219,18 @@ int BrookBonded::setup( int numberOfParticles,
...
@@ -1220,11 +1219,18 @@ int BrookBonded::setup( int numberOfParticles,
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"BrookBonded::setup"
;
static
const
std
::
string
methodName
=
"BrookBonded::setup"
;
static
const
int
PrintOn
=
0
;
static
const
int
PrintOn
=
1
;
double
dangleValue
=
0.0
;
double
dangleValue
=
0.0
;
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
if
(
PrintOn
&&
getLog
()
){
(
void
)
fprintf
(
getLog
(),
"%s particles=%d
\n
[%p %p %p %p %p] (bond, angle, pd, rb, 14)
\n
"
"14Scale=%f %f StreamW=%d StreamSz=%d
\n
"
,
methodName
.
c_str
(),
numberOfParticles
,
harmonicBondBrookBondParameters
,
harmonicAngleBrookBondParameters
,
periodicTorsionBrookBondParameters
,
rbTorsionBrookBondParameters
,
nonBonded14ForceParameters
,
lj14Scale
,
coulombScale
,
particleStreamWidth
,
particleStreamSize
);
fflush
(
getLog
()
);
}
_numberOfParticles
=
numberOfParticles
;
_numberOfParticles
=
numberOfParticles
;
// check that particle indices & parameters agree
// check that particle indices & parameters agree
...
@@ -1233,6 +1239,7 @@ int BrookBonded::setup( int numberOfParticles,
...
@@ -1233,6 +1239,7 @@ int BrookBonded::setup( int numberOfParticles,
int
maxBonds
=
10
*
numberOfParticles
;
int
maxBonds
=
10
*
numberOfParticles
;
int
*
particles
=
new
int
[
5
*
maxBonds
];
int
*
particles
=
new
int
[
5
*
maxBonds
];
float
*
charges
=
new
BrookOpenMMFloat
[
maxBonds
];
BrookOpenMMFloat
**
params
=
new
BrookOpenMMFloat
*
[
getNumberOfParameterStreams
()];
BrookOpenMMFloat
**
params
=
new
BrookOpenMMFloat
*
[
getNumberOfParameterStreams
()];
for
(
int
ii
=
0
;
ii
<
getNumberOfParameterStreams
();
ii
++
){
for
(
int
ii
=
0
;
ii
<
getNumberOfParameterStreams
();
ii
++
){
...
@@ -1250,6 +1257,7 @@ int BrookBonded::setup( int numberOfParticles,
...
@@ -1250,6 +1257,7 @@ int BrookBonded::setup( int numberOfParticles,
// All parameters must be initialized to values that will
// All parameters must be initialized to values that will
// produce zero for the corresponding force.
// produce zero for the corresponding force.
memset
(
charges
,
0
,
maxBonds
*
sizeof
(
BrookOpenMMFloat
)
);
for
(
int
ii
=
0
;
ii
<
maxBonds
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
maxBonds
;
ii
++
){
ATOMS
(
ii
,
0
)
=
-
1
;
ATOMS
(
ii
,
0
)
=
-
1
;
...
@@ -1273,46 +1281,50 @@ int BrookBonded::setup( int numberOfParticles,
...
@@ -1273,46 +1281,50 @@ int BrookBonded::setup( int numberOfParticles,
int
nbondeds
=
0
;
int
nbondeds
=
0
;
if
(
rbTorsionBrookBondParameters
){
if
(
rbTorsionBrookBondParameters
){
addRBTorsions
(
&
nbondeds
,
particles
,
params
,
rbTorsionBrookBondParameters
->
getParticleIndices
(),
rbTorsionBrookBondParameters
->
getBondParameters
()
);
addRBTorsions
(
&
nbondeds
,
particles
,
params
,
rbTorsionBrookBondParameters
->
getParticleIndices
(),
rbTorsionBrookBondParameters
->
getBondParameters
()
);
}
}
if
(
periodicTorsionBrookBondParameters
){
if
(
periodicTorsionBrookBondParameters
){
addPTorsions
(
&
nbondeds
,
particles
,
params
,
periodicTorsionBrookBondParameters
->
getParticleIndices
(),
periodicTorsionBrookBondParameters
->
getBondParameters
()
);
addPTorsions
(
&
nbondeds
,
particles
,
params
,
periodicTorsionBrookBondParameters
->
getParticleIndices
(),
periodicTorsionBrookBondParameters
->
getBondParameters
()
);
}
}
if
(
harmonicAngleBrookBondParameters
){
if
(
harmonicAngleBrookBondParameters
){
addAngles
(
&
nbondeds
,
particles
,
params
,
harmonicAngleBrookBondParameters
->
getParticleIndices
(),
harmonicAngleBrookBondParameters
->
getBondParameters
()
);
addAngles
(
&
nbondeds
,
particles
,
params
,
harmonicAngleBrookBondParameters
->
getParticleIndices
(),
harmonicAngleBrookBondParameters
->
getBondParameters
()
);
}
}
if
(
harmonicBondBrookBondParameters
){
if
(
harmonicBondBrookBondParameters
){
addBonds
(
&
nbondeds
,
particles
,
params
,
harmonicBondBrookBondParameters
->
getParticleIndices
(),
harmonicBondBrookBondParameters
->
getBondParameters
()
);
addBonds
(
&
nbondeds
,
particles
,
params
,
harmonicBondBrookBondParameters
->
getParticleIndices
(),
harmonicBondBrookBondParameters
->
getBondParameters
()
);
}
}
// ---------------------------------------------------------------------------------------
// charge stream
_chargeStream
=
new
BrookFloatStreamInternal
(
BrookCommon
::
BondedChargeStream
,
numberOfParticles
,
particleStreamWidth
,
BrookStreamInternal
::
Float
,
dangleValue
);
BrookOpenMMFloat
*
charges
=
new
BrookOpenMMFloat
[
_chargeStream
->
getStreamSize
()];
memset
(
charges
,
0
,
_chargeStream
->
getStreamSize
()
*
sizeof
(
BrookOpenMMFloat
)
);
// ---------------------------------------------------------------------------------------
//(void) fprintf( getLog(), "%s Post addBonds particles=%d number of bonds=%d maxBonds=%d\n", methodName.c_str(), numberOfParticles, nbondeds, maxBonds );
if
(
nonBonded14ForceParameters
){
if
(
nonBonded14ForceParameters
){
addPairs
(
&
nbondeds
,
particles
,
params
,
charges
,
nonBonded14ForceParameters
->
getParticleIndices
(),
nonBonded14ForceParameters
->
getBondParameters
(),
lj14Scale
,
coulombScale
);
addPairs
(
&
nbondeds
,
particles
,
params
,
charges
,
nonBonded14ForceParameters
->
getParticleIndices
(),
nonBonded14ForceParameters
->
getBondParameters
(),
lj14Scale
,
coulombScale
);
}
}
// ---------------------------------------------------------------------------------------
// check that number of bonds not too large for memory allocated
// check that number of bonds not too large for memory allocated
if
(
nbondeds
>=
maxBonds
){
if
(
nbondeds
>=
maxBonds
){
std
::
stringstream
message
;
std
::
stringstream
message
;
message
<<
methodName
<<
" number of bonds="
<<
nbondeds
<<
" is greater than maxBonds="
<<
maxBonds
<<
" numberOfParticles="
<<
numberOfParticles
;
message
<<
methodName
<<
" number of bonds="
<<
nbondeds
<<
" is greater than maxBonds="
<<
maxBonds
<<
" numberOfParticles="
<<
numberOfParticles
;
throw
OpenMMException
(
message
.
str
()
);
throw
OpenMMException
(
message
.
str
()
);
}
else
if
(
nbondeds
<
1
){
// return if no bonds
(
void
)
fprintf
(
getLog
(),
"%s WARNING: particles=%d number of bonds=%d maxBonds=%d
\n
"
,
methodName
.
c_str
(),
numberOfParticles
,
nbondeds
,
maxBonds
);
_setupCompleted
=
1
;
return
DefaultReturnValue
;
}
else
if
(
PrintOn
&&
getLog
()
){
}
else
if
(
PrintOn
&&
getLog
()
){
(
void
)
fprintf
(
getLog
(),
"%s particles=%d number of bonds=%d maxBonds=%d
\n
"
,
methodName
.
c_str
(),
numberOfParticles
,
nbondeds
,
maxBonds
);
(
void
)
fprintf
(
getLog
(),
"%s particles=%d number of bonds=%d maxBonds=%d
\n
"
,
methodName
.
c_str
(),
numberOfParticles
,
nbondeds
,
maxBonds
);
(
void
)
fflush
(
getLog
()
);
(
void
)
fflush
(
getLog
()
);
}
}
// ---------------------------------------------------------------------------------------
// charge stream
_chargeStream
=
new
BrookFloatStreamInternal
(
BrookCommon
::
BondedChargeStream
,
nbondeds
,
particleStreamWidth
,
BrookStreamInternal
::
Float
,
dangleValue
);
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// particle indices stream
// particle indices stream
...
@@ -1381,13 +1393,13 @@ int BrookBonded::setup( int numberOfParticles,
...
@@ -1381,13 +1393,13 @@ int BrookBonded::setup( int numberOfParticles,
" phi[%10.6f %6.1f %5.1f]
\n
"
" phi[%10.6f %6.1f %5.1f]
\n
"
" ang[%6.3f %8.2f] [%6.3f %8.2f]
\n
"
" ang[%6.3f %8.2f] [%6.3f %8.2f]
\n
"
" h[%8.5f %14.6e] [%8.5f %14.6e] [%8.5f %14.6e]
\n
"
" h[%8.5f %14.6e] [%8.5f %14.6e] [%8.5f %14.6e]
\n
"
" 14[%15.6e %15.6e]
\n
"
,
index
,
" 14[%15.6e %15.6e]
q14=%15.6e
\n
"
,
index
,
ATOMS
(
index
,
0
),
ATOMS
(
index
,
1
),
ATOMS
(
index
,
2
),
ATOMS
(
index
,
3
),
ATOMS
(
index
,
0
),
ATOMS
(
index
,
1
),
ATOMS
(
index
,
2
),
ATOMS
(
index
,
3
),
params
[
kIndex
][
ii
],
params
[
kIndex
][
ii
+
1
],
params
[
kIndex
][
ii
+
2
],
params
[
kIndex
][
ii
+
3
],
params
[
jIndex
][
ii
],
params
[
kIndex
][
ii
],
params
[
kIndex
][
ii
+
1
],
params
[
kIndex
][
ii
+
2
],
params
[
kIndex
][
ii
+
3
],
params
[
jIndex
][
ii
],
params
[
jIndex
][
ii
+
1
],
params
[
jIndex
][
ii
+
2
],
params
[
jIndex
][
ii
+
3
],
params
[
jIndex
][
ii
+
1
],
params
[
jIndex
][
ii
+
2
],
params
[
jIndex
][
ii
+
3
],
params
[
iIndex
][
ii
],
params
[
iIndex
][
ii
+
1
],
params
[
iIndex
][
ii
+
2
],
params
[
iIndex
][
ii
+
3
],
params
[
iIndex
][
ii
],
params
[
iIndex
][
ii
+
1
],
params
[
iIndex
][
ii
+
2
],
params
[
iIndex
][
ii
+
3
],
params
[
lIndex
][
ii
],
params
[
lIndex
][
ii
+
1
],
params
[
lIndex
][
ii
+
2
],
params
[
lIndex
][
ii
+
3
],
params
[
lIndex
][
ii
],
params
[
lIndex
][
ii
+
1
],
params
[
lIndex
][
ii
+
2
],
params
[
lIndex
][
ii
+
3
],
params
[
mIndex
][
ii
],
params
[
mIndex
][
ii
+
1
],
params
[
mIndex
][
ii
+
2
],
params
[
mIndex
][
ii
+
3
]
);
params
[
mIndex
][
ii
],
params
[
mIndex
][
ii
+
1
],
params
[
mIndex
][
ii
+
2
],
params
[
mIndex
][
ii
+
3
]
,
charges
[
index
]
);
}
}
}
}
...
...
platforms/brook/src/BrookCalcNonbondedForceKernel.cpp
View file @
b31196d9
...
@@ -48,6 +48,8 @@ const std::string BrookCalcNonbondedForceKernel::BondName = "LJ14";
...
@@ -48,6 +48,8 @@ const std::string BrookCalcNonbondedForceKernel::BondName = "LJ14";
*
*
* @param name kernel name
* @param name kernel name
* @param platform platform
* @param platform platform
* @param openMMBrookInterface OpenMMBrookInterface reference
* @param system System reference
*
*
*/
*/
...
@@ -68,12 +70,6 @@ BrookCalcNonbondedForceKernel::BrookCalcNonbondedForceKernel( std::string name,
...
@@ -68,12 +70,6 @@ BrookCalcNonbondedForceKernel::BrookCalcNonbondedForceKernel( std::string name,
_log
=
NULL
;
_log
=
NULL
;
_refForceField
=
NULL
;
_refSystem
=
NULL
;
_refOpenMMContext
=
NULL
;
_referencePlatform
=
NULL
;
_refVerletIntegrator
=
NULL
;
const
BrookPlatform
brookPlatform
=
dynamic_cast
<
const
BrookPlatform
&>
(
platform
);
const
BrookPlatform
brookPlatform
=
dynamic_cast
<
const
BrookPlatform
&>
(
platform
);
if
(
brookPlatform
.
getLog
()
!=
NULL
){
if
(
brookPlatform
.
getLog
()
!=
NULL
){
setLog
(
brookPlatform
.
getLog
()
);
setLog
(
brookPlatform
.
getLog
()
);
...
@@ -94,17 +90,8 @@ BrookCalcNonbondedForceKernel::~BrookCalcNonbondedForceKernel( ){
...
@@ -94,17 +90,8 @@ BrookCalcNonbondedForceKernel::~BrookCalcNonbondedForceKernel( ){
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
//delete _brookBondParameters;
delete
_brookBondParameters
;
// deleted w/ kernel delete? If activated, program crashes
//delete _refForceField;
/*
delete _refSystem;
delete _refOpenMMContext;
delete _referencePlatform;
delete _refVerletIntegrator;
*/
}
}
/**
/**
...
@@ -133,9 +120,11 @@ int BrookCalcNonbondedForceKernel::setLog( FILE* log ){
...
@@ -133,9 +120,11 @@ int BrookCalcNonbondedForceKernel::setLog( FILE* log ){
}
}
/**
/**
*
Set log file reference
*
Initialize object
*
*
* @param log file reference
* @param system System reference (currently not used)
* @param force NonbondedForce reference -- extract charge, and vdw parameters from this object
* @param exclusions list of execlusions
*
*
* @return DefaultReturnValue
* @return DefaultReturnValue
*
*
...
@@ -150,6 +139,8 @@ void BrookCalcNonbondedForceKernel::initialize( const System& system, const Nonb
...
@@ -150,6 +139,8 @@ void BrookCalcNonbondedForceKernel::initialize( const System& system, const Nonb
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
FILE
*
log
=
getLog
();
FILE
*
log
=
getLog
();
(
void
)
fprintf
(
log
,
"%s begin
\n
"
,
methodName
.
c_str
()
);
fflush
(
log
);
_numberOfParticles
=
force
.
getNumParticles
();
_numberOfParticles
=
force
.
getNumParticles
();
/*
/*
nonbondedMethod = CalcNonbondedForceKernel::NonbondedMethod(force.getNonbondedMethod());
nonbondedMethod = CalcNonbondedForceKernel::NonbondedMethod(force.getNonbondedMethod());
...
@@ -173,14 +164,13 @@ void BrookCalcNonbondedForceKernel::initialize( const System& system, const Nonb
...
@@ -173,14 +164,13 @@ void BrookCalcNonbondedForceKernel::initialize( const System& system, const Nonb
// charge & LJ parameters
// charge & LJ parameters
std
::
vector
<
std
::
vector
<
double
>
>
nonbondedParameters
;
std
::
vector
<
std
::
vector
<
double
>
>
nonbondedParameters
;
nonbondedParameters
.
resize
(
_numberOfParticles
);
for
(
int
ii
=
0
;
ii
<
_numberOfParticles
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
_numberOfParticles
;
ii
++
){
double
charge
,
radius
,
depth
;
double
charge
,
radius
,
depth
;
force
.
getParticleParameters
(
ii
,
charge
,
radius
,
depth
);
force
.
getParticleParameters
(
ii
,
charge
,
radius
,
depth
);
std
::
vector
<
double
>
particleParamArray
;
nonbondedParameters
[
ii
].
push_back
(
charge
);
nonbondedParameters
[
ii
]
=
particleParamArray
;
nonbondedParameters
[
ii
].
push_back
(
radius
);
particleParamArray
[
0
]
=
radius
;
nonbondedParameters
[
ii
].
push_back
(
depth
);
particleParamArray
[
1
]
=
depth
;
particleParamArray
[
2
]
=
charge
;
}
}
brookNonBonded
.
setup
(
_numberOfParticles
,
nonbondedParameters
,
exclusions
,
getPlatform
()
);
brookNonBonded
.
setup
(
_numberOfParticles
,
nonbondedParameters
,
exclusions
,
getPlatform
()
);
...
@@ -219,44 +209,53 @@ void BrookCalcNonbondedForceKernel::initialize14Interactions( const System& syst
...
@@ -219,44 +209,53 @@ void BrookCalcNonbondedForceKernel::initialize14Interactions( const System& syst
FILE
*
log
=
getLog
();
FILE
*
log
=
getLog
();
//(void) fprintf( log, "%s begin\n", methodName.c_str() ); fflush( log );
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// create _brookBondParameters object containing particle indices/parameters
// create _brookBondParameters object containing particle indices/parameters
int
numberOf14Forces
=
force
.
getNumNonbonded14
();
int
numberOf14Forces
=
force
.
getNumNonbonded14
();
if
(
numberOf14Forces
>
0
){
//delete _brookBondParameters;
_brookBondParameters
=
new
BrookBondParameters
(
BondName
,
NumberOfParticlesInBond
,
NumberOfParametersInBond
,
numberOf14Forces
,
getLog
()
);
_brookBondParameters
=
new
BrookBondParameters
(
BondName
,
NumberOfParticlesInBond
,
NumberOfParametersInBond
,
numberOf14Forces
,
getLog
()
);
for
(
int
ii
=
0
;
ii
<
numberOf14Forces
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
numberOf14Forces
;
ii
++
){
int
particle1
,
particle2
;
int
particle1
,
particle2
;
double
charge
,
radius
,
depth
;
double
charge
,
radius
,
depth
;
int
particles
[
NumberOfParticlesInBond
];
int
particles
[
NumberOfParticlesInBond
];
double
parameters
[
NumberOfParametersInBond
];
double
parameters
[
NumberOfParametersInBond
];
force
.
getNonbonded14Parameters
(
ii
,
particle1
,
particle2
,
charge
,
radius
,
depth
);
force
.
getNonbonded14Parameters
(
ii
,
particle1
,
particle2
,
charge
,
radius
,
depth
);
particles
[
0
]
=
particle1
;
particles
[
1
]
=
particle2
;
(
void
)
fprintf
(
log
,
"%s idx=%d [%d %d] [%f %f %f]
\n
"
,
methodName
.
c_str
(),
ii
,
particle1
,
particle2
,
charge
,
radius
,
depth
);
particles
[
0
]
=
particle1
;
parameters
[
0
]
=
charge
;
particles
[
1
]
=
particle2
;
parameters
[
1
]
=
radius
;
parameters
[
2
]
=
depth
;
parameters
[
0
]
=
charge
;
parameters
[
1
]
=
radius
;
_brookBondParameters
->
setBond
(
ii
,
particles
,
parameters
);
parameters
[
2
]
=
depth
;
}
_openMMBrookInterface
.
setNonBonded14ForceParameters
(
_brookBondParameters
,
1.0
,
1.0
);
_brookBondParameters
->
setBond
(
ii
,
particles
,
parameters
);
}
if
(
log
){
_openMMBrookInterface
.
setNonBonded14ForceParameters
(
_brookBondParameters
,
1.0
,
1.0
);
std
::
string
contents
=
_brookBondParameters
->
getContentsString
(
);
(
void
)
fprintf
(
log
,
"%s contents:
\n
%s"
,
methodName
.
c_str
(),
contents
.
c_str
()
);
if
(
log
){
std
::
string
contents
=
_brookBondParameters
->
getContentsString
(
);
(
void
)
fprintf
(
log
,
"%s contents:
\n
%s"
,
methodName
.
c_str
(),
contents
.
c_str
()
);
(
void
)
fflush
(
log
);
}
}
else
if
(
log
){
(
void
)
fprintf
(
log
,
"%s no 14 ixns
\n
"
,
methodName
.
c_str
()
);
(
void
)
fflush
(
log
);
(
void
)
fflush
(
log
);
}
}
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
}
}
/**
/**
* Execute the kernel to calculate the nonbonded forces
* Execute the kernel to calculate the nonbonded forces
*
*
...
@@ -304,35 +303,3 @@ double BrookCalcNonbondedForceKernel::executeEnergy( OpenMMContextImpl& context
...
@@ -304,35 +303,3 @@ double BrookCalcNonbondedForceKernel::executeEnergy( OpenMMContextImpl& context
}
}
}
}
/**
* Get reference Context
*
* @param numberOfParticles number of particles
*
* @return OpenMMContext
*
*/
OpenMMContext
*
BrookCalcNonbondedForceKernel
::
getReferenceOpenMMContext
(
int
numberOfParticles
){
// ---------------------------------------------------------------------------------------
//static const std::string methodName = "BrookCalcNonbondedForceKernel::getReferenceOpenMMContext";
// ---------------------------------------------------------------------------------------
if
(
_refOpenMMContext
==
NULL
){
_referencePlatform
=
new
ReferencePlatform
();
_refSystem
=
new
System
(
numberOfParticles
,
0
);
_refVerletIntegrator
=
new
VerletIntegrator
(
0.01
);
_refSystem
->
addForce
(
_refForceField
);
_refOpenMMContext
=
new
OpenMMContext
(
*
_refSystem
,
*
_refVerletIntegrator
,
*
_referencePlatform
);
}
return
_refOpenMMContext
;
}
platforms/brook/src/BrookCalcNonbondedForceKernel.h
View file @
b31196d9
...
@@ -33,7 +33,6 @@
...
@@ -33,7 +33,6 @@
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
#include "kernels.h"
#include "kernels.h"
//#include "../../reference/src/SimTKUtilities/SimTKOpenMMRealType.h"
#include "OpenMMBrookInterface.h"
#include "OpenMMBrookInterface.h"
#include "NonbondedForce.h"
#include "NonbondedForce.h"
...
@@ -110,17 +109,6 @@ class BrookCalcNonbondedForceKernel : public CalcNonbondedForceKernel {
...
@@ -110,17 +109,6 @@ class BrookCalcNonbondedForceKernel : public CalcNonbondedForceKernel {
double
executeEnergy
(
OpenMMContextImpl
&
context
);
double
executeEnergy
(
OpenMMContextImpl
&
context
);
/**
* Get reference Context
*
* @param numberOfParticles number of particles
*
* @return OpenMMContext
*
*/
OpenMMContext
*
getReferenceOpenMMContext
(
int
numberOfParticles
);
/**
/**
* Set log file reference
* Set log file reference
*
*
...
@@ -158,6 +146,8 @@ class BrookCalcNonbondedForceKernel : public CalcNonbondedForceKernel {
...
@@ -158,6 +146,8 @@ class BrookCalcNonbondedForceKernel : public CalcNonbondedForceKernel {
static
const
std
::
string
BondName
;
static
const
std
::
string
BondName
;
// number of LJ14 particles/parameters in 'bond'
static
const
int
NumberOfParticlesInBond
=
2
;
static
const
int
NumberOfParticlesInBond
=
2
;
static
const
int
NumberOfParametersInBond
=
3
;
static
const
int
NumberOfParametersInBond
=
3
;
...
@@ -174,14 +164,6 @@ class BrookCalcNonbondedForceKernel : public CalcNonbondedForceKernel {
...
@@ -174,14 +164,6 @@ class BrookCalcNonbondedForceKernel : public CalcNonbondedForceKernel {
BrookBondParameters
*
_brookBondParameters
;
BrookBondParameters
*
_brookBondParameters
;
// used to calculate energy
NonbondedForce
*
_refForceField
;
System
*
_refSystem
;
OpenMMContext
*
_refOpenMMContext
;
ReferencePlatform
*
_referencePlatform
;
VerletIntegrator
*
_refVerletIntegrator
;
};
};
}
// namespace OpenMM
}
// namespace OpenMM
...
...
platforms/brook/src/BrookNonBonded.cpp
View file @
b31196d9
...
@@ -45,7 +45,7 @@ using namespace std;
...
@@ -45,7 +45,7 @@ using namespace std;
*
*
*/
*/
BrookNonBonded
::
BrookNonBonded
(
){
BrookNonBonded
::
BrookNonBonded
(
){
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -958,8 +958,7 @@ int BrookNonBonded::setup( int numberOfParticles, const std::vector<std::vector<
...
@@ -958,8 +958,7 @@ int BrookNonBonded::setup( int numberOfParticles, const std::vector<std::vector<
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
static
const
std
::
string
methodName
=
"BrookNonBonded::setup"
;
//static const std::string methodName = "BrookNonBonded::setup";
static
const
int
debug
=
1
;
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -972,6 +971,8 @@ int BrookNonBonded::setup( int numberOfParticles, const std::vector<std::vector<
...
@@ -972,6 +971,8 @@ int BrookNonBonded::setup( int numberOfParticles, const std::vector<std::vector<
_initializeVdwAndCharge
(
nonbondedParameters
,
platform
);
_initializeVdwAndCharge
(
nonbondedParameters
,
platform
);
_initializeJStreamVdw
(
nonbondedParameters
,
platform
);
_initializeJStreamVdw
(
nonbondedParameters
,
platform
);
setIsActive
(
1
);
return
DefaultReturnValue
;
return
DefaultReturnValue
;
}
}
...
@@ -1325,35 +1326,38 @@ nonbondedForceStreams[3]->fillWithValue( &zerof );
...
@@ -1325,35 +1326,38 @@ nonbondedForceStreams[3]->fillWithValue( &zerof );
// diagnostics
// diagnostics
if
(
1
&&
PrintOn
){
if
(
1
&&
PrintOn
&&
getLog
()
){
(
void
)
fprintf
(
getLog
(),
"
\n
Post knbforce_CDLJ4: particles=%6d ceiling=%3d dupFac=%3d"
,
getNumberOfParticles
(),
FILE
*
log
=
getLog
();
(
void
)
fprintf
(
log
,
"%s
\n
"
,
methodName
.
c_str
()
);
(
void
)
fflush
(
log
);
(
void
)
fprintf
(
log
,
"
\n
Post knbforce_CDLJ4: particles=%6d ceiling=%3d dupFac=%3d"
,
getNumberOfParticles
(),
getParticleSizeCeiling
(),
getParticleSizeCeiling
(),
getDuplicationFactor
()
);
getDuplicationFactor
()
);
(
void
)
fprintf
(
getLog
()
,
"
\n
hght=%6d width=%3d jWid=%3d"
,
getParticleStreamHeight
(
),
(
void
)
fprintf
(
log
,
"
\n
hght=%6d width=%3d jWid=%3d"
,
getParticleStreamHeight
(
),
getParticleStreamWidth
(
),
getParticleStreamWidth
(
),
getJStreamWidth
(
)
);
getJStreamWidth
(
)
);
(
void
)
fprintf
(
getLog
()
,
"
\n
pFrc=%6d eps=%12.5e
\n
"
,
getPartialForceStreamWidth
(
),
epsfac
);
(
void
)
fprintf
(
log
,
"
\n
pFrc=%6d eps=%12.5e
\n
"
,
getPartialForceStreamWidth
(
),
epsfac
);
(
void
)
fprintf
(
getLog
()
,
"
\n
OuterVdwStreamd
\n
"
);
(
void
)
fprintf
(
log
,
"
\n
OuterVdwStreamd
\n
"
);
getOuterVdwStream
()
->
printToFile
(
getLog
()
);
getOuterVdwStream
()
->
printToFile
(
log
);
(
void
)
fprintf
(
getLog
()
,
"
\n
InnerSigmaStream
\n
"
);
(
void
)
fprintf
(
log
,
"
\n
InnerSigmaStream
\n
"
);
getInnerSigmaStream
()
->
printToFile
(
getLog
()
);
getInnerSigmaStream
()
->
printToFile
(
log
);
(
void
)
fprintf
(
getLog
()
,
"
\n
InnerEpsilonStream
\n
"
);
(
void
)
fprintf
(
log
,
"
\n
InnerEpsilonStream
\n
"
);
getInnerEpsilonStream
()
->
printToFile
(
getLog
()
);
getInnerEpsilonStream
()
->
printToFile
(
log
);
(
void
)
fprintf
(
getLog
()
,
"
\n
ExclusionStream
\n
"
);
(
void
)
fprintf
(
log
,
"
\n
ExclusionStream
\n
"
);
getExclusionStream
()
->
printToFile
(
getLog
()
);
getExclusionStream
()
->
printToFile
(
log
);
(
void
)
fprintf
(
getLog
()
,
"
\n
ChargeStream
\n
"
);
(
void
)
fprintf
(
log
,
"
\n
ChargeStream
\n
"
);
getChargeStream
()
->
printToFile
(
getLog
()
);
getChargeStream
()
->
printToFile
(
log
);
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
){
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
){
(
void
)
fprintf
(
getLog
()
,
"
\n
Force stream %d
\n
"
,
ii
);
(
void
)
fprintf
(
log
,
"
\n
Force stream %d
\n
"
,
ii
);
nonbondedForceStreams
[
ii
]
->
printToFile
(
getLog
()
);
nonbondedForceStreams
[
ii
]
->
printToFile
(
log
);
}
}
(
void
)
fflush
(
log
);
}
}
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
...
@@ -1374,11 +1378,12 @@ nonbondedForceStreams[3]->fillWithValue( &zerof );
...
@@ -1374,11 +1378,12 @@ nonbondedForceStreams[3]->fillWithValue( &zerof );
// diagnostics
// diagnostics
if
(
0
&&
PrintOn
){
if
(
PrintOn
&&
getLog
()
){
(
void
)
fprintf
(
getLog
(),
"
\n
NB forces"
);
FILE
*
log
=
getLog
();
BrookStreamInternal
*
brookStreamInternalF
=
forceStream
.
getBrookStreamImpl
();
(
void
)
fprintf
(
log
,
"
\n
%s NB forces"
,
methodName
.
c_str
()
);
(
void
)
fflush
(
log
);
brookStreamInternalF
->
printToFile
(
getLog
()
);
// forceStream.printToFile( log );
(
void
)
fprintf
(
log
,
"
\n
%s Done"
,
methodName
.
c_str
()
);
(
void
)
fflush
(
log
);
}
}
...
...
platforms/brook/src/BrookPlatform.cpp
View file @
b31196d9
...
@@ -197,7 +197,6 @@ BrookPlatform::BrookPlatform( ){
...
@@ -197,7 +197,6 @@ BrookPlatform::BrookPlatform( ){
_particleStreamWidth
=
DefaultParticleStreamWidth
;
_particleStreamWidth
=
DefaultParticleStreamWidth
;
_log
=
NULL
;
_log
=
NULL
;
_openMMBrookInterface
=
NULL
;
// get Brook runtime
// get Brook runtime
...
@@ -234,8 +233,6 @@ BrookPlatform::BrookPlatform( int particleStreamWidth, const std::string& runtim
...
@@ -234,8 +233,6 @@ BrookPlatform::BrookPlatform( int particleStreamWidth, const std::string& runtim
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
_openMMBrookInterface
=
NULL
;
_initializeKernelFactory
(
);
_initializeKernelFactory
(
);
_setBrookRuntime
(
runtime
);
_setBrookRuntime
(
runtime
);
...
@@ -476,6 +473,4 @@ void BrookPlatform::contextDestroyed( OpenMMContextImpl& context ) const {
...
@@ -476,6 +473,4 @@ void BrookPlatform::contextDestroyed( OpenMMContextImpl& context ) const {
// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
delete
_openMMBrookInterface
;
}
}
platforms/brook/src/OpenMMBrookInterface.cpp
View file @
b31196d9
...
@@ -581,19 +581,22 @@ void OpenMMBrookInterface::computeForces( OpenMMContextImpl& context ){
...
@@ -581,19 +581,22 @@ void OpenMMBrookInterface::computeForces( OpenMMContextImpl& context ){
// bonded forces
// bonded forces
(
void
)
fprintf
(
stderr
,
"%s done nonbonded: bonded=%d completed=%d
\n
"
,
methodName
.
c_str
(),
_brookBonded
.
isActive
(),
_brookBonded
.
isSetupCompleted
()
);
(
void
)
fflush
(
stderr
);
if
(
_brookBonded
.
isActive
()
){
if
(
_brookBonded
.
isActive
()
){
//(void) fprintf( stderr, "%s Bonded\n", methodName.c_str() ); (void) fflush( stderr );
//(void) fprintf( stderr, "%s Bonded\n", methodName.c_str() ); (void) fflush( stderr );
// perform setup first time through
// perform setup first time through
if
(
_brookBonded
.
isSetupCompleted
()
=
=
0
){
if
(
_brookBonded
.
isSetupCompleted
()
>
=
-
1
){
_brookBonded
.
setup
(
getNumberOfParticles
(),
getHarmonicBondForceParameters
(),
getHarmonicAngleForceParameters
(),
_brookBonded
.
setup
(
getNumberOfParticles
(),
getHarmonicBondForceParameters
(),
getHarmonicAngleForceParameters
(),
getPeriodicTorsionForceParameters
(),
getRBTorsionForceParameters
(),
getPeriodicTorsionForceParameters
(),
getRBTorsionForceParameters
(),
getNonBonded14ForceParameters
(),
getNonBonded14ForceParameters
(),
getLj14Scale
(),
getCoulomb14Scale
(),
getParticleStreamWidth
(),
getParticleStreamSize
()
);
getLj14Scale
(),
getCoulomb14Scale
(),
getParticleStreamWidth
(),
getParticleStreamSize
()
);
}
}
(
void
)
fprintf
(
stderr
,
"%s done setup bonded=%d completed=%d
\n
"
,
methodName
.
c_str
(),
_brookBonded
.
isActive
(),
_brookBonded
.
isSetupCompleted
()
);
(
void
)
fflush
(
stderr
);
_brookBonded
.
computeForces
(
*
positions
,
*
forces
);
_brookBonded
.
computeForces
(
*
positions
,
*
forces
);
(
void
)
fprintf
(
stderr
,
"%s done forces bonded=%d completed=%d
\n
"
,
methodName
.
c_str
(),
_brookBonded
.
isActive
(),
_brookBonded
.
isSetupCompleted
()
);
(
void
)
fflush
(
stderr
);
// diagnostics
// diagnostics
...
...
platforms/brook/src/gpu/kforce_CDLJ.br
View file @
b31196d9
...
@@ -583,7 +583,7 @@ kernel void kbonded_CDLJ (
...
@@ -583,7 +583,7 @@ kernel void kbonded_CDLJ (
float xstrwidth,
float xstrwidth,
float4 nbparams,
float4 nbparams,
float3 posq[][],
float3 posq[][],
float charge
[][]
,
float charge
<>
,
float4 atoms<>,
float4 atoms<>,
float4 parm0<>,
float4 parm0<>,
float4 parm1<>,
float4 parm1<>,
...
@@ -596,6 +596,7 @@ kernel void kbonded_CDLJ (
...
@@ -596,6 +596,7 @@ kernel void kbonded_CDLJ (
out float3 fl<>
out float3 fl<>
)
)
{
{
float3 rij, rkj, rkl, ril;
float3 rij, rkj, rkl, ril;
float2 ai, aj, ak, al;
float2 ai, aj, ak, al;
float3 m, n;
float3 m, n;
...
@@ -619,23 +620,11 @@ kernel void kbonded_CDLJ (
...
@@ -619,23 +620,11 @@ kernel void kbonded_CDLJ (
float theta1, costheta1, invsintheta1;
float theta1, costheta1, invsintheta1;
float theta2, costheta2, invsintheta2;
float theta2, costheta2, invsintheta2;
float3 posqi, posqj, posqk, posql;
float3 posqi, posqj, posqk, posql;
float chargei, chargel;
float sig, eps;
float sig, eps;
ai.y = round( (atoms.x - fmod( atoms.x, xstrwidth ))/xstrwidth );
ai.y = round( (atoms.x - fmod( atoms.x, xstrwidth ))/xstrwidth );
ai.x = atoms.x - ai.y * xstrwidth;
ai.x = atoms.x - ai.y * xstrwidth;
posqi = posq[ ai ];
posqi = posq[ ai ];
chargei = charge[ ai ];
if ( atoms.y > -0.5f ) {
if ( atoms.y > -0.5f ) {
...
@@ -656,17 +645,13 @@ kernel void kbonded_CDLJ (
...
@@ -656,17 +645,13 @@ kernel void kbonded_CDLJ (
posqk = float4( 0.0f, 1.0f, 1.0f, 0.0f );
posqk = float4( 0.0f, 1.0f, 1.0f, 0.0f );
if ( atoms.w > -0.5f ) {
if ( atoms.w > -0.5f ) {
al.y = round( (atoms.w - fmod( atoms.w, xstrwidth ))/xstrwidth );
al.y = round( (atoms.w - fmod( atoms.w, xstrwidth ))/xstrwidth );
al.x = atoms.w - al.y * xstrwidth;
al.x = atoms.w - al.y * xstrwidth;
posql = posq[ al ];
posql = posq[ al ];
chargel = charge[ al ];
} else {
} else {
posql = float4( 1.0f, 1.0f, 1.0f, 0.0f );
posql = float4( 1.0f, 1.0f, 1.0f, 0.0f );
chargel = 0.0f;
}
}
qq = chargei*chargel;
rij = posqi.xyz - posqj.xyz;
rij = posqi.xyz - posqj.xyz;
rkj = posqk.xyz - posqj.xyz;
rkj = posqk.xyz - posqj.xyz;
rkl = posqk.xyz - posql.xyz;
rkl = posqk.xyz - posql.xyz;
...
@@ -789,7 +774,7 @@ kernel void kbonded_CDLJ (
...
@@ -789,7 +774,7 @@ kernel void kbonded_CDLJ (
if ( parm4.z > -0.5f ) {
if ( parm4.z > -0.5f ) {
r2 = dot( ril, ril );
r2 = dot( ril, ril );
fs = scalar_force_single_CDLJ(
qq
, epsfac, parm4.z, parm4.w, r2, nbparams );
fs = scalar_force_single_CDLJ(
charge
, epsfac, parm4.z, parm4.w, r2, nbparams );
fi_pair = fs * ril;
fi_pair = fs * ril;
fi += fi_pair;
fi += fi_pair;
fl -= fi_pair;
fl -= fi_pair;
...
...
platforms/brook/src/gpu/knlforce.br
deleted
100644 → 0
View file @
7ed51ce4
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Authors: Peter Eastman, Mark Friedrichs, Chris Bruns *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
/*
* 3rd attempt at writing a force kernel that uses neighborlists.
* Keeping things very simple this time - no unrolling at all.
*
* Starting with simple Coul-LJ
* */
//Constant dielectric, LJ (normal forces)
kernel float4 nl_scalar_force_CDLJ( float4 qq, float epsfac, float4 sig, float4 eps, float4 r2 ) {
float4 invr, invrsig2, invrsig6;
float4 f;
invr = rsqrt( r2 ); // 1 or 2 flops?
invrsig2 = invr * sig; //1 flop
invrsig2 = invrsig2 * invrsig2; //1 flop
invrsig6 = invrsig2 * invrsig2 * invrsig2; //2flops
f = eps * ( 12.0f*invrsig6 - 6.0f ) * invrsig6; //4flops
f += epsfac*qq*invr; //2 flops
f *= invr*invr; //2 flops
return f; //Total ? flops
}
kernel float4 nl_get_r2( float3 d1, float3 d2, float3 d3, float3 d4 ) {
float4 r2;
r2 = float4( dot(d1, d1), dot( d2, d2 ), dot( d3, d3 ), dot( d4, d4 ) ); //5*4 flops
return r2;
}
kernel void knbforce_nl(
float AtomStrWidth, //Width of atom position stream
float epsfac,
iter float2 wpos<>, //pixel position of output (i-atom)
float4 posq[][], //coordinates and charges
float3 inforce<>,
float4 nlist0<>, //nbor indices
float4 sig0<>, //LJ sigmas
float4 eps0<>, //LJ epsilons
//We'll add more nlists here to reduce number of kernel calls
out float3 force<> //output forces
)
{
float2 jind;
float4 ind_tmp1, ind_tmp2;
float4 qj;
float3 jpos1, jpos2, jpos3, jpos4;
float4 r2, fs, qq;
float3 d1, d2, d3, d4;
float3 ipos;
float qi;
//Since neighbors will not be adjacent in memory
//We may want to stagger compute and etch, but
//with fxc, we don't have control over scheduling anyway.
//Will try hand scheduling the ps3 code later
//etch i parameters
ipos = posq[ wpos ].xyz;
qi = posq[ wpos ].w;
//etch j parameters
ind_tmp1 = floor( nlist0 / AtomStrWidth );
ind_tmp2 = nlist0 - ind_tmp1 * AtomStrWidth;
force = inforce;
//1st set of 4 neighbors
jind.y = ind_tmp1.x;
jind.x = ind_tmp2.x;
jpos1 = posq[ jind ].xyz;
qj.x = posq[ jind ].w;
jind.y = ind_tmp1.y;
jind.x = ind_tmp2.y;
jpos2 = posq[ jind ].xyz;
qj.y = posq[ jind ].w;
jind.y = ind_tmp1.z;
jind.x = ind_tmp2.z;
jpos3 = posq[ jind ].xyz;
qj.z = posq[ jind ].w;
jind.y = ind_tmp1.w;
jind.x = ind_tmp2.w;
jpos4 = posq[ jind ].xyz;
qj.w = posq[ jind ].w;
d1 = ipos - jpos1;
d2 = ipos - jpos2;
d3 = ipos - jpos3;
d4 = ipos - jpos4;
r2 = nl_get_r2( d1, d2, d3, d4 );
qq = qi * qj;
fs = nl_scalar_force_CDLJ( qq, epsfac, sig0, eps0, r2 );
force += fs.x * d1;
force += fs.y * d2;
force += fs.z * d3;
force += fs.w * d4;
}
platforms/brook/src/gpu/pre_test.br
deleted
100644 → 0
View file @
7ed51ce4
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Authors: Peter Eastman, Mark Friedrichs, Chris Bruns *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
/* pre-tests, known to be right */
kernel void pre_test0( float input<>, out float output<> )
{
output = input;
}
kernel void pre_test1( float input<>, out float output<> )
{
output = ( input * input ) + input;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment