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
0bb293f8
Commit
0bb293f8
authored
Jul 25, 2014
by
peastman
Browse files
CPU platform works on PNaCl
parent
074e3cd9
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
36 additions
and
12 deletions
+36
-12
openmmapi/include/openmm/internal/vectorize_pnacl.h
openmmapi/include/openmm/internal/vectorize_pnacl.h
+2
-1
platforms/cpu/CMakeLists.txt
platforms/cpu/CMakeLists.txt
+3
-1
platforms/cpu/include/CpuGBSAOBCForce.h
platforms/cpu/include/CpuGBSAOBCForce.h
+3
-3
platforms/cpu/src/CpuGBSAOBCForce.cpp
platforms/cpu/src/CpuGBSAOBCForce.cpp
+9
-1
platforms/cpu/src/CpuNonbondedForceVec4.cpp
platforms/cpu/src/CpuNonbondedForceVec4.cpp
+8
-0
platforms/cpu/src/CpuRandom.cpp
platforms/cpu/src/CpuRandom.cpp
+1
-1
platforms/cpu/staticTarget/CMakeLists.txt
platforms/cpu/staticTarget/CMakeLists.txt
+5
-3
platforms/cpu/tests/CMakeLists.txt
platforms/cpu/tests/CMakeLists.txt
+5
-2
No files found.
openmmapi/include/openmm/internal/vectorize_pnacl.h
View file @
0bb293f8
...
...
@@ -33,6 +33,7 @@
* -------------------------------------------------------------------------- */
#include <cmath>
#include <cstdlib>
// This file defines classes and functions to simplify vectorizing code with portable SIMD vectors.
...
...
@@ -276,7 +277,7 @@ static inline ivec4 max(const ivec4& v1, const ivec4& v2) {
}
static
inline
ivec4
abs
(
const
ivec4
&
v
)
{
return
ivec4
(
std
::
abs
(
v
[
0
]),
std
::
abs
(
v
[
1
]),
std
::
abs
(
v
[
2
]),
std
::
abs
(
v
[
3
]));
return
ivec4
(
abs
(
v
[
0
]),
abs
(
v
[
1
]),
abs
(
v
[
2
]),
abs
(
v
[
3
]));
}
static
inline
bool
any
(
const
ivec4
&
v
)
{
...
...
platforms/cpu/CMakeLists.txt
View file @
0bb293f8
...
...
@@ -76,7 +76,9 @@ INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/src)
FILE
(
GLOB CORE_HEADERS include/*.h
)
INSTALL_FILES
(
/include/openmm/cpu FILES
${
CORE_HEADERS
}
)
SUBDIRS
(
sharedTarget
)
IF
(
OPENMM_BUILD_SHARED_LIB
)
SUBDIRS
(
sharedTarget
)
ENDIF
(
OPENMM_BUILD_SHARED_LIB
)
IF
(
OPENMM_BUILD_STATIC_LIB
)
SUBDIRS
(
staticTarget
)
ENDIF
(
OPENMM_BUILD_STATIC_LIB
)
...
...
platforms/cpu/include/CpuGBSAOBCForce.h
View file @
0bb293f8
...
...
@@ -98,9 +98,9 @@ private:
float
periodicBoxSize
[
3
];
float
cutoffDistance
,
soluteDielectric
,
solventDielectric
;
std
::
vector
<
std
::
pair
<
float
,
float
>
>
particleParams
;
std
::
vector
<
float
>
bornRadii
;
std
::
vector
<
std
::
vector
<
float
>
>
threadBornForces
;
std
::
vector
<
float
>
obcChain
;
AlignedArray
<
float
>
bornRadii
;
std
::
vector
<
AlignedArray
<
float
>
>
threadBornForces
;
AlignedArray
<
float
>
obcChain
;
std
::
vector
<
double
>
threadEnergy
;
std
::
vector
<
float
>
logTable
;
float
logDX
,
logDXInv
;
...
...
platforms/cpu/src/CpuGBSAOBCForce.cpp
View file @
0bb293f8
...
...
@@ -213,7 +213,7 @@ void CpuGBSAOBCForce::threadComputeForce(ThreadPool& threads, int threadIndex) {
const
float
probeRadius
=
0.14
f
;
const
float
surfaceAreaFactor
=
28.3919551
;
double
energy
=
0.0
;
vector
<
float
>&
bornForces
=
threadBornForces
[
threadIndex
];
AlignedArray
<
float
>&
bornForces
=
threadBornForces
[
threadIndex
];
for
(
int
i
=
0
;
i
<
numParticles
;
i
++
)
bornForces
[
i
]
=
0.0
f
;
while
(
true
)
{
...
...
@@ -410,10 +410,18 @@ fvec4 CpuGBSAOBCForce::fastLog(const fvec4& x) {
return
fvec4
(
logf
(
x
[
0
]),
logf
(
x
[
1
]),
logf
(
x
[
2
]),
logf
(
x
[
3
]));
fvec4
coeff2
=
x1
-
index
;
fvec4
coeff1
=
1.0
f
-
coeff2
;
#ifdef __PNACL__
// PNaCl crashes on unaligned loads.
fvec4
t1
(
logTable
[
index
[
0
]],
logTable
[
index
[
0
]
+
1
],
logTable
[
index
[
0
]
+
2
],
logTable
[
index
[
0
]
+
3
]);
fvec4
t2
(
logTable
[
index
[
1
]],
logTable
[
index
[
1
]
+
1
],
logTable
[
index
[
1
]
+
2
],
logTable
[
index
[
1
]
+
3
]);
fvec4
t3
(
logTable
[
index
[
2
]],
logTable
[
index
[
2
]
+
1
],
logTable
[
index
[
2
]
+
2
],
logTable
[
index
[
2
]
+
3
]);
fvec4
t4
(
logTable
[
index
[
3
]],
logTable
[
index
[
3
]
+
1
],
logTable
[
index
[
3
]
+
2
],
logTable
[
index
[
3
]
+
3
]);
#else
fvec4
t1
(
&
logTable
[
index
[
0
]]);
fvec4
t2
(
&
logTable
[
index
[
1
]]);
fvec4
t3
(
&
logTable
[
index
[
2
]]);
fvec4
t4
(
&
logTable
[
index
[
3
]]);
#endif
transpose
(
t1
,
t2
,
t3
,
t4
);
return
coeff1
*
t1
+
coeff2
*
t2
;
}
platforms/cpu/src/CpuNonbondedForceVec4.cpp
View file @
0bb293f8
...
...
@@ -292,10 +292,18 @@ fvec4 CpuNonbondedForceVec4::ewaldScaleFunction(const fvec4& x) {
ivec4
index
=
min
(
floor
(
x1
),
NUM_TABLE_POINTS
);
fvec4
coeff2
=
x1
-
index
;
fvec4
coeff1
=
1.0
f
-
coeff2
;
#ifdef __PNACL__
// PNaCl crashes on unaligned loads.
fvec4
t1
(
ewaldScaleTable
[
index
[
0
]],
ewaldScaleTable
[
index
[
0
]
+
1
],
ewaldScaleTable
[
index
[
0
]
+
2
],
ewaldScaleTable
[
index
[
0
]
+
3
]);
fvec4
t2
(
ewaldScaleTable
[
index
[
1
]],
ewaldScaleTable
[
index
[
1
]
+
1
],
ewaldScaleTable
[
index
[
1
]
+
2
],
ewaldScaleTable
[
index
[
1
]
+
3
]);
fvec4
t3
(
ewaldScaleTable
[
index
[
2
]],
ewaldScaleTable
[
index
[
2
]
+
1
],
ewaldScaleTable
[
index
[
2
]
+
2
],
ewaldScaleTable
[
index
[
2
]
+
3
]);
fvec4
t4
(
ewaldScaleTable
[
index
[
3
]],
ewaldScaleTable
[
index
[
3
]
+
1
],
ewaldScaleTable
[
index
[
3
]
+
2
],
ewaldScaleTable
[
index
[
3
]
+
3
]);
#else
fvec4
t1
(
&
ewaldScaleTable
[
index
[
0
]]);
fvec4
t2
(
&
ewaldScaleTable
[
index
[
1
]]);
fvec4
t3
(
&
ewaldScaleTable
[
index
[
2
]]);
fvec4
t4
(
&
ewaldScaleTable
[
index
[
3
]]);
#endif
transpose
(
t1
,
t2
,
t3
,
t4
);
return
coeff1
*
t1
+
coeff2
*
t2
;
}
platforms/cpu/src/CpuRandom.cpp
View file @
0bb293f8
...
...
@@ -33,7 +33,7 @@ CpuRandom::CpuRandom() : hasInitialized(false) {
}
CpuRandom
::~
CpuRandom
()
{
for
(
int
i
=
0
;
i
<
threadRandom
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
(
int
)
threadRandom
.
size
();
i
++
)
delete
threadRandom
[
i
];
}
...
...
platforms/cpu/staticTarget/CMakeLists.txt
View file @
0bb293f8
...
...
@@ -2,18 +2,20 @@ FOREACH(file ${SOURCE_FILES})
IF
(
file MATCHES
".*Vec8.*"
)
IF
(
MSVC
)
SET_SOURCE_FILES_PROPERTIES
(
${
file
}
PROPERTIES COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
/arch:AVX /D__AVX__"
)
ELSEIF
(
PNACL
)
SET_SOURCE_FILES_PROPERTIES
(
${
file
}
PROPERTIES COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
"
)
ELSE
(
MSVC
)
SET_SOURCE_FILES_PROPERTIES
(
${
file
}
PROPERTIES COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
-msse4.1 -mavx"
)
ENDIF
(
MSVC
)
ELSE
(
file MATCHES
".*Vec8.*"
)
IF
(
NOT MSVC
)
IF
(
NOT
(
MSVC
OR ANDROID OR PNACL
)
)
SET_SOURCE_FILES_PROPERTIES
(
${
file
}
PROPERTIES COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
-msse4.1"
)
ENDIF
(
NOT MSVC
)
ENDIF
(
NOT
(
MSVC
OR ANDROID OR PNACL
)
)
ENDIF
(
file MATCHES
".*Vec8.*"
)
ENDFOREACH
(
file
)
ADD_LIBRARY
(
${
STATIC_TARGET
}
STATIC
${
SOURCE_FILES
}
${
SOURCE_INCLUDE_FILES
}
${
API_ABS_INCLUDE_FILES
}
)
TARGET_LINK_LIBRARIES
(
${
STATIC_TARGET
}
${
OPENMM_LIBRARY_NAME
}
${
PTHREADS_LIB_STATIC
}
)
TARGET_LINK_LIBRARIES
(
${
STATIC_TARGET
}
${
OPENMM_LIBRARY_NAME
}
_static
${
PTHREADS_LIB_STATIC
}
)
#-DPTW32_STATIC_LIB only works for the windows pthreads.
SET_TARGET_PROPERTIES
(
${
STATIC_TARGET
}
PROPERTIES LINK_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
"
COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
-DOPENMM_CPU_BUILDING_STATIC_LIBRARY -DPTW32_STATIC_LIB"
)
...
...
platforms/cpu/tests/CMakeLists.txt
View file @
0bb293f8
...
...
@@ -17,9 +17,12 @@ FILE(GLOB TEST_PROGS "*Test*.cpp")
FOREACH
(
TEST_PROG
${
TEST_PROGS
}
)
GET_FILENAME_COMPONENT
(
TEST_ROOT
${
TEST_PROG
}
NAME_WE
)
# Link with shared library
ADD_EXECUTABLE
(
${
TEST_ROOT
}
${
TEST_PROG
}
)
IF
(
OPENMM_BUILD_SHARED_LIB
)
TARGET_LINK_LIBRARIES
(
${
TEST_ROOT
}
${
SHARED_TARGET
}
)
ELSE
(
OPENMM_BUILD_SHARED_LIB
)
TARGET_LINK_LIBRARIES
(
${
TEST_ROOT
}
${
STATIC_TARGET
}
)
ENDIF
(
OPENMM_BUILD_SHARED_LIB
)
SET_TARGET_PROPERTIES
(
${
TEST_ROOT
}
PROPERTIES LINK_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
"
COMPILE_FLAGS
"
${
EXTRA_COMPILE_FLAGS
}
"
)
ADD_TEST
(
${
TEST_ROOT
}
${
EXECUTABLE_OUTPUT_PATH
}
/
${
TEST_ROOT
}
single
)
...
...
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