cudaMemset why this?


Whose fault is it ?

Me or CUDA? :)

perhaps you should try the same experiment without CUDA.

unsigned int count, *global_count;
global_count = (unsigned int *)malloc(sizeof(unsigned int));
memset(global_count, 1, sizeof(unsigned int));
memcpy(&count, global_count, sizeof(unsigned int));
std::cout << "count: " << count << std::endl;

what result do you get?

1 Like

The program produced the correct result.

16843009 == 0x01010101.

Memset/cudaMemset sets each byte of the destination to the specified value.

memset handles memory in bytes by default.