int main() { unsigned flag = 0; HIPCHECK(hipDeviceReset()); int deviceCount = 0; HIPCHECK(hipGetDeviceCount(&deviceCount)); for(int j=0;j<deviceCount;j++){ HIPCHECK(hipSetDevice(j)); for(int i=0;i<4;i++){ flag = 1 << i; printf ("Flag=%x\n", flag); HIPCHECK(hipSetDeviceFlags(flag)); //HIPCHECK_API(hipSetDeviceFlags(flag), hipErrorInvalidValue); } flag = 0; } passed(); }
int main() { hipDeviceProp_t prop; HIP_PRINT_STATUS(hipGetDeviceProperties(&prop, -1)); int cnt; hipGetDeviceCount(&cnt); HIP_PRINT_STATUS(hipGetDeviceProperties(&prop, cnt+1)); HIP_PRINT_STATUS(hipGetDeviceProperties(NULL, 0)); }
int main() { int numDevices = 0; int device; HIPCHECK(hipGetDeviceCount(&numDevices)); for(int i=0;i<numDevices;i++){ HIPCHECK(hipSetDevice(i)); HIPCHECK(hipGetDevice(&device)); HIPASSERT(device == i); } passed(); }
int main() { int numDevices = 0; char name[len]; hipDevice_t device; HIPCHECK(hipGetDeviceCount(&numDevices)); for (int i = 0; i < numDevices; i++) { HIPCHECK(hipDeviceGet(&device, i)); HIPCHECK(hipDeviceGetName(name, len, device)); HIPASSERT(name != ""); } passed(); }
int main() { int numDevices = 0; size_t totMem; hipDevice_t device; HIPCHECK(hipGetDeviceCount(&numDevices)); for (int i = 0; i < numDevices; i++) { HIPCHECK(hipDeviceGet(&device, i)); HIPCHECK(hipDeviceTotalMem(&totMem, device)); HIPASSERT(totMem != 0); } passed(); }
int main() { int numDevices = 0; int major,minor; hipDevice_t device; HIPCHECK(hipGetDeviceCount(&numDevices)); for(int i=0;i<numDevices;i++){ HIPCHECK(hipDeviceGet(&device,i)); HIPCHECK(hipDeviceComputeCapability(&major, &minor, device)); HIPASSERT(major >= 0); HIPASSERT(minor >= 0); } passed(); }
int main() { size_t Nbytes = N * sizeof(int); int numDevices = 0; int *A_d, *B_d, *C_d, *X_d, *Y_d, *Z_d; int *A_h, *B_h, *C_h; hipStream_t s; HIPCHECK(hipGetDeviceCount(&numDevices)); if (numDevices > 1) { HIPCHECK(hipSetDevice(0)); unsigned blocks = HipTest::setNumBlocks(blocksPerCU, threadsPerBlock, N); HipTest::initArrays(&A_d, &B_d, &C_d, &A_h, &B_h, &C_h, N, false); HIPCHECK(hipSetDevice(1)); HIPCHECK(hipMalloc(&X_d, Nbytes)); HIPCHECK(hipMalloc(&Y_d, Nbytes)); HIPCHECK(hipMalloc(&Z_d, Nbytes)); HIPCHECK(hipSetDevice(0)); HIPCHECK(hipMemcpy(A_d, A_h, Nbytes, hipMemcpyHostToDevice)); HIPCHECK(hipMemcpy(B_d, B_h, Nbytes, hipMemcpyHostToDevice)); hipLaunchKernelGGL(HipTest::vectorADD, dim3(blocks), dim3(threadsPerBlock), 0, 0, static_cast<const int*>(A_d), static_cast<const int*>(B_d), C_d, N); HIPCHECK(hipMemcpy(C_h, C_d, Nbytes, hipMemcpyDeviceToHost)); HIPCHECK(hipDeviceSynchronize()); HipTest::checkVectorADD(A_h, B_h, C_h, N); HIPCHECK(hipSetDevice(1)); HIPCHECK(hipStreamCreate(&s)); HIPCHECK(hipMemcpyDtoDAsync((hipDeviceptr_t)X_d, (hipDeviceptr_t)A_d, Nbytes, s)); HIPCHECK(hipMemcpyDtoDAsync((hipDeviceptr_t)Y_d, (hipDeviceptr_t)B_d, Nbytes, s)); hipLaunchKernelGGL(HipTest::vectorADD, dim3(blocks), dim3(threadsPerBlock), 0, 0, static_cast<const int*>(X_d), static_cast<const int*>(Y_d), Z_d, N); HIPCHECK(hipMemcpyDtoHAsync(C_h, (hipDeviceptr_t)Z_d, Nbytes, s)); HIPCHECK(hipStreamSynchronize(s)); HIPCHECK(hipDeviceSynchronize()); HipTest::checkVectorADD(A_h, B_h, C_h, N); HIPCHECK(hipStreamDestroy(s)); HipTest::freeArrays(A_d, B_d, C_d, A_h, B_h, C_h, false); HIPCHECK(hipFree(X_d)); HIPCHECK(hipFree(Y_d)); HIPCHECK(hipFree(Z_d)); } passed(); }
int main() { int numDevices = 0; HIPCHECK_API(hipGetDeviceCount(&numDevices), hipSuccess); if (numDevices > 0) { for (int deviceId = 0; deviceId < numDevices; deviceId++) { HIPCHECK_API(hipSetDevice(deviceId), hipSuccess); } HIPCHECK_API(hipSetDevice(numDevices), hipErrorInvalidDevice); HIPCHECK_API(hipSetDevice(-1), hipErrorInvalidDevice); } else { failed("Error: failed to find any compatible devices."); } passed(); }