af::array d_myArray(dim1, dim2, c32); -> Creates memory.
d_myArray = af::array(dim1, dim2, (af::cfloat*)h_myData); -> Creates memory space and copies host to device
d_myArray = af::array(dim1, dim2, (af::cfloat*)d_myData, afDevice); -> Creates memory space and copies device to device
for(int i = 0; i< 10; i++) {
array a = randu(10);
af_print(a);
}
classA::classA() :
d_myArray(dim1, dim2, c32) -> Allocates memory
{
}
classA::run(float* h_myData)
{
d_myArray = af::array(dim1, dim2, (af::cfloat*)h_myData); -> Uses "free" memory if available, otherwise allocates, then copies. Old pointer is marked free and can be reused. Old array object is destructed. No device-to-device copy.
}
So the constructor allocates a device buffer managed by d_myArray, run() just copies the memory from the host.
Now my question is: Is that every time run() is called a new device buffer gets allocated, host memory gets copied to it and then copied again into the current d_myArray device buffer allocated at construction?
2. I see, but how about if one wants to have control over how much device memory gets allocated at every moment in time? I wanna be able to control how much memory gets allocated on the device and when to free it whereas it seems that's not the case, I'm at the discretion of the Memory manager.
--
You received this message because you are subscribed to the Google Groups "ArrayFire Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arrayfire-use...@googlegroups.com.
To post to this group, send email to arrayfi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/arrayfire-users/0f59fb68-ceb4-43d4-ac57-12053bb62c20%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/arrayfire-users/dded5afb-8224-48e7-8b6f-f1435af907fe%40googlegroups.com.