[arrayfire] 24/34: Added enviornment variable to disable multi gpu tests
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Sun Sep 27 14:46:04 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch dfsg-clean
in repository arrayfire.
commit d639289d6b89bdbee09f435f5f79d68c4a4ae964
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date: Thu Sep 24 16:22:13 2015 -0400
Added enviornment variable to disable multi gpu tests
---
test/blas.cpp | 37 +++++++++++++++++++++----------------
test/info.cpp | 36 ++++++++++++++++++++++++------------
2 files changed, 45 insertions(+), 28 deletions(-)
diff --git a/test/blas.cpp b/test/blas.cpp
index af73359..507cc6d 100644
--- a/test/blas.cpp
+++ b/test/blas.cpp
@@ -209,34 +209,39 @@ TYPED_TEST(MatrixMultiply, RectangleVector_CPP)
cppMatMulCheck<TypeParam, true>(TEST_DIR"/blas/RectangleVector.test");
}
+#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);
+
+
TYPED_TEST(MatrixMultiply, MultiGPUSquare_CPP)
{
- for(int i = 0; i < af::getDeviceCount(); i++) {
- af::setDevice(i);
- cppMatMulCheck<TypeParam, false>(TEST_DIR"/blas/Basic.test");
- }
+ DEVICE_ITERATE((cppMatMulCheck<TypeParam, false>(TEST_DIR"/blas/Basic.test")));
}
TYPED_TEST(MatrixMultiply, MultiGPUNonSquare_CPP)
{
- for(int i = 0; i < af::getDeviceCount(); i++) {
- af::setDevice(i);
- cppMatMulCheck<TypeParam, false>(TEST_DIR"/blas/NonSquare.test");
- }
+ DEVICE_ITERATE((cppMatMulCheck<TypeParam, false>(TEST_DIR"/blas/NonSquare.test")));
}
TYPED_TEST(MatrixMultiply, MultiGPUSquareVector_CPP)
{
- for(int i = 0; i < af::getDeviceCount(); i++) {
- af::setDevice(i);
- cppMatMulCheck<TypeParam, true>(TEST_DIR"/blas/SquareVector.test");
- }
+ DEVICE_ITERATE((cppMatMulCheck<TypeParam, true>(TEST_DIR"/blas/SquareVector.test")));
}
TYPED_TEST(MatrixMultiply, MultiGPURectangleVector_CPP)
{
- for(int i = 0; i < af::getDeviceCount(); i++) {
- af::setDevice(i);
- cppMatMulCheck<TypeParam, true>(TEST_DIR"/blas/RectangleVector.test");
- }
+ DEVICE_ITERATE((cppMatMulCheck<TypeParam, true>(TEST_DIR"/blas/RectangleVector.test")));
}
+
+#undef DEVICE_ITERATE
diff --git a/test/info.cpp b/test/info.cpp
index bd70a66..ff2cea6 100644
--- a/test/info.cpp
+++ b/test/info.cpp
@@ -36,23 +36,35 @@ typedef ::testing::Types<float> TestTypes;
TYPED_TEST_CASE(Info, TestTypes);
template<typename T>
-void infoTest()
+void testFunction()
{
- if (noDoubleTests<T>()) return;
+ af::info();
- int nDevices = 0;
- ASSERT_EQ(AF_SUCCESS, af_get_device_count(&nDevices));
+ af_array outArray = 0;
+ af::dim4 dims(32, 32, 1, 1);
+ ASSERT_EQ(AF_SUCCESS, af_randu(&outArray, dims.ndims(), dims.get(), (af_dtype) af::dtype_traits<T>::af_type));
+ // cleanup
+ if(outArray != 0) ASSERT_EQ(AF_SUCCESS, af_release_array(outArray));
+}
- for(int d = 0; d < nDevices; d++) {
+template<typename T>
+void infoTest()
+{
+ if (noDoubleTests<T>()) return;
- af::setDevice(d);
- af::info();
+ const char* ENV = getenv("AF_MULTI_GPU_TESTS");
+ if(ENV && ENV[0] == '0') {
+ testFunction<T>();
+ } else {
+ int nDevices = 0;
+ ASSERT_EQ(AF_SUCCESS, af_get_device_count(&nDevices));
- af_array outArray = 0;
- af::dim4 dims(32, 32, 1, 1);
- ASSERT_EQ(AF_SUCCESS, af_randu(&outArray, dims.ndims(), dims.get(), (af_dtype) af::dtype_traits<T>::af_type));
- // cleanup
- if(outArray != 0) ASSERT_EQ(AF_SUCCESS, af_release_array(outArray));
+ int oldDevice = af::getDevice();
+ for(int d = 0; d < nDevices; d++) {
+ af::setDevice(d);
+ testFunction<T>();
+ }
+ af::setDevice(oldDevice);
}
}
--
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