Binding: now releasing profiles in clblasTeardown()

This commit is contained in:
Philippe Tillet
2015-08-25 19:34:23 -04:00
parent 7b77d5ae4b
commit cf2d88a0a2
4 changed files with 19 additions and 3 deletions

View File

@@ -51,6 +51,7 @@ private:
static void import(std::string const & fname, driver::CommandQueue const & queue); static void import(std::string const & fname, driver::CommandQueue const & queue);
static map_type & init(driver::CommandQueue const & queue); static map_type & init(driver::CommandQueue const & queue);
public: public:
static void release();
static map_type & get(driver::CommandQueue const & queue); static map_type & get(driver::CommandQueue const & queue);
static void set(driver::CommandQueue const & queue, expression_type operation, numeric_type dtype, std::shared_ptr<value_type> const & profile); static void set(driver::CommandQueue const & queue, expression_type operation, numeric_type dtype, std::shared_ptr<value_type> const & profile);
private: private:

View File

@@ -127,11 +127,15 @@ std::list<Context const *> backend::contexts::cache_;
void backend::platforms(std::vector<Platform> & platforms) void backend::platforms(std::vector<Platform> & platforms)
{ {
bool has_cuda = false;
//if cuda is here //if cuda is here
if(dispatch::cuinit()) if(dispatch::cuinit())
{ {
if(dispatch::nvrtcinit()) if(dispatch::nvrtcinit()){
platforms.push_back(Platform(CUDA)); platforms.push_back(Platform(CUDA));
has_cuda = true;
}
else else
throw std::runtime_error("ISAAC: Unable to find NVRTC. Make sure you are using CUDA >= 7.0"); throw std::runtime_error("ISAAC: Unable to find NVRTC. Make sure you are using CUDA >= 7.0");
} }
@@ -143,8 +147,12 @@ void backend::platforms(std::vector<Platform> & platforms)
ocl::check(dispatch::dispatch::clGetPlatformIDs(0, NULL, &nplatforms)); ocl::check(dispatch::dispatch::clGetPlatformIDs(0, NULL, &nplatforms));
std::vector<cl_platform_id> clplatforms(nplatforms); std::vector<cl_platform_id> clplatforms(nplatforms);
ocl::check(dispatch::dispatch::clGetPlatformIDs(nplatforms, clplatforms.data(), NULL)); ocl::check(dispatch::dispatch::clGetPlatformIDs(nplatforms, clplatforms.data(), NULL));
for(cl_platform_id p: clplatforms) for(cl_platform_id p: clplatforms){
platforms.push_back(Platform(p)); Platform tmp(p);
if(tmp.name().find("CUDA")!=std::string::npos && has_cuda)
continue;
platforms.push_back(tmp);
}
} }
if(platforms.empty()) if(platforms.empty())

View File

@@ -253,6 +253,12 @@ void profiles::set(driver::CommandQueue const & queue, expression_type operation
cache_[queue][std::make_pair(operation,dtype)] = profile; cache_[queue][std::make_pair(operation,dtype)] = profile;
} }
void profiles::release()
{
cache_.clear();
}
std::map<driver::CommandQueue, profiles::map_type> profiles::cache_; std::map<driver::CommandQueue, profiles::map_type> profiles::cache_;
/////////////////// ///////////////////

View File

@@ -14,6 +14,7 @@ extern "C"
void clblasTeardown() void clblasTeardown()
{ {
isaac::profiles::release();
isaac::driver::backend::release(); isaac::driver::backend::release();
} }