[arrayfire] 42/84: Creating streams for devices only when device is active

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Jan 4 23:22:21 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository arrayfire.

commit ed0373fa2d24113fc52d6d4f222a7d3826161372
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date:   Mon Dec 21 14:35:34 2015 -0500

    Creating streams for devices only when device is active
---
 src/backend/cuda/platform.cpp | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/backend/cuda/platform.cpp b/src/backend/cuda/platform.cpp
index 76b336c..0dcad38 100644
--- a/src/backend/cuda/platform.cpp
+++ b/src/backend/cuda/platform.cpp
@@ -332,10 +332,10 @@ DeviceManager::DeviceManager()
 
     sortDevices();
 
-    for(int i = 0; i < nDevices; i++) {
-        setActiveDevice(i, cuDevices[i].nativeId);
-        CUDA_CHECK(cudaStreamCreate(&streams[i]));
-    }
+    // Initialize all streams to 0.
+    // Streams will be created in setActiveDevice()
+    for(int i = 0; i < (int)MAX_DEVICES; i++)
+        streams[i] = (cudaStream_t)0;
 
     const char* deviceENV = getenv("AF_CUDA_DEFAULT_DEVICE");
     if(!deviceENV) {
@@ -381,6 +381,11 @@ int DeviceManager::setActiveDevice(int device, int nId)
         if(nId == -1) nId = getDeviceNativeId(device);
         CUDA_CHECK(cudaSetDevice(nId));
         activeDev = device;
+
+        if(!streams[device]) {
+            CUDA_CHECK(cudaStreamCreate(&streams[device]));
+        }
+
         return old;
     }
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git



More information about the debian-science-commits mailing list