jam11
1
Here is my test code:
[codebox]#include <stdio.h>
void test1_b()
{
//int nbytes=100000;
float free_m,total_m,used_m;
size_t *free,*total;
cudaSetDevice(0);
// float3 *d_input,*h_input;
// cudaHostAlloc((void **)&h_input, nbytes, 6);
// cudaHostGetDevicePointer((void **)&d_input, (void *)h_input, 0);
// cudaFreeHost(h_input);
// cudaFree(d_input);
cudaMemGetInfo((size_t*)&free,(size_t*)&total);
free_m =(size_t)free/1048576.0 ;
total_m=(size_t)total/1048576.0;
used_m=(total_m-free_m);
printf ( " mem free %d … %f MB mem total %d…%f MB mem used %f MB\n",free,free_m,total,total_m,used_m);
}
int main()
{
test1_b();
}
[/codebox]
And the result:
mem free 529989632 … 134214136.000000 MB mem total 939196416…895.687500 MB mem used -134213240.000000 MB
The total is Ok, but the free memomry is all over the place. Does it work for 64 bits machine (Linux)
size_t and size_t* are both 8.
giammy
2
Hi,
do you tryed to use %ld in printf format?
bye
giammy
jam11
3
%ld does not help,the float value is still the same.
Can someone compile this on a 32 bits machine?
jam11
4
Ok, Got it to work by changing:
size_t *free,*total;
to
size_t free_t,total_t;
Also, since free is also a linux command, it is a good idea not to use this name.