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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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, AtlasContext* ctx);
  29. namespace atlas {
  30. //! convert acl error code to error string
  31. const char* get_error_str(aclError error);
  32. } // namespace atlas
  33. } // namespace megcore
  34. inline megcoreStatus_t megcoreCreateComputingHandleWithACLStream(
  35. megcoreComputingHandle_t* compHandle, megcoreDeviceHandle_t devHandle,
  36. unsigned int flags, aclrtStream stream) {
  37. megcore::AtlasContext ctx{stream};
  38. return megcore::createComputingHandleWithAtlasContext(
  39. compHandle, devHandle, flags, ctx);
  40. }
  41. inline megcoreStatus_t megcoreGetACLStream(
  42. megcoreComputingHandle_t handle, aclrtStream* stream) {
  43. megcore::AtlasContext ctx;
  44. auto ret = megcore::getAtlasContext(handle, &ctx);
  45. *stream = ctx.stream;
  46. return ret;
  47. }
  48. #include "megdnn/internal/visibility_epilogue.h"
  49. // vim: syntax=cpp.doxygen

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