[arrayfire] 10/41: BUGFIX cuFFT plans when using multiple devices

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Mar 21 14:56:21 UTC 2016


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

ghisvail-guest pushed a commit to branch debian/experimental
in repository arrayfire.

commit 28305c8b54459c849ad629fe0426ab8a3643f2f2
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date:   Wed Mar 9 11:13:39 2016 -0500

    BUGFIX cuFFT plans when using multiple devices
---
 src/backend/cuda/fft.cpp |  4 ++--
 test/fft.cpp             | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/src/backend/cuda/fft.cpp b/src/backend/cuda/fft.cpp
index 13d108a..29f85f9 100644
--- a/src/backend/cuda/fft.cpp
+++ b/src/backend/cuda/fft.cpp
@@ -41,8 +41,8 @@ class cuFFTPlanner
 
     public:
         static cuFFTPlanner& getInstance() {
-            static cuFFTPlanner single_instance;
-            return single_instance;
+            static cuFFTPlanner instances[cuda::DeviceManager::MAX_DEVICES];
+            return instances[cuda::getActiveDeviceId()];
         }
 
     private:
diff --git a/test/fft.cpp b/test/fft.cpp
index 48ff865..19b0ae0 100644
--- a/test/fft.cpp
+++ b/test/fft.cpp
@@ -683,3 +683,39 @@ TEST(ifft3, InPlace)
         ASSERT_EQ(ha[i], hb[i]);
     }
 }
+
+void fft2InPlaceFunc()
+{
+    af::array a = af::randu(1024, 1024, c32);
+    af::array b = af::fft2(a);
+    af::fft2InPlace(a);
+
+    std::vector<af::cfloat> ha(a.elements());
+    std::vector<af::cfloat> hb(b.elements());
+
+    a.host(&ha[0]);
+    b.host(&hb[0]);
+
+    for (int i = 0; i < (int)a.elements(); i++) {
+        ASSERT_EQ(ha[i], hb[i]);
+    }
+}
+
+#define DEVICE_ITERATE(func) do {                                           \
+    const char* ENV = getenv("AF_MULTI_GPU_TESTS");                         \
+    if(ENV && ENV[0] == '0') {                                              \
+        func;                                                               \
+    } else {                                                                \
+        int oldDevice = af::getDevice();                                    \
+        for(int i = 0; i < af::getDeviceCount(); i++) {                     \
+            af::setDevice(i);                                               \
+            func;                                                           \
+        }                                                                   \
+        af::setDevice(oldDevice);                                           \
+    }                                                                       \
+} while(0);
+
+TEST(FFT2, MultiGPUInPlaceSquare_CPP)
+{
+    DEVICE_ITERATE((fft2InPlaceFunc()));
+}

-- 
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