You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by jx...@apache.org on 2017/08/23 21:41:20 UTC
[incubator-mxnet] branch master updated: Set dev_id in streams,
also update mshadow. (#7526)
This is an automated email from the ASF dual-hosted git repository.
jxie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new 050d85e Set dev_id in streams, also update mshadow. (#7526)
050d85e is described below
commit 050d85e338beed7880577b76aaf73c2948fc8a35
Author: Dick Carter <di...@comcast.net>
AuthorDate: Wed Aug 23 14:41:17 2017 -0700
Set dev_id in streams, also update mshadow. (#7526)
* Set dev_id in streams, also update mshadow.
* Fix cpplint error.
* Empty commit to trigger CI.
* Further update of mshadow to match current hash.
---
src/common/cuda_utils.h | 19 ++++++++++++-------
src/engine/naive_engine.cc | 2 +-
src/engine/stream_manager.h | 4 ++--
src/engine/threaded_engine_perdevice.cc | 4 ++--
tests/cpp/include/test_op.h | 3 ++-
5 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/src/common/cuda_utils.h b/src/common/cuda_utils.h
index 0213c73..0f63895 100644
--- a/src/common/cuda_utils.h
+++ b/src/common/cuda_utils.h
@@ -274,26 +274,31 @@ inline int SMArch(int device_id) {
/*!
* \brief Determine whether a cuda-capable gpu's architecture supports float16 math.
+ * Assume not if device_id is negative.
* \param device_id The device index of the cuda-capable gpu of interest.
* \return whether the gpu's architecture supports float16 math.
*/
inline bool SupportsFloat16Compute(int device_id) {
- // Kepler and most Maxwell GPUs do not support fp16 compute
- int computeCapabilityMajor = ComputeCapabilityMajor(device_id);
- int computeCapabilityMinor = ComputeCapabilityMinor(device_id);
- return (computeCapabilityMajor > 5) ||
- (computeCapabilityMajor == 5 && computeCapabilityMinor >= 3);
+ if (device_id < 0) {
+ return false;
+ } else {
+ // Kepler and most Maxwell GPUs do not support fp16 compute
+ int computeCapabilityMajor = ComputeCapabilityMajor(device_id);
+ return (computeCapabilityMajor > 5) ||
+ (computeCapabilityMajor == 5 && ComputeCapabilityMinor(device_id) >= 3);
+ }
}
/*!
* \brief Determine whether a cuda-capable gpu's architecture supports Tensor Core math.
+ * Assume not if device_id is negative.
* \param device_id The device index of the cuda-capable gpu of interest.
* \return whether the gpu's architecture supports Tensor Core math.
*/
inline bool SupportsTensorCore(int device_id) {
// Volta (sm_70) supports TensorCore algos
- int computeCapabilityMajor = ComputeCapabilityMajor(device_id);
- return (computeCapabilityMajor >= 7);
+ return device_id >= 0 &&
+ ComputeCapabilityMajor(device_id) >=7;
}
// The policy if the user hasn't set the environment variable MXNET_CUDA_ALLOW_TENSOR_CORE
diff --git a/src/engine/naive_engine.cc b/src/engine/naive_engine.cc
index 85ec3ae..b354418 100644
--- a/src/engine/naive_engine.cc
+++ b/src/engine/naive_engine.cc
@@ -154,7 +154,7 @@ class NaiveEngine final : public Engine {
streams_.resize(dev_id + 1, nullptr);
}
if (streams_[dev_id] == nullptr) {
- streams_[dev_id] = mshadow::NewStream<gpu>(true, MXNET_USE_CUDNN != 0);
+ streams_[dev_id] = mshadow::NewStream<gpu>(true, MXNET_USE_CUDNN != 0, dev_id);
}
exec_fun(RunContext{exec_ctx, streams_[dev_id]}, callback);
#else
diff --git a/src/engine/stream_manager.h b/src/engine/stream_manager.h
index 1a66277..cd6db53 100644
--- a/src/engine/stream_manager.h
+++ b/src/engine/stream_manager.h
@@ -77,7 +77,7 @@ RunContext StreamManager<kNumGpus, kStreams>::GetRunContext(
auto&& counter = gpu_cnt_.at(ctx.dev_id);
if (counter == -1) {
for (auto&& i : gpu_streams_.at(ctx.dev_id)) {
- i = mshadow::NewStream<gpu>(true, MXNET_USE_CUDNN != 0);
+ i = mshadow::NewStream<gpu>(true, MXNET_USE_CUDNN != 0, ctx.dev_id);
}
counter = 0;
}
@@ -108,7 +108,7 @@ RunContext StreamManager<kNumGpus, kStreams>::GetIORunContext(
{
std::lock_guard<std::mutex> lock{m_};
if (gpu_io_streams_.at(ctx.dev_id) == nullptr) {
- gpu_io_streams_.at(ctx.dev_id) = mshadow::NewStream<gpu>(false, false);
+ gpu_io_streams_.at(ctx.dev_id) = mshadow::NewStream<gpu>(false, false, ctx.dev_id);
}
}
ret = RunContext{ctx, gpu_io_streams_.at(ctx.dev_id)};
diff --git a/src/engine/threaded_engine_perdevice.cc b/src/engine/threaded_engine_perdevice.cc
index 66cfc9d..5cd8ca0 100644
--- a/src/engine/threaded_engine_perdevice.cc
+++ b/src/engine/threaded_engine_perdevice.cc
@@ -183,9 +183,9 @@ class ThreadedEnginePerDevice : public ThreadedEngine {
// allocate stream
mshadow::SetDevice<gpu>(ctx.dev_id);
if (is_copy_worker) {
- stream = mshadow::NewStream<gpu>(false, false);
+ stream = mshadow::NewStream<gpu>(false, false, ctx.dev_id);
} else {
- stream = mshadow::NewStream<gpu>(true, MXNET_USE_CUDNN != 0);
+ stream = mshadow::NewStream<gpu>(true, MXNET_USE_CUDNN != 0, ctx.dev_id);
}
} while (false);
// execute task
diff --git a/tests/cpp/include/test_op.h b/tests/cpp/include/test_op.h
index d8f90df..951affa 100644
--- a/tests/cpp/include/test_op.h
+++ b/tests/cpp/include/test_op.h
@@ -75,7 +75,8 @@ class BasicOperatorData {
: opContext_(*opContext) {
CHECK_EQ(opContext_.run_ctx.stream == nullptr, true)
<< "Invalid runtime context stream state";
- opContext_.run_ctx.stream = mshadow::NewStream<gpu>(true, true);
+ auto device_id = opContext->run_ctx.get_ctx().dev_id;
+ opContext_.run_ctx.stream = mshadow::NewStream<gpu>(true, true, device_id);
CHECK_EQ(opContext_.run_ctx.stream != nullptr, true)
<< "Unable to allocate a GPU stream";
}
--
To stop receiving notification emails like this one, please contact
['"commits@mxnet.apache.org" <co...@mxnet.apache.org>'].