From c08a582c48d1b28e201adb0b2f5a1adec1f5eef6 Mon Sep 17 00:00:00 2001
From: hyperfraise <damien.menigaux@polytechnique.edu>
Date: Tue, 23 Nov 2021 11:23:40 +0100
Subject: [PATCH] Implement stream priority feature

---
 doc/driver.rst               | 4 ++--
 src/cpp/cuda.hpp             | 4 ++--
 src/wrapper/wrap_cudadrv.cpp | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/doc/driver.rst b/doc/driver.rst
index 86fa2e1b..288ed7cb 100644
--- a/doc/driver.rst
+++ b/doc/driver.rst
@@ -331,7 +331,7 @@ Constants
         CUDA 6.0 and above.
 
         .. versionadded:: 2014.1
-        
+
     .. attribute :: HOST_NATIVE_ATOMIC_SUPPORTED
         SINGLE_TO_DOUBLE_PRECISION_PERF_RATIO
         PAGEABLE_MEMORY_ACCESS
@@ -813,7 +813,7 @@ Devices and Contexts
 Concurrency and Streams
 -----------------------
 
-.. class:: Stream(flags=0)
+.. class:: Stream(flags=0, priority=0)
 
     A handle for a queue of operations that will be carried out in order.
 
diff --git a/src/cpp/cuda.hpp b/src/cpp/cuda.hpp
index 21cb219c..655f595b 100644
--- a/src/cpp/cuda.hpp
+++ b/src/cpp/cuda.hpp
@@ -997,8 +997,8 @@ namespace pycuda
       CUstream m_stream;
 
     public:
-      stream(unsigned int flags=0)
-      { CUDAPP_CALL_GUARDED(cuStreamCreate, (&m_stream, flags)); }
+      stream(unsigned int flags=0, int priority=0)
+      { CUDAPP_CALL_GUARDED(cuStreamCreateWithPriority, (&m_stream, flags, priority)); }
 
       ~stream()
       {
diff --git a/src/wrapper/wrap_cudadrv.cpp b/src/wrapper/wrap_cudadrv.cpp
index 6d95edad..27b364ac 100644
--- a/src/wrapper/wrap_cudadrv.cpp
+++ b/src/wrapper/wrap_cudadrv.cpp
@@ -1199,7 +1199,7 @@ BOOST_PYTHON_MODULE(_driver)
   {
     typedef stream cl;
     py::class_<cl, boost::noncopyable, shared_ptr<cl> >
-      ("Stream", py::init<unsigned int>(py::arg("flags")=0))
+      ("Stream", py::init<unsigned int, int>(py::arg("flags")=0, py::arg("priority")=0))
       .DEF_SIMPLE_METHOD(synchronize)
       .DEF_SIMPLE_METHOD(is_done)
 #if CUDAPP_CUDA_VERSION >= 3020
-- 
GitLab