Matrix arrays not accessible after moving to accelerator

Front page Forums General Matrix arrays not accessible after moving to accelerator

This topic contains 3 replies, has 2 voices, and was last updated by  nico 10 months, 2 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1460

    Isaac-a95
    Member

    Hello,

    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

    if(firstIter){
    m_mat.AllocateCSR(“SystemMatrix”, _size, size, size);
    m_mat.CopyFromCSR(_rowoff, _col, _val);
    firstIter=false;
    }
    m_mat.UpdateValuesCSR(_val);

    m_mat.MoveToAccelerator();

    //Build and solve the system

    m_mat.MoveToHost();

    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.

    Any idea about the cause of this problem?

    Thanks and happy new year!

    Isaac

    #1461

    nico
    Participant

    Hi Isaac,

    you can use the Set/LeaveDataPtr functions to access the raw data pointers without copying.

    Best
    Nico

    #1462

    Isaac-a95
    Member

    Hi Nico,

    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?

    Thanks!

    Isaac

    #1464

    nico
    Participant

    Hi Isaac,

    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).

    Best
    Nico

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.