static */
| 735 | } |
| 736 | |
| 737 | /* static */ bool GpuDriver::CreateStream(GpuContext* context, |
| 738 | CUstream* stream, |
| 739 | int priority) { |
| 740 | // TODO(leary) can we switch this to CU_STREAM_NON_BLOCKING or will that mess |
| 741 | // up synchronization with respect to memsets and any other things that have |
| 742 | // to occur on the default stream? |
| 743 | ScopedActivateContext activated{context}; |
| 744 | CUresult res; |
| 745 | // If the priority is 0, then use the previous api to create the stream with |
| 746 | // the default priority for backward compatibility. Probably there is no |
| 747 | // difference in using the new api call but leaving it as is for now. |
| 748 | if (priority == 0) { |
| 749 | res = cuStreamCreate(stream, 0); |
| 750 | } else { |
| 751 | res = cuStreamCreateWithPriority(stream, 0, priority); |
| 752 | } |
| 753 | if (res != CUDA_SUCCESS) { |
| 754 | LOG(ERROR) << "could not allocate CUDA stream for context " |
| 755 | << context->context() << ": " << ToString(res); |
| 756 | return false; |
| 757 | } |
| 758 | |
| 759 | VLOG(2) << "successfully created stream " << *stream << " for context " |
| 760 | << context->context() << " on thread"; |
| 761 | return true; |
| 762 | } |
| 763 | |
| 764 | /* static */ void GpuDriver::DestroyStream(GpuContext* context, |
| 765 | CUstream* stream) { |