Kernels: Bugfix with large temporary sizes

This commit is contained in:
Philippe Tillet
2015-08-17 16:30:21 -07:00
parent 470ae7f4be
commit a23e976ca7
2 changed files with 11 additions and 8 deletions

View File

@@ -109,6 +109,8 @@ void profiles::value_type::execute(controller<expressions_tuple> const & expr)
}
//Prediction
static const int MAX_TEMPORARY_WORKSPACE = 1e6;
int label = 0;
if(expr.dispatcher_options().label>=0)
label = expr.dispatcher_options().label;
@@ -120,13 +122,13 @@ void profiles::value_type::execute(controller<expressions_tuple> const & expr)
do{
label = std::distance(predictions.begin(),std::max_element(predictions.begin(), predictions.end()));
predictions[label] = 0;
}while(templates_[label]->is_invalid(expr.x(),queue_.device()));
}while(templates_[label]->temporary_workspace(expr.x()) > MAX_TEMPORARY_WORKSPACE);
}
//Execution
int err = templates_[label]->is_invalid(expr.x(), queue_.device());
if(err != 0)
throw operation_not_supported_exception("The supplied parameters for this template are invalid : err " + tools::to_string(err));
if(templates_[label]->temporary_workspace(expr.x()) > MAX_TEMPORARY_WORKSPACE)
throw operation_not_supported_exception("Running this operation would require an overly large temporary.");
return templates_[label]->enqueue(queue_, program, tools::to_string(label), *fallback_, expr);
}