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.

device.cpp 1.3 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "hcc_detail/hcc_defs_prologue.h"
  2. #include "megcore.h"
  3. #include "./fixture.h"
  4. #include "hip_header.h"
  5. #include "test/common/utils.h"
  6. #include "test/rocm/utils.h"
  7. TEST_F(MegcoreROCM, DEVICE) {
  8. for (int id = -1; id < std::min(nr_devices(), 2); ++id) {
  9. megcoreDeviceHandle_t handle;
  10. megcoreCreateDeviceHandle(&handle, megcorePlatformROCM, id, 0);
  11. int deviceID;
  12. megcoreGetDeviceID(handle, &deviceID);
  13. ASSERT_EQ(id, deviceID);
  14. megcorePlatform_t platform;
  15. megcoreGetPlatform(handle, &platform);
  16. ASSERT_EQ(megcorePlatformROCM, platform);
  17. unsigned int flags;
  18. megcoreGetDeviceFlags(handle, &flags);
  19. ASSERT_EQ(0u, flags);
  20. size_t memAlignmentInBytes;
  21. megcoreGetMemAlignment(handle, &memAlignmentInBytes);
  22. megcoreActivate(handle);
  23. void* ptr;
  24. megcoreMalloc(handle, &ptr, 256);
  25. megcoreFree(handle, ptr);
  26. megcoreDestroyDeviceHandle(handle);
  27. }
  28. }
  29. TEST_F(MegcoreROCM, ERROR_MSG) {
  30. #if MEGDNN_ENABLE_EXCEPTIONS
  31. megcoreDeviceHandle_t handle;
  32. ASSERT_THROW(
  33. megcoreCreateDeviceHandle(&handle, megcorePlatformROCM, nr_devices(), 0),
  34. megdnn::test::MegDNNError);
  35. hipGetLastError();
  36. hip_check(hipGetLastError());
  37. #endif
  38. }
  39. // vim: syntax=cpp.doxygen