I am trying to solve a system in the accelerator (CUDA), and I want to re-use the allocated matrix to solve different systems.. In the first run (firstIter=true), I allocate the matrix and copy the row offset, column and values to the object. In the followings, I only update the values
Now, I would like to have access to the _rowoff, _col and _val arrays, but they are not accessible (segmentation fault error).. so in order to recover the arrays I do:
_rowoff = new int[_rowlength];
_col = new int[_size];
_val = new float[_size];
m_mat.CopyToCSR(_rowoff, _col, _val);
And this way I can have back the arrays.. The problem here is that there is a memory leak, I suppose that the “older” _val, _rowoff and _col arrays are somewhere in memory, but I can not deallocate them if I call m_mat.MoveToAccelerator()
If I solve the system without moving it to the accelerator, there is no problem and there is no need to allocate memory for the arrays in each iteration.
If I use the Set/LeaveDataPtr everything works, but I think that the performance can be improved, as I am deallocating and allocating all the matrix each time.. That is why I tried to use UpdateValuesCSR. Do you think that there is a proper way to do this?
if you use the Set/LeaveDataPtr functions, raw pointers to the structures are passed from paralution to you. You can do with the data what ever you like. You don’t have to reallocate anything, just update the data with your own functions (keep in mind, that the pointers are only valid on the device where you extracted them from).