Commit c2dfdb5f authored by Peter Eastman's avatar Peter Eastman
Browse files

Minor cleanup

parent 3e16cab9
......@@ -225,7 +225,7 @@ OpenCLContext::OpenCLContext(const System& system, int platformIndex, int device
// Create utility kernels that are used in multiple places.
utilities = createProgram(OpenCLKernelSources::utilities);
cl::Program utilities = createProgram(OpenCLKernelSources::utilities);
clearBufferKernel = cl::Kernel(utilities, "clearBuffer");
clearTwoBuffersKernel = cl::Kernel(utilities, "clearTwoBuffers");
clearThreeBuffersKernel = cl::Kernel(utilities, "clearThreeBuffers");
......@@ -340,25 +340,6 @@ void OpenCLContext::addForce(OpenCLForceInfo* 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 result = input;
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
}
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;
if (!options.empty())
src << "// Compilation Options: " << options << endl << endl;
......
......@@ -242,18 +242,7 @@ public:
return posCellOffsets;
}
/**
* Load OpenCL source code from a file in the kernels directory.
*/
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.
* Replace all occurrences of a list of substrings.
*
* @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
......@@ -526,7 +515,6 @@ private:
cl::Context context;
cl::Device device;
cl::CommandQueue queue;
cl::Program utilities;
cl::Kernel clearBufferKernel;
cl::Kernel clearTwoBuffersKernel;
cl::Kernel clearThreeBuffersKernel;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment