diff --git a/dnn/src/common/handle.cpp b/dnn/src/common/handle.cpp index 44fb13ba35fc123185c7282b571bd8211cde21fb..17e7edfaedf015fc7904b82e325a2d477b28c9cd 100644 --- a/dnn/src/common/handle.cpp +++ b/dnn/src/common/handle.cpp @@ -31,6 +31,7 @@ #endif + #if MEGDNN_WITH_CUDA #include "src/cuda/handle.h" #endif diff --git a/dnn/src/common/megcore/common/computing_context.cpp b/dnn/src/common/megcore/common/computing_context.cpp index f1d3a76b3897f1d6e93d468d23488e9487ef1f12..df191d75bf92e171795bfb28788776328734493e 100644 --- a/dnn/src/common/megcore/common/computing_context.cpp +++ b/dnn/src/common/megcore/common/computing_context.cpp @@ -18,6 +18,7 @@ #endif + #if MEGDNN_WITH_ROCM #include "src/rocm/megcore/computing_context.hpp" #endif diff --git a/src/core/impl/comp_node/comp_node.cpp b/src/core/impl/comp_node/comp_node.cpp index 725eb3832762c4811f4725fba5a2ec795be55d7f..47b9d4e07602e361331c6e4141ea03d3e6a10b97 100644 --- a/src/core/impl/comp_node/comp_node.cpp +++ b/src/core/impl/comp_node/comp_node.cpp @@ -182,7 +182,8 @@ CompNode::Locator CompNode::Locator::parse(const std::string &id) { } dev_type = DeviceType::MULTITHREAD; ptr += 11; - } else { + } + else { if (ptr[1] != 'p' || ptr[2] != 'u') { err(); } @@ -237,7 +238,7 @@ CompNode::Locator CompNode::Locator::parse(const std::string &id) { //! num_steam store the nr_thread std::swap(num_dev, num_stream); } - + return {dev_type, num_dev, {num_stream}}; } diff --git a/src/core/impl/comp_node/cpu/comp_node.cpp b/src/core/impl/comp_node/cpu/comp_node.cpp index 68cbba9015687d9afc87c1e97f80a187c5392947..d5d3bf4b456ab56c5a77279a1969049c98476e7c 100644 --- a/src/core/impl/comp_node/cpu/comp_node.cpp +++ b/src/core/impl/comp_node/cpu/comp_node.cpp @@ -1021,13 +1021,12 @@ void CpuCompNode::CpuDispatchableBase::EventImpl::do_device_wait_by( { auto type = cn_impl->env().property().type; - mgb_throw_if( - type != CompNode::DeviceType::CPU && - type != CompNode::DeviceType::CUDA - && type != CompNode::DeviceType::ATLAS && - type != CompNode::DeviceType::CAMBRICON, - MegBrainError, - "currently CPU can only wait for CPU, CUDA, ATLAS, CAMBRICON" + mgb_throw_if(type != CompNode::DeviceType::CPU + && type != CompNode::DeviceType::CUDA + && type != CompNode::DeviceType::ATLAS + , + MegBrainError, + "currently CPU can only wait for CPU, CUDA, ATLAS" ); } diff --git a/src/core/impl/comp_node_env.cpp b/src/core/impl/comp_node_env.cpp index f58f0f3c61b1b67281105043f46d7dc95e77ecd7..3ca26df4337b3788c04f4bd084108b4ff45f1fb5 100644 --- a/src/core/impl/comp_node_env.cpp +++ b/src/core/impl/comp_node_env.cpp @@ -36,6 +36,7 @@ #endif + using namespace mgb; /* =================== MegDNNHandle =================== */ @@ -232,6 +233,7 @@ void CompNodeEnv::init_cuda_async(int dev, CompNode comp_node, } #endif + #if MGB_ATLAS void mgb::_on_atlas_error(const char* expr, int err, const char* file, @@ -421,6 +423,7 @@ void CompNodeEnv::fini() { MGB_CUDA_CHECK(cudaStreamDestroy(m_cuda_env.stream)); } #endif + #if MGB_ROCM if (m_property.type == DeviceType::ROCM) { m_rocm_env.activate(); @@ -440,6 +443,7 @@ void CompNodeEnv::fini() { MGB_ATLAS_CHECK(aclrtDestroyStream(m_atlas_env.stream)); } #endif + } #if MGB_ENABLE_COMP_NODE_ASYNC_INIT diff --git a/src/core/impl/exception.cpp b/src/core/impl/exception.cpp index 2c3e42c33edf389ad13441a254b4a4a0ed8bef97..7d990a180ff0a54a8a13d4061056812fd6c7e2c8 100644 --- a/src/core/impl/exception.cpp +++ b/src/core/impl/exception.cpp @@ -73,6 +73,7 @@ std::string CudaError::get_cuda_extra_info() { #endif } + AtlasError::AtlasError(const std::string &msg): SystemError(msg) { diff --git a/src/core/include/megbrain/comp_node.h b/src/core/include/megbrain/comp_node.h index 265f8e67746903dba272df151a57d2da5c338ec4..647f74662787ceec1c77e3c3b92dd6aa0917109b 100644 --- a/src/core/include/megbrain/comp_node.h +++ b/src/core/include/megbrain/comp_node.h @@ -82,7 +82,7 @@ class CompNode { CAMBRICON = 3, ROCM = 8, ATLAS = 9, - MULTITHREAD, + MULTITHREAD = 11, MAX_DEVICE_ID, }; static constexpr size_t NR_DEVICE_TYPE = diff --git a/src/core/include/megbrain/comp_node_env.h b/src/core/include/megbrain/comp_node_env.h index 960e1b72079677d138c120bc0c1cef7210f06245..a850b6cf5e60859c8e521d94b8391087444e6d35 100644 --- a/src/core/include/megbrain/comp_node_env.h +++ b/src/core/include/megbrain/comp_node_env.h @@ -63,6 +63,7 @@ #endif //MGB_ENABLE_LOGGING #endif //MGB_CUDA + #if MGB_ATLAS #include "megcore_atlas.h" #include @@ -205,6 +206,7 @@ namespace mgb { #endif + #if MGB_ROCM [[noreturn]] void _on_hip_error(const char* expr, hipError_t err, const char* file, const char* func, int line); @@ -369,6 +371,7 @@ public: const ContinuationCtx& cont); #endif + #if MGB_ATLAS struct AtlasEnv { int device = -1; diff --git a/src/core/include/megbrain/exception.h b/src/core/include/megbrain/exception.h index d2d1eda082b0bf9250bd198abe15e82df97d91af..a58bd8433ce92a45f99c874a1b4ed2139a7b5758 100644 --- a/src/core/include/megbrain/exception.h +++ b/src/core/include/megbrain/exception.h @@ -139,6 +139,11 @@ public: CudaError(const std::string& msg); }; +class EnFlameError final : public SystemError { +public: + EnFlameError(const std::string& msg); +}; + class AtlasError final: public SystemError { public: AtlasError(const std::string& msg); diff --git a/src/core/test/comp_node.cpp b/src/core/test/comp_node.cpp index 9b9b9fccb91199f6c44c5c34ae6f4bfc18e35661..663d80b6d715340eeb32f9eb8ef2c81da8a07eed 100644 --- a/src/core/test/comp_node.cpp +++ b/src/core/test/comp_node.cpp @@ -166,6 +166,7 @@ TEST(TestCompNode, Load) { ASSERT_NE(atlas0, atlas1); #endif + } TEST(TestCompNode, FreeAfterFinalize) { @@ -754,6 +755,7 @@ TEST(TestCompNodeCambricon, P2PCopy) { #endif #endif // MGB_CAMBRICON + #if MGB_ATLAS TEST(TestCompNodeAtlas, D2DCopy) {