How to release read_only & write_only memory in GPU.
suppose i load a write only array and another read only array in GPU. Then
later once I am done retrieving the output from GPU, i want to load new
arrays in the GPU. But i want to get rid of old arrays in the GPU.
This would help me when I want to selectively delete old arrays from GPU
and load new arrays.
I am going to load 3 arrays from CPU to GPU 4 times in a loop in my
function. Then GPU will work on those arrays and generate output.
1 of the 3 arrays is going to be the same every time. SO i want to find a
way to keep that 1 array *(arrazy_z)* constant instead of loading it each
time. I also want to make sure that the other 2 new arrays that i load each
time, they dont get stored separately on each iteration, otherwise I would
run out of GPU memory soon.
iteration 1 - array_x1, array_y1, array_z
iteration 2 - array_x2, array_y2, array_z
iteration 3 - array_x3, array_y3, array_z
iteration 4 - array_x4, array_y4, array_z
I want to be able to load *array_z* only once and use it all 4 times with
on iteration_1 i will load *array_x1 & array_y1* from CPU to GPU. Then on
Iteration_2 I want the GPU to clear the memory space from array_x1 &
array_y1, and store fresh new arrays *array_x2, array_y2.*
To keep array_z unchanged on CPU i would just run following command once
and then not modify "az" in the entire function
on CPU my variable *az * will remain as it is until the function ends. I
can call *az* whenever i need in the same function. I can also pass it to
another function with new name.
But i dont know if same works on GPU.
To solve array_x1, array_y1 case On CPU i would do:
Then on iteration_2
that way old value from ax & ay is gone and new value is stored.
But I dont know if this works on GPU too.