diff --git a/Samples/cudaCompressibleMemory/compMalloc.cpp b/Samples/cudaCompressibleMemory/compMalloc.cpp index 7503e3d35..78f0a43de 100644 --- a/Samples/cudaCompressibleMemory/compMalloc.cpp +++ b/Samples/cudaCompressibleMemory/compMalloc.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -67,6 +68,16 @@ cudaError_t allocateCompressible(void **adr, size_t size, bool UseCompressibleMe if (cuMemCreate(&allocationHandle, size, &prop, 0) != CUDA_SUCCESS) 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) return cudaErrorMemoryAllocation;