Menu

matio doesn't support big file output?

philee
2013-08-19
2013-08-21
  • philee

    philee - 2013-08-19

    Hi there,
    I am using matio in linux on 64bit system with 64G memory and 2TB harddrive installed. There is no limit on the size of file output on the system. But it seems that matio doesn't support big file output. I try the following code (compiled with intel c++)

    #include <iostream>
    #include "matio.h"
    #include <vector>
    
    using namespace std;
    
    #define N 180000
    #define M 10000
    
    int main(int argc, char *argv[])
    {
      vector<double> A(N*M);
      mat_t *matfp;
      matvar_t *matvar;
      size_t dim[1];
    
      dim[0] = N*M;
    
      matfp = Mat_CreateVer("data.mat", NULL, MAT_FT_MAT73);
    
      for (size_t i=0; i<N*M; i++) A[i] = i;
      matvar = Mat_VarCreate("A", MAT_C_DOUBLE, MAT_T_DOUBLE, 1, dim, &A[0], 0);
      if (NULL!=matvar)
      {
        Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB);
        Mat_VarFree(matvar);
      }
      Mat_Close(matfp);
    
      return 0;
    }
    

    it doesn't generate the correct output unless I make the dimension small enough.

     

    Last edit: philee 2013-08-19
  • cch

    cch - 2013-08-21

    A couple notes:
    1. For MAT files, the minimum dimension is 2. There is currently no error check on that which should be fixed. So, just define the other dimension as 1.
    2. Without passing MAT_F_DONT_COPY_DATA in the options to Mat_VarCreate, matio will make a copy of the data which would be ill-advised for large data.
    3. If you do pass the MAT_F_DONT_COPY_DATA, note that matio will keep a pointer to YOUR data. So you should be careful using STL components that can change pointers when resizing the buffers.

    If it still does not create the correct output, can you give me more information as to what you get vs. what you expected. I do not have access to a system that will support the size of your data.

     

Log in to post a comment.