From 8ff723dcf136b8632f42eb2a9bd5242641474263 Mon Sep 17 00:00:00 2001 From: Siddharth Bhat Date: Tue, 8 Aug 2017 09:03:27 +0000 Subject: [PATCH] [NFC] [GPUJIT] Print line number & size information on allocateMemoryForDeviceCuda failure - It's useful to know the amount of memory asked for since, for example, asking for `0` bytes of memory is illegal. - Line number is helpful since we print the same message in the function at different points. llvm-svn: 310340 --- polly/tools/GPURuntime/GPUJIT.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/polly/tools/GPURuntime/GPUJIT.c b/polly/tools/GPURuntime/GPUJIT.c index 74d1839..7bfecfe 100644 --- a/polly/tools/GPURuntime/GPUJIT.c +++ b/polly/tools/GPURuntime/GPUJIT.c @@ -1478,12 +1478,18 @@ static PollyGPUDevicePtr *allocateMemoryForDeviceCUDA(long MemSize) { PollyGPUDevicePtr *DevData = malloc(sizeof(PollyGPUDevicePtr)); if (DevData == 0) { - fprintf(stderr, "Allocate memory for GPU device memory pointer failed.\n"); + fprintf(stderr, + "Allocate memory for GPU device memory pointer failed." + " Line: %d | Size: %ld\n", + __LINE__, MemSize); exit(-1); } DevData->DevicePtr = (CUDADevicePtr *)malloc(sizeof(CUDADevicePtr)); if (DevData->DevicePtr == 0) { - fprintf(stderr, "Allocate memory for GPU device memory pointer failed.\n"); + fprintf(stderr, + "Allocate memory for GPU device memory pointer failed." + " Line: %d | Size: %ld\n", + __LINE__, MemSize); exit(-1); } @@ -1491,7 +1497,10 @@ static PollyGPUDevicePtr *allocateMemoryForDeviceCUDA(long MemSize) { CuMemAllocFcnPtr(&(((CUDADevicePtr *)DevData->DevicePtr)->Cuda), MemSize); if (Res != CUDA_SUCCESS) { - fprintf(stderr, "Allocate memory for GPU device memory pointer failed.\n"); + fprintf(stderr, + "Allocate memory for GPU device memory pointer failed." + " Line: %d | Size: %ld\n", + __LINE__, MemSize); exit(-1); } -- 2.7.4