"vscode:/vscode.git/clone" did not exist on "c88efea2b853ae2d45554cafca82dcdfa635e779"
Commit bf34e947 authored by peastman's avatar peastman
Browse files

Can set OPENMM_CACHE_DIR to specify where PTX files should be cached

parent 50eb44c5
...@@ -515,7 +515,7 @@ private: ...@@ -515,7 +515,7 @@ private:
int numAtomBlocks; int numAtomBlocks;
int numThreadBlocks; int numThreadBlocks;
bool useBlockingSync, useDoublePrecision, useMixedPrecision, contextIsValid, atomsWereReordered; bool useBlockingSync, useDoublePrecision, useMixedPrecision, contextIsValid, atomsWereReordered;
std::string compiler, tempDir, gpuArchitecture; std::string compiler, tempDir, cacheDir, gpuArchitecture;
float4 periodicBoxSizeFloat, invPeriodicBoxSizeFloat; float4 periodicBoxSizeFloat, invPeriodicBoxSizeFloat;
double4 periodicBoxSize, invPeriodicBoxSize; double4 periodicBoxSize, invPeriodicBoxSize;
std::string defaultOptimizationOptions; std::string defaultOptimizationOptions;
......
...@@ -92,10 +92,14 @@ CudaContext::CudaContext(const System& system, int deviceIndex, bool useBlocking ...@@ -92,10 +92,14 @@ CudaContext::CudaContext(const System& system, int deviceIndex, bool useBlocking
} }
else else
throw OpenMMException("Illegal value for CudaPrecision: "+precision); throw OpenMMException("Illegal value for CudaPrecision: "+precision);
char* cacheVariable = getenv("OPENMM_CACHE_DIR");
cacheDir = (cacheVariable == NULL ? tempDir : string(cacheVariable));
#ifdef WIN32 #ifdef WIN32
this->tempDir = tempDir+"\\"; this->tempDir = tempDir+"\\";
cacheDir = cacheDir+"\\";
#else #else
this->tempDir = tempDir+"/"; this->tempDir = tempDir+"/";
cacheDir = cacheDir+"/";
#endif #endif
contextIndex = platformData.contexts.size(); contextIndex = platformData.contexts.size();
int numDevices; int numDevices;
...@@ -408,7 +412,7 @@ CUmodule CudaContext::createModule(const string source, const map<string, string ...@@ -408,7 +412,7 @@ CUmodule CudaContext::createModule(const string source, const map<string, string
UINT_8 hash[20]; UINT_8 hash[20];
sha1.GetHash(hash); sha1.GetHash(hash);
stringstream cacheFile; stringstream cacheFile;
cacheFile << tempDir; cacheFile << cacheDir;
cacheFile.flags(ios::hex); cacheFile.flags(ios::hex);
for (int i = 0; i < 20; i++) for (int i = 0; i < 20; i++)
cacheFile << setw(2) << setfill('0') << (int) hash[i]; cacheFile << setw(2) << setfill('0') << (int) hash[i];
......
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