Skip to content

Commit

Permalink
cudaCompressibleMemory: when unable to allocate compressible memory w…
Browse files Browse the repository at this point in the history
…aive the execution
  • Loading branch information
mdoijade committed Jun 1, 2020
1 parent 908dddb commit 0ec4bd5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Samples/cudaCompressibleMemory/compMalloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <stdio.h>
#include <string.h>
#include <helper_cuda.h>
#include <cuda.h>
#include <cuda_runtime_api.h>

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 0ec4bd5

Please sign in to comment.