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
c2dfdb5f
Commit
c2dfdb5f
authored
Jun 06, 2012
by
Peter Eastman
Browse files
Minor cleanup
parent
3e16cab9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
34 deletions
+3
-34
platforms/opencl/src/OpenCLContext.cpp
platforms/opencl/src/OpenCLContext.cpp
+2
-21
platforms/opencl/src/OpenCLContext.h
platforms/opencl/src/OpenCLContext.h
+1
-13
No files found.
platforms/opencl/src/OpenCLContext.cpp
View file @
c2dfdb5f
...
@@ -225,7 +225,7 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
...
@@ -225,7 +225,7 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
// Create utility kernels that are used in multiple places.
// Create utility kernels that are used in multiple places.
utilities
=
createProgram
(
OpenCLKernelSources
::
utilities
);
cl
::
Program
utilities
=
createProgram
(
OpenCLKernelSources
::
utilities
);
clearBufferKernel
=
cl
::
Kernel
(
utilities
,
"clearBuffer"
);
clearBufferKernel
=
cl
::
Kernel
(
utilities
,
"clearBuffer"
);
clearTwoBuffersKernel
=
cl
::
Kernel
(
utilities
,
"clearTwoBuffers"
);
clearTwoBuffersKernel
=
cl
::
Kernel
(
utilities
,
"clearTwoBuffers"
);
clearThreeBuffersKernel
=
cl
::
Kernel
(
utilities
,
"clearThreeBuffers"
);
clearThreeBuffersKernel
=
cl
::
Kernel
(
utilities
,
"clearThreeBuffers"
);
...
@@ -340,25 +340,6 @@ void OpenCLContext::addForce(OpenCLForceInfo* force) {
...
@@ -340,25 +340,6 @@ void OpenCLContext::addForce(OpenCLForceInfo* force) {
forces
.
push_back
(
force
);
forces
.
push_back
(
force
);
}
}
string
OpenCLContext
::
loadSourceFromFile
(
const
string
&
filename
)
const
{
ifstream
file
((
Platform
::
getDefaultPluginsDirectory
()
+
"/opencl/"
+
filename
).
c_str
());
if
(
!
file
.
is_open
())
throw
OpenMMException
(
"Unable to load kernel: "
+
filename
);
string
kernel
;
string
line
;
while
(
!
file
.
eof
())
{
getline
(
file
,
line
);
kernel
+=
line
;
kernel
+=
'\n'
;
}
file
.
close
();
return
kernel
;
}
string
OpenCLContext
::
loadSourceFromFile
(
const
string
&
filename
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
replacements
)
const
{
return
replaceStrings
(
loadSourceFromFile
(
filename
),
replacements
);
}
string
OpenCLContext
::
replaceStrings
(
const
string
&
input
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
replacements
)
const
{
string
OpenCLContext
::
replaceStrings
(
const
string
&
input
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
replacements
)
const
{
string
result
=
input
;
string
result
=
input
;
for
(
map
<
string
,
string
>::
const_iterator
iter
=
replacements
.
begin
();
iter
!=
replacements
.
end
();
iter
++
)
{
for
(
map
<
string
,
string
>::
const_iterator
iter
=
replacements
.
begin
();
iter
!=
replacements
.
end
();
iter
++
)
{
...
@@ -377,7 +358,7 @@ cl::Program OpenCLContext::createProgram(const string source, const char* optimi
...
@@ -377,7 +358,7 @@ cl::Program OpenCLContext::createProgram(const string source, const char* optimi
}
}
cl
::
Program
OpenCLContext
::
createProgram
(
const
string
source
,
const
map
<
string
,
string
>&
defines
,
const
char
*
optimizationFlags
)
{
cl
::
Program
OpenCLContext
::
createProgram
(
const
string
source
,
const
map
<
string
,
string
>&
defines
,
const
char
*
optimizationFlags
)
{
string
options
=
(
optimizationFlags
==
NULL
?
defaultOptimizationOptions
:
optimizationFlags
);
string
options
=
(
optimizationFlags
==
NULL
?
defaultOptimizationOptions
:
string
(
optimizationFlags
)
)
;
stringstream
src
;
stringstream
src
;
if
(
!
options
.
empty
())
if
(
!
options
.
empty
())
src
<<
"// Compilation Options: "
<<
options
<<
endl
<<
endl
;
src
<<
"// Compilation Options: "
<<
options
<<
endl
<<
endl
;
...
...
platforms/opencl/src/OpenCLContext.h
View file @
c2dfdb5f
...
@@ -242,18 +242,7 @@ public:
...
@@ -242,18 +242,7 @@ public:
return
posCellOffsets
;
return
posCellOffsets
;
}
}
/**
/**
* Load OpenCL source code from a file in the kernels directory.
* Replace all occurrences of a list of substrings.
*/
std
::
string
loadSourceFromFile
(
const
std
::
string
&
filename
)
const
;
/**
* Load OpenCL source code from a file in the kernels directory.
*
* @param filename the file to load
* @param replacements a set of strings that should be replaced with new strings wherever they appear in the
*/
std
::
string
loadSourceFromFile
(
const
std
::
string
&
filename
,
const
std
::
map
<
std
::
string
,
std
::
string
>&
replacements
)
const
;
/**
* Replace all occurance of a list of substrings.
*
*
* @param input a string to process
* @param input a string to process
* @param replacements a set of strings that should be replaced with new strings wherever they appear in the input string
* @param replacements a set of strings that should be replaced with new strings wherever they appear in the input string
...
@@ -526,7 +515,6 @@ private:
...
@@ -526,7 +515,6 @@ private:
cl
::
Context
context
;
cl
::
Context
context
;
cl
::
Device
device
;
cl
::
Device
device
;
cl
::
CommandQueue
queue
;
cl
::
CommandQueue
queue
;
cl
::
Program
utilities
;
cl
::
Kernel
clearBufferKernel
;
cl
::
Kernel
clearBufferKernel
;
cl
::
Kernel
clearTwoBuffersKernel
;
cl
::
Kernel
clearTwoBuffersKernel
;
cl
::
Kernel
clearThreeBuffersKernel
;
cl
::
Kernel
clearThreeBuffersKernel
;
...
...
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