Giter VIP home page Giter VIP logo

Comments (3)

S-Dafarra avatar S-Dafarra commented on September 21, 2024

Hi @pascalreinhold, thanks for opening the issue!

matio-cpp is a cpp interface toward the matio library, that takes care of dealing with the mat file. When opening a mat file, matio loads its entire content in memory. Hence, when reading and writing variables, it always accesses the same portion of memory. Thus, there are possible concurrency issues, and by extension, also matio-cpp is not thread-safe.

If your goal is to speed up the reading of the file, I would suggest splitting it in separate files, or to use a format that supports reading in chunks like hdf5 (see for example https://docs.hdfgroup.org/hdf5/v1_12/group___h5_d.html#gac1092a63b718ec949d6539590a914b60). Recent mat files are compatible with hdf5, but mat files on their own do not support this option unfortunately.

from matio-cpp.

pascalreinhold avatar pascalreinhold commented on September 21, 2024

Hey thank you for the fast reply.

Does this is also apply to me, because I'm just reading the file and not writing?

Hence, when reading and writing variables [...] there are possible concurrency issues, and by extension, also matio-cpp is not thread-safe.

Not sure, but I think you are mistaken. In matio there are the Mat_VarReadInfo() and Mat_VarRead() functions to avoid loading a variable into memory until you need it.

When opening a 'mat' file, 'matio' loads its entire content in memory

from matio-cpp.

S-Dafarra avatar S-Dafarra commented on September 21, 2024

Not sure, but I think you are mistaken. In matio there are the Mat_VarReadInfo() and Mat_VarRead() functions to avoid loading a variable into memory until you need it.

When opening a 'mat' file, 'matio' loads its entire content in memory

Both those function require opening the mat file first, i.e. loading it into memory. See:

Btw, Mat_VarRead is the exact function that matio-cpp uses to read a variable:

matvar_t *matVar = Mat_VarRead(m_pimpl->mat_ptr, name.c_str());

Note that Mat_VarRead requires a non-const pointer to a mat_t object. This means that even the read can potentially modify this object. Hence, there could be possible concurrent reads and writes. So to answer your question,

Does this is also apply to me, because I'm just reading the file and not writing?

unfortunately, yes.

from matio-cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.