cudaMallocHost not returning errors in emulation mode

Here is my code:

[codebox]#include <stdio.h>

#include <cuda_runtime_api.h>

define SAFE_CALL(call) do { \

cudaError_t err = call; \

if(err != cudaSuccess) { \

fprintf(stderr, “Cuda error in file ‘%s’ in line %i : %s.\n”, \

FILE, LINE, cudaGetErrorString(err) ); \

exit(1); \

} } while (0)

#define NUM_BYTES 2000000000

int main() {

unsigned char* host1;

unsigned char* host2;

unsigned char* host3;

unsigned char* host4;

unsigned char* device;






printf(“done mallocing\n”);



printf(“done with program\n”);


Now, I’ve requested 2GB of memory 4 times, so obviously cudaMallocHost should fail at some point (I only have 3GB of memory total). If I compile this code in non-emulation mode (nvcc, I get the output “Cuda error in file ‘’ in line 21 : unknown error.”, followed by program termination, which is fine. However when I compile the code in emulation mode (nvcc -deviceemu, I get the output “done mallocing” followed by an abnormal program termination “a.exe has encountered a problem and needs to close… blah blah blah”. So the cudaMallocHost is not returning an error it seems. Am I missing something dumb? Otherwise, I guess this is (yet another) CUDA bug?

I forgot to mention I am using CUDA 2.1 and I am not able to upgrade to 2.2 (no administrator privileges on this machine). So if it’s a CUDA bug, it’s possibly fixed in 2.2.