File indexing completed on 2024-04-06 12:15:46
0001 #include <hip/hip_runtime.h>
0002
0003 #include "isRocmDeviceSupported.h"
0004
0005 namespace {
0006 __global__ void setSupported(bool* result) { *result = true; }
0007 }
0008
0009 bool isRocmDeviceSupported(int device) {
0010 bool supported = false;
0011 bool* supported_d;
0012
0013
0014 hipError_t status = hipSetDevice(device);
0015 if (status != hipSuccess)
0016 return false;
0017
0018
0019 status = hipMalloc(&supported_d, sizeof(bool));
0020 if (status != hipSuccess)
0021 return false;
0022
0023
0024 status = hipMemset(supported_d, 0x00, sizeof(bool));
0025 if (status != hipSuccess)
0026 return false;
0027
0028
0029 setSupported<<<1, 1>>>(supported_d);
0030
0031
0032 status = hipGetLastError();
0033 if (status != hipSuccess)
0034 return false;
0035
0036
0037 status = hipDeviceSynchronize();
0038 if (status != hipSuccess)
0039 return false;
0040
0041
0042 status = hipMemcpy(&supported, supported_d, sizeof(bool), hipMemcpyDeviceToHost);
0043 if (status != hipSuccess)
0044 return false;
0045
0046
0047 status = hipFree(supported_d);
0048 if (status != hipSuccess)
0049 return false;
0050
0051
0052 status = hipDeviceReset();
0053 if (status != hipSuccess)
0054 return false;
0055
0056 return supported;
0057 }