You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

megcore_atlas.h 2.0 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * \file dnn/include/megcore_atlas.h
  3. * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  4. *
  5. * Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
  6. *
  7. * Unless required by applicable law or agreed to in writing,
  8. * software distributed under the License is distributed on an
  9. * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or
  10. * implied.
  11. */
  12. #pragma once
  13. #include "megcore.h"
  14. #include <acl/acl.h>
  15. #include "megdnn/internal/visibility_prologue.h"
  16. namespace megcore {
  17. megcoreStatus_t createAtlasDeviceHandleWithGlobalInitStatus(
  18. megcoreDeviceHandle_t* devHandle, int deviceID, unsigned int flags,
  19. bool global_initialized);
  20. struct AtlasContext {
  21. aclrtStream stream = nullptr;
  22. AtlasContext() = default;
  23. AtlasContext(aclrtStream s) : stream{s} {}
  24. };
  25. megcoreStatus_t createComputingHandleWithAtlasContext(
  26. megcoreComputingHandle_t* compHandle, megcoreDeviceHandle_t devHandle,
  27. unsigned int flags, const AtlasContext& ctx);
  28. megcoreStatus_t getAtlasContext(megcoreComputingHandle_t handle,
  29. AtlasContext* ctx);
  30. namespace atlas {
  31. //! convert acl error code to error string
  32. const char* get_error_str(aclError error);
  33. } // namespace atlas
  34. } // namespace megcore
  35. inline megcoreStatus_t megcoreCreateComputingHandleWithACLStream(
  36. megcoreComputingHandle_t* compHandle, megcoreDeviceHandle_t devHandle,
  37. unsigned int flags, aclrtStream stream) {
  38. megcore::AtlasContext ctx{stream};
  39. return megcore::createComputingHandleWithAtlasContext(compHandle, devHandle,
  40. flags, ctx);
  41. }
  42. inline megcoreStatus_t megcoreGetACLStream(megcoreComputingHandle_t handle,
  43. aclrtStream* stream) {
  44. megcore::AtlasContext ctx;
  45. auto ret = megcore::getAtlasContext(handle, &ctx);
  46. *stream = ctx.stream;
  47. return ret;
  48. }
  49. #include "megdnn/internal/visibility_epilogue.h"
  50. // vim: syntax=cpp.doxygen

MegEngine 安装包中集成了使用 GPU 运行代码所需的 CUDA 环境,不用区分 CPU 和 GPU 版。 如果想要运行 GPU 程序,请确保机器本身配有 GPU 硬件设备并安装好驱动。 如果你想体验在云端 GPU 算力平台进行深度学习开发的感觉,欢迎访问 MegStudio 平台