mirror of
https://github.com/NVIDIA/cuda-samples.git
synced 2024-11-24 15:09:17 +08:00
cudaCompressibleMemory: when unable to allocate compressible memory waive the execution
This commit is contained in:
parent
908dddb207
commit
0ec4bd58e5
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <helper_cuda.h>
|
||||
#include <cuda.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)
|
||||
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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user