Code Quality: some cleanups

This commit is contained in:
Philippe Tillet
2017-05-11 16:11:40 -07:00
parent 3ff543151c
commit 9212ab5a3d
40 changed files with 112 additions and 60 deletions

View File

@@ -42,15 +42,22 @@ Stream::Stream(CUstream stream, bool take_ownership): cu_(stream, take_ownership
{}
Stream::Stream(Context const & context): context_(context), cu_(CUstream(), true)
{ dispatch::cuStreamCreate(&*cu_, 0); }
{
ContextSwitcher ctx_switch(context_);
dispatch::cuStreamCreate(&*cu_, 0);
}
void Stream::synchronize()
{ dispatch::cuStreamSynchronize(*cu_); }
{
ContextSwitcher ctx_switch(context_);
dispatch::cuStreamSynchronize(*cu_);
}
Context const & Stream::context() const
{ return context_; }
void Stream::enqueue(Kernel const & kernel, std::array<size_t, 3> grid, std::array<size_t, 3> block, std::vector<Event> const *, Event* event){
ContextSwitcher ctx_switch(context_);
if(event)
dispatch::cuEventRecord(((cu_event_t)*event).first, *cu_);
dispatch::cuLaunchKernel(kernel, grid[0], grid[1], grid[2], block[0], block[1], block[2], 0, *cu_,(void**)kernel.cu_params(), NULL);