cudaCompressibleMemory: when unable to allocate compressible memory waive the execution

This commit is contained in:
Mahesh Doijade 2020-06-01 20:22:22 +05:30
parent 908dddb207
commit 0ec4bd58e5

View File

@ -27,6 +27,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <helper_cuda.h>
#include <cuda.h> #include <cuda.h>
#include <cuda_runtime_api.h> #include <cuda_runtime_api.h>
@ -67,6 +68,16 @@ cudaError_t allocateCompressible(void **adr, size_t size, bool UseCompressibleMe
if (cuMemCreate(&allocationHandle, size, &prop, 0) != CUDA_SUCCESS) if (cuMemCreate(&allocationHandle, size, &prop, 0) != CUDA_SUCCESS)
return cudaErrorMemoryAllocation; return cudaErrorMemoryAllocation;
// Check if cuMemCreate was able to allocate compressible memory.
if (UseCompressibleMemory) {
CUmemAllocationProp allocationProp = {};
cuMemGetAllocationPropertiesFromHandle(&allocationProp, allocationHandle);
if (allocationProp.allocFlags.compressionType != CU_MEM_ALLOCATION_COMP_GENERIC) {
printf("Could not allocate compressible memory... so waiving execution\n");
exit(EXIT_WAIVED);
}
}
if (cuMemMap(dptr, size, 0, allocationHandle, 0) != CUDA_SUCCESS) if (cuMemMap(dptr, size, 0, allocationHandle, 0) != CUDA_SUCCESS)
return cudaErrorMemoryAllocation; return cudaErrorMemoryAllocation;