Error when allocating mapped memory after allocating other memory

Hello!

I have encountered a weird problem and I wonder whether this is a bug or my bad:

I am trying to allocate mapped memory. That works without a problem, but if I allocated some host memory before (using cudaHostAlloc) I am getting an error. Here is some code that causes the problem:

#include <stdio.h>

int main() {

	cudaError_t err;

	int *host;

	int host_size = 1073741824;

	cudaSetDevice(0);

	err = cudaHostAlloc((void **) &host, host_size, cudaHostAllocDefault);

	printf("cudaHostAlloc returned %d: %s\n", err, cudaGetErrorString(err));

	cudaFree(host);

	err = cudaHostAlloc((void **) &host, host_size, cudaHostAllocMapped);

	printf("cudaHostAlloc returned %d: %s\n", err, cudaGetErrorString(err));

	cudaFree(host);

	

	return 0;

}

The output on my system is

No error occurs if the flags of the second cudaHostAlloc are set to cudaHostAllocPortable, cudaHostAllocWriteCombined or cudaHostAllocDefault.

Is there something wrong with my setup? I am using the toolkit version 3.0 on Debian lenny.

Thanks!

Volker

Use

cudaFreeHost

Use

cudaFreeHost

Hi,

I am also facing the same problem but with ‘cudaHostAllocPortable’ flag (and I am using ‘cudaFreeHost()’ ).

the error says " unknown error"