提交 1e8b72f8 编写于 作者: A Andrey Pavlenko 提交者: OpenCV Buildbot

Merge pull request #1658 from alalek:ocl_fixes

......@@ -61,12 +61,16 @@ namespace cv { namespace ocl {
cv::Mutex ProgramCache::mutexFiles;
cv::Mutex ProgramCache::mutexCache;
std::auto_ptr<ProgramCache> _programCache;
ProgramCache* _programCache = NULL;
ProgramCache* ProgramCache::getProgramCache()
{
if (NULL == _programCache.get())
_programCache.reset(new ProgramCache());
return _programCache.get();
if (NULL == _programCache)
{
cv::AutoLock lock(getInitializationMutex());
if (NULL == _programCache)
_programCache = new ProgramCache();
}
return _programCache;
}
ProgramCache::ProgramCache()
......@@ -78,6 +82,12 @@ ProgramCache::ProgramCache()
ProgramCache::~ProgramCache()
{
releaseProgram();
if (this == _programCache)
{
cv::AutoLock lock(getInitializationMutex());
if (this == _programCache)
_programCache = NULL;
}
}
cl_program ProgramCache::progLookup(const string& srcsign)
......@@ -420,22 +430,17 @@ struct ProgramFileCache
{
if(status == CL_BUILD_PROGRAM_FAILURE)
{
cl_int logStatus;
char *buildLog = NULL;
size_t buildLogSize = 0;
logStatus = clGetProgramBuildInfo(program,
getClDeviceID(ctx), CL_PROGRAM_BUILD_LOG, buildLogSize,
buildLog, &buildLogSize);
if(logStatus != CL_SUCCESS)
std::cout << "Failed to build the program and get the build info." << endl;
buildLog = new char[buildLogSize];
CV_DbgAssert(!!buildLog);
memset(buildLog, 0, buildLogSize);
openCLSafeCall(clGetProgramBuildInfo(program, getClDeviceID(ctx),
CL_PROGRAM_BUILD_LOG, buildLogSize, buildLog, NULL));
std::cout << "\nBUILD LOG: " << options << "\n";
std::cout << buildLog << endl;
delete [] buildLog;
CL_PROGRAM_BUILD_LOG, 0, NULL, &buildLogSize));
std::vector<char> buildLog; buildLog.resize(buildLogSize);
memset(&buildLog[0], 0, buildLogSize);
openCLSafeCall(clGetProgramBuildInfo(program, getClDeviceID(ctx),
CL_PROGRAM_BUILD_LOG, buildLogSize, &buildLog[0], NULL));
std::cout << std::endl << "BUILD LOG: "
<< (source->name ? source->name : "dynamic program") << ": "
<< options << "\n";
std::cout << &buildLog[0] << endl;
}
openCLVerifyCall(status);
}
......
......@@ -52,7 +52,6 @@ class ProgramCache
protected:
ProgramCache();
~ProgramCache();
friend class std::auto_ptr<ProgramCache>;
public:
static ProgramCache *getProgramCache();
......
......@@ -126,7 +126,8 @@ void cv::ocl::fft_setup()
{
return;
}
pCache.setupData = new clAmdFftSetupData;
if (pCache.setupData == NULL)
pCache.setupData = new clAmdFftSetupData;
openCLSafeCall(clAmdFftInitSetupData( pCache.setupData ));
pCache.started = true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册