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.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include "megcore.h"
  3. #include <acl/acl.h>
  4. #include "megdnn/internal/visibility_prologue.h"
  5. namespace megcore {
  6. megcoreStatus_t createAtlasDeviceHandleWithGlobalInitStatus(
  7. megcoreDeviceHandle_t* devHandle, int deviceID, unsigned int flags,
  8. bool global_initialized);
  9. struct AtlasContext {
  10. aclrtStream stream = nullptr;
  11. AtlasContext() = default;
  12. AtlasContext(aclrtStream s) : stream{s} {}
  13. };
  14. megcoreStatus_t createComputingHandleWithAtlasContext(
  15. megcoreComputingHandle_t* compHandle, megcoreDeviceHandle_t devHandle,
  16. unsigned int flags, const AtlasContext& ctx);
  17. megcoreStatus_t getAtlasContext(megcoreComputingHandle_t handle, AtlasContext* ctx);
  18. namespace atlas {
  19. //! convert acl error code to error string
  20. const char* get_error_str(aclError error);
  21. } // namespace atlas
  22. } // namespace megcore
  23. inline megcoreStatus_t megcoreCreateComputingHandleWithACLStream(
  24. megcoreComputingHandle_t* compHandle, megcoreDeviceHandle_t devHandle,
  25. unsigned int flags, aclrtStream stream) {
  26. megcore::AtlasContext ctx{stream};
  27. return megcore::createComputingHandleWithAtlasContext(
  28. compHandle, devHandle, flags, ctx);
  29. }
  30. inline megcoreStatus_t megcoreGetACLStream(
  31. megcoreComputingHandle_t handle, aclrtStream* stream) {
  32. megcore::AtlasContext ctx;
  33. auto ret = megcore::getAtlasContext(handle, &ctx);
  34. *stream = ctx.stream;
  35. return ret;
  36. }
  37. #include "megdnn/internal/visibility_epilogue.h"
  38. // vim: syntax=cpp.doxygen