| 8 | #include "test/rocm/utils.h" |
| 9 | |
| 10 | TEST_F(MegcoreROCM, COMPUTING) { |
| 11 | for (int id = -1; id < std::min(nr_devices(), 2); ++id) { |
| 12 | megcoreDeviceHandle_t devHandle; |
| 13 | megcoreCreateDeviceHandle(&devHandle, megcorePlatformROCM, id, 0); |
| 14 | megcoreActivate(devHandle); |
| 15 | |
| 16 | megcoreComputingHandle_t compHandle; |
| 17 | megcoreCreateComputingHandle(&compHandle, devHandle, 0); |
| 18 | |
| 19 | megcoreDeviceHandle_t devHandle2; |
| 20 | megcoreGetDeviceHandle(compHandle, &devHandle2); |
| 21 | ASSERT_EQ(devHandle, devHandle2); |
| 22 | |
| 23 | unsigned int flags; |
| 24 | megcoreGetComputingFlags(compHandle, &flags); |
| 25 | ASSERT_EQ(0u, flags); |
| 26 | |
| 27 | unsigned char *src, *dst; |
| 28 | static const size_t N = 5; |
| 29 | unsigned char src_host[N], dst_host[N]; |
| 30 | megcoreMalloc(devHandle, (void**)&src, N); |
| 31 | megcoreMalloc(devHandle, (void**)&dst, N); |
| 32 | megcoreMemset(compHandle, src, 0x0F, N); |
| 33 | megcoreMemset(compHandle, dst, 0xF0, N); |
| 34 | megcoreMemcpy(compHandle, src_host, src, N, megcoreMemcpyDeviceToHost); |
| 35 | megcoreMemcpy(compHandle, dst_host, dst, N, megcoreMemcpyDeviceToHost); |
| 36 | megcoreSynchronize(compHandle); |
| 37 | for (size_t i = 0; i < N; ++i) { |
| 38 | ASSERT_EQ(0x0F, src_host[i]); |
| 39 | ASSERT_EQ(0xF0, dst_host[i]); |
| 40 | } |
| 41 | megcoreMemcpy(compHandle, dst, src, N, megcoreMemcpyDeviceToDevice); |
| 42 | megcoreMemcpy(compHandle, src_host, src, N, megcoreMemcpyDeviceToHost); |
| 43 | megcoreMemcpy(compHandle, dst_host, dst, N, megcoreMemcpyDeviceToHost); |
| 44 | megcoreSynchronize(compHandle); |
| 45 | for (size_t i = 0; i < N; ++i) { |
| 46 | ASSERT_EQ(dst_host[i], src_host[i]); |
| 47 | } |
| 48 | megcoreFree(devHandle, src); |
| 49 | megcoreFree(devHandle, dst); |
| 50 | |
| 51 | megcoreDestroyComputingHandle(compHandle); |
| 52 | megcoreDestroyDeviceHandle(devHandle); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | TEST_F(MegcoreROCM, STREAM) { |
| 57 | megcoreDeviceHandle_t devHandle; |
nothing calls this directly
no test coverage detected