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

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * \file dnn/test/common/megcore/device.cpp
  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 implied.
  10. */
  11. #include "megcore.h"
  12. #include <gtest/gtest.h>
  13. #include "test/common/utils.h"
  14. TEST(MegcoreCPU, DEVICE) {
  15. megcoreDeviceHandle_t handle;
  16. megcoreCreateDeviceHandle(&handle, megcorePlatformCPU, -1, 0);
  17. int deviceID;
  18. megcoreGetDeviceID(handle, &deviceID);
  19. ASSERT_EQ(-1, deviceID);
  20. megcorePlatform_t platform;
  21. megcoreGetPlatform(handle, &platform);
  22. ASSERT_EQ(megcorePlatformCPU, platform);
  23. unsigned int flags;
  24. megcoreGetDeviceFlags(handle, &flags);
  25. ASSERT_EQ(0u, flags);
  26. size_t memAlignmentInBytes;
  27. megcoreGetMemAlignment(handle, &memAlignmentInBytes);
  28. megcoreActivate(handle);
  29. void* ptr;
  30. megcoreMalloc(handle, &ptr, 256);
  31. megcoreFree(handle, ptr);
  32. megcoreDestroyDeviceHandle(handle);
  33. }
  34. // vim: syntax=cpp.doxygen